Package org.hornetq.core.persistence.impl.journal

Examples of org.hornetq.core.persistence.impl.journal.JournalStorageManager$QueueEncoding


   /**
    * @return
    */
   private JournalStorageManager getStorage()
   {
      return new JournalStorageManager(createDefaultConfig(), factory);
   }
View Full Code Here


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

   public void testReloadDuplication() throws Exception
   {

      JournalStorageManager journal = null;

      try
      {
         clearData();

         SimpleString ADDRESS = new SimpleString("address");

         Configuration configuration = createDefaultConfig();

         PostOffice postOffice = new FakePostOffice();

         ScheduledExecutorService scheduledThreadPool = Executors.newScheduledThreadPool(ConfigurationImpl.DEFAULT_SCHEDULED_THREAD_POOL_MAX_SIZE);

         journal = new JournalStorageManager(configuration, factory);

         journal.start();
         journal.loadBindingJournal(new ArrayList<QueueBindingInfo>(), new ArrayList<GroupingInfo>());

         HashMap<SimpleString, List<Pair<byte[], Long>>> mapDups = new HashMap<SimpleString, List<Pair<byte[], Long>>>();

         journal.loadMessageJournal(postOffice,
                                    new FakePagingManager(),
                                    new ResourceManagerImpl(0, 0, scheduledThreadPool),
                                    new HashMap<Long, Queue>(),
                                    mapDups);

         Assert.assertEquals(0, mapDups.size());

         DuplicateIDCacheImpl cacheID = new DuplicateIDCacheImpl(ADDRESS, 10, journal, true);

         for (int i = 0; i < 100; i++)
         {
            cacheID.addToCache(RandomUtil.randomBytes(), null);
         }

         journal.stop();

         journal = new JournalStorageManager(configuration, factory);
         journal.start();
         journal.loadBindingJournal(new ArrayList<QueueBindingInfo>(), new ArrayList<GroupingInfo>());

         journal.loadMessageJournal(postOffice,
                                    new FakePagingManager(),
                                    new ResourceManagerImpl(0, 0, scheduledThreadPool),
                                    new HashMap<Long, Queue>(),
                                    mapDups);

         Assert.assertEquals(1, mapDups.size());

         List<Pair<byte[], Long>> values = mapDups.get(ADDRESS);

         Assert.assertEquals(10, values.size());

         cacheID = new DuplicateIDCacheImpl(ADDRESS, 10, journal, true);
         cacheID.load(values);

         for (int i = 0; i < 100; i++)
         {
            cacheID.addToCache(RandomUtil.randomBytes(), null);
         }

         journal.stop();

         mapDups.clear();

         journal = new JournalStorageManager(configuration, factory);
         journal.start();
         journal.loadBindingJournal(new ArrayList<QueueBindingInfo>(), new ArrayList<GroupingInfo>());

         journal.loadMessageJournal(postOffice,
                                    new FakePagingManager(),
                                    new ResourceManagerImpl(0, 0, scheduledThreadPool),
                                    new HashMap<Long, Queue>(),
                                    mapDups);

         Assert.assertEquals(1, mapDups.size());

         values = mapDups.get(ADDRESS);

         Assert.assertEquals(10, values.size());
      }
      finally
      {
         if (journal != null)
         {
            try
            {
               journal.stop();
            }
            catch (Throwable ignored)
            {
            }
         }
View Full Code Here

    */
   public void start() throws Exception
   {
      Configuration config = server.getConfiguration();

      storage = new JournalStorageManager(config, server.getExecutorFactory());
      storage.start();

      server.getManagementService().setStorageManager(storage);

      registerJournal((byte)1, storage.getMessageJournal());
View Full Code Here

    */
   protected StorageManager createStorageManager()
   {
      if (configuration.isPersistenceEnabled())
      {
         return new JournalStorageManager(configuration, executorFactory, replicationManager, shutdownOnCriticalIO);
      }
      else
      {
         return new NullStorageManager();
      }
View Full Code Here

      }
   }

   protected JournalStorageManager createJournalStorageManager(Configuration configuration)
   {
      return new JournalStorageManager(configuration, execFactory)
      {
         public void deleteMessage(final long messageID) throws Exception
         {
            System.out.println("message : " + messageID);
            deletedMessage.add(messageID);
View Full Code Here

      Configuration configuration = createDefaultConfig();

      PostOffice postOffice = new FakePostOffice();

      final JournalStorageManager journal = new JournalStorageManager(configuration, execFactory);

      try
      {

         journal.start();

         List<QueueBindingInfo> queueBindingInfos = new ArrayList<QueueBindingInfo>();

         journal.loadBindingJournal(queueBindingInfos, new ArrayList<GroupingInfo>());

         Map<Long, Queue> queues = new HashMap<Long, Queue>();

         journal.loadMessageJournal(postOffice, null, null, queues, null, null, null);

         journal.stop();

         deleteDirectory(testdir);

         journal.start();

         queues = new HashMap<Long, Queue>();

         journal.loadMessageJournal(postOffice, null, null, queues, null, null, null);

         queueBindingInfos = new ArrayList<QueueBindingInfo>();

         journal.loadBindingJournal(queueBindingInfos, new ArrayList<GroupingInfo>());

         journal.start();
      }
      finally
      {

         try
         {
            journal.stop();
         }
         catch (Exception ex)
         {
            RestartSMTest.log.warn(ex.getMessage(), ex);
         }
View Full Code Here

   /**
    * @return
    */
   private JournalStorageManager getStorage()
   {
      return new JournalStorageManager(createDefaultConfig(), factory);
   }
View Full Code Here

   /**
    * @param configuration
    */
   protected JournalStorageManager createJournalStorageManager(Configuration configuration)
   {
      return new JournalStorageManager(configuration, execFactory);
   }
View Full Code Here

     
      OrderedExecutorFactory factory = new OrderedExecutorFactory(executor);
     
      final ExecutorService deleteExecutor = Executors.newCachedThreadPool();

      final JournalStorageManager storage = new JournalStorageManager(config, factory);

      storage.start();
      storage.loadInternalOnly();
     
      ((JournalImpl)storage.getMessageJournal()).setAutoReclaim(false);
      final LinkedList<Long> survivingMsgs = new LinkedList<Long>();

      Runnable producerRunnable = new Runnable()
      {
         public void run()
         {
            try
            {
               while (running.get())
               {
                  final long[] values = new long[100];
                  long tx = seqGenerator.incrementAndGet();

                  OperationContextImpl ctx = new OperationContextImpl(executor);
                  storage.setContext(ctx);

                  for (int i = 0; i < 100; i++)
                  {
                     long id = seqGenerator.incrementAndGet();
                     values[i] = id;

                     ServerMessageImpl message = new ServerMessageImpl(id, 100);

                     message.getBodyBuffer().writeBytes(new byte[1024]);

                     storage.storeMessageTransactional(tx, message);
                  }
                  ServerMessageImpl message = new ServerMessageImpl(seqGenerator.incrementAndGet(), 100);
                 
                  survivingMsgs.add(message.getMessageID());
                 
                  // This one will stay here forever
                  storage.storeMessage(message);

                  storage.commit(tx);

                  ctx.executeOnCompletion(new IOAsyncTask()
                  {
                     public void onError(int errorCode, String errorMessage)
                     {
                     }

                     public void done()
                     {
                        deleteExecutor.execute(new Runnable()
                        {
                           public void run()
                           {
                              try
                              {
                                 for (long messageID : values)
                                 {
                                    storage.deleteMessage(messageID);
                                 }
                              }
                              catch (Exception e)
                              {
                                 e.printStackTrace();
                                 errors.incrementAndGet();
                              }

                           }
                        });
                     }
                  });

               }
            }
            catch (Throwable e)
            {
               e.printStackTrace();
               errors.incrementAndGet();
            }
         }
      };

      Runnable compressRunnable = new Runnable()
      {
         public void run()
         {
            try
            {
               int i = 0;
               while (running.get())
               {
                  Thread.sleep(500);
                  System.out.println("Compacting");
                  ((JournalImpl)storage.getMessageJournal()).testCompact();
                  ((JournalImpl)storage.getMessageJournal()).checkReclaimStatus();
               }
            }
            catch (Throwable e)
            {
               e.printStackTrace();
               errors.incrementAndGet();
            }

         }
      };

      Thread producerThread = new Thread(producerRunnable);
      producerThread.start();

      Thread compactorThread = new Thread(compressRunnable);
      compactorThread.start();

      Thread.sleep(10000);

      running.set(false);

      producerThread.join();

      compactorThread.join();

      executor.shutdown();

      assertTrue(executor.awaitTermination(10, TimeUnit.SECONDS));
     
      deleteExecutor.shutdown();
     
      assertTrue(deleteExecutor.awaitTermination(30, TimeUnit.SECONDS));

      storage.stop();
   }
View Full Code Here

         {
            return executor;
         }
      };

      storageManager = new JournalStorageManager(config, executorFactory);

      messageRefs = new HashMap<Long, HashMap<Long, ReferenceDescribe>>();

      messages = new HashMap<Long, Message>();
View Full Code Here

TOP

Related Classes of org.hornetq.core.persistence.impl.journal.JournalStorageManager$QueueEncoding

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.