public void appendPrepareRecord( final byte journalID, final long txID, final EncodingSupport transactionData) throws Exception { if (enabled) { sendReplicatePacket(new ReplicationPrepareMessage(journalID, txID, transactionData)); } }
/** * Reserves several LargeMessage IDs in the backup. * * <p>Doing this before hand removes the need of synchronizing large-message deletes with the * largeMessageSyncList. * * @param largeMessages */ public void sendLargeMessageIdListMessage(Map<Long, Pair<String, Long>> largeMessages) { ArrayList<Long> idsToSend; largeMessagesToSync.putAll(largeMessages); idsToSend = new ArrayList<Long>(largeMessagesToSync.keySet()); if (enabled) sendReplicatePacket(new ReplicationStartSyncMessage(idsToSend)); }
public void appendDeleteRecordTransactional(final byte journalID, final long txID, final long id) throws Exception { if (enabled) { sendReplicatePacket( new ReplicationDeleteTXMessage(journalID, txID, id, NullEncoding.instance)); } }
/** * Reserve the following fileIDs in the backup server. * * @param datafiles * @param contentType * @throws HornetQException */ public void sendStartSyncMessage( JournalFile[] datafiles, JournalContent contentType, String nodeID, boolean allowsAutoFailBack) throws HornetQException { if (enabled) sendReplicatePacket( new ReplicationStartSyncMessage(datafiles, contentType, nodeID, allowsAutoFailBack)); }
public void appendUpdateRecord( final byte journalID, final ADD_OPERATION_TYPE operation, final long id, final byte recordType, final EncodingSupport record) throws Exception { if (enabled) { sendReplicatePacket(new ReplicationAddMessage(journalID, operation, id, recordType, record)); } }
/** * Sends large files in reasonably sized chunks to the backup during replication synchronization. * * @param content journal type or {@code null} for large-messages and pages * @param pageStore page store name for pages, or {@code null} otherwise * @param id journal file id or (large) message id * @param file * @param maxBytesToSend maximum number of bytes to read and send from the file * @throws Exception */ private void sendLargeFile( JournalContent content, SimpleString pageStore, final long id, SequentialFile file, long maxBytesToSend) throws Exception { if (!enabled) return; if (!file.isOpen()) { file.open(); } try { final FileInputStream fis = new FileInputStream(file.getJavaFile()); try { final FileChannel channel = fis.getChannel(); try { final ByteBuffer buffer = ByteBuffer.allocate(1 << 17); while (true) { buffer.clear(); final int bytesRead = channel.read(buffer); int toSend = bytesRead; if (bytesRead > 0) { if (bytesRead >= maxBytesToSend) { toSend = (int) maxBytesToSend; maxBytesToSend = 0; } else { maxBytesToSend = maxBytesToSend - bytesRead; } buffer.limit(toSend); } buffer.rewind(); // sending -1 or 0 bytes will close the file at the backup sendReplicatePacket( new ReplicationSyncFileMessage(content, pageStore, id, toSend, buffer)); if (bytesRead == -1 || bytesRead == 0 || maxBytesToSend == 0) break; } } finally { channel.close(); } } finally { fis.close(); } } finally { if (file.isOpen()) file.close(); } }
/** * Informs backup that data synchronization is done. * * <p>So if 'live' fails, the (up-to-date) backup now may take over its duties. To do so, it must * know which is the live's {@code nodeID}. * * @param nodeID */ public void sendSynchronizationDone(String nodeID) { if (enabled) { sendReplicatePacket(new ReplicationStartSyncMessage(nodeID)); inSync = false; } }
public void largeMessageWrite(final long messageId, final byte[] body) { if (enabled) { sendReplicatePacket(new ReplicationLargeMessageWriteMessage(messageId, body)); } }
public void largeMessageDelete(final Long messageId) { if (enabled) { sendReplicatePacket(new ReplicationLargeMessageEndMessage(messageId)); } }
public void largeMessageBegin(final long messageId) { if (enabled) { sendReplicatePacket(new ReplicationLargeMessageBeginMessage(messageId)); } }
public void pageWrite(final PagedMessage message, final int pageNumber) { if (enabled) { sendReplicatePacket(new ReplicationPageWriteMessage(message, pageNumber)); } }
public void pageDeleted(final SimpleString storeName, final int pageNumber) { if (enabled) { sendReplicatePacket(new ReplicationPageEventMessage(storeName, pageNumber, true)); } }
public void appendRollbackRecord(final byte journalID, final long txID) throws Exception { if (enabled) { sendReplicatePacket(new ReplicationCommitMessage(journalID, true, txID)); } }
public void appendCommitRecord( final byte journalID, final long txID, boolean sync, final boolean lineUp) throws Exception { if (enabled) { sendReplicatePacket(new ReplicationCommitMessage(journalID, false, txID), lineUp); } }
public void appendDeleteRecord(final byte journalID, final long id) throws Exception { if (enabled) { sendReplicatePacket(new ReplicationDeleteMessage(journalID, id)); } }