Package org.codehaus.activemq.journal

Examples of org.codehaus.activemq.journal.InvalidRecordLocationException


  public void setMark(RecordLocation recordLocator, boolean force)
      throws InvalidRecordLocationException, IOException {
    try {
      if (recordLocator == null
          || recordLocator.getClass() != LongRecordLocation.class)
        throw new InvalidRecordLocationException();

      long location = ((LongRecordLocation) recordLocator)
          .getLongLocation();
      logger.mark(location, force);
      lastMark = recordLocator;

    } catch (InterruptedException e) {
      throw (InterruptedIOException) new InterruptedIOException()
          .initCause(e);
    } catch (IOException e) {
      throw e;
    } catch (InvalidLogKeyException e) {
      throw new InvalidRecordLocationException(e.getMessage(), e);
    } catch (Exception e) {
      throw (IOException) new IOException("Journal write failed: " + e)
          .initCause(e);
    }
  }
View Full Code Here


   * @throws IOException
   * @throws InterruptedException
   */
  synchronized public void setMark(final RecordLocationImpl recordLocator, boolean force) throws InvalidRecordLocationException, InterruptedException, IOException {
    if( recordLocator==null )
          throw new InvalidRecordLocationException("The location cannot be null.");           
      if( lastMarkedLocation!=null && recordLocator.compareTo(lastMarkedLocation)<0 )
          throw new InvalidRecordLocationException("The location is less than the last mark.");           
      lastMarkedLocation = recordLocator;
      Mark mark = new Mark(recordLocator);
      byte data[] = mark.writeExternal();
      write(LogFile.MARK_RECORD_TYPE,data,force,mark);
  }
View Full Code Here

            return (RecordLocationImpl)result.get();
        } catch (InterruptedException e) {
            throw (IOException)new IOException("Interrupted.").initCause(e);
        } catch (InvocationTargetException e) {
            if( e.getTargetException() instanceof InvalidRecordLocationException)
                throw new InvalidRecordLocationException(e.getTargetException().getMessage(),e.getTargetException());
            if( e.getTargetException() instanceof IOException)
                throw (IOException)new IOException(e.getTargetException().getMessage()).initCause(e.getTargetException());
            throw (IOException)new IOException("Unexpected Exception: ").initCause(e.getTargetException());
        }       
  } 
View Full Code Here

            return (byte[])result.get();
        } catch (InterruptedException e) {
            throw (IOException)new IOException("Interrupted.").initCause(e);
        } catch (InvocationTargetException e) {
            if( e.getTargetException() instanceof InvalidRecordLocationException)
                throw new InvalidRecordLocationException(e.getTargetException().getMessage(),e.getTargetException());
            if( e.getTargetException() instanceof IOException)
                throw (IOException)new IOException(e.getTargetException().getMessage()).initCause(e.getTargetException());
            throw (IOException)new IOException("Unexpected Exception: ").initCause(e.getTargetException());
        }       
  }
View Full Code Here

       
    }

    private RecordInfo readRecordInfo(RecordLocationImpl location) throws IOException, InvalidRecordLocationException {
        if (0 > location.getSegmentIndex() || location.getSegmentIndex() > segments.length) {
            throw new InvalidRecordLocationException("Invalid segment id.");
        }

        Segment segment = segments[location.getSegmentIndex()];
        segment.seek(location.getSegmentOffset());
       
        // There can be no record at the append offset.
        if (segment.isAtAppendOffset()) {
            throw new InvalidRecordLocationException("No record at end of log.");
        }
       
        // Is there a record header at the seeked location?
        try {
            RecordHeader header = new RecordHeader();
            segment.readRecordHeader(header);
            return new RecordInfo(location, header);
        }
        catch (IOException e) {
            throw new InvalidRecordLocationException("No record at found.");
        }
    }
View Full Code Here

      throw (InterruptedIOException) new InterruptedIOException()
          .initCause(e);
    } catch (IOException e) {
      throw e;
    } catch (InvalidLogKeyException e) {
      throw new InvalidRecordLocationException(e.getMessage(), e);
    } catch (Exception e) {
      throw (IOException) new IOException("Journal write failed: " + e)
          .initCause(e);
    }
  }
View Full Code Here

     * @throws InvalidRecordLocationException
     */
    private long toLong(RecordLocation recordLocator) throws InvalidRecordLocationException {
        if (recordLocator == null
            || recordLocator.getClass() != LongRecordLocation.class)
          throw new InvalidRecordLocationException();

        long location = ((LongRecordLocation) recordLocator)
            .getLongLocation();
        return location;
    }
View Full Code Here

              lastLocation = new LongRecordLocation(next.key);
              if( !next.isCTRL() )
                  return lastLocation;
          }
    } catch (Exception e) {
      throw (InvalidRecordLocationException)new InvalidRecordLocationException().initCause(e);
        }
   
  }
View Full Code Here

     
      try {
            LogRecord record = logger.get(null, toLong(location));
            return record.data;           
    } catch (InvalidLogKeyException e) {
      throw new InvalidRecordLocationException(e.getMessage(), e);
    } catch (Exception e) {
      throw (IOException) new IOException("Journal write failed: " + e)
          .initCause(e);
    }
   
View Full Code Here

       
    }

    private RecordInfo readRecordInfo(RecordLocationImpl location) throws IOException, InvalidRecordLocationException {
        if (0 > location.getSegmentIndex() || location.getSegmentIndex() > segments.length) {
            throw new InvalidRecordLocationException("Invalid segment id.");
        }

        Segment segment = segments[location.getSegmentIndex()];
        segment.seek(location.getSegmentOffset());
       
        // There can be no record at the append offset.
        if (segment.isAtAppendOffset()) {
            throw new InvalidRecordLocationException("No record at end of log.");
        }
       
        // Is there a record header at the seeked location?
        try {
            RecordHeader header = new RecordHeader();
            segment.readRecordHeader(header);
            return new RecordInfo(location, header);
        }
        catch (IOException e) {
            throw new InvalidRecordLocationException("No record at found.");
        }
    }
View Full Code Here

TOP

Related Classes of org.codehaus.activemq.journal.InvalidRecordLocationException

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.