use of org.apache.activemq.artemis.core.protocol.core.Packet in project activemq-artemis by apache.
the class ServerPacketDecoder method slowPathDecode.
// separating for performance reasons
private Packet slowPathDecode(ActiveMQBuffer in, byte packetType, CoreRemotingConnection connection) {
Packet packet;
switch(packetType) {
case SESS_SEND_LARGE:
{
packet = new SessionSendLargeMessage(new CoreMessage());
break;
}
case REPLICATION_APPEND:
{
packet = new ReplicationAddMessage();
break;
}
case REPLICATION_APPEND_TX:
{
packet = new ReplicationAddTXMessage();
break;
}
case REPLICATION_DELETE:
{
packet = new ReplicationDeleteMessage();
break;
}
case REPLICATION_DELETE_TX:
{
packet = new ReplicationDeleteTXMessage();
break;
}
case REPLICATION_PREPARE:
{
packet = new ReplicationPrepareMessage();
break;
}
case REPLICATION_COMMIT_ROLLBACK:
{
packet = new ReplicationCommitMessage();
break;
}
case REPLICATION_RESPONSE:
{
packet = new ReplicationResponseMessage();
break;
}
case REPLICATION_RESPONSE_V2:
{
packet = new ReplicationResponseMessageV2();
break;
}
case REPLICATION_PAGE_WRITE:
{
packet = new ReplicationPageWriteMessage();
break;
}
case REPLICATION_PAGE_EVENT:
{
packet = new ReplicationPageEventMessage();
break;
}
case REPLICATION_LARGE_MESSAGE_BEGIN:
{
packet = new ReplicationLargeMessageBeginMessage();
break;
}
case REPLICATION_LARGE_MESSAGE_END:
{
packet = new ReplicationLargeMessageEndMessage();
break;
}
case REPLICATION_LARGE_MESSAGE_WRITE:
{
packet = new ReplicationLargeMessageWriteMessage();
break;
}
case PacketImpl.BACKUP_REGISTRATION:
{
packet = new BackupRegistrationMessage();
break;
}
case PacketImpl.BACKUP_REGISTRATION_FAILED:
{
packet = new BackupReplicationStartFailedMessage();
break;
}
case PacketImpl.REPLICATION_START_FINISH_SYNC:
{
packet = new ReplicationStartSyncMessage();
break;
}
case PacketImpl.REPLICATION_SYNC_FILE:
{
packet = new ReplicationSyncFileMessage();
break;
}
case PacketImpl.REPLICATION_SCHEDULED_FAILOVER:
{
packet = new ReplicationLiveIsStoppingMessage();
break;
}
case CLUSTER_CONNECT:
{
packet = new ClusterConnectMessage();
break;
}
case CLUSTER_CONNECT_REPLY:
{
packet = new ClusterConnectReplyMessage();
break;
}
case NODE_ANNOUNCE:
{
packet = new NodeAnnounceMessage();
break;
}
case BACKUP_REQUEST:
{
packet = new BackupRequestMessage();
break;
}
case BACKUP_REQUEST_RESPONSE:
{
packet = new BackupResponseMessage();
break;
}
case QUORUM_VOTE:
{
packet = new QuorumVoteMessage();
break;
}
case QUORUM_VOTE_REPLY:
{
packet = new QuorumVoteReplyMessage();
break;
}
case SCALEDOWN_ANNOUNCEMENT:
{
packet = new ScaleDownAnnounceMessage();
break;
}
default:
{
packet = super.decode(packetType, connection);
}
}
packet.decode(in);
return packet;
}
use of org.apache.activemq.artemis.core.protocol.core.Packet in project activemq-artemis by apache.
the class ActiveMQPacketHandler method handleReattachSession.
private void handleReattachSession(final ReattachSessionMessage request) {
Packet response = null;
try {
if (!server.isStarted()) {
response = new ReattachSessionResponseMessage(-1, false);
}
logger.debug("Reattaching request from " + connection.getRemoteAddress());
ServerSessionPacketHandler sessionHandler = protocolManager.getSessionHandler(request.getName());
// HORNETQ-720 XXX ataylor?
if (/*!server.checkActivate() || */
sessionHandler == null) {
response = new ReattachSessionResponseMessage(-1, false);
} else {
if (sessionHandler.getChannel().getConfirmationWindowSize() == -1) {
// Even though session exists, we can't reattach since confi window size == -1,
// i.e. we don't have a resend cache for commands, so we just close the old session
// and let the client recreate
ActiveMQServerLogger.LOGGER.reattachRequestFailed(connection.getRemoteAddress());
sessionHandler.closeListeners();
sessionHandler.close();
response = new ReattachSessionResponseMessage(-1, false);
} else {
// Reconnect the channel to the new connection
int serverLastConfirmedCommandID = sessionHandler.transferConnection(connection, request.getLastConfirmedCommandID());
response = new ReattachSessionResponseMessage(serverLastConfirmedCommandID, true);
}
}
} catch (Exception e) {
ActiveMQServerLogger.LOGGER.failedToReattachSession(e);
response = new ActiveMQExceptionMessage(new ActiveMQInternalErrorException());
}
channel1.send(response);
}
use of org.apache.activemq.artemis.core.protocol.core.Packet in project activemq-artemis by apache.
the class ActiveMQSessionContext method xaStart.
@Override
public void xaStart(Xid xid, int flags) throws XAException, ActiveMQException {
Packet packet;
if (flags == XAResource.TMJOIN) {
packet = new SessionXAJoinMessage(xid);
} else if (flags == XAResource.TMRESUME) {
packet = new SessionXAResumeMessage(xid);
} else if (flags == XAResource.TMNOFLAGS) {
// Don't need to flush since the previous end will have done this
packet = new SessionXAStartMessage(xid);
} else {
throw new XAException(XAException.XAER_INVAL);
}
SessionXAResponseMessage response = (SessionXAResponseMessage) sessionChannel.sendBlocking(packet, PacketImpl.SESS_XA_RESP);
if (response.isError()) {
ActiveMQClientLogger.LOGGER.errorCallingStart(response.getMessage(), response.getResponseCode());
throw new XAException(response.getResponseCode());
}
}
use of org.apache.activemq.artemis.core.protocol.core.Packet in project activemq-artemis by apache.
the class ChannelImpl method clearUpTo.
private void clearUpTo(final int lastReceivedCommandID) {
final int numberToClear = 1 + lastReceivedCommandID - firstStoredCommandID;
if (logger.isTraceEnabled()) {
logger.trace("RemotingConnectionID=" + (connection == null ? "NULL" : connection.getID()) + " ChannelImpl::clearUpTo lastReceived commandID=" + lastReceivedCommandID + " first commandID=" + firstStoredCommandID + " number to clear " + numberToClear);
}
for (int i = 0; i < numberToClear; i++) {
final Packet packet = resendCache.poll();
if (packet == null) {
ActiveMQClientLogger.LOGGER.cannotFindPacketToClear(lastReceivedCommandID, firstStoredCommandID);
firstStoredCommandID = lastReceivedCommandID + 1;
return;
}
if (logger.isTraceEnabled()) {
logger.trace("RemotingConnectionID=" + connection.getID() + " ChannelImpl::clearUpTo confirming " + packet + " towards " + commandConfirmationHandler);
}
if (commandConfirmationHandler != null) {
commandConfirmationHandler.commandConfirmed(packet);
}
}
firstStoredCommandID += numberToClear;
}
use of org.apache.activemq.artemis.core.protocol.core.Packet in project activemq-artemis by apache.
the class ChannelImpl method flushConfirmations.
// Needs to be synchronized since can be called by remoting service timer thread too for timeout flush
@Override
public synchronized void flushConfirmations() {
if (resendCache != null && receivedBytes != 0) {
receivedBytes = 0;
final Packet confirmed = new PacketsConfirmedMessage(lastConfirmedCommandID.get());
confirmed.setChannelID(id);
if (logger.isTraceEnabled()) {
logger.trace("RemotingConnectionID=" + (connection == null ? "NULL" : connection.getID()) + " ChannelImpl::flushConfirmation flushing confirmation " + confirmed);
}
doWrite(confirmed);
}
}
Aggregations