@Override public void run() { connectionInUse.fail(me); } });
@Override public void scheduledFlush() { flush(); }
@Override public boolean isWritable(ReadyListener callback) { return remotingConnection.isWritable(callback); }
@Override public void bufferReceived(final Object connectionID, final ActiveMQBuffer buffer) { RemotingConnection theConn = connection; if (theConn != null && connectionID.equals(theConn.getID())) { try { theConn.bufferReceived(connectionID, buffer); } catch (final RuntimeException e) { ActiveMQClientLogger.LOGGER.disconnectOnErrorDecoding(e); threadPool.execute(new Runnable() { @Override public void run() { theConn.fail(new ActiveMQException(e.getMessage())); } }); } } else { logger.debug("TheConn == null on ClientSessionFactoryImpl::DelegatingBufferHandler, ignoring packet"); } } }
@Override public synchronized void run() { if (cancelled || stopPingingAfterOne && !first) { return; } first = false; long now = System.currentTimeMillis(); final RemotingConnection connectionInUse = connection; if (connectionInUse != null && clientFailureCheckPeriod != -1 && connectionTTL != -1 && now >= lastCheck + connectionTTL) { if (!connectionInUse.checkDataReceived()) { // We use a different thread to send the fail // but the exception has to be created here to preserve the stack trace final ActiveMQException me = ActiveMQClientMessageBundle.BUNDLE.connectionTimedOut(connection.getTransportConnection()); cancelled = true; threadPool.execute(new Runnable() { // Must be executed on different thread @Override public void run() { connectionInUse.fail(me); } }); return; } else { lastCheck = now; } } send(); }
protected RemotingConnection establishNewConnection() { Connection transportConnection = createTransportConnection(); if (transportConnection == null) { if (ClientSessionFactoryImpl.logger.isTraceEnabled()) { logger.trace("Neither backup or live were active, will just give up now"); } return null; } RemotingConnection newConnection = clientProtocolManager.connect(transportConnection, callTimeout, callFailoverTimeout, incomingInterceptors, outgoingInterceptors, new SessionFactoryTopologyHandler()); newConnection.addFailureListener(new DelegatingFailureListener(newConnection.getID())); schedulePing(); if (logger.isTraceEnabled()) { logger.trace("returning " + newConnection); } return newConnection; }
default boolean isSameTarget(TransportConfiguration... configs) { return getTransportConnection().isSameTarget(configs); } }
private void checkCloseConnection() { RemotingConnection connectionInUse = connection; Connector connectorInUse = connector; if (connectionInUse != null && sessions.size() == 0) { cancelScheduledTasks(); try { connectionInUse.destroy(); } catch (Throwable ignore) { } connection = null; try { if (connectorInUse != null) { connectorInUse.close(); } } catch (Throwable ignore) { } connector = null; } }
public Object getID() { return connection.getID(); }
List<FailureListener> oldListeners = oldConnection.getFailureListeners(); List<FailureListener> newListeners = new ArrayList<>(connection.getFailureListeners()); connection.setFailureListeners(newListeners);
@Override public void bufferReceived(final Object connectionID, final ActiveMQBuffer buffer) { try { final Packet packet = packetDecoder.decode(buffer, this); if (logger.isTraceEnabled()) { logger.trace("RemotingConnectionID=" + getID() + " handling packet " + packet); } dataReceived = true; doBufferReceived(packet); super.bufferReceived(connectionID, buffer); } catch (Throwable e) { ActiveMQClientLogger.LOGGER.errorDecodingPacket(e); throw new IllegalStateException(e); } }
csf.getConnection().addFailureListener(new FailureListener() {
@Override public void fail(final ActiveMQException me) { fail(me, null); }
@Override public List<FailureListener> removeFailureListeners() { List<FailureListener> ret = getFailureListeners(); failureListeners.clear(); return ret; }
/** * We only need to check if the connection point to the same node, * don't need to compare the whole params map. * @param connection The connection to the target node * @return true if the connection point to the same node * as this member represents. */ @Override public boolean isMember(RemotingConnection connection) { return connection.isSameTarget(getConnector().getA(), getConnector().getB()); }
@Override public void run() { theConn.fail(new ActiveMQException(e.getMessage())); } });
public static X509Certificate[] getCertsFromConnection(RemotingConnection remotingConnection) { X509Certificate[] certificates = null; if (remotingConnection != null) { Connection transportConnection = remotingConnection.getTransportConnection(); if (transportConnection instanceof NettyConnection) { certificates = org.apache.activemq.artemis.utils.CertificateUtil.getCertsFromChannel(((NettyConnection) transportConnection).getChannel()); } } return certificates; }
@Override public void run() { try { CLOSE_RUNNABLES.add(this); if (scaleDownTargetNodeID == null) { conn.fail(ActiveMQClientMessageBundle.BUNDLE.disconnected()); } else { conn.fail(ActiveMQClientMessageBundle.BUNDLE.disconnected(), scaleDownTargetNodeID); } } finally { CLOSE_RUNNABLES.remove(this); } }
public static Principal getPeerPrincipalFromConnection(RemotingConnection remotingConnection) { Principal result = null; if (remotingConnection != null) { Connection transportConnection = remotingConnection.getTransportConnection(); if (transportConnection instanceof NettyConnection) { NettyConnection nettyConnection = (NettyConnection) transportConnection; ChannelHandler channelHandler = nettyConnection.getChannel().pipeline().get("ssl"); if (channelHandler != null && channelHandler instanceof SslHandler) { SslHandler sslHandler = (SslHandler) channelHandler; try { result = sslHandler.engine().getSession().getPeerPrincipal(); } catch (SSLPeerUnverifiedException ignored) { } } } } return result; } }