use of org.apache.activemq.artemis.spi.core.protocol.RemotingConnection in project activemq-artemis by apache.
the class CertificateUtil method getPeerPrincipalFromConnection.
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;
}
use of org.apache.activemq.artemis.spi.core.protocol.RemotingConnection in project activemq-artemis by apache.
the class BridgeImpl method nodeUP.
// To be called by the topology update
// This logic will be updated on the cluster connection
protected void nodeUP(TopologyMember member, boolean last) {
ClientSessionInternal sessionToUse = session;
RemotingConnection connectionToUse = sessionToUse != null ? sessionToUse.getConnection() : null;
if (member != null && this.targetNodeID != null && this.targetNodeID.equals(member.getNodeId())) {
// this could be an update of the topology say after a backup started
BridgeImpl.this.targetNode = member;
} else {
// we don't need synchronization here, but we need to make sure we won't get a NPE on races
if (connectionToUse != null && member.isMember(connectionToUse)) {
this.targetNode = member;
this.targetNodeID = member.getNodeId();
}
}
}
use of org.apache.activemq.artemis.spi.core.protocol.RemotingConnection in project activemq-artemis by apache.
the class RemotingServiceImpl method stop.
@Override
public void stop(final boolean criticalError) throws Exception {
if (!started) {
return;
}
failureCheckAndFlushThread.close(criticalError);
// We need to stop them accepting first so no new connections are accepted after we send the disconnect message
for (Acceptor acceptor : acceptors.values()) {
if (logger.isDebugEnabled()) {
logger.debug("Pausing acceptor " + acceptor);
}
try {
acceptor.pause();
} catch (Throwable t) {
ActiveMQServerLogger.LOGGER.errorStoppingAcceptor(acceptor.getName());
}
}
if (logger.isDebugEnabled()) {
logger.debug("Sending disconnect on live connections");
}
HashSet<ConnectionEntry> connectionEntries = new HashSet<>(connections.values());
// then send a disconnect packet
for (ConnectionEntry entry : connectionEntries) {
RemotingConnection conn = entry.connection;
if (logger.isTraceEnabled()) {
logger.trace("Sending connection.disconnection packet to " + conn);
}
conn.disconnect(criticalError);
}
for (Acceptor acceptor : acceptors.values()) {
try {
acceptor.stop();
} catch (Throwable t) {
ActiveMQServerLogger.LOGGER.errorStoppingAcceptor(acceptor.getName());
}
}
acceptors.clear();
connections.clear();
connectionCountLatch.setCount(0);
if (managementService != null) {
managementService.unregisterAcceptors();
}
threadPool.shutdown();
if (!criticalError) {
boolean ok = threadPool.awaitTermination(10000, TimeUnit.MILLISECONDS);
if (!ok) {
ActiveMQServerLogger.LOGGER.timeoutRemotingThreadPool();
}
}
started = false;
}
use of org.apache.activemq.artemis.spi.core.protocol.RemotingConnection in project activemq-artemis by apache.
the class ReplicationManager method stop.
@Override
public void stop() throws Exception {
synchronized (this) {
if (!started) {
logger.trace("Stopping being ignored as it hasn't been started");
return;
}
}
// This is to avoid the write holding a lock while we are trying to close it
if (replicatingChannel != null) {
replicatingChannel.close();
replicatingChannel.getConnection().getTransportConnection().fireReady(true);
}
enabled = false;
writable.set(true);
clearReplicationTokens();
RemotingConnection toStop = remotingConnection;
if (toStop != null) {
toStop.removeFailureListener(failureListener);
}
remotingConnection = null;
started = false;
}
use of org.apache.activemq.artemis.spi.core.protocol.RemotingConnection in project activemq-artemis by apache.
the class ProtonClientConnectionManager method connectionDestroyed.
@Override
public void connectionDestroyed(Object connectionID) {
RemotingConnection connection = connectionMap.remove(connectionID);
if (connection != null) {
log.info("Connection " + connection.getRemoteAddress() + " destroyed");
connection.fail(new ActiveMQRemoteDisconnectException());
} else {
log.error("Connection with id " + connectionID + " not found in connectionDestroyed");
}
}
Aggregations