Package org.hornetq.core.journal

Examples of org.hornetq.core.journal.Journal


   // Public --------------------------------------------------------

   public void testSequence() throws Exception
   {
      NIOSequentialFileFactory factory = new NIOSequentialFileFactory(getTestDir());
      Journal journal = new JournalImpl(10 * 1024, 2, 0, 0, factory, "test-data", "tst", 1);

      journal.start();

      journal.load(new ArrayList<RecordInfo>(), new ArrayList<PreparedTransactionInfo>(), null);

      BatchingIDGenerator batch = new BatchingIDGenerator(0, 1000, journal);
      long id1 = batch.generateID();
      long id2 = batch.generateID();

      Assert.assertTrue(id2 > id1);

      journal.stop();
      batch = new BatchingIDGenerator(0, 1000, journal);
      loadIDs(journal, batch);

      long id3 = batch.generateID();

      Assert.assertEquals(1000, id3);

      long id4 = batch.generateID();

      Assert.assertTrue(id4 > id3 && id4 < 2000);

      batch.close();

      journal.stop();
      batch = new BatchingIDGenerator(0, 1000, journal);
      loadIDs(journal, batch);

      long id5 = batch.generateID();
      Assert.assertTrue(id5 > id4 && id5 < 2000);

      long lastId = id5;

      boolean close = true;
      for (int i = 0; i < 100000; i++)
      {
         if (i % 1000 == 0)
         {
            System.out.println("lastId = " + lastId);
            // interchanging closes and simulated crashes
            if (close)
            {
               batch.close();
            }

            close = !close;

            journal.stop();
            batch = new BatchingIDGenerator(0, 1000, journal);
            loadIDs(journal, batch);
         }

         long id = batch.generateID();

         Assert.assertTrue(id > lastId);

         lastId = id;
      }

      batch.close();
      journal.stop();
      batch = new BatchingIDGenerator(0, 1000, journal);
      loadIDs(journal, batch);

      lastId = batch.getCurrentID();

      journal.stop();
      batch = new BatchingIDGenerator(0, 1000, journal);
      loadIDs(journal, batch);

      Assert.assertEquals("No Ids were generated, so the currentID was supposed to stay the same",
                          lastId,
View Full Code Here


      createDir = config.isCreateBindingsDir();

      SequentialFileFactory bindingsJMS = new NIOSequentialFileFactory(journalDir);

      Journal localJMS = new JournalImpl(1024 * 1024,
                                              2,
                                              config.getJournalCompactMinFiles(),
                                              config.getJournalCompactPercentage(),
                                              bindingsJMS,
                                              "hornetq-jms",
View Full Code Here

   private void finishSynchronization(String liveID) throws Exception
   {
      for (JournalContent jc : EnumSet.allOf(JournalContent.class))
      {
         Journal journal = journalsHolder.remove(jc);
         journal.synchronizationLock();
         try
         {
            // files should be already in place.
            filesReservedForSync.remove(jc);
            registerJournal(jc.typeByte, journal);
            journal.stop();
            journal.start();
            journal.loadSyncOnly(JournalState.SYNCING_UP_TO_DATE);
         }
         finally
         {
            journal.synchronizationUnlock();
         }
      }
      ByteBuffer buffer = ByteBuffer.allocate(4 * 1024);
      for (Entry<Long, ReplicatedLargeMessage> entry : largeMessages.entrySet())
      {
View Full Code Here

               {
                  HornetQServerLogger.LOGGER.autoFailBackDenied();
               }

               final JournalContent journalContent = SyncDataType.getJournalContentType(packet.getDataType());
               final Journal journal = journalsHolder.get(journalContent);

               if (packet.getNodeID() != null)
               {
                  // At the start of replication, we still do not know which is the nodeID that the live uses.
                  // This is the point where the backup gets this information.
                  quorumManager.setLiveID(packet.getNodeID());
               }
               Map<Long, JournalSyncFile> mapToFill = filesReservedForSync.get(journalContent);

               for (Entry<Long, JournalFile> entry : journal.createFilesForBackupSync(packet.getFileIds()).entrySet())
               {
                  mapToFill.put(entry.getKey(), new JournalSyncFile(entry.getValue()));
               }
               FileWrapperJournal syncJournal = new FileWrapperJournal(journal);
               registerJournal(journalContent.typeByte, syncJournal);
View Full Code Here

   /**
    * @param packet
    */
   private void handleCommitRollback(final ReplicationCommitMessage packet) throws Exception
   {
      Journal journalToUse = getJournal(packet.getJournalID());
      if (packet.isRollback())
      {
         journalToUse.appendRollbackRecord(packet.getTxId(), noSync);
      }
      else
      {
         journalToUse.appendCommitRecord(packet.getTxId(), noSync);
      }
   }
View Full Code Here

   /**
    * @param packet
    */
   private void handlePrepare(final ReplicationPrepareMessage packet) throws Exception
   {
      Journal journalToUse = getJournal(packet.getJournalID());
      journalToUse.appendPrepareRecord(packet.getTxId(), packet.getRecordData(), noSync);
   }
View Full Code Here

   /**
    * @param packet
    */
   private void handleAppendDeleteTX(final ReplicationDeleteTXMessage packet) throws Exception
   {
      Journal journalToUse = getJournal(packet.getJournalID());

      journalToUse.appendDeleteRecordTransactional(packet.getTxId(), packet.getId(), packet.getRecordData());
   }
View Full Code Here

   /**
    * @param packet
    */
   private void handleAppendDelete(final ReplicationDeleteMessage packet) throws Exception
   {
      Journal journalToUse = getJournal(packet.getJournalID());
      journalToUse.appendDeleteRecord(packet.getId(), noSync);
   }
View Full Code Here

   /**
    * @param packet
    */
   private void handleAppendAddTXRecord(final ReplicationAddTXMessage packet) throws Exception
   {
      Journal journalToUse = getJournal(packet.getJournalID());

      if (packet.getOperation() == ADD_OPERATION_TYPE.UPDATE)
      {
         journalToUse.appendUpdateRecordTransactional(packet.getTxId(),
                                                      packet.getId(),
                                                      packet.getRecordType(),
                                                      packet.getRecordData());
      }
      else
      {
         journalToUse.appendAddRecordTransactional(packet.getTxId(),
                                                   packet.getId(),
                                                   packet.getRecordType(),
                                                   packet.getRecordData());
      }
   }
View Full Code Here

    * @param packet
    * @throws Exception
    */
   private void handleAppendAddRecord(final ReplicationAddMessage packet) throws Exception
   {
      Journal journalToUse = getJournal(packet.getJournalID());
      if (packet.getRecord() == ADD_OPERATION_TYPE.UPDATE)
      {
         if (ReplicationEndpoint.trace)
         {
            HornetQServerLogger.LOGGER.trace("Endpoint appendUpdate id = " + packet.getId());
         }
         journalToUse.appendUpdateRecord(packet.getId(), packet.getJournalRecordType(), packet.getRecordData(), noSync);
      }
      else
      {
         if (ReplicationEndpoint.trace)
         {
            HornetQServerLogger.LOGGER.trace("Endpoint append id = " + packet.getId());
         }
         journalToUse.appendAddRecord(packet.getId(), packet.getJournalRecordType(), packet.getRecordData(), noSync);
      }
   }
View Full Code Here

TOP

Related Classes of org.hornetq.core.journal.Journal

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.