use of org.apache.activemq.artemis.spi.core.protocol.ConnectionEntry in project activemq-artemis by apache.
the class CoreProtocolManager method createConnectionEntry.
@Override
public ConnectionEntry createConnectionEntry(final Acceptor acceptorUsed, final Connection connection) {
final Configuration config = server.getConfiguration();
Executor connectionExecutor = server.getExecutorFactory().getExecutor();
final CoreRemotingConnection rc = new RemotingConnectionImpl(new ServerPacketDecoder(), connection, incomingInterceptors, outgoingInterceptors, config.isAsyncConnectionExecutionEnabled() ? connectionExecutor : null, server.getNodeID());
Channel channel1 = rc.getChannel(CHANNEL_ID.SESSION.id, -1);
ChannelHandler handler = new ActiveMQPacketHandler(this, server, channel1, rc);
channel1.setHandler(handler);
long ttl = ActiveMQClient.DEFAULT_CONNECTION_TTL;
if (config.getConnectionTTLOverride() != -1) {
ttl = config.getConnectionTTLOverride();
}
final ConnectionEntry entry = new ConnectionEntry(rc, connectionExecutor, System.currentTimeMillis(), ttl);
final Channel channel0 = rc.getChannel(ChannelImpl.CHANNEL_ID.PING.id, -1);
channel0.setHandler(new LocalChannelHandler(config, entry, channel0, acceptorUsed, rc));
server.getClusterManager().addClusterChannelHandler(rc.getChannel(CHANNEL_ID.CLUSTER.id, -1), acceptorUsed, rc, server.getActivation());
return entry;
}
use of org.apache.activemq.artemis.spi.core.protocol.ConnectionEntry in project activemq-artemis by apache.
the class RemotingServiceImpl method removeConnection.
@Override
public RemotingConnection removeConnection(final Object remotingConnectionID) {
ConnectionEntry entry = connections.remove(remotingConnectionID);
if (entry != null) {
logger.debug("RemotingServiceImpl::removing connection ID " + remotingConnectionID);
connectionCountLatch.countDown();
return entry.connection;
} else {
logger.debug("The connectionID::" + remotingConnectionID + " was already removed by some other module");
return null;
}
}
use of org.apache.activemq.artemis.spi.core.protocol.ConnectionEntry in project activemq-artemis by apache.
the class RemotingServiceImpl method connectionCreated.
@Override
public void connectionCreated(final ActiveMQComponent component, final Connection connection, final ProtocolManager protocol) {
if (server == null) {
throw new IllegalStateException("Unable to create connection, server hasn't finished starting up");
}
ConnectionEntry entry = protocol.createConnectionEntry((Acceptor) component, connection);
try {
if (server.hasBrokerPlugins()) {
server.callBrokerPlugins(plugin -> plugin.afterCreateConnection(entry.connection));
}
} catch (ActiveMQException t) {
logger.warn("Error executing afterCreateConnection plugin method: {}", t.getMessage(), t);
throw new IllegalStateException(t.getMessage(), t.getCause());
}
if (logger.isTraceEnabled()) {
logger.trace("Connection created " + connection);
}
connections.put(connection.getID(), entry);
connectionCountLatch.countUp();
totalConnectionCount.incrementAndGet();
}
use of org.apache.activemq.artemis.spi.core.protocol.ConnectionEntry 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.ConnectionEntry in project activemq-artemis by apache.
the class ProtonProtocolManager method createConnectionEntry.
@Override
public ConnectionEntry createConnectionEntry(Acceptor acceptorUsed, Connection remotingConnection) {
AMQPConnectionCallback connectionCallback = new AMQPConnectionCallback(this, remotingConnection, server.getExecutorFactory().getExecutor(), server);
long ttl = ActiveMQClient.DEFAULT_CONNECTION_TTL;
if (server.getConfiguration().getConnectionTTLOverride() != -1) {
ttl = server.getConfiguration().getConnectionTTLOverride();
}
String id = server.getConfiguration().getName();
boolean useCoreSubscriptionNaming = server.getConfiguration().isAmqpUseCoreSubscriptionNaming();
AMQPConnectionContext amqpConnection = new AMQPConnectionContext(this, connectionCallback, id, (int) ttl, getMaxFrameSize(), AMQPConstants.Connection.DEFAULT_CHANNEL_MAX, useCoreSubscriptionNaming, server.getScheduledPool(), true, null, null);
Executor executor = server.getExecutorFactory().getExecutor();
ActiveMQProtonRemotingConnection delegate = new ActiveMQProtonRemotingConnection(this, amqpConnection, remotingConnection, executor);
delegate.addFailureListener(connectionCallback);
delegate.addCloseListener(connectionCallback);
connectionCallback.setProtonConnectionDelegate(delegate);
ConnectionEntry entry = new ConnectionEntry(delegate, executor, System.currentTimeMillis(), ttl);
return entry;
}
Aggregations