Package org.hornetq.utils

Examples of org.hornetq.utils.TimeAndCounterIDGenerator


   }

   public void testCalculationRefresh()
   {
      TimeAndCounterIDGenerator seq = new TimeAndCounterIDGenerator();

      long id1 = seq.generateID();
      Assert.assertEquals(1, id1 & 0xffff);
      Assert.assertEquals(2, seq.generateID() & 0xffff);

      seq.refresh();

      long id2 = seq.generateID();

      Assert.assertTrue(id2 > id1);

      Assert.assertEquals(1, id2 & 0xffff);
View Full Code Here


    */
   protected void createJMSStorage() throws Exception
   {
      Configuration configuration = createDefaultConfig();

      jmsJournal = new JMSJournalStorageManagerImpl(new TimeAndCounterIDGenerator(), configuration, null);

      jmsJournal.start();
     
      jmsJournal.load();
   }
View Full Code Here

   // Inner classes -------------------------------------------------

   public static void main(final String arg[])
   {
      TimeAndCounterIDGenerator idgenerator = new TimeAndCounterIDGenerator();
      try
      {
         SequentialFileFactory fileFactory = new AIOSequentialFileFactory("/tmp"); // any dir you want
         // SequentialFileFactory fileFactory = new NIOSequentialFileFactory("/tmp"); // any dir you want
         JournalImpl journalExample = new JournalImpl(10 * 1024 * 1024, // 10M.. we believe that's the usual cilinder
                                                      // bufferSize.. not an exact science here
                                                      2, // number of files pre-allocated
                                                      0,
                                                      0,
                                                      fileFactory, // AIO or NIO
                                                      "exjournal", // file name
                                                      "dat", // extension
                                                      10000); // it's like a semaphore for callback on the AIO layer

         ArrayList<RecordInfo> committedRecords = new ArrayList<RecordInfo>();
         ArrayList<PreparedTransactionInfo> preparedTransactions = new ArrayList<PreparedTransactionInfo>();
         journalExample.start();
         System.out.println("Loading records and creating data files");
         journalExample.load(committedRecords, preparedTransactions, null);

         System.out.println("Loaded Record List:");

         for (RecordInfo record : committedRecords)
         {
            System.out.println("Record id = " + record.id +
                               " userType = " +
                               record.userRecordType +
                               " with " +
                               record.data.length +
                               " bytes is stored on the journal");
         }

         System.out.println("Adding Records:");

         for (int i = 0; i < 10; i++)
         {
            journalExample.appendAddRecord(idgenerator.generateID(), (byte)1, new byte[] { 0,
                                                                                          1,
                                                                                          2,
                                                                                          0,
                                                                                          1,
                                                                                          2,
                                                                                          0,
                                                                                          1,
                                                                                          2,
                                                                                          0,
                                                                                          1,
                                                                                          2,
                                                                                          0,
                                                                                          1,
                                                                                          2,
                                                                                          0,
                                                                                          1,
                                                                                          2,
                                                                                          0,
                                                                                          1,
                                                                                          2 }, false);
         }

         long tx = idgenerator.generateID(); // some id generation system

         for (int i = 0; i < 100; i++)
         {
            journalExample.appendAddRecordTransactional(tx, idgenerator.generateID(), (byte)2, new byte[] { 0,
                                                                                                           1,
                                                                                                           2,
                                                                                                           0,
                                                                                                           1,
                                                                                                           2,
View Full Code Here

   {
      if (storage == null)
      {
         if (coreConfig.isPersistenceEnabled())
         {
            storage = new JMSJournalStorageManagerImpl(new TimeAndCounterIDGenerator(),
                                                       server.getConfiguration(),
                                                       server.getReplicationManager());
         }
         else
         {
View Full Code Here

   {
      if (storage == null)
      {
         if (coreConfig.isPersistenceEnabled())
         {
            storage = new JMSJournalStorageManagerImpl(new TimeAndCounterIDGenerator(),
                                                       server.getConfiguration(),
                                                       server.getReplicationManager());
         }
         else
         {
View Full Code Here

   {
      if (storage == null)
      {
         if (coreConfig.isPersistenceEnabled())
         {
            storage = new JMSJournalStorageManagerImpl(new TimeAndCounterIDGenerator(),
                                                       server.getConfiguration(),
                                                       server.getReplicationManager());
         }
         else
         {
View Full Code Here

    */
   protected void createJMSStorage() throws Exception
   {
      Configuration configuration = createDefaultConfig();

      jmsJournal = new JMSJournalStorageManagerImpl(new TimeAndCounterIDGenerator(), configuration, null);

      jmsJournal.start();
     
      jmsJournal.load();
   }
View Full Code Here

   {
      if (storage == null)
      {
         if (coreConfig.isPersistenceEnabled())
         {
            storage = new JMSJournalStorageManagerImpl(new TimeAndCounterIDGenerator(),
                                                       server.getConfiguration(),
                                                       server.getReplicationManager());
         }
         else
         {
View Full Code Here

   {
      if (storage == null)
      {
         if (coreConfig.isPersistenceEnabled())
         {
            storage = new JMSJournalStorageManagerImpl(new TimeAndCounterIDGenerator(),
                                                       server.getConfiguration(),
                                                       server.getReplicationManager());
         }
         else
         {
View Full Code Here

   {
      if (storage == null)
      {
         if (coreConfig.isPersistenceEnabled())
         {
            storage = new JMSJournalStorageManagerImpl(new TimeAndCounterIDGenerator(),
                                                       server.getConfiguration(),
                                                       server.getReplicationManager());
         }
         else
         {
View Full Code Here

TOP

Related Classes of org.hornetq.utils.TimeAndCounterIDGenerator

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.