if (!configuredOk()) { return; synchronized (AbstractInactivityMonitor.class) { if (ASYNC_TASKS == null || ASYNC_TASKS.isShutdown()) { ASYNC_TASKS = createExecutor();
@Override public void oneway(Object o) throws IOException { // To prevent the inactivity monitor from sending a message while we // are performing a send we take a read lock. The inactivity monitor // sends its Heart-beat commands under a write lock. This means that // the MutexTransport is still responsible for synchronizing sends sendLock.readLock().lock(); inSend.set(true); try { doOnewaySend(o); } finally { commandSent.set(true); inSend.set(false); sendLock.readLock().unlock(); } }
public synchronized void startConnectCheckTask() { startConnectCheckTask(getConnectAttemptTimeout()); }
try { info.setResponseRequired(false); oneway(info); } catch (IOException e) { onException(e); } finally { sendLock.readLock().unlock(); synchronized (this) { try { processInboundWireFormatInfo((WireFormatInfo) command); } catch (IOException e) { onException(e);
@Override public void run() { LOG.debug("Running {}", this); onException(new InactivityIOException("Channel was inactive for too (>" + readCheckTime + ") long: " + next.getRemoteAddress())); }
@Override public String toString() { return "WriteCheck[" + getRemoteAddress() + "]"; }; });
private void doOnewaySend(Object command) throws IOException { if (failed.get()) { throw new InactivityIOException("Cannot send, channel has already failed: " + next.getRemoteAddress()); } if (command.getClass() == WireFormatInfo.class) { synchronized (this) { processOutboundWireFormatInfo((WireFormatInfo) command); } } next.oneway(command); }
private ThreadPoolExecutor createExecutor() { ThreadPoolExecutor exec = new ThreadPoolExecutor(0, Integer.MAX_VALUE, getDefaultKeepAliveTime(), TimeUnit.SECONDS, new SynchronousQueue<Runnable>(), factory); exec.allowCoreThreadTimeOut(true); return exec; }
public synchronized void startConnectCheckTask(long connectionTimeout) { if (connectionTimeout <= 0) { return; } LOG.trace("Starting connection check task for: {}", this); this.connectAttemptTimeout = connectionTimeout; if (connectCheckerTask == null) { connectCheckerTask = new SchedulerTimerTask(connectChecker); synchronized (AbstractInactivityMonitor.class) { if (CHECKER_COUNTER == 0) { if (ASYNC_TASKS == null || ASYNC_TASKS.isShutdown()) { ASYNC_TASKS = createExecutor(); } if (READ_CHECK_TIMER == null) { READ_CHECK_TIMER = new Timer("ActiveMQ InactivityMonitor ReadCheckTimer", true); } } CHECKER_COUNTER++; READ_CHECK_TIMER.schedule(connectCheckerTask, connectionTimeout); } } }
try { info.setResponseRequired(false); oneway(info); } catch (IOException e) { onException(e); } finally { sendLock.readLock().unlock(); synchronized (this) { try { processInboundWireFormatInfo((WireFormatInfo) command); } catch (IOException e) { onException(e);
@Override public void run() { LOG.debug("Running {}", this); if (monitorStarted.get()) { try { // If we can't get the lock it means another // write beat us into the // send and we don't need to heart beat now. if (sendLock.writeLock().tryLock()) { KeepAliveInfo info = new KeepAliveInfo(); info.setResponseRequired(keepAliveResponseRequired); doOnewaySend(info); } } catch (IOException e) { onException(e); } finally { if (sendLock.writeLock().isHeldByCurrentThread()) { sendLock.writeLock().unlock(); } } } }
@Override public String toString() { return "ReadCheck[" + getRemoteAddress() + "]"; }; });
private void doOnewaySend(Object command) throws IOException { if (failed.get()) { throw new InactivityIOException("Cannot send, channel has already failed: " + next.getRemoteAddress()); } if (command.getClass() == WireFormatInfo.class) { synchronized (this) { processOutboundWireFormatInfo((WireFormatInfo) command); } } next.oneway(command); }
private ThreadPoolExecutor createExecutor() { ThreadPoolExecutor exec = new ThreadPoolExecutor(0, Integer.MAX_VALUE, getDefaultKeepAliveTime(), TimeUnit.SECONDS, new SynchronousQueue<Runnable>(), factory); exec.allowCoreThreadTimeOut(true); return exec; }
public synchronized void startConnectCheckTask(long connectionTimeout) { if (connectionTimeout <= 0) { return; } LOG.trace("Starting connection check task for: {}", this); this.connectAttemptTimeout = connectionTimeout; if (connectCheckerTask == null) { connectCheckerTask = new SchedulerTimerTask(connectChecker); synchronized (AbstractInactivityMonitor.class) { if (CHECKER_COUNTER == 0) { if (ASYNC_TASKS == null || ASYNC_TASKS.isShutdown()) { ASYNC_TASKS = createExecutor(); } if (READ_CHECK_TIMER == null) { READ_CHECK_TIMER = new Timer("ActiveMQ InactivityMonitor ReadCheckTimer", true); } } CHECKER_COUNTER++; READ_CHECK_TIMER.schedule(connectCheckerTask, connectionTimeout); } } }
try { info.setResponseRequired(false); oneway(info); } catch (IOException e) { onException(e); } finally { sendLock.readLock().unlock(); synchronized (this) { try { processInboundWireFormatInfo((WireFormatInfo) command); } catch (IOException e) { onException(e);
public synchronized void startConnectCheckTask() { startConnectCheckTask(getConnectAttemptTimeout()); }
if (!configuredOk()) { return; synchronized (AbstractInactivityMonitor.class) { if (ASYNC_TASKS == null || ASYNC_TASKS.isShutdown()) { ASYNC_TASKS = createExecutor();
@Override public void run() { LOG.debug("Running {}", this); onException(new InactivityIOException("Channel was inactive for too (>" + readCheckTime + ") long: " + next.getRemoteAddress())); }
@Override public String toString() { return "ReadCheck[" + getRemoteAddress() + "]"; }; });