public void awaitTermination() throws InterruptedException { this.messageProcessedLatch.await(); } }
public RetryWorker(RetryPolicyTemplate delegate, RetryCallback callback, WorkManager workManager, Latch startLatch) { this.callback = callback; this.workManager = workManager; this.delegate = delegate; this.startLatch = startLatch; if (this.startLatch == null) { this.startLatch = new Latch(); this.startLatch.countDown(); } }
@Override public void messageProcessingEnded() { messageProcessedLatch.release(); }
public void release() { countDown(); }
public JettyContinuationsMessageProcessTemplate(HttpServletRequest request, HttpServletResponse response, AbstractMessageReceiver messageReceiver, MuleContext muleContext, Continuation continuation) { super(request, response, messageReceiver, muleContext); this.continuation = continuation; this.suspendLatch = new Latch(); }
private void countDown() { latch.countDown(); }
/** * Creates the lock used to synchronize a given event * @return a new Latch instance */ protected Latch createEventLock() { return new Latch(); }
@Override public boolean waitUntilStarted(int timeout) throws InterruptedException { return startLatch.await(timeout, TimeUnit.MILLISECONDS); }
@Override public void handshakeCompleted(HandshakeCompletedEvent handshakeCompletedEvent) { try { localCertificateChain = handshakeCompletedEvent.getLocalCertificates(); try { peerCertificateChain = handshakeCompletedEvent.getPeerCertificates(); } catch (SSLPeerUnverifiedException e) { logger.debug("Cannot get peer certificate chain: " + e.getMessage()); } } finally { sslSocketHandshakeComplete.release(); } }
public void suspended() { this.suspendLatch.countDown(); }
public void doExecute(WorkerContext work, Executor executor) throws WorkException, InterruptedException { Latch latch = work.provideStartLatch(); executor.execute(work); latch.await(); }
/** * Stops the <code>MuleContext</code> which stops all sessions and * connectors * * @throws MuleException if either any of the sessions or connectors fail to stop */ @Override public synchronized void stop() throws MuleException { startLatch.release(); getLifecycleManager().checkPhase(Stoppable.PHASE_NAME); fireNotification(new MuleContextNotification(this, MuleContextNotification.CONTEXT_STOPPING)); getLifecycleManager().fireLifecycle(Stoppable.PHASE_NAME); fireNotification(new MuleContextNotification(this, MuleContextNotification.CONTEXT_STOPPED)); }
@Override public void messageProcessingEnded() { try { this.suspendLatch.await(); } catch (InterruptedException e) { Thread.interrupted(); } this.continuation.resume(); } }
@Override public synchronized void start() throws MuleException { getLifecycleManager().checkPhase(Startable.PHASE_NAME); if (getQueueManager() == null) { throw new MuleRuntimeException(CoreMessages.objectIsNull("queueManager")); } startDate = System.currentTimeMillis(); fireNotification(new MuleContextNotification(this, MuleContextNotification.CONTEXT_STARTING)); getLifecycleManager().fireLifecycle(Startable.PHASE_NAME); overridePollingController(); overrideClusterConfiguration(); startMessageSources(); fireNotification(new MuleContextNotification(this, MuleContextNotification.CONTEXT_STARTED)); startLatch.release(); if (logger.isInfoEnabled()) { SplashScreen startupScreen = buildStartupSplash(); logger.info(startupScreen.toString()); } }
public void run() { try { startLatch.await(); } catch (InterruptedException e) { logger.warn("Retry thread interupted for callback: " + callback.getWorkDescription()); return; } try { context.setDelegateContext(delegate.execute(callback, workManager)); } catch (Exception e) { this.exception = e; logger.fatal(e, e); } }
@Override public MuleEvent beforeRouteEvent(MuleEvent muleEvent) throws MuleException { try { long timeout = ((HttpsConnector) getConnector()).getSslHandshakeTimeout(); boolean handshakeComplete = getHttpServerConnection().getSslSocketHandshakeCompleteLatch().await(timeout, TimeUnit.MILLISECONDS); if (!handshakeComplete) { throw new MessagingException(HttpMessages.sslHandshakeDidNotComplete(), muleEvent); } } catch (InterruptedException e) { throw new MessagingException(HttpMessages.sslHandshakeDidNotComplete(), muleEvent, e); } if (getHttpServerConnection().getPeerCertificateChain() != null) { muleEvent.getMessage().setOutboundProperty(HttpsConnector.PEER_CERTIFICATES, getHttpServerConnection().getPeerCertificateChain()); } if (getHttpServerConnection().getLocalCertificateChain() != null) { muleEvent.getMessage().setOutboundProperty(HttpsConnector.LOCAL_CERTIFICATES, getHttpServerConnection().getLocalCertificateChain()); } super.beforeRouteEvent(muleEvent); return muleEvent; } }