Package org.hornetq.core.journal.impl

Examples of org.hornetq.core.journal.impl.JournalImpl$PerfBlast


      journalDir = config.getJournalDirectory();

      SequentialFileFactory bindingsFF = new NIOSequentialFileFactory(bindingsDir, criticalErrorListener);

      Journal localBindings = new JournalImpl(1024 * 1024,
                                              2,
                                              config.getJournalCompactMinFiles(),
                                              config.getJournalCompactPercentage(),
                                              bindingsFF,
                                              "hornetq-bindings",
                                              "bindings",
                                              1);

      if (replicator != null)
      {
         bindingsJournal = new ReplicatedJournal((byte)0, localBindings, replicator);
      }
      else
      {
         bindingsJournal = localBindings;
      }

      if (journalDir == null)
      {
         throw new NullPointerException("journal-dir is null");
      }

      createJournalDir = config.isCreateJournalDir();

      syncNonTransactional = config.isJournalSyncNonTransactional();

      syncTransactional = config.isJournalSyncTransactional();

      if (config.getJournalType() == JournalType.ASYNCIO)
      {
         JournalStorageManager.log.info("Using AIO Journal");

         journalFF = new AIOSequentialFileFactory(journalDir,
                                                  config.getJournalBufferSize_AIO(),
                                                  config.getJournalBufferTimeout_AIO(),
                                                  config.isLogJournalWriteRate(),
                                                  criticalErrorListener);
      }
      else if (config.getJournalType() == JournalType.NIO)
      {
         JournalStorageManager.log.info("Using NIO Journal");
         journalFF = new NIOSequentialFileFactory(journalDir,
                                                  true,
                                                  config.getJournalBufferSize_NIO(),
                                                  config.getJournalBufferTimeout_NIO(),
                                                  config.isLogJournalWriteRate(),
                                                  criticalErrorListener);
      }
      else
      {
         throw new IllegalArgumentException("Unsupported journal type " + config.getJournalType());
      }

      if (config.isBackup() && !config.isSharedStore())
      {
         idGenerator = null;
      }
      else
      {
         idGenerator = new BatchingIDGenerator(0, JournalStorageManager.CHECKPOINT_BATCH_SIZE, bindingsJournal);
      }
      Journal localMessage = new JournalImpl(config.getJournalFileSize(),
                                             config.getJournalMinFiles(),
                                             config.getJournalCompactMinFiles(),
                                             config.getJournalCompactPercentage(),
                                             journalFF,
                                             "hornetq-data",
View Full Code Here


   public static void describeBindingJournal(final String bindingsDir) throws Exception
   {

      SequentialFileFactory bindingsFF = new NIOSequentialFileFactory(bindingsDir, null);

      JournalImpl bindings = new JournalImpl(1024 * 1024, 2, -1, 0, bindingsFF, "hornetq-bindings", "bindings", 1);

      describeJournal(bindingsFF, bindings);
   }
View Full Code Here

      SequentialFileFactory messagesFF = new NIOSequentialFileFactory(messagesDir, null);

      // Will use only default values. The load function should adapt to anything different
      ConfigurationImpl defaultValues = new ConfigurationImpl();

      JournalImpl messagesJournal = new JournalImpl(defaultValues.getJournalFileSize(),
                                                    defaultValues.getJournalMinFiles(),
                                                    0,
                                                    0,
                                                    messagesFF,
                                                    "hornetq-data",
View Full Code Here

      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,
                                                                                                           0,
                                                                                                           1,
                                                                                                           2,
                                                                                                           0,
                                                                                                           1,
                                                                                                           2,
                                                                                                           0,
                                                                                                           1,
                                                                                                           2,
                                                                                                           0,
                                                                                                           1,
                                                                                                           2,
                                                                                                           0,
                                                                                                           1,
                                                                                                           2,
                                                                                                           5 });
         }

         // After this is complete, you're sure the records are there
         journalExample.appendCommitRecord(tx, true);

         System.out.println("Done!");

         journalExample.stop();
      }
      catch (Exception e)
      {
         e.printStackTrace();
      }
View Full Code Here

   protected Map<Long, AtomicInteger> loadQueues(HornetQServer serverToInvestigate) throws Exception
   {
      SequentialFileFactory messagesFF = new NIOSequentialFileFactory(serverToInvestigate.getConfiguration()
                                                                                         .getJournalDirectory());

      JournalImpl messagesJournal = new JournalImpl(serverToInvestigate.getConfiguration().getJournalFileSize(),
                                                    serverToInvestigate.getConfiguration().getJournalMinFiles(),
                                                    0,
                                                    0,
                                                    messagesFF,
                                                    "hornetq-data",
                                                    "hq",
                                                    1);
      List<RecordInfo> records = new LinkedList<RecordInfo>();

      List<PreparedTransactionInfo> preparedTransactions = new LinkedList<PreparedTransactionInfo>();

      messagesJournal.start();
      messagesJournal.load(records, preparedTransactions, null);

      // These are more immutable integers
      Map<Long, AtomicInteger> messageRefCounts = new HashMap<Long, AtomicInteger>();

      for (RecordInfo info : records)
      {
         Object o = JournalStorageManager.newObjectEncoding(info);
         if (info.getUserRecordType() == JournalStorageManager.ADD_REF)
         {
            ReferenceDescribe ref = (ReferenceDescribe)o;
            AtomicInteger count = messageRefCounts.get(ref.refEncoding.queueID);
            if (count == null)
            {
               count = new AtomicInteger(1);
               messageRefCounts.put(ref.refEncoding.queueID, count);
            }
            else
            {
               count.incrementAndGet();
            }
         }
      }

      messagesJournal.stop();

      return messageRefCounts;

   }
View Full Code Here

         session.close();
      }

      server.stop();

      JournalImpl journal = new JournalImpl(server.getConfiguration().getJournalFileSize(),
                                            2,
                                            0,
                                            0,
                                            new NIOSequentialFileFactory(server.getConfiguration()
                                                                               .getJournalDirectory()),
                                            "hornetq-data",
                                            "hq",
                                            1);

      final AtomicInteger updates = new AtomicInteger();

      journal.start();
      journal.load(new LoaderCallback()
      {

         public void failedTransaction(long transactionID, List<RecordInfo> records, List<RecordInfo> recordsToDelete)
         {
         }

         public void updateRecord(RecordInfo info)
         {
            if (info.userRecordType == JournalStorageManager.UPDATE_DELIVERY_COUNT)
            {
               updates.incrementAndGet();
            }
         }

         public void deleteRecord(long id)
         {
         }

         public void addRecord(RecordInfo info)
         {
         }

         public void addPreparedTransaction(PreparedTransactionInfo preparedTransaction)
         {
         }
      });

      journal.stop();

      assertEquals(7, updates.get());

   }
View Full Code Here

      journalDir = config.getJournalDirectory();

      SequentialFileFactory bindingsFF = new NIOSequentialFileFactory(bindingsDir, criticalErrorListener);

      Journal localBindings = new JournalImpl(1024 * 1024,
         2,
         config.getJournalCompactMinFiles(),
         config.getJournalCompactPercentage(),
         bindingsFF,
         "hornetq-bindings",
         "bindings",
         1);

      bindingsJournal = localBindings;
      originalBindingsJournal = localBindings;

      if (journalDir == null)
      {
         throw new NullPointerException("journal-dir is null");
      }

      createJournalDir = config.isCreateJournalDir();

      syncNonTransactional = config.isJournalSyncNonTransactional();

      syncTransactional = config.isJournalSyncTransactional();

      if (config.getJournalType() == JournalType.ASYNCIO)
      {
         HornetQServerLogger.LOGGER.journalUseAIO();

         journalFF = new AIOSequentialFileFactory(journalDir,
            config.getJournalBufferSize_AIO(),
            config.getJournalBufferTimeout_AIO(),
            config.isLogJournalWriteRate(),
            criticalErrorListener);
      }
      else if (config.getJournalType() == JournalType.NIO)
      {
         HornetQServerLogger.LOGGER.journalUseNIO();
         journalFF = new NIOSequentialFileFactory(journalDir,
            true,
            config.getJournalBufferSize_NIO(),
            config.getJournalBufferTimeout_NIO(),
            config.isLogJournalWriteRate(),
            criticalErrorListener);
      }
      else
      {
         throw HornetQMessageBundle.BUNDLE.invalidJournalType2(config.getJournalType());
      }

      idGenerator = new BatchingIDGenerator(0, JournalStorageManager.CHECKPOINT_BATCH_SIZE, this);

      Journal localMessage = new JournalImpl(config.getJournalFileSize(),
         config.getJournalMinFiles(),
         config.getJournalCompactMinFiles(),
         config.getJournalCompactPercentage(),
         journalFF,
         "hornetq-data",
View Full Code Here

   public static final void describeBindingsJournal(final String bindingsDir) throws Exception
   {

      SequentialFileFactory bindingsFF = new NIOSequentialFileFactory(bindingsDir, null);

      JournalImpl bindings = new JournalImpl(1024 * 1024, 2, -1, 0, bindingsFF, "hornetq-bindings", "bindings", 1);
      describeJournal(bindingsFF, bindings, bindingsDir);
   }
View Full Code Here

      SequentialFileFactory messagesFF = new NIOSequentialFileFactory(messagesDir, null);

      // Will use only default values. The load function should adapt to anything different
      ConfigurationImpl defaultValues = new ConfigurationImpl();

      JournalImpl messagesJournal = new JournalImpl(defaultValues.getJournalFileSize(),
         defaultValues.getJournalMinFiles(),
         0,
         0,
         messagesFF,
         "hornetq-data",
View Full Code Here

      journalDir = config.getJournalDirectory();

      SequentialFileFactory bindingsFF = new NIOSequentialFileFactory(bindingsDir, criticalErrorListener);

      Journal localBindings = new JournalImpl(1024 * 1024,
         2,
         config.getJournalCompactMinFiles(),
         config.getJournalCompactPercentage(),
         bindingsFF,
         "hornetq-bindings",
         "bindings",
         1);

      bindingsJournal = localBindings;
      originalBindingsJournal = localBindings;

      if (journalDir == null)
      {
         throw new NullPointerException("journal-dir is null");
      }

      createJournalDir = config.isCreateJournalDir();

      syncNonTransactional = config.isJournalSyncNonTransactional();

      syncTransactional = config.isJournalSyncTransactional();

      if (config.getJournalType() == JournalType.ASYNCIO)
      {
         HornetQServerLogger.LOGGER.journalUseAIO();

         journalFF = new AIOSequentialFileFactory(journalDir,
            config.getJournalBufferSize_AIO(),
            config.getJournalBufferTimeout_AIO(),
            config.isLogJournalWriteRate(),
            criticalErrorListener);
      }
      else if (config.getJournalType() == JournalType.NIO)
      {
         HornetQServerLogger.LOGGER.journalUseNIO();
         journalFF = new NIOSequentialFileFactory(journalDir,
            true,
            config.getJournalBufferSize_NIO(),
            config.getJournalBufferTimeout_NIO(),
            config.isLogJournalWriteRate(),
            criticalErrorListener);
      }
      else
      {
         throw HornetQMessageBundle.BUNDLE.invalidJournalType2(config.getJournalType());
      }

      idGenerator = new BatchingIDGenerator(0, JournalStorageManager.CHECKPOINT_BATCH_SIZE, this);

      Journal localMessage = new JournalImpl(config.getJournalFileSize(),
         config.getJournalMinFiles(),
         config.getJournalCompactMinFiles(),
         config.getJournalCompactPercentage(),
         journalFF,
         "hornetq-data",
View Full Code Here

TOP

Related Classes of org.hornetq.core.journal.impl.JournalImpl$PerfBlast

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.