Package nexj.core.rpc.file.ra

Examples of nexj.core.rpc.file.ra.JournalManagementException


      if (!journalDirectory.exists())
      {
         if (!journalDirectory.mkdirs())
         {
            throw new JournalManagementException("err.rpc.file.journalIoErr",
               new Object[] {journalDirectory.getAbsolutePath()});
         }
      }

      m_journalFile = new File(journalDirectory, JOURNAL_FILE1_NAME);
      m_compactionJournalFile = new File(journalDirectory, JOURNAL_FILE2_NAME);
      m_activeJournalPointerFile = new File(journalDirectory, JOURNAL_POINTER_FILE_NAME);
      m_journal = new LockableFile(m_journalFile);
      m_compactionJournal = new LockableFile(m_compactionJournalFile);

      boolean bReady = false;

      try
      {
         if (!m_journal.tryLock(false))
         {
            throw new IllegalStateException("Journal \"" + m_journalFile.getAbsolutePath() + "\" is already locked.");
         }

         if (!m_compactionJournal.tryLock(false))
         {
            throw new IllegalStateException("Journal \"" + m_compactionJournalFile.getAbsolutePath() + "\" is already locked.");
         }

         boolean bSecondFileIsActive = true;

         if (m_activeJournalPointerFile.exists())
         {
            //Read the active journal pointer.
            try
            {
               FileInputStream activePointerStream = new FileInputStream(m_activeJournalPointerFile);

               try
               {
                  bSecondFileIsActive = activePointerStream.read() == 2;
               }
               finally
               {
                  IOUtil.close(activePointerStream);
               }
            }
            catch (IOException ex)
            {
               throw new JournalManagementException("err.rpc.file.journalIoErr",
                  new Object[] {m_activeJournalPointerFile.getAbsolutePath()}, ex);
            }
         }
         else
         {
            writeActiveJournalPointer((byte)2);
         }

         if (bSecondFileIsActive)
         {
            swapJournalFiles();
         }

         //Check/write version code
         try
         {
            if (m_journalFile.length() >= JOURNAL_VERSION.length)
            {
               InputStream istream = m_journal.getInputStream();
               byte[] nVersionCodeArray = new byte[JOURNAL_VERSION.length];

               istream.read(nVersionCodeArray);

               if (Binary.compare(nVersionCodeArray, JOURNAL_VERSION) != 0)
               {
                  throw new JournalManagementException("err.rpc.file.versionMismatch",
                     new Object[]{new Binary(JOURNAL_VERSION).toString(),
                        new Binary(nVersionCodeArray).toString(),
                        journalDirectory.getAbsolutePath()});
               }
            }
            else
            {
               m_journal.writeData(new Binary(JOURNAL_VERSION));
            }
         }
         catch (IOException ex)
         {
            throw new JournalManagementException("err.rpc.file.journalIoErr",
               new Object[] {m_journalFile.getAbsolutePath()}, ex);
         }

         m_indoubtXids = recoverInternal();
         m_activeXids = new HashHolder();
View Full Code Here


            {
               // Suppress it because an I/O error will already be thrown.
            }
         }

         throw new JournalManagementException("err.rpc.file.journalIoErr",
            new Object[] {m_journalFile}, ex);
      }
   }
View Full Code Here

         m_journal.appendData(new Binary(byteOStream.toByteArray()));
         m_journal.force();
      }
      catch (IOException ex)
      {
         throw new JournalManagementException("err.rpc.file.journalIoErr",
            new Object[] {m_journalFile.getAbsolutePath()}, ex);
      }
   }
View Full Code Here

         m_journal.appendData(new Binary(byteOStream.toByteArray()));
         m_journal.force();
      }
      catch (IOException ex)
      {
         throw new JournalManagementException("err.rpc.file.journalIoErr",
            new Object[] {m_journalFile.getAbsolutePath()}, ex);
      }
   }
View Full Code Here

            activePointerStream.close();
         }
      }
      catch (IOException ex)
      {
         throw new JournalManagementException("err.rpc.file.journalIoErr",
            new Object[] {m_activeJournalPointerFile}, ex);
      }
   }
View Full Code Here

TOP

Related Classes of nexj.core.rpc.file.ra.JournalManagementException

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.