Skip to content

Commit

Permalink
Remove retry logic.
Browse files Browse the repository at this point in the history
If the thread pool throws a RejectedExecutionException, we throw a
RuntimeException to indicate that an increase in thread pool size is
necessary.

If the thread pool is interrupted while waiting for its worker threads
to terminate, we also throw a RuntimException because something wrong
has happened somewhere else that causes the main log server thread to
terminate.
  • Loading branch information
riversand9 committed Aug 28, 2017
1 parent cd3dfd9 commit c6a8ae1
Showing 1 changed file with 16 additions and 31 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
import alluxio.Process;
import alluxio.PropertyKey;
import alluxio.retry.ExponentialBackoffRetry;
import alluxio.retry.RetryPolicy;
import alluxio.util.CommonUtils;
import alluxio.util.WaitForOptions;

Expand Down Expand Up @@ -110,25 +109,18 @@ public void start() throws Exception {
}
InetAddress inetAddress = client.getInetAddress();
AlluxioLog4jSocketNode clientSocketNode = new AlluxioLog4jSocketNode(this, client);
RetryPolicy retryPolicy = new ExponentialBackoffRetry(
BASE_SLEEP_TIME_MS, MAX_SLEEP_TIME_MS, MAX_NUM_RETRY);
while (true) {
try {
mThreadPool.execute(clientSocketNode);
break;
} catch (RejectedExecutionException e) {
if (!retryPolicy.attemptRetry()) {
LOG.warn("Connection with {} has been rejected by ExecutorService {} times"
+ "till timedout, reason: {}",
inetAddress.getHostAddress(), retryPolicy.getRetryCount(), e);
// Alluxio log clients (master, secondary master, proxy and workers establish
// long-living connections with the log server. Therefore, if the log server cannot
// find a thread to service a log client, it is very likely due to low number of
// worker threads. If retry fails, then it makes sense just to let system throw
// an exception. The system admin should increase the thread pool size.
throw new RuntimeException(
"Increase the number of worker threads in the thread pool", e);
}
// Alluxio log clients (master, secondary master, proxy and workers establish
// long-living connections with the log server. Therefore, if the log server cannot
// find a thread to service a log client, it is very likely due to low number of
// worker threads. If retry fails, then it makes sense just to let system throw
// an exception. The system admin should increase the thread pool size.
throw new RuntimeException(
"Increase the number of worker threads in the thread pool", e);
} catch (Error | Exception e) {
LOG.error("ExecutorService threw error: ", e);
throw e;
Expand Down Expand Up @@ -157,23 +149,16 @@ public void stop() throws Exception {
}

mThreadPool.shutdown();
long timeoutMS = THREAD_KEEP_ALIVE_TIME_MS;
long now = System.currentTimeMillis();
while (timeoutMS >= 0) {
try {
boolean ret = mThreadPool.awaitTermination(timeoutMS, TimeUnit.MILLISECONDS);
if (ret) {
LOG.info("All worker threads have terminated.");
} else {
LOG.warn("Log server has timeout waiting for worker threads to terminate.");
}
break;
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
long newnow = System.currentTimeMillis();
timeoutMS -= (newnow - now);
now = newnow;
try {
boolean ret = mThreadPool.awaitTermination(THREAD_KEEP_ALIVE_TIME_MS, TimeUnit.MILLISECONDS);
if (ret) {
LOG.info("All worker threads have terminated.");
} else {
LOG.warn("Log server has timedout waiting for worker threads to terminate.");
}
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
throw new RuntimeException(e);
}
}

Expand Down

0 comments on commit c6a8ae1

Please sign in to comment.