Package org.apache.activeio.journal

Examples of org.apache.activeio.journal.InvalidRecordLocationException


        LogFile logFile;
        LogFileNode logFileState = getLogFileWithId(location.getLogFileId());
        if( logFileState !=null ) {
            // There can be no record at the append offset.
            if (logFileState.getAppendOffset() == location.getLogFileOffset()) {
                throw new InvalidRecordLocationException("No record at (" + location
                        + ") found.  Location past end of logged data.");
            }
            logFile = logFileState.getLogFile();
        } else {
            if( archiveDirectory==null ) {
                throw new InvalidRecordLocationException("Log file: " + location.getLogFileId() + " is not active.");
            } else {
                logFile = getArchivedLogFile(location.getLogFileId());
            }
        }

        // Is there a record header at the seeked location?
        try {
            Record header = new Record();
            logFile.readRecordHeader(location.getLogFileOffset(), header);
            return new RecordInfo(location, header, logFileState, logFile);
        } catch (IOException e) {
            throw new InvalidRecordLocationException("No record at (" + location + ") found.");
        }
    }
View Full Code Here


        Integer key = new Integer(logFileId);
        LogFile rc = (LogFile) openArchivedLogs.get(key);
        if( rc == null ) {
            File archiveFile = getArchiveFile(logFileId);
            if( !archiveFile.canRead() )
                throw new InvalidRecordLocationException("Log file: " + logFileId + " does not exist.");
            rc = new LogFile(archiveFile, getInitialLogFileSize());
            openArchivedLogs.put(key, rc);
           
            // TODO: turn openArchivedLogs into LRU cache and close old log files.
        }
View Full Code Here

    synchronized public void setMark(RecordLocation l, boolean force) throws InvalidRecordLocationException,
            IOException {
       
        Location location = (Location) l;
        if (location == null)
            throw new InvalidRecordLocationException("The location cannot be null.");
        if (lastMarkedLocation != null && location.compareTo(lastMarkedLocation) < 0)
            throw new InvalidRecordLocationException("The location is less than the last mark.");
       
        markPacket.clear();
        location.writeToPacket(markPacket);   
        markPacket.flip();
        write(LogFileManager.MARK_RECORD_TYPE, markPacket, force, location);
View Full Code Here

        LogFile logFile;
        LogFileNode logFileState = getLogFileWithId(location.getLogFileId());
        if( logFileState !=null ) {
            // There can be no record at the append offset.
            if (logFileState.getAppendOffset() == location.getLogFileOffset()) {
                throw new InvalidRecordLocationException("No record at (" + location
                        + ") found.  Location past end of logged data.");
            }
            logFile = logFileState.getLogFile();
        } else {
            if( archiveDirectory==null ) {
                throw new InvalidRecordLocationException("Log file: " + location.getLogFileId() + " is not active.");
            } else {
                logFile = getArchivedLogFile(location.getLogFileId());
            }
        }

        // Is there a record header at the seeked location?
        try {
            Record header = new Record();
            logFile.readRecordHeader(location.getLogFileOffset(), header);
            return new RecordInfo(location, header, logFileState, logFile);
        } catch (IOException e) {
            throw new InvalidRecordLocationException("No record at (" + location + ") found.");
        }
    }
View Full Code Here

        Integer key = new Integer(logFileId);
        LogFile rc = (LogFile) openArchivedLogs.get(key);
        if( rc == null ) {
            File archiveFile = getArchiveFile(logFileId);
            if( !archiveFile.canRead() )
                throw new InvalidRecordLocationException("Log file: " + logFileId + " does not exist.");
            rc = new LogFile(archiveFile, getInitialLogFileSize());
            openArchivedLogs.put(key, rc);
           
            // TODO: turn openArchivedLogs into LRU cache and close old log files.
        }
View Full Code Here

    synchronized public void setMark(RecordLocation l, boolean force) throws InvalidRecordLocationException,
            IOException {
       
        Location location = (Location) l;
        if (location == null)
            throw new InvalidRecordLocationException("The location cannot be null.");
        if (lastMarkedLocation != null && location.compareTo(lastMarkedLocation) < 0)
            throw new InvalidRecordLocationException("The location is less than the last mark.");
       
        markPacket.clear();
        location.writeToPacket(markPacket);   
        markPacket.flip();
        write(LogFileManager.MARK_RECORD_TYPE, markPacket, force, location);
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 new ByteArrayPacket(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

TOP

Related Classes of org.apache.activeio.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.