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:io.kodokojo.bdd.stage.BrickStateNotificationThen.java

public SELF i_receive_all_notification() {
    try {/*  ww w .j a v  a 2 s  .  c  om*/
        nbMessageExpected.await(2, TimeUnit.MINUTES);
    } catch (InterruptedException e) {
        Thread.currentThread().interrupt();
    }
    GsonBuilder builder = new GsonBuilder();
    builder.registerTypeAdapter(WebSocketMessage.class, new WebSocketMessageGsonAdapter());
    Gson gson = builder.create();
    LinkedList<String> srcMessages = new LinkedList<>(listener.getMessages());
    assertThat(srcMessages).isNotEmpty();

    List<WebSocketMessage> webSocketMessages = srcMessages.stream()
            .map(m -> gson.fromJson(m, WebSocketMessage.class)).collect(Collectors.toList());
    Map<String, List<WebSocketMessage>> messagePerBrick = new HashMap<>();
    for (WebSocketMessage message : webSocketMessages) {
        if ("brick".equals(message.getEntity())) {
            assertThat(message.getEntity()).isEqualTo("brick");
            assertThat(message.getAction()).isEqualTo("updateState");
            assertThat(message.getData().has("projectConfiguration")).isTrue();
            assertThat(message.getData().has("brickType")).isTrue();
            assertThat(message.getData().has("brickName")).isTrue();
            assertThat(message.getData().has("state")).isTrue();

            String brickName = message.getData().get("brickName").getAsString();
            assertThat(brickName).isIn(expectedBrickStarted);
            List<WebSocketMessage> previous = messagePerBrick.get(brickName);
            if (previous != null) {
            } else {
                previous = new ArrayList<>();
                messagePerBrick.put(brickName, previous);
            }
            previous.add(message);
        }
    }

    for (Map.Entry<String, List<WebSocketMessage>> entry : messagePerBrick.entrySet()) {
        List<WebSocketMessage> messages = entry.getValue();
        boolean configuring = false, starting = false, running = false;
        for (WebSocketMessage webSocketMessage : messages) {
            String state = webSocketMessage.getData().get("state").getAsString();
            switch (state) {
            case "STARTING":
                starting = true;
                break;
            case "CONFIGURING":
                configuring = true;
                break;
            case "RUNNING":
                running = true;
                break;
            default:
                fail("UnExpected state " + state);
            }
        }
        assertThat(configuring).isTrue();
        assertThat(starting).isTrue();
        assertThat(running).isTrue();
    }

    currentStep.addAttachment(Attachment.plainText(StringUtils.join(srcMessages, "\n"))
            .withTitle("WebSocket messages receive").withFileName("websocketMessages"));

    return self();
}

From source file:com.kinglcc.spring.jms.filter.SharedTopicFilter.java

@Override
public boolean doFilter(Message jmsMessage, Session session) {
    try {/*from   ww w. j  ava2s.  c  o  m*/
        String messageId = jmsMessage.getJMSMessageID();
        return putIfAbsent(messageId, VALUE_STORE_IN_REDIS, MSGID_EXPIREDTIME, TimeUnit.MINUTES);
    } catch (JMSException e) {
        LOGGER.error("Get JMS message id error", e);
    }
    return false;
}

From source file:com.mmj.app.lucene.search.build.SearchBuilder.java

@PostConstruct
public void cronCache() {
    ScheduledExecutorService newScheduledThreadPool = Executors.newScheduledThreadPool(1);
    newScheduledThreadPool.scheduleAtFixedRate(new Runnable() {

        @Override/*  www.j a  v  a  2 s  .  co m*/
        public void run() {
            try {
                build(SearchTypeEnum.USER, DEFAULT_VERSION, SearchTypeEnum.USER.getDateFetcher(null));
                build(SearchTypeEnum.TOPIC, DEFAULT_VERSION, SearchTypeEnum.TOPIC.getDateFetcher(null));
            } catch (Throwable e) {
                logger.error("start searchBuilder error,build search index error!", e);
            }
        }

    }, 1, 24 * 60, TimeUnit.MINUTES);
}

From source file:io.apiman.test.integration.rest.apis.metrics.AbstractIntervalMetricsIT.java

protected void recordMetricsInFollowingMinute() throws InterruptedException {
    // wait until current minute expires
    long millisWithinMinute = System.currentTimeMillis() % TimeUnit.MINUTES.toMillis(1);
    long waitFor = TimeUnit.MINUTES.toMillis(1) - millisWithinMinute;
    LOG.info(String.format("Waiting %d seconds current minute expires.",
            TimeUnit.MILLISECONDS.toSeconds(waitFor)));
    Thread.sleep(waitFor);/*  w  ww . ja v  a 2  s.c  om*/

    recordSuccessfulRequests(2);
    recordFailedRequests(5);
    TimeUnit.SECONDS.sleep(TIME_DELAY);
}

From source file:com.netflix.spinnaker.halyard.deploy.provider.v1.KubernetesProvider.java

@Override
public void bootstrapClouddriver() {
    JobRequest request = new JobRequest().setTokenizedCommand(Arrays.asList("kubectl", "create", "-f", "-"))
            .setTimeoutMillis(TimeUnit.MINUTES.toMillis(TIMEOUT_MINUTES));

    InputStream cloudddriverConfig = getClass().getResourceAsStream(CLOUDRIVER_CONFIG_PATH);

    String jobId = jobExecutor.startJob(request, System.getenv(), cloudddriverConfig);

    JobStatus jobStatus = jobExecutor.backoffWait(jobId, TimeUnit.SECONDS.toMillis(MIN_POLL_INTERVAL_SECONDS),
            TimeUnit.SECONDS.toMillis(MAX_POLL_INTERVAL_SECONDS));

    System.out.println(jobStatus.getStdOut());
    System.out.println(jobStatus.getStdErr());
}

From source file:fi.jumi.launcher.JumiLauncherBuilder.java

public JumiLauncher build() {
    ExecutorService actorsThreadPool = createActorsThreadPool();
    ProcessStarter processStarter = createProcessStarter();
    NetworkServer networkServer = createNetworkServer();
    OutputStream daemonOutputListener = createDaemonOutputListener();

    Actors actors = new MultiThreadedActors(actorsThreadPool, new DynamicEventizerProvider(),
            new PrintStreamFailureLogger(System.out), new NullMessageListener());
    ActorThread actorThread = startActorThread(actors);

    ActorRef<DaemonSummoner> daemonSummoner = actorThread.bindActor(DaemonSummoner.class,
            new ProcessStartingDaemonSummoner(new DirBasedSteward(new EmbeddedDaemonJar()), processStarter,
                    networkServer, daemonOutputListener));
    ActorRef<SuiteLauncher> suiteLauncher = actorThread.bindActor(SuiteLauncher.class,
            new RemoteSuiteLauncher(actorThread, daemonSummoner));

    return new JumiLauncher(suiteLauncher, () -> {
        networkServer.close();//from   w w w.  jav  a  2  s.  com
        actorThread.stop();
        actorsThreadPool.shutdown();
        try {
            actorsThreadPool.awaitTermination(1, TimeUnit.MINUTES);
        } catch (InterruptedException e) {
            Thread.currentThread().interrupt();
        }
    });
}

From source file:org.cloudfoundry.practical.demo.RootConfiguration.java

@Bean
public TimeoutProtectionStrategy timeoutProtectionStrategy() {
    ReplayingTimeoutProtectionStrategy strategy = new ReplayingTimeoutProtectionStrategy();
    strategy.setThreshold(TimeUnit.SECONDS.toMillis(12));
    strategy.setFailTimeout(TimeUnit.MINUTES.toMillis(4));
    return strategy;
}

From source file:net.i2cat.netconf.utils.TimerKeepAlive.java

public void reset() {
    close();
    schedulerHandler = timer.scheduleAtFixedRate(this, period, period, TimeUnit.MINUTES);
}

From source file:com.openshift.internal.restclient.capability.resources.OpenShiftBinaryRSync.java

private void waitForExit(String source, String destination, Process process) {
    try {//from  ww  w . j  a va  2 s  .  c  o  m
        if (process == null) {
            throw new OpenShiftException("Could not sync %s to %s, no process was launched.", destination);
        }
        if (!process.waitFor(WAIT_FOR_EXIT_TIMEOUT, TimeUnit.MINUTES)) {
            throw new OpenShiftException("Syncing %s to %s did not terminate within %d minutes.", source,
                    destination, WAIT_FOR_EXIT_TIMEOUT);
        }

        if (process.exitValue() != 0) {
            String errorMessage = getErrorMessage(process.getErrorStream());
            throw new OpenShiftException(
                    "Syncing %s to %s failed" + (StringUtil.isBlank(errorMessage) ? "" : ":%s"), source,
                    destination, errorMessage);
        }
    } catch (InterruptedException e) {
        throw new OpenShiftException(e, "Syncing %s to %s was interrupted.", source, destination);
    }
}

From source file:org.flite.cach3.aop.LogicalCacheImpl.java

public void afterPropertiesSet() throws Exception {
    this.nanny = CacheBuilder.newBuilder().maximumSize(10000).expireAfterWrite(5, TimeUnit.MINUTES).build();

    // TODO: Refactor to use a configurable set of cache sizes.
    for (final Duration duration : DURATION_SET) {
        final Cache<String, Object> single = CacheBuilder.newBuilder().maximumSize(1000)
                .expireAfterWrite(duration.getMillis(), TimeUnit.MILLISECONDS).build();
        caches.put(duration, single);//from  w  w w . ja v  a  2  s. c  om
    }
}