Example usage for java.util.concurrent TimeUnit MINUTES

List of usage examples for java.util.concurrent TimeUnit MINUTES

Introduction

In this page you can find the example usage for java.util.concurrent TimeUnit MINUTES.

Prototype

TimeUnit MINUTES

To view the source code for java.util.concurrent TimeUnit MINUTES.

Click Source Link

Document

Time unit representing sixty seconds.

Usage

From source file:com.amazonaws.services.simpleworkflow.flow.worker.GenericActivityWorker.java

@Override
protected TaskPoller createPoller() {
    ThreadPoolExecutor tasksExecutor = new ThreadPoolExecutor(1, taskExecutorThreadPoolSize, 1,
            TimeUnit.MINUTES, new SynchronousQueue<Runnable>());
    tasksExecutor.setThreadFactory(/*from ww w .  j a v a2  s. co m*/
            new ExecutorThreadFactory(ACTIVITY_THREAD_NAME_PREFIX + " " + getTaskListToPoll() + " "));
    tasksExecutor.setRejectedExecutionHandler(new BlockCallerPolicy());
    return new ActivityTaskPoller(service, domain, getTaskListToPoll(), activityImplementationFactory,
            tasksExecutor);
}

From source file:org.trustedanalytics.platformoperations.service.PlatformOperationsScheduler.java

private Runnable platformSummary() {
    return () -> {

        if (flag.compareAndSet(false, true)) {
            try {
                LOGGER.info("Trigger Platform Summary");

                final CompletableFuture<ComponentSummary> componentSummary = CompletableFuture
                        .supplyAsync(new ComponentDiscoverTask(nats), executor)
                        .thenApply(messages -> new ComponentMetricsTask("DEA", messages).get())
                        .thenApply(ComponentSummary::new);

                final CompletableFuture<ControllerSummary> controllerSummary = CompletableFuture
                        .supplyAsync(new ControllerMetricsTask(client), executor);

                CompletableFuture.allOf(componentSummary, controllerSummary).get(10, TimeUnit.MINUTES);

                repository.save(new PlatformSummary(componentSummary.get(1, TimeUnit.MINUTES),
                        controllerSummary.get(1, TimeUnit.MINUTES)));
            } catch (TimeoutException | ExecutionException | InterruptedException ex) {
                LOGGER.error("Exception during fetching metrics: {}" + ex);
            } finally {
                flag.set(false);/*from   w ww .j a v a  2s.  c o  m*/
            }
        } else {
            LOGGER.info("Request skipped, task already submitted!");
        }
    };
}

From source file:ddf.catalog.metrics.CatalogMetrics.java

public CatalogMetrics(FilterAdapter filterAdapter) {

    this.filterAdapter = filterAdapter;

    resultCount = metrics.register(MetricRegistry.name(QUERIES_SCOPE, "TotalResults"),
            new Histogram(new SlidingTimeWindowReservoir(1, TimeUnit.MINUTES)));

    queries = metrics.meter(MetricRegistry.name(QUERIES_SCOPE));
    federatedQueries = metrics.meter(MetricRegistry.name(QUERIES_SCOPE, "Federated"));
    comparisonQueries = metrics.meter(MetricRegistry.name(QUERIES_SCOPE, "Comparison"));
    spatialQueries = metrics.meter(MetricRegistry.name(QUERIES_SCOPE, "Spatial"));
    xpathQueries = metrics.meter(MetricRegistry.name(QUERIES_SCOPE, "Xpath"));
    fuzzyQueries = metrics.meter(MetricRegistry.name(QUERIES_SCOPE, "Fuzzy"));
    temporalQueries = metrics.meter(MetricRegistry.name(QUERIES_SCOPE, "Temporal"));
    functionQueries = metrics.meter(MetricRegistry.name(QUERIES_SCOPE, "Function"));

    exceptions = metrics.meter(MetricRegistry.name(EXCEPTIONS_SCOPE));
    unsupportedQueryExceptions = metrics.meter(MetricRegistry.name(EXCEPTIONS_SCOPE, "UnsupportedQuery"));
    sourceUnavailableExceptions = metrics.meter(MetricRegistry.name(EXCEPTIONS_SCOPE, "SourceUnavailable"));
    federationExceptions = metrics.meter(MetricRegistry.name(EXCEPTIONS_SCOPE, "Federation"));

    createdMetacards = metrics.meter(MetricRegistry.name(INGEST_SCOPE, "Created"));
    updatedMetacards = metrics.meter(MetricRegistry.name(INGEST_SCOPE, "Updated"));
    deletedMetacards = metrics.meter(MetricRegistry.name(INGEST_SCOPE, "Deleted"));

    resourceRetrival = metrics.meter(MetricRegistry.name(RESOURCE_SCOPE));

    reporter.start();//from   w w  w . j a  v a2 s.  co  m
}

From source file:sample.server.GemFireServer.java

@Bean
CacheServerFactoryBean gemfireCacheServer(Cache gemfireCache,
        @Value("${gemfire.cache.server.bind-address:localhost}") String bindAddress,
        @Value("${gemfire.cache.server.hostname-for-clients:localhost}") String hostnameForClients,
        @Value("${gemfire.cache.server.port:12480}") int port) { // <4>

    CacheServerFactoryBean gemfireCacheServer = new CacheServerFactoryBean();

    gemfireCacheServer.setAutoStartup(true);
    gemfireCacheServer.setCache(gemfireCache);
    gemfireCacheServer.setBindAddress(bindAddress);
    gemfireCacheServer.setHostNameForClients(hostnameForClients);
    gemfireCacheServer.setMaxTimeBetweenPings(Long.valueOf(TimeUnit.MINUTES.toMillis(1)).intValue());
    gemfireCacheServer.setNotifyBySubscription(true);
    gemfireCacheServer.setPort(port);//from  ww  w .  ja  v a 2s .co  m

    return gemfireCacheServer;
}

From source file:de.fabianonline.telegram_backup.DownloadManager.java

public void downloadMessages(Integer limit) throws RpcErrorException, IOException {
    boolean completed = true;
    do {/*from w w w  .  ja v  a  2s  .c o m*/
        completed = true;
        try {
            _downloadMessages(limit);
        } catch (RpcErrorException e) {
            if (e.getCode() == 420) { // FLOOD_WAIT
                completed = false;
                Utils.obeyFloodWaitException(e);
            } else {
                throw e;
            }
        } catch (TimeoutException e) {
            completed = false;
            System.out.println("");
            System.out.println("Telegram took too long to respond to our request.");
            System.out.println("I'm going to wait a minute and then try again.");
            try {
                TimeUnit.MINUTES.sleep(1);
            } catch (InterruptedException e2) {
            }
            System.out.println("");
        }
    } while (!completed);
}

From source file:eu.tango.energymodeller.energypredictor.AveragePowerEnergyPredictor.java

/**
 * This creates a new average power energy predictor. The predictor when
 * running takes the last power reading and makes the assumption no change
 * will occur. An observation time window is used for taking the measurement,
 * which is set via a configuration file.
 */// w  w  w . j a va2s .  c o m
public AveragePowerEnergyPredictor() {
    try {
        if (database == null) {
            database = new DefaultDatabaseConnector();
        }
        PropertiesConfiguration config;
        if (new File(CONFIG_FILE).exists()) {

            config = new PropertiesConfiguration(CONFIG_FILE);
        } else {
            config = new PropertiesConfiguration();
            config.setFile(new File(CONFIG_FILE));
        }
        config.setAutoSave(true); //This will save the configuration file back to disk. In case the defaults need setting.
        powerObservationTimeMin = config.getInt(
                "energy.modeller.energy.predictor.cpu.utilisation.observe_time.min", powerObservationTimeMin);
        config.setProperty("energy.modeller.energy.predictor.cpu.utilisation.observe_time.min",
                powerObservationTimeMin);
        powerObservationTimeSec = config.getInt(
                "energy.modeller.energy.predictor.cpu.utilisation.observe_time.sec", powerObservationTimeSec);
        config.setProperty("energy.modeller.energy.predictor.cpu.utilisation.observe_time.sec",
                powerObservationTimeSec);
        observationTime = powerObservationTimeSec + (int) TimeUnit.MINUTES.toSeconds(powerObservationTimeMin);
    } catch (ConfigurationException ex) {
        Logger.getLogger(AveragePowerEnergyPredictor.class.getName()).log(Level.SEVERE,
                "The average power energy predictor failed to initialise", ex);
    }
}

From source file:com.zaxxer.hikari.benchmark.BenchBase.java

protected void setupTomcat() {
    PoolProperties props = new PoolProperties();
    props.setUrl(jdbcURL);/*from  w  ww.  j av  a2s  . com*/
    props.setDriverClassName(dbDriver);
    props.setUsername("sa");
    props.setPassword("");
    props.setInitialSize(MIN_POOL_SIZE);
    props.setMinIdle(MIN_POOL_SIZE);
    props.setMaxIdle(maxPoolSize);
    props.setMaxActive(maxPoolSize);
    props.setMaxWait(8000);
    props.setDefaultAutoCommit(false);
    props.setRollbackOnReturn(true);
    props.setMinEvictableIdleTimeMillis((int) TimeUnit.MINUTES.toMillis(30));
    props.setTestOnBorrow(true);
    props.setDefaultTransactionIsolation(Connection.TRANSACTION_READ_COMMITTED);
    props.setValidationQuery("VALUES 1");
    props.setJdbcInterceptors("ConnectionState");

    DS = new org.apache.tomcat.jdbc.pool.DataSource(props);
}

From source file:com.amazonaws.codepipeline.jobworker.JobWorkerDaemon.java

/**
 * Stops the daemon. Shuts down the executor service gracefully.
 * Waits until the job poller and job processors finished their work.
 * @throws Exception exception during shutdown
 *//*from   w ww .  ja v a2s  .c  om*/
@Override
public void stop() throws Exception {
    LOGGER.info("Stopping daemon.");

    this.executorService.shutdown();
    try {
        if (!this.executorService.awaitTermination(1, TimeUnit.MINUTES)) {
            this.executorService.shutdownNow();
            if (!this.executorService.awaitTermination(1, TimeUnit.MINUTES)) {
                throw new IllegalStateException("Failed graceful shutdown of executor threads");
            }
        }
    } catch (final InterruptedException e) {
        this.executorService.shutdownNow();
        Thread.currentThread().interrupt();
    }
    LOGGER.info("Stopped daemon.");
}

From source file:edu.unc.lib.dl.cdr.services.FixityLogService.java

@Override
public void abort() {
    this.executor.pause();
    this.executor.shutdownNow();
    try {/*from  w  ww  .  j  a va 2 s .  c  o  m*/
        this.executor.awaitTermination(5, TimeUnit.MINUTES);
    } catch (InterruptedException ignored) {
    }
    initializeExecutor();
    this.executor.pause();
}

From source file:de.openali.odysseus.chart.factory.config.resolver.ChartTypeResolver.java

private ChartTypeResolver() {
    final CacheBuilder<Object, Object> builder = CacheBuilder.newBuilder().expireAfterAccess(10,
            TimeUnit.MINUTES);
    m_loaderCache = builder.build();/*from   w  w  w  .j av a  2s  .c  om*/
}