@Override public GetClusterStatusResponse getClusterStatus() { ActorGateway jmGateway; try { jmGateway = getJobManagerGateway(); Future<Object> future = jmGateway.ask(GetClusterStatus.getInstance(), timeout); Object result = Await.result(future, timeout); if (result instanceof GetClusterStatusResponse) { return (GetClusterStatusResponse) result; } else { throw new RuntimeException("Received the wrong reply " + result + " from cluster."); } } catch (Exception e) { throw new RuntimeException("Couldn't retrieve the cluster status.", e); } }
/** * This method is only available if the cluster hasn't been started in detached mode. */ @Override public GetClusterStatusResponse getClusterStatus() { try { final Future<Object> clusterStatusOption = getJobManagerGateway().ask( GetClusterStatus.getInstance(), akkaDuration); return (GetClusterStatusResponse) Await.result(clusterStatusOption, akkaDuration); } catch (Exception e) { throw new RuntimeException("Unable to get ClusterClient status from Application Client", e); } }
/** * Cancels a job identified by the job id. * @param jobId the job id * @throws Exception In case an error occurred. */ public void cancel(JobID jobId) throws Exception { final ActorGateway jobManager = getJobManagerGateway(); Object cancelMsg = new JobManagerMessages.CancelJob(jobId); Future<Object> response = jobManager.ask(cancelMsg, timeout); final Object rc = Await.result(response, timeout); if (rc instanceof JobManagerMessages.CancellationSuccess) { // no further action required } else if (rc instanceof JobManagerMessages.CancellationFailure) { throw new Exception("Canceling the job with ID " + jobId + " failed.", ((JobManagerMessages.CancellationFailure) rc).cause()); } else { throw new IllegalStateException("Unexpected response: " + rc); } }
/** * Cancels a job identified by the job id and triggers a savepoint. * @param jobId the job id * @param savepointDirectory directory the savepoint should be written to * @return path where the savepoint is located * @throws Exception In case an error occurred. */ public String cancelWithSavepoint(JobID jobId, @Nullable String savepointDirectory) throws Exception { final ActorGateway jobManager = getJobManagerGateway(); Object cancelMsg = new JobManagerMessages.CancelJobWithSavepoint(jobId, savepointDirectory); Future<Object> response = jobManager.ask(cancelMsg, timeout); final Object rc = Await.result(response, timeout); if (rc instanceof JobManagerMessages.CancellationSuccess) { JobManagerMessages.CancellationSuccess success = (JobManagerMessages.CancellationSuccess) rc; return success.savepointPath(); } else if (rc instanceof JobManagerMessages.CancellationFailure) { throw new Exception("Cancel & savepoint for the job with ID " + jobId + " failed.", ((JobManagerMessages.CancellationFailure) rc).cause()); } else { throw new IllegalStateException("Unexpected response: " + rc); } }
/** * Stops a program on Flink cluster whose job-manager is configured in this client's configuration. * Stopping works only for streaming programs. Be aware, that the program might continue to run for * a while after sending the stop command, because after sources stopped to emit data all operators * need to finish processing. * * @param jobId * the job ID of the streaming program to stop * @throws Exception * If the job ID is invalid (ie, is unknown or refers to a batch job) or if sending the stop signal * failed. That might be due to an I/O problem, ie, the job-manager is unreachable. */ public void stop(final JobID jobId) throws Exception { final ActorGateway jobManager = getJobManagerGateway(); Future<Object> response = jobManager.ask(new JobManagerMessages.StopJob(jobId), timeout); final Object rc = Await.result(response, timeout); if (rc instanceof JobManagerMessages.StoppingSuccess) { // no further action required } else if (rc instanceof JobManagerMessages.StoppingFailure) { throw new Exception("Stopping the job with ID " + jobId + " failed.", ((JobManagerMessages.StoppingFailure) rc).cause()); } else { throw new IllegalStateException("Unexpected response: " + rc); } }
YarnMessages.getLocalGetYarnMessage(), new Timeout(akkaDuration)); result = Await.result(response, akkaDuration); } catch (Exception ioe) { LOG.warn("Error retrieving the YARN messages locally", ioe);
/** * Requests and returns the accumulators for the given job identifier. Accumulators can be * requested while a is running or after it has finished. * @param jobID The job identifier of a job. * @param loader The class loader for deserializing the accumulator results. * @return A Map containing the accumulator's name and its value. */ public Map<String, OptionalFailure<Object>> getAccumulators(JobID jobID, ClassLoader loader) throws Exception { ActorGateway jobManagerGateway = getJobManagerGateway(); Future<Object> response; try { response = jobManagerGateway.ask(new RequestAccumulatorResults(jobID), timeout); } catch (Exception e) { throw new Exception("Failed to query the job manager gateway for accumulators.", e); } Object result = Await.result(response, timeout); if (result instanceof AccumulatorResultsFound) { Map<String, SerializedValue<OptionalFailure<Object>>> serializedAccumulators = ((AccumulatorResultsFound) result).result(); return AccumulatorHelper.deserializeAccumulators(serializedAccumulators, loader); } else if (result instanceof AccumulatorResultsErroneous) { throw ((AccumulatorResultsErroneous) result).cause(); } else { throw new Exception("Failed to fetch accumulators for the job " + jobID + "."); } }
private Status sendMessageToLocalRouters( QakkaMessage message ) { int maxRetries = 5; int retries = 0; while ( retries++ < maxRetries ) { try { Timeout t = new Timeout( 1, TimeUnit.SECONDS ); // ask ClientActor and wait (up to timeout) for response Future<Object> fut = Patterns.ask( actorSystemManager.getClientActor(), message, t ); final QakkaMessage response = (QakkaMessage)Await.result( fut, t.duration() ); if ( response != null && response instanceof QueueAckResponse) { QueueAckResponse qprm = (QueueAckResponse)response; return qprm.getStatus(); } else if ( response != null ) { logger.debug("UNKNOWN RESPONSE sending message, retrying {}", retries ); } else { logger.trace("TIMEOUT sending message, retrying {}", retries ); } } catch ( TimeoutException e ) { logger.trace( "TIMEOUT sending message, retrying " + retries, e ); } catch ( Exception e ) { logger.debug("ERROR sending message, retrying " + retries, e ); } } throw new QakkaRuntimeException( "Error sending message " + message + "after " + retries ); }
private void waitForClientActor( ActorRef ra ) { logger.info( "Waiting on ClientActor [{}]...", ra.path() ); started = false; int retries = 0; int maxRetries = 60; while (retries < maxRetries) { Timeout t = new Timeout( 10, TimeUnit.SECONDS ); Future<Object> fut = Patterns.ask( ra, new ClientActor.StatusRequest(), t ); try { ClientActor.StatusMessage result = (ClientActor.StatusMessage) Await.result( fut, t.duration() ); if (result.getStatus().equals( ClientActor.StatusMessage.Status.READY )) { started = true; break; } logger.info( "Waiting for ClientActor [{}] region [{}] for [{}s]", ra.path(), currentRegion, retries ); Thread.sleep( 1000 ); } catch (Exception e) { logger.error( "Error: Timeout waiting for ClientActor [{}]", ra.path() ); } retries++; } if (started) { logger.info( "ClientActor [{}] has started", ra.path() ); } else { throw new RuntimeException( "ClientActor ["+ra.path()+"] did not start in time, validate that akka seeds are configured properly" ); } }
final Object response = Await.result( fut, t.duration() );
final Object response = Await.result( fut, t.duration() );
response = (UniqueValueActor.Response) Await.result( fut, t.duration() );
int numberOfRegisteredResources = (Integer) Await.result(numberOfRegisteredResourcesFuture, deadline.timeLeft());
timeout); int numRegisteredTMs = (Integer) Await.result(registeredTMs, timeout);
Await.result(jobSubmission.resultPromise.future(), deadline.timeLeft());
commandResponseFromManager = (ResponseFromManager) Await.result( future, duration);
@Benchmark public String setValue() throws Exception { Promise<String> p = Promise.<String>apply(); p.success(string); return Await.result(p.future(), inf); }
@Benchmark public String flatMapPromiseN() throws Exception { Promise<String> p = Promise.<String>apply(); Future<String> f = p.future(); for (int i = 0; i < N.n; i++) f = f.flatMap(flatMapF, ec); p.success(string); return Await.result(f, inf); }
@Test public void testGetProvidedSources() throws Exception { Set<SourceIdentifier> remoteProvidedSources = Await.result(remoteRepository .getProvidedSources(), FiniteDuration.Zero()); assertEquals(providedSources, remoteProvidedSources); }