Search in sources :

Example 1 with DaemonThreadFactory

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);
}
Also used : LinkedBlockingDeque(java.util.concurrent.LinkedBlockingDeque) RPCNetworkParams(com.yahoo.messagebus.network.rpc.RPCNetworkParams) MessageBusDocumentAccess(com.yahoo.documentapi.messagebus.MessageBusDocumentAccess) DaemonThreadFactory(com.yahoo.concurrent.DaemonThreadFactory) MessageBusParams(com.yahoo.documentapi.messagebus.MessageBusParams) ThreadPoolExecutor(java.util.concurrent.ThreadPoolExecutor) Identity(com.yahoo.messagebus.network.Identity) ThroughputLimitQueue(com.yahoo.documentapi.ThroughputLimitQueue) LoadTypeSet(com.yahoo.documentapi.messagebus.loadtypes.LoadTypeSet)

Example 2 with DaemonThreadFactory

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);
}
Also used : ApplicationMetaData(com.yahoo.config.application.api.ApplicationMetaData) FileDistributionStatus(com.yahoo.vespa.config.server.application.FileDistributionStatus) RemoteSession(com.yahoo.vespa.config.server.session.RemoteSession) Inject(com.google.inject.Inject) Vtag(com.yahoo.component.Vtag) ApplicationFile(com.yahoo.config.application.api.ApplicationFile) ConfigserverConfig(com.yahoo.cloud.config.ConfigserverConfig) DeployLogger(com.yahoo.config.application.api.DeployLogger) TenantName(com.yahoo.config.provision.TenantName) LogServerLogGrabber(com.yahoo.vespa.config.server.application.LogServerLogGrabber) Future(java.util.concurrent.Future) Path(com.yahoo.path.Path) Rotations(com.yahoo.vespa.config.server.tenant.Rotations) Provisioner(com.yahoo.config.provision.Provisioner) Duration(java.time.Duration) Map(java.util.Map) LogLevel(com.yahoo.log.LogLevel) CompressedApplicationInputStream(com.yahoo.vespa.config.server.http.CompressedApplicationInputStream) URI(java.net.URI) Application(com.yahoo.vespa.config.server.application.Application) Instant(java.time.Instant) Logger(java.util.logging.Logger) Executors(java.util.concurrent.Executors) HostFilter(com.yahoo.config.provision.HostFilter) RestartActions(com.yahoo.vespa.config.server.configchange.RestartActions) List(java.util.List) HostProvisionerProvider(com.yahoo.vespa.config.server.provision.HostProvisionerProvider) Optional(java.util.Optional) DeployHandlerLogger(com.yahoo.vespa.config.server.deploy.DeployHandlerLogger) HttpResponse(com.yahoo.container.jdisc.HttpResponse) ConfigChangeActions(com.yahoo.vespa.config.server.configchange.ConfigChangeActions) Version(com.yahoo.component.Version) ApplicationId(com.yahoo.config.provision.ApplicationId) Slime(com.yahoo.slime.Slime) DaemonThreadFactory(com.yahoo.concurrent.DaemonThreadFactory) Tenant(com.yahoo.vespa.config.server.tenant.Tenant) HashMap(java.util.HashMap) IOUtils(com.yahoo.io.IOUtils) TenantApplications(com.yahoo.vespa.config.server.application.TenantApplications) ApplicationConvergenceChecker(com.yahoo.vespa.config.server.application.ApplicationConvergenceChecker) Level(java.util.logging.Level) RefeedActions(com.yahoo.vespa.config.server.configchange.RefeedActions) Files(com.google.common.io.Files) NestedTransaction(com.yahoo.transaction.NestedTransaction) PrepareParams(com.yahoo.vespa.config.server.session.PrepareParams) ExecutorService(java.util.concurrent.ExecutorService) HttpProxy(com.yahoo.vespa.config.server.application.HttpProxy) PrepareResult(com.yahoo.vespa.config.server.http.v2.PrepareResult) SilentDeployLogger(com.yahoo.vespa.config.server.session.SilentDeployLogger) LocalSessionRepo(com.yahoo.vespa.config.server.session.LocalSessionRepo) ApplicationSet(com.yahoo.vespa.config.server.application.ApplicationSet) Environment(com.yahoo.config.provision.Environment) IOException(java.io.IOException) Tenants(com.yahoo.vespa.config.server.tenant.Tenants) SessionFactory(com.yahoo.vespa.config.server.session.SessionFactory) File(java.io.File) Deployment(com.yahoo.vespa.config.server.deploy.Deployment) ExecutionException(java.util.concurrent.ExecutionException) TimeUnit(java.util.concurrent.TimeUnit) LocalSession(com.yahoo.vespa.config.server.session.LocalSession) SimpleHttpFetcher(com.yahoo.vespa.config.server.http.SimpleHttpFetcher) Clock(java.time.Clock) Session(com.yahoo.vespa.config.server.session.Session) InputStream(java.io.InputStream) HashMap(java.util.HashMap) DaemonThreadFactory(com.yahoo.concurrent.DaemonThreadFactory) ExecutorService(java.util.concurrent.ExecutorService) Future(java.util.concurrent.Future) ApplicationId(com.yahoo.config.provision.ApplicationId) ExecutionException(java.util.concurrent.ExecutionException) Map(java.util.Map) HashMap(java.util.HashMap)

Example 3 with DaemonThreadFactory

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);
}
Also used : ScheduledThreadPoolExecutor(java.util.concurrent.ScheduledThreadPoolExecutor) DaemonThreadFactory(com.yahoo.concurrent.DaemonThreadFactory)

Aggregations

DaemonThreadFactory (com.yahoo.concurrent.DaemonThreadFactory)3 Files (com.google.common.io.Files)1 Inject (com.google.inject.Inject)1 ConfigserverConfig (com.yahoo.cloud.config.ConfigserverConfig)1 Version (com.yahoo.component.Version)1 Vtag (com.yahoo.component.Vtag)1 ApplicationFile (com.yahoo.config.application.api.ApplicationFile)1 ApplicationMetaData (com.yahoo.config.application.api.ApplicationMetaData)1 DeployLogger (com.yahoo.config.application.api.DeployLogger)1 ApplicationId (com.yahoo.config.provision.ApplicationId)1 Environment (com.yahoo.config.provision.Environment)1 HostFilter (com.yahoo.config.provision.HostFilter)1 Provisioner (com.yahoo.config.provision.Provisioner)1 TenantName (com.yahoo.config.provision.TenantName)1 HttpResponse (com.yahoo.container.jdisc.HttpResponse)1 ThroughputLimitQueue (com.yahoo.documentapi.ThroughputLimitQueue)1 MessageBusDocumentAccess (com.yahoo.documentapi.messagebus.MessageBusDocumentAccess)1 MessageBusParams (com.yahoo.documentapi.messagebus.MessageBusParams)1 LoadTypeSet (com.yahoo.documentapi.messagebus.loadtypes.LoadTypeSet)1 IOUtils (com.yahoo.io.IOUtils)1