Examples of IFileStorable


Examples of net.sf.joafip.kvstore.entity.IFileStorable

  @Override
  public void clearReadCache() {
    final Iterator<IFileStorable> iterator = cache.values().iterator();
    while (iterator.hasNext()) {
      final IFileStorable next = iterator.next();
      if (!next.isValueChangedToSave()) {
        iterator.remove();
      }
    }
  }
View Full Code Here

Examples of net.sf.joafip.kvstore.entity.IFileStorable

  @Override
  public IFileStorable readHeapFileDataRecord(final long positionInFile)
      throws HeapException {
    assertTransactionOpenned();
    IFileStorable fileStorable = cache.get(positionInFile);
    if (fileStorable == null) {
      fileStorable = heapRecordFactory.createHeapRecord(this,
          positionInFile);
      cache.put(positionInFile, fileStorable);
      fileStorable.readFromFile();
    }
    return fileStorable;
  }
View Full Code Here

Examples of net.sf.joafip.kvstore.entity.IFileStorable

      throws HeapException {
    long lastWrotePositionInFile = header.getRecordSize() - 1;
    long lastRecordPositionInFile = 0;
    for (Map.Entry<Long, IFileStorable> entry : heapRecordToWriteMap
        .entrySet()) {
      final IFileStorable heapRecord = entry.getValue();
      if (heapRecord != NULL_FILE_STORABLE) {
        try {
          assert false;
        } catch (AssertionError error) {
          // ASSERTX
          final long recordPositionInFile = heapRecord
              .getPositionInFile();
          if (recordPositionInFile != entry.getKey()) {
            throw new HeapException(// NOPMD
                "integrity error record position is "
                    + recordPositionInFile
                    + " and map key is " + entry.getKey());
          }
          if (recordPositionInFile <= lastWrotePositionInFile) {
            throw new HeapException("last wrote position is "// NOPMD
                + lastWrotePositionInFile
                + " and record position in file is "
                + recordPositionInFile
                + " for \n"
                + heapRecord.toString());
          }
          final long previousRecordPositionInFile = heapRecord
              .getPreviousRecordPositionInFile();
          if (previousRecordPositionInFile == -1) {
            if (recordPositionInFile != header.getRecordSize()) {
              throw new HeapException(
                  "bad position of first record "// NOPMD
                      + recordPositionInFile
                      + " for "
                      + header.getRecordSize()
                      + " expected");
            }
          } else if (previousRecordPositionInFile < lastRecordPositionInFile) {
            badPreviousRecordPositionInFileError(
                lastRecordPositionInFile, recordPositionInFile,
                previousRecordPositionInFile);
          }
          lastWrotePositionInFile = recordPositionInFile
              + heapRecord.getRecordSize() - 1;
          lastRecordPositionInFile = recordPositionInFile;
        }
        saveHeapRecord(heapRecord, toBackupList);
      }
    }
View Full Code Here

Examples of net.sf.joafip.kvstore.entity.IFileStorable

      final long lastRecordPositionInFile,
      final long recordPositionInFile,
      final long previousRecordPositionInFile) throws HeapException {
    String nextOfPrevious;
    try {
      final IFileStorable heapRecord = readHeapRecordInFile(previousRecordPositionInFile);
      final long nNextOfPrevious = previousRecordPositionInFile
          + heapRecord.getRecordSize();
      nextOfPrevious = String.valueOf(nNextOfPrevious);

    } catch (Exception exception) {
      nextOfPrevious = exception.getMessage();
    }

    final IFileStorable heapRecord = heapRecordToWriteMap
        .get(lastRecordPositionInFile);

    final long nEndOfFilePosition = lastRecordPositionInFile
        + heapRecord.getRecordSize();
    throw new HeapException("for record at " + recordPositionInFile
        + ", bad previous position in file "
        + previousRecordPositionInFile + ", last record position is "
        + lastRecordPositionInFile + ",next of previous position "
        + nextOfPrevious + ",next of last " + nEndOfFilePosition
        + Thread.currentThread().getName() + "\nrecord:\n"
        + heapRecord.toString());
  }
View Full Code Here

Examples of net.sf.joafip.kvstore.entity.IFileStorable

   * @return
   * @throws HeapException
   */
  private IFileStorable readHeapRecordInFile(final long positionInFile)
      throws HeapException {
    final IFileStorable heapRecord = heapRecordFactory.createHeapRecord(
        this, positionInFile);
    try {
      heapRecord.readFromFile();
    } catch (HeapException exception) {
      final String message = READ_HEAP_FILE_NODE_FAILED
          + "read record failed, position in file #" + positionInFile;
      LOGGER.fatal(message, exception);
      throw new HeapException(message, exception);
View Full Code Here

Examples of net.sf.joafip.kvstore.entity.IFileStorable

    /*
     * in write mode, read are put in cache to guaranty that same object for
     * same record is returned in same transaction<br>
     */

    IFileStorable heapRecord;
    heapRecord = heapRecordToWriteMap.get(positionInFile);
    if (heapRecord == NULL_FILE_STORABLE) {
      final String message = READ_HEAP_FILE_NODE_FAILED
          + "read record at poistion " + positionInFile + " failed";
      LOGGER.fatal(message);
      throw new HeapException(message);
    }
    if (heapRecord == null) {
      heapRecord = readHeapRecordMap.get(positionInFile);
    }
    if (heapRecord == null) {
      heapRecord = heapRecordFactory.createHeapRecord(this,
          positionInFile);
      try {
        heapRecord.readFromFile();
      } catch (HeapException exception) {
        final String message = READ_HEAP_FILE_NODE_FAILED
            + "read record at poistion " + positionInFile
            + " failed";
        LOGGER.fatal(message, exception);
View Full Code Here

Examples of net.sf.joafip.kvstore.entity.IFileStorable

    final long positionInFile = heapRecord.getPositionInFile();
    // ASSERTX
    assert assertTransactionOpened();
    // ASSERTX
    assert assertPositionInFile(positionInFile);
    IFileStorable previous = heapRecordToWriteMap.put(positionInFile,
        heapRecord);
    if (previous == NULL_FILE_STORABLE) {
      previous = null;
    }
    // ASSERTX
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.