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.spotify.helios.agent.QueueingHistoryWriter.java

@Override
protected void shutDown() throws Exception {
    zkWriterExecutor.shutdownNow();
    zkWriterExecutor.awaitTermination(1, TimeUnit.MINUTES);
}

From source file:com.shmsoft.dmass.ec2.EC2Agent.java

private void setInitializedState(Cluster cluster) {
    ExecutorService es = Executors.newCachedThreadPool();
    for (Server server : cluster) {
        LoginChecker checker = new LoginChecker();
        checker.setServer(server);/*w  w w . j  ava 2 s  .  co  m*/
        server.setCheckerThread(checker);
        es.execute(checker);

    }
    es.shutdown();
    boolean finished = false;
    try {
        finished = es.awaitTermination(1, TimeUnit.MINUTES);
    } catch (InterruptedException e) {
        e.printStackTrace(System.out);
    }
    // TODO what to do if 'finished" is false       
}

From source file:gobblin.source.extractor.utils.Utils.java

/**
 * Print time difference in minutes, seconds and milliseconds
 *///from w  ww .  j ava2 s .  c  o m
public static String printTiming(long start, long end) {
    long totalMillis = end - start;
    long mins = TimeUnit.MILLISECONDS.toMinutes(totalMillis);
    long secs = TimeUnit.MILLISECONDS.toSeconds(totalMillis) - TimeUnit.MINUTES.toSeconds(mins);
    long millis = TimeUnit.MILLISECONDS.toMillis(totalMillis) - TimeUnit.MINUTES.toMillis(mins)
            - TimeUnit.SECONDS.toMillis(secs);
    return String.format("%d min, %d sec, %d millis", mins, secs, millis);
}

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

@Test
public void shouldForceStoppingSchedulingJobPollerWhenInterruptedExceptionIsThrow() throws Exception {
    // given//from w w  w  .  ja va 2 s  . c o  m
    when(executorService.awaitTermination(1, TimeUnit.MINUTES)).thenThrow(new InterruptedException());

    // when
    jobWorkerDaemon.stop();

    // then
    verify(executorService).shutdown();
    verify(executorService).shutdownNow();
}

From source file:com.cfelde.aws.ddb.management.TableThroughput.java

private static void initTableThroughput(AmazonCloudWatch client, AmazonDynamoDBClient ddb, String table,
        int minRead, int maxRead, int minWrite, int maxWrite) {
    final TableThroughput tt = new TableThroughput(client, ddb, table, minRead, maxRead, minWrite, maxWrite);

    tt.initCapacityValues();/*  w  w  w. ja  v a  2s .  c  o m*/

    executor.scheduleWithFixedDelay(new Runnable() {
        @Override
        public void run() {
            tt.updateDownscaleCounter();
        }
    }, 1, 60 * 15, TimeUnit.SECONDS);

    executor.scheduleWithFixedDelay(new Runnable() {
        @Override
        public void run() {
            tt.runRead();
            tt.runWrite();
        }
    }, 10, 60 * 5, TimeUnit.SECONDS);

    executor.scheduleWithFixedDelay(new Runnable() {
        @Override
        public void run() {
            tt.updateCapacity();
        }
    }, 20, 120, TimeUnit.SECONDS);

    executor.scheduleWithFixedDelay(new Runnable() {
        @Override
        public void run() {
            tt.runExceptionCheck();
        }
    }, 5, 60, TimeUnit.MINUTES);
}

From source file:cf.component.VcapComponent.java

private String formatUptime() {
    long delta = System.currentTimeMillis() - startTime;
    delta /= 1000; // Drop the milliseconds
    final long days = delta / TimeUnit.DAYS.toSeconds(1);
    delta -= TimeUnit.DAYS.toSeconds(days);
    final long hours = delta / TimeUnit.HOURS.toSeconds(1);
    delta -= TimeUnit.HOURS.toSeconds(hours);
    final long minutes = delta / TimeUnit.MINUTES.toSeconds(1);
    delta -= TimeUnit.MINUTES.toSeconds(1);
    final long seconds = delta;
    return String.format("%dd:%dh:%dm:%ds", days, hours, minutes, seconds);
}

From source file:io.scigraph.owlapi.loader.BatchOwlLoader.java

public static void load(OwlLoadConfiguration config) throws InterruptedException, ExecutionException {
    Injector i = Guice.createInjector(new OwlLoaderModule(config),
            new Neo4jModule(config.getGraphConfiguration()));
    BatchOwlLoader loader = i.getInstance(BatchOwlLoader.class);
    logger.info("Loading ontologies...");
    Stopwatch timer = Stopwatch.createStarted();
    // TODO catch exception and delete the incomplete graph through the graph location
    loader.loadOntology();// w w w.j  a v  a 2  s  .com
    DB mapDb = i.getInstance(DB.class);
    mapDb.close();
    logger.info(format("Loading took %d minutes", timer.elapsed(TimeUnit.MINUTES)));
}

From source file:co.cask.hydrator.plugin.batch.action.FileActionTestRun.java

private void startMapReduceJob(ApplicationManager appManager) throws Exception {
    WorkflowManager manager = appManager.getWorkflowManager(ETLWorkflow.NAME);
    manager.start(ImmutableMap.of("logical.start.time", "0"));
    manager.waitForFinish(5, TimeUnit.MINUTES);
}

From source file:net.praqma.jenkins.rqm.collector.RqmTestSuiteExectionRecordCollectionStrategy.java

@Override
public <T extends RqmObject> List<T> collect(BuildListener listener, AbstractBuild<?, ?> build)
        throws Exception {
    NameValuePair[] filterProperties = TestSuiteExecutionRecord.getFilteringProperties(executionRecordName,
            planName);//from   www  . j a  v  a 2  s  . c  o  m
    String request = TestSuiteExecutionRecord.getResourceFeedUrl(getHostName(), getPort(), getContextRoot(),
            projectName);
    listener.getLogger().println(String.format("Resource request feed is %s", request));

    RqmParameterList list;
    if (!StringUtils.isBlank(credentialId) && !credentialId.equals("none")) {
        listener.getLogger().println("Using credentials");
        StandardUsernameCredentials usrName = CredentialsProvider.findCredentialById(credentialId,
                StandardUsernameCredentials.class, build, Collections.EMPTY_LIST);
        UsernamePasswordCredentials userPasswordCreds = (UsernamePasswordCredentials) usrName;
        list = new RqmParameterList(getHostName(), getPort(), getContextRoot(), projectName, userPasswordCreds,
                request, filterProperties, "GET", null);
    } else {
        listener.getLogger().println("Using legacy");
        list = new RqmParameterList(getHostName(), getPort(), getContextRoot(), projectName, getUsrName(),
                getPasswd(), request, filterProperties, "GET", null);
    }

    /*
    TODO:
    Get a list of all plans in the current project. We need to do this since the feed-url does NOT allow us to filter based on names of a test when looking for test
    suite execution records. 
    */

    RqmObjectCreator<TestSuiteExecutionRecord> object = new RqmObjectCreator<TestSuiteExecutionRecord>(
            TestSuiteExecutionRecord.class, list, listener);
    Future<List<TestSuiteExecutionRecord>> result = build.getWorkspace().actAsync(object);
    return (List<T>) result.get(20, TimeUnit.MINUTES);

}

From source file:org.commonjava.indy.promote.callback.PromotionCallbackHelper.java

private <T extends AbstractPromoteResult> void stash(CallbackJob job) {
    if (job.getRetryCount() >= MAX_RETRY) {
        logger.warn("Callback failed after {} retries.", job.getRetryCount());
        return;/*w  w  w . ja  va 2 s .  c o  m*/
    }

    int exponentialBackoff = getExponentialBackoff(job.getRetryCount());
    job.increaseRetryCount();
    logger.debug("Add {} to retry cache, retryCount: {}", job.getId(), job.getRetryCount());
    retryCache.put(job.getId(), job, exponentialBackoff, TimeUnit.MINUTES);
}