use of com.yahoo.concurrent.DaemonThreadFactory in project vespa by vespa-engine.
the class DummyReceiver method init.
public void init() {
MessageBusParams params = new MessageBusParams(new LoadTypeSet());
params.setRPCNetworkParams(new RPCNetworkParams().setIdentity(new Identity(name)));
params.setDocumentManagerConfigId("client");
params.getMessageBusParams().setMaxPendingCount(maxPendingCount);
params.getMessageBusParams().setMaxPendingSize(0);
da = new MessageBusDocumentAccess(params);
queue = (maxQueueTime < 0) ? new LinkedBlockingDeque<>() : new ThroughputLimitQueue<>(maxQueueTime);
session = da.getMessageBus().createDestinationSession("default", true, this);
executor = new ThreadPoolExecutor(threads, threads, 5, TimeUnit.SECONDS, queue, new DaemonThreadFactory());
System.out.println("Registered listener at " + name + "/default with " + maxPendingCount + " max pending and sleep time of " + sleepTime);
}
use of com.yahoo.concurrent.DaemonThreadFactory in project vespa by vespa-engine.
the class ApplicationRepository method redeployAllApplications.
void redeployAllApplications() throws InterruptedException {
ExecutorService executor = Executors.newFixedThreadPool(configserverConfig.numParallelTenantLoaders(), new DaemonThreadFactory("redeploy apps"));
// Keep track of deployment per application
Map<ApplicationId, Future<?>> futures = new HashMap<>();
tenants.getAllTenants().forEach(tenant -> listApplicationIds(tenant).forEach(appId -> deployFromLocalActive(appId).ifPresent(deployment -> futures.put(appId, executor.submit(deployment::activate)))));
for (Map.Entry<ApplicationId, Future<?>> f : futures.entrySet()) {
try {
f.getValue().get();
} catch (ExecutionException e) {
throw new RuntimeException("Redeploying of " + f.getKey() + " failed", e);
}
}
executor.shutdown();
// Timeout should never happen
executor.awaitTermination(365, TimeUnit.DAYS);
}
use of com.yahoo.concurrent.DaemonThreadFactory in project vespa by vespa-engine.
the class ConfiguredApplication method startShutdownDeadlineExecutor.
// Workaround for ApplicationLoader.stop not being able to shutdown
private void startShutdownDeadlineExecutor() {
shutdownDeadlineExecutor = new ScheduledThreadPoolExecutor(1, new DaemonThreadFactory("Shutdown deadline timer"));
shutdownDeadlineExecutor.setExecuteExistingDelayedTasksAfterShutdownPolicy(false);
long delayMillis = 50 * 1000;
shutdownDeadlineExecutor.schedule(new Runnable() {
@Override
public void run() {
com.yahoo.protect.Process.logAndDie("Timed out waiting for application shutdown. Please check that all your request handlers " + "drain their request content channels.", true);
}
}, delayMillis, TimeUnit.MILLISECONDS);
}
Aggregations