Java Code Examples for scala.concurrent.duration.FiniteDuration#apply()
The following examples show how to use
scala.concurrent.duration.FiniteDuration#apply() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: RetrieveConnectionLogsAggregatorActorTest.java From ditto with Eclipse Public License 2.0 | 6 votes |
@Test public void withTimeoutWithMessages() { new TestKit(actorSystem) {{ final TestProbe sender = TestProbe.apply(actorSystem); final Duration aggregatorTimeout = Duration.ofSeconds(5); final FiniteDuration expectMessageTimeout = FiniteDuration.apply(aggregatorTimeout.getSeconds() + 1, TimeUnit.SECONDS); // create connection with more clients than responses final Connection connection = createConnectionWithClients(2); final ActorRef underTest = childActorOf( RetrieveConnectionLogsAggregatorActor.props(connection, sender.ref(), DITTO_HEADERS, aggregatorTimeout, LOGGER_CONFIG.maxLogSizeInBytes())); // only send one response final RetrieveConnectionLogsResponse expectedResponse = createRetrieveConnectionLogsResponse(connection.getId(), Instant.now().minusSeconds(123), Instant.now().plusSeconds(444)); underTest.tell(expectedResponse, getRef()); // expect that known response will be sent, ignoring missing responses sender.expectMsg(expectMessageTimeout, expectedResponse); }}; }
Example 2
Source File: ActorGatewayKvStateLocationOracle.java From Flink-CEPplus with Apache License 2.0 | 5 votes |
public ActorGatewayKvStateLocationOracle( ActorGateway jobManagerActorGateway, Time timeout) { this.jobManagerActorGateway = Preconditions.checkNotNull(jobManagerActorGateway); Preconditions.checkNotNull(timeout); this.timeout = FiniteDuration.apply(timeout.toMilliseconds(), TimeUnit.MILLISECONDS); }
Example 3
Source File: CompositeCachingHealthCheckingActor.java From ditto with Eclipse Public License 2.0 | 5 votes |
@Override public void preStart() throws Exception { super.preStart(); if (enabled) { final FiniteDuration interval = FiniteDuration.apply(updateInterval.toMillis(), TimeUnit.MILLISECONDS); checkHealthCancellable = getContext().system().scheduler() .schedule(interval, interval, getSelf(), CheckHealth.newInstance(), getContext().dispatcher(), getSelf()); } else { log.warning("HealthCheck is DISABLED - not polling for health at all"); } }
Example 4
Source File: StreamingSessionActor.java From ditto with Eclipse Public License 2.0 | 5 votes |
private Cancellable startSessionTimeout(final Instant sessionExpirationTime) { final long timeout = sessionExpirationTime.minusMillis(Instant.now().toEpochMilli()).toEpochMilli(); logger.debug("Starting session timeout - session will expire in {} ms", timeout); final FiniteDuration sessionExpirationTimeMillis = FiniteDuration.apply(timeout, TimeUnit.MILLISECONDS); return getContext().getSystem().getScheduler().scheduleOnce(sessionExpirationTimeMillis, this::handleSessionTimeout, getContext().getDispatcher()); }
Example 5
Source File: OlapJobStatus.java From spliceengine with GNU Affero General Public License v3.0 | 5 votes |
public OlapJobStatus(long tickTime,int numTicks){ //TODO -sf- remove the constants FiniteDuration maxHeartbeatInterval = FiniteDuration.apply(numTicks*tickTime,TimeUnit.MILLISECONDS); FiniteDuration stdDev = FiniteDuration.apply(2*tickTime,TimeUnit.MILLISECONDS); FiniteDuration firstTick = FiniteDuration.apply(tickTime,TimeUnit.MILLISECONDS); failureDetector = new PhiAccrualFailureDetector(10,128,stdDev,maxHeartbeatInterval,firstTick, FailureDetector$.MODULE$.defaultClock()); this.tickTime = tickTime; this.results = new ArrayBlockingQueue<>(1); }
Example 6
Source File: MesosEntrypointUtils.java From Flink-CEPplus with Apache License 2.0 | 4 votes |
/** * Loads and validates the Mesos scheduler configuration. * @param flinkConfig the global configuration. * @param hostname the hostname to advertise to the Mesos master. */ public static MesosConfiguration createMesosSchedulerConfiguration(Configuration flinkConfig, String hostname) { Protos.FrameworkInfo.Builder frameworkInfo = Protos.FrameworkInfo.newBuilder() .setHostname(hostname); Protos.Credential.Builder credential = null; if (!flinkConfig.contains(MesosOptions.MASTER_URL)) { throw new IllegalConfigurationException(MesosOptions.MASTER_URL.key() + " must be configured."); } String masterUrl = flinkConfig.getString(MesosOptions.MASTER_URL); Duration failoverTimeout = FiniteDuration.apply( flinkConfig.getInteger( MesosOptions.FAILOVER_TIMEOUT_SECONDS), TimeUnit.SECONDS); frameworkInfo.setFailoverTimeout(failoverTimeout.toSeconds()); frameworkInfo.setName(flinkConfig.getString( MesosOptions.RESOURCEMANAGER_FRAMEWORK_NAME)); frameworkInfo.setRole(flinkConfig.getString( MesosOptions.RESOURCEMANAGER_FRAMEWORK_ROLE)); frameworkInfo.setUser(flinkConfig.getString( MesosOptions.RESOURCEMANAGER_FRAMEWORK_USER)); if (flinkConfig.contains(MesosOptions.RESOURCEMANAGER_FRAMEWORK_PRINCIPAL)) { frameworkInfo.setPrincipal(flinkConfig.getString( MesosOptions.RESOURCEMANAGER_FRAMEWORK_PRINCIPAL)); credential = Protos.Credential.newBuilder(); credential.setPrincipal(frameworkInfo.getPrincipal()); // some environments use a side-channel to communicate the secret to Mesos, // and thus don't set the 'secret' configuration setting if (flinkConfig.contains(MesosOptions.RESOURCEMANAGER_FRAMEWORK_SECRET)) { credential.setSecret(flinkConfig.getString( MesosOptions.RESOURCEMANAGER_FRAMEWORK_SECRET)); } } MesosConfiguration mesos = new MesosConfiguration(masterUrl, frameworkInfo, scala.Option.apply(credential)); return mesos; }
Example 7
Source File: MesosEntrypointUtils.java From flink with Apache License 2.0 | 4 votes |
/** * Loads and validates the Mesos scheduler configuration. * @param flinkConfig the global configuration. * @param hostname the hostname to advertise to the Mesos master. */ public static MesosConfiguration createMesosSchedulerConfiguration(Configuration flinkConfig, String hostname) { Protos.FrameworkInfo.Builder frameworkInfo = Protos.FrameworkInfo.newBuilder() .setHostname(hostname); Protos.Credential.Builder credential = null; if (!flinkConfig.contains(MesosOptions.MASTER_URL)) { throw new IllegalConfigurationException(MesosOptions.MASTER_URL.key() + " must be configured."); } String masterUrl = flinkConfig.getString(MesosOptions.MASTER_URL); Duration failoverTimeout = FiniteDuration.apply( flinkConfig.getInteger( MesosOptions.FAILOVER_TIMEOUT_SECONDS), TimeUnit.SECONDS); frameworkInfo.setFailoverTimeout(failoverTimeout.toSeconds()); frameworkInfo.setName(flinkConfig.getString( MesosOptions.RESOURCEMANAGER_FRAMEWORK_NAME)); frameworkInfo.setRole(flinkConfig.getString( MesosOptions.RESOURCEMANAGER_FRAMEWORK_ROLE)); frameworkInfo.setUser(flinkConfig.getString( MesosOptions.RESOURCEMANAGER_FRAMEWORK_USER)); if (flinkConfig.contains(MesosOptions.RESOURCEMANAGER_FRAMEWORK_PRINCIPAL)) { frameworkInfo.setPrincipal(flinkConfig.getString( MesosOptions.RESOURCEMANAGER_FRAMEWORK_PRINCIPAL)); credential = Protos.Credential.newBuilder(); credential.setPrincipal(frameworkInfo.getPrincipal()); // some environments use a side-channel to communicate the secret to Mesos, // and thus don't set the 'secret' configuration setting if (flinkConfig.contains(MesosOptions.RESOURCEMANAGER_FRAMEWORK_SECRET)) { credential.setSecret(flinkConfig.getString( MesosOptions.RESOURCEMANAGER_FRAMEWORK_SECRET)); } } MesosConfiguration mesos = new MesosConfiguration(masterUrl, frameworkInfo, scala.Option.apply(credential)); return mesos; }
Example 8
Source File: BlockedNamespaces.java From ditto with Eclipse Public License 2.0 | 4 votes |
private Replicator.WriteConsistency writeAll() { return new Replicator.WriteAll(FiniteDuration.apply(writeTimeout.toMillis(), TimeUnit.MILLISECONDS)); }
Example 9
Source File: ReconnectActor.java From ditto with Eclipse Public License 2.0 | 4 votes |
private FiniteDuration getInitialDelay() { final Duration initialDelay = reconnectConfig.getInitialDelay(); return FiniteDuration.apply(initialDelay.toMillis(), TimeUnit.MILLISECONDS); }
Example 10
Source File: ReconnectActor.java From ditto with Eclipse Public License 2.0 | 4 votes |
private FiniteDuration getInterval() { final Duration interval = reconnectConfig.getInterval(); return FiniteDuration.apply(interval.toMillis(), TimeUnit.MILLISECONDS); }
Example 11
Source File: MesosUtils.java From flink with Apache License 2.0 | 4 votes |
/** * Loads and validates the Mesos scheduler configuration. * @param flinkConfig the global configuration. * @param hostname the hostname to advertise to the Mesos master. */ public static MesosConfiguration createMesosSchedulerConfiguration(Configuration flinkConfig, String hostname) { Protos.FrameworkInfo.Builder frameworkInfo = Protos.FrameworkInfo.newBuilder() .setHostname(hostname); Protos.Credential.Builder credential = null; if (!flinkConfig.contains(MesosOptions.MASTER_URL)) { throw new IllegalConfigurationException(MesosOptions.MASTER_URL.key() + " must be configured."); } String masterUrl = flinkConfig.getString(MesosOptions.MASTER_URL); Duration failoverTimeout = FiniteDuration.apply( flinkConfig.getInteger( MesosOptions.FAILOVER_TIMEOUT_SECONDS), TimeUnit.SECONDS); frameworkInfo.setFailoverTimeout(failoverTimeout.toSeconds()); frameworkInfo.setName(flinkConfig.getString( MesosOptions.RESOURCEMANAGER_FRAMEWORK_NAME)); frameworkInfo.setRole(flinkConfig.getString( MesosOptions.RESOURCEMANAGER_FRAMEWORK_ROLE)); frameworkInfo.setUser(flinkConfig.getString( MesosOptions.RESOURCEMANAGER_FRAMEWORK_USER)); if (flinkConfig.contains(MesosOptions.RESOURCEMANAGER_FRAMEWORK_PRINCIPAL)) { frameworkInfo.setPrincipal(flinkConfig.getString( MesosOptions.RESOURCEMANAGER_FRAMEWORK_PRINCIPAL)); credential = Protos.Credential.newBuilder(); credential.setPrincipal(frameworkInfo.getPrincipal()); // some environments use a side-channel to communicate the secret to Mesos, // and thus don't set the 'secret' configuration setting if (flinkConfig.contains(MesosOptions.RESOURCEMANAGER_FRAMEWORK_SECRET)) { credential.setSecret(flinkConfig.getString( MesosOptions.RESOURCEMANAGER_FRAMEWORK_SECRET)); } } MesosConfiguration mesos = new MesosConfiguration(masterUrl, frameworkInfo, scala.Option.apply(credential)); return mesos; }