/** * Cancel request and workers. */ @SuppressWarnings("deprecation") private void cancelRequestAndWorkers() { for (ActorRef worker : workers.values()) { if (worker != null && !worker.isTerminated()) { worker.tell(OperationWorkerMsgType.CANCEL, getSelf()); } } logger.info("ExecutionManager sending cancelPendingRequest at time: " + PcDateUtils.getNowDateTimeStr()); }
/** * Cancel request and worker on host. * * @param targetHosts * the target hosts */ @SuppressWarnings("deprecation") private void cancelRequestAndWorkerOnHost(List<String> targetHosts) { List<String> validTargetHosts = new ArrayList<String>(workers.keySet()); validTargetHosts.retainAll(targetHosts); logger.info("targetHosts for cancel: Total: {}" + " Valid in current manager with worker threads: {}", targetHosts.size(), validTargetHosts.size()); for (String targetHost : validTargetHosts) { ActorRef worker = workers.get(targetHost); if (worker != null && !worker.isTerminated()) { worker.tell(OperationWorkerMsgType.CANCEL, getSelf()); logger.info("Submitted CANCEL request on Host {}", targetHost); } else { logger.info( "Did NOT Submitted " + "CANCEL request on Host {} as worker on this host is null or already killed", targetHost); } } }
&& !executionManager.isTerminated()) { executionManager.tell(new CancelTaskOnHostRequest( targetHosts), executionManager);
case IN_PROGRESS: if (executionManager != null && !executionManager.isTerminated()) {
/** * will trigger workers to cancel then wait for it to report back. */ @SuppressWarnings("deprecation") private final void operationTimeout() { /** * first kill async http worker; before suicide LESSON: MUST KILL AND * WAIT FOR CHILDREN to reply back before kill itself. */ cancelCancellable(); if (asyncWorker != null && !asyncWorker.isTerminated()) { asyncWorker .tell(RequestWorkerMsgType.PROCESS_ON_TIMEOUT, getSelf()); } else { logger.info("asyncWorker has been killed or uninitialized (null). " + "Not send PROCESS ON TIMEOUT.\nREQ: " + request.toString()); replyErrors(PcConstants.OPERATION_TIMEOUT, PcConstants.OPERATION_TIMEOUT, PcConstants.NA, PcConstants.NA_INT); } }
/** * Cancel. */ @SuppressWarnings("deprecation") private final void cancel() { /** * first kill async http worker; before suicide LESSON: MUST KILL AND * WAIT FOR CHILDREN to reply back before kill itself. */ cancelCancellable(); if (asyncWorker != null && asyncWorker.isTerminated()) { asyncWorker.tell(RequestWorkerMsgType.CANCEL, getSelf()); } else { logger.info("asyncWorker has not been initilized (null). " + "Will not tell it cancel"); // in case this is the 1st request. currently only manager can send // this. if (sender == null) sender = getSender(); replyErrors(PcConstants.REQUEST_CANCELED, PcConstants.REQUEST_CANCELED, PcConstants.NA, PcConstants.NA_INT); } }
&& !batchSenderAsstManager.isTerminated()) { getContext().stop(batchSenderAsstManager); if (getSelf() != null && !getSelf().isTerminated()) { getContext().stop(getSelf());
if (executionManager != null && !executionManager.isTerminated()) { ActorConfig.createAndGetActorSystem().stop(executionManager);
if (asyncWorker != null && !asyncWorker.isTerminated()) { getContext().stop(asyncWorker);
/** * Returns true if the Actor corresponding to the supplied TypedActor proxy is terminated. * * @param proxy The TypedActor. * @return true if the corresponding Actor is terminated. */ public boolean actorForRefTerminated(@Nonnull final Object proxy) { assert proxy != null; return TypedActor.get(system).getActorRefFor(proxy).isTerminated(); } }
/** * Cancel request and workers. */ @SuppressWarnings("deprecation") private void cancelRequestAndWorkers() { for (ActorRef worker : workers.values()) { if (worker != null && !worker.isTerminated()) { worker.tell(OperationWorkerMsgType.CANCEL, getSelf()); } } logger.info("ExecutionManager sending cancelPendingRequest at time: " + PcDateUtils.getNowDateTimeStr()); }
private MediaSession getSession() { MediaSession s=null; try{ s = new MediaSession((int) sessionIdPool.get()); }catch(Exception e){ logger.error("Exception in getSession: "+e.getMessage() +" is MediaGateway actor terminated? "+self().isTerminated() +" current object snapshot: \n"+this.toString(), e); } return s; }
while (!supervisor.isTerminated()) { Thread.sleep(100);
/** * Cancel. */ @SuppressWarnings("deprecation") private final void cancel() { /** * first kill async http worker; before suicide LESSON: MUST KILL AND * WAIT FOR CHILDREN to reply back before kill itself. */ cancelCancellable(); if (asyncWorker != null && asyncWorker.isTerminated()) { asyncWorker.tell(RequestWorkerMsgType.CANCEL, getSelf()); } else { logger.info("asyncWorker has not been initilized (null). " + "Will not tell it cancel"); // in case this is the 1st request. currently only manager can send // this. if (sender == null) sender = getSender(); replyErrors(PcConstants.REQUEST_CANCELED, PcConstants.REQUEST_CANCELED, PcConstants.NA, PcConstants.NA_INT); } }
/** * will trigger workers to cancel then wait for it to report back. */ @SuppressWarnings("deprecation") private final void operationTimeout() { /** * first kill async http worker; before suicide LESSON: MUST KILL AND * WAIT FOR CHILDREN to reply back before kill itself. */ cancelCancellable(); if (asyncWorker != null && !asyncWorker.isTerminated()) { asyncWorker .tell(RequestWorkerMsgType.PROCESS_ON_TIMEOUT, getSelf()); } else { logger.info("asyncWorker has been killed or uninitialized (null). " + "Not send PROCESS ON TIMEOUT.\nREQ: " + request.toString()); replyErrors(PcConstants.OPERATION_TIMEOUT, PcConstants.OPERATION_TIMEOUT, PcConstants.NA, PcConstants.NA_INT); } }
@Override public void postStop() { if(logger.isDebugEnabled()) logger.debug("postStop called for: "+self()); // Cleanup resources cleanup(); // Clean observers observers.clear(); // Terminate actor if(self() != null && !self().isTerminated()){ getContext().stop(self()); } }
@Override public void execute(final Object message) throws Exception { final EndpointCredentials response = (EndpointCredentials) message; primaryEndpointId = response.endpointId(); if (secondaryEndpoint != null) { secondaryEndpoint.tell(new InviteEndpoint(), source); } logger.info("Link: "+self().path()+" ,state: "+fsm.state()+" ,primaryEndpointId: "+primaryEndpointId+" ,secondaryEndpoint: "+secondaryEndpoint.path()+" secondaryEndpoint isTerminated: "+secondaryEndpoint.isTerminated()); } }
@Override public void postStop () { if (logger.isInfoEnabled()) { logger.info("CallApiClient at post stop"); } if(httpAsycClientHelper != null && !httpAsycClientHelper.isTerminated()) getContext().stop(httpAsycClientHelper); getContext().stop(self()); super.postStop(); } }
@Override public void execute(final Object message) throws Exception { final InitializeLink request = (InitializeLink) message; primaryEndpoint = request.primaryEndpoint(); secondaryEndpoint = request.secondaryEndpoint(); logger.info("Link: "+self().path()+" ,state: "+fsm.state()+" ,primaryEndpoint: "+primaryEndpoint.path()+" ,secondaryEndpoint: "+secondaryEndpoint.path()); if (primaryEndpoint != null && !primaryEndpoint.isTerminated()) { primaryEndpoint.tell(new InviteEndpoint(), source); logger.info("Link: "+self().path()+" ,state: "+fsm.state()+" InviteEndpoint sent to primaryEndpoint: "+primaryEndpoint.path()); } else { logger.info("Link: "+self().path()+" ,state: "+fsm.state()+" InviteEndpoint DIDN'T sent to primaryEndpoint: "+primaryEndpoint.path()+" primaryEndpoint is Terminated: "+primaryEndpoint.isTerminated()); } } }
protected final ActorRef obtainWorkerRef(final NamedWorkerMetadata inputClassId) { ActorRef deviceRef = startingActors.get(inputClassId); if (null == deviceRef) { final String url = getInputActorUrl(inputClassId); deviceRef = getContext().system().actorFor(url); if (deviceRef.isTerminated()) { final String actId = inputClassId.getIdentifier(); log.debug("Starting new input processing actor with id {} in supervisor '{}'...", actId, getSelf().path().name()); deviceRef = getContext().actorOf(newInputProps(inputClassId), actId); startingActors.put(inputClassId, deviceRef); deviceRef.tell(new StartupRequest(), getSelf()); } else { log.debug("Passing existing device actor..."); } } else { log.debug("Passing existing device actor which is starting now..."); } return deviceRef; }