Package org.hornetq.core.journal

Examples of org.hornetq.core.journal.SequentialFile


   }
  
   public boolean checkPage(final int pageNumber)
   {
      String fileName = createFileName(pageNumber);
      SequentialFile file = fileFactory.createSequentialFile(fileName, 1);
      return file.exists();
   }
View Full Code Here


      if (fileFactory == null)
      {
         fileFactory = storeFactory.newFileFactory(getStoreName());
      }

      SequentialFile file = fileFactory.createSequentialFile(fileName, 1000);

      Page page = new PageImpl(storeName, storageManager, fileFactory, file, pageNumber);

      // To create the file
      file.open();

      file.position(0);

      file.close();

      return page;
   }
View Full Code Here

    */
   private synchronized void handleReplicationSynchronization(ReplicationSyncFileMessage msg) throws Exception
   {
      Long id = Long.valueOf(msg.getId());
      byte[] data = msg.getData();
      SequentialFile channel1;
      switch (msg.getFileType())
      {
         case LARGE_MESSAGE:
         {
            ReplicatedLargeMessage largeMessage = lookupLargeMessage(id, false);
            if (!(largeMessage instanceof LargeServerMessageInSync))
            {
               HornetQServerLogger.LOGGER.largeMessageIncompatible();
               return;
            }
            LargeServerMessageInSync largeMessageInSync=(LargeServerMessageInSync)largeMessage;
            channel1 = largeMessageInSync.getSyncFile();
            break;
         }
         case PAGE:
         {
            Page page = getPage(msg.getPageStore(), (int)msg.getId());
            channel1 = page.getFile();
            break;
         }
         case JOURNAL:
         {
            JournalSyncFile journalSyncFile = filesReservedForSync.get(msg.getJournalContent()).get(id);
            FileChannel channel2 = journalSyncFile.getChannel();
            if (data == null)
            {
               channel2.close();
               return;
            }
            channel2.write(ByteBuffer.wrap(data));
            return;
         }
         default:
            throw HornetQMessageBundle.BUNDLE.replicationUnhandledFileType(msg.getFileType());
      }

      if (data == null)
      {
         channel1.close();
         return;
      }

      if (!channel1.isOpen())
      {
         channel1.open(1, false);
      }
      channel1.writeDirect(ByteBuffer.wrap(data), true);
   }
View Full Code Here

      private final File file;
      private FileOutputStream fos;

      public JournalSyncFile(JournalFile jFile) throws Exception
      {
         SequentialFile seqFile = jFile.getFile();
         file = seqFile.getJavaFile();
         seqFile.close();
      }
View Full Code Here

   }

   @Override
   public synchronized ServerMessage copy()
   {
      SequentialFile newfile = storageManager.createFileForLargeMessage(messageID, durable);

      ServerMessage newMessage = new LargeServerMessageImpl(this,
                                                            properties,
                                                            newfile,
                                                            messageID);
View Full Code Here

   @Override
   public void finishCopy() throws Exception
   {
      if (pendingCopy != null)
      {
         SequentialFile copyTo = createFile();
         try
         {
            this.pendingRecordID = storageManager.storePendingLargeMessage(this.messageID);
            copyTo.open();
            pendingCopy.open();
            pendingCopy.copyTo(copyTo);
         }
         finally
         {
            copyTo.close();
            pendingCopy.close();
            pendingCopy = null;
         }

         closeFile();
View Full Code Here

   @Override
   public synchronized ServerMessage copy(final long newID)
   {
      try
      {
         SequentialFile newfile = storageManager.createFileForLargeMessage(newID, durable);

         LargeServerMessageImpl newMessage = new LargeServerMessageImpl(this,
                                                               properties,
                                                               newfile,
                                                               newID);
View Full Code Here

    */
   private void performCachedLargeMessageDeletes()
   {
      for (Long largeMsgId : largeMessagesToDelete)
      {
         SequentialFile msg = createFileForLargeMessage(largeMsgId, LargeMessageExtension.DURABLE);
         try
         {
            msg.delete();
         }
         catch (Exception e)
         {
            HornetQServerLogger.LOGGER.journalErrorDeletingMessage(e, largeMsgId);
         }
View Full Code Here

            break;
         }
         String fileName = entry.getValue().getA();
         final long id = entry.getKey();
         long size = entry.getValue().getB();
         SequentialFile seqFile = largeMessagesFactory.createSequentialFile(fileName, 1);
         if (!seqFile.exists())
            continue;
         if (!started)
            return;
         replicator.syncLargeMessageFile(seqFile, size, id);
      }
View Full Code Here

      List<Long> idList = new ArrayList<Long>();
      for (String filename : filenames)
      {
         Long id = getLargeMessageIdFromFilename(filename);
         idList.add(id);
         SequentialFile seqFile = largeMessagesFactory.createSequentialFile(filename, 1);
         long size = seqFile.size();
         largeMessages.put(id, new Pair<String, Long>(filename, size));
      }
      replicator.sendLargeMessageIdListMessage(largeMessages);
   }
View Full Code Here

TOP

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

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.