Search in sources :

Example 1 with PacketImpl

use of org.apache.activemq.artemis.core.protocol.core.impl.PacketImpl in project activemq-artemis by apache.

the class ReplicationEndpoint method handlePacket.

@Override
public void handlePacket(final Packet packet) {
    if (logger.isTraceEnabled()) {
        logger.trace("handlePacket::handling " + packet);
    }
    PacketImpl response = new ReplicationResponseMessage();
    final byte type = packet.getType();
    try {
        if (!started) {
            if (logger.isTraceEnabled()) {
                logger.trace("handlePacket::ignoring " + packet);
            }
            return;
        }
        if (type == PacketImpl.REPLICATION_APPEND) {
            handleAppendAddRecord((ReplicationAddMessage) packet);
        } else if (type == PacketImpl.REPLICATION_APPEND_TX) {
            handleAppendAddTXRecord((ReplicationAddTXMessage) packet);
        } else if (type == PacketImpl.REPLICATION_DELETE) {
            handleAppendDelete((ReplicationDeleteMessage) packet);
        } else if (type == PacketImpl.REPLICATION_DELETE_TX) {
            handleAppendDeleteTX((ReplicationDeleteTXMessage) packet);
        } else if (type == PacketImpl.REPLICATION_PREPARE) {
            handlePrepare((ReplicationPrepareMessage) packet);
        } else if (type == PacketImpl.REPLICATION_COMMIT_ROLLBACK) {
            handleCommitRollback((ReplicationCommitMessage) packet);
        } else if (type == PacketImpl.REPLICATION_PAGE_WRITE) {
            handlePageWrite((ReplicationPageWriteMessage) packet);
        } else if (type == PacketImpl.REPLICATION_PAGE_EVENT) {
            handlePageEvent((ReplicationPageEventMessage) packet);
        } else if (type == PacketImpl.REPLICATION_LARGE_MESSAGE_BEGIN) {
            handleLargeMessageBegin((ReplicationLargeMessageBeginMessage) packet);
        } else if (type == PacketImpl.REPLICATION_LARGE_MESSAGE_WRITE) {
            handleLargeMessageWrite((ReplicationLargeMessageWriteMessage) packet);
        } else if (type == PacketImpl.REPLICATION_LARGE_MESSAGE_END) {
            handleLargeMessageEnd((ReplicationLargeMessageEndMessage) packet);
        } else if (type == PacketImpl.REPLICATION_START_FINISH_SYNC) {
            response = handleStartReplicationSynchronization((ReplicationStartSyncMessage) packet);
        } else if (type == PacketImpl.REPLICATION_SYNC_FILE) {
            handleReplicationSynchronization((ReplicationSyncFileMessage) packet);
        } else if (type == PacketImpl.REPLICATION_SCHEDULED_FAILOVER) {
            handleLiveStopping((ReplicationLiveIsStoppingMessage) packet);
        } else if (type == PacketImpl.BACKUP_REGISTRATION_FAILED) {
            handleFatalError((BackupReplicationStartFailedMessage) packet);
        } else {
            ActiveMQServerLogger.LOGGER.invalidPacketForReplication(packet);
        }
    } catch (ActiveMQException e) {
        logger.warn(e.getMessage(), e);
        ActiveMQServerLogger.LOGGER.errorHandlingReplicationPacket(e, packet);
        response = new ActiveMQExceptionMessage(e);
    } catch (Exception e) {
        logger.warn(e.getMessage(), e);
        ActiveMQServerLogger.LOGGER.errorHandlingReplicationPacket(e, packet);
        response = new ActiveMQExceptionMessage(ActiveMQMessageBundle.BUNDLE.replicationUnhandledError(e));
    }
    if (response != null) {
        if (logger.isTraceEnabled()) {
            logger.trace("Returning " + response);
        }
        channel.send(response);
    } else {
        logger.trace("Response is null, ignoring response");
    }
}
Also used : ReplicationPageEventMessage(org.apache.activemq.artemis.core.protocol.core.impl.wireformat.ReplicationPageEventMessage) ReplicationAddTXMessage(org.apache.activemq.artemis.core.protocol.core.impl.wireformat.ReplicationAddTXMessage) ReplicationCommitMessage(org.apache.activemq.artemis.core.protocol.core.impl.wireformat.ReplicationCommitMessage) ActiveMQException(org.apache.activemq.artemis.api.core.ActiveMQException) ReplicationLargeMessageWriteMessage(org.apache.activemq.artemis.core.protocol.core.impl.wireformat.ReplicationLargeMessageWriteMessage) PacketImpl(org.apache.activemq.artemis.core.protocol.core.impl.PacketImpl) ActiveMQExceptionMessage(org.apache.activemq.artemis.core.protocol.core.impl.wireformat.ActiveMQExceptionMessage) ReplicationDeleteTXMessage(org.apache.activemq.artemis.core.protocol.core.impl.wireformat.ReplicationDeleteTXMessage) ReplicationLiveIsStoppingMessage(org.apache.activemq.artemis.core.protocol.core.impl.wireformat.ReplicationLiveIsStoppingMessage) ReplicationResponseMessage(org.apache.activemq.artemis.core.protocol.core.impl.wireformat.ReplicationResponseMessage) ActiveMQException(org.apache.activemq.artemis.api.core.ActiveMQException) IOException(java.io.IOException)

Aggregations

IOException (java.io.IOException)1 ActiveMQException (org.apache.activemq.artemis.api.core.ActiveMQException)1 PacketImpl (org.apache.activemq.artemis.core.protocol.core.impl.PacketImpl)1 ActiveMQExceptionMessage (org.apache.activemq.artemis.core.protocol.core.impl.wireformat.ActiveMQExceptionMessage)1 ReplicationAddTXMessage (org.apache.activemq.artemis.core.protocol.core.impl.wireformat.ReplicationAddTXMessage)1 ReplicationCommitMessage (org.apache.activemq.artemis.core.protocol.core.impl.wireformat.ReplicationCommitMessage)1 ReplicationDeleteTXMessage (org.apache.activemq.artemis.core.protocol.core.impl.wireformat.ReplicationDeleteTXMessage)1 ReplicationLargeMessageWriteMessage (org.apache.activemq.artemis.core.protocol.core.impl.wireformat.ReplicationLargeMessageWriteMessage)1 ReplicationLiveIsStoppingMessage (org.apache.activemq.artemis.core.protocol.core.impl.wireformat.ReplicationLiveIsStoppingMessage)1 ReplicationPageEventMessage (org.apache.activemq.artemis.core.protocol.core.impl.wireformat.ReplicationPageEventMessage)1 ReplicationResponseMessage (org.apache.activemq.artemis.core.protocol.core.impl.wireformat.ReplicationResponseMessage)1