예제 #1
0
 public void appendPrepareRecord(
     final byte journalID, final long txID, final EncodingSupport transactionData)
     throws Exception {
   if (enabled) {
     sendReplicatePacket(new ReplicationPrepareMessage(journalID, txID, transactionData));
   }
 }
예제 #2
0
  /**
   * 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));
  }
예제 #3
0
 public void appendDeleteRecordTransactional(final byte journalID, final long txID, final long id)
     throws Exception {
   if (enabled) {
     sendReplicatePacket(
         new ReplicationDeleteTXMessage(journalID, txID, id, NullEncoding.instance));
   }
 }
예제 #4
0
 /**
  * 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));
 }
예제 #5
0
 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));
   }
 }
예제 #6
0
  /**
   * 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();
    }
  }
예제 #7
0
 /**
  * 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;
   }
 }
예제 #8
0
 public void largeMessageWrite(final long messageId, final byte[] body) {
   if (enabled) {
     sendReplicatePacket(new ReplicationLargeMessageWriteMessage(messageId, body));
   }
 }
예제 #9
0
 public void largeMessageDelete(final Long messageId) {
   if (enabled) {
     sendReplicatePacket(new ReplicationLargeMessageEndMessage(messageId));
   }
 }
예제 #10
0
 public void largeMessageBegin(final long messageId) {
   if (enabled) {
     sendReplicatePacket(new ReplicationLargeMessageBeginMessage(messageId));
   }
 }
예제 #11
0
 public void pageWrite(final PagedMessage message, final int pageNumber) {
   if (enabled) {
     sendReplicatePacket(new ReplicationPageWriteMessage(message, pageNumber));
   }
 }
예제 #12
0
 public void pageDeleted(final SimpleString storeName, final int pageNumber) {
   if (enabled) {
     sendReplicatePacket(new ReplicationPageEventMessage(storeName, pageNumber, true));
   }
 }
예제 #13
0
 public void appendRollbackRecord(final byte journalID, final long txID) throws Exception {
   if (enabled) {
     sendReplicatePacket(new ReplicationCommitMessage(journalID, true, txID));
   }
 }
예제 #14
0
 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);
   }
 }
예제 #15
0
 public void appendDeleteRecord(final byte journalID, final long id) throws Exception {
   if (enabled) {
     sendReplicatePacket(new ReplicationDeleteMessage(journalID, id));
   }
 }