Package net.sf.joafip.kvstore.record.entity

Examples of net.sf.joafip.kvstore.record.entity.DataRecordIdentifier


    appendHeaderInEmptyFile();
    heapElementManager.startService();
    heapElementManager.openTransaction();
    record1pos = HeapHeader.HEAP_HEADER_SIZE;
    final int dataSize = 100;
    final DataRecordIdentifier dataRecordIdentifier = DataRecordIdentifier.ZERO;
    heapRecordAppened1 = new HeapRecord(heapElementManager, record1pos,
        -1L/* prev pos */, dataRecordIdentifier/* id */,
        false/* free */, dataSize, dataSize
            + HeapRecord.MAX_RECORD_HEADER_SIZE + 4/*
                                 * area size: +
View Full Code Here


  }

  @Override
  public DataRecordIdentifier getNextFreeDataRecordIdentifier()
      throws HeapException {
    final DataRecordIdentifier next1 = firstDataManager
        .getNextFreeDataRecordIdentifier();
    final DataRecordIdentifier next2 = secondDataManager
        .getNextFreeDataRecordIdentifier();
    if (next1.value != next2.value) {
      throw new HeapException("new data record identifier missmatch "
          + next1.value + " " + next2.value);
    }
View Full Code Here

  }

  @Override
  public DataRecordIdentifier getNewDataRecordIdentifier()
      throws HeapException {
    final DataRecordIdentifier new1 = firstDataManager
        .getNewDataRecordIdentifier();
    final DataRecordIdentifier new2 = secondDataManager
        .getNewDataRecordIdentifier();
    if (new1.value != new2.value) {
      throw new HeapException("new data record identifier missmatch "
          + new1.value + " " + new2.value);
    }
View Full Code Here

    return deleted1;
  }

  @Override
  public DataRecordIdentifier removeFirstDataRecord() throws HeapException {
    final DataRecordIdentifier dr1 = firstDataManager
        .removeFirstDataRecord();
    final DataRecordIdentifier dr2 = secondDataManager
        .removeFirstDataRecord();
    if (dr1.value != dr2.value) {
      throw new HeapException(DATA_RECORD_MISMATCH + dr1.value + " "
          + dr2.value);
    }
View Full Code Here

  }

  @Override
  public DataRecordIdentifier firstDataRecordIdentifier()
      throws HeapException {
    final DataRecordIdentifier dr1 = firstDataManager
        .firstDataRecordIdentifier();
    final DataRecordIdentifier dr2 = secondDataManager
        .firstDataRecordIdentifier();
    if (dr1.value != dr2.value) {
      throw new HeapException(DATA_RECORD_MISMATCH + dr1.value + " "
          + dr2.value);
    }
View Full Code Here

  @Override
  public DataRecordIdentifier nextDataRecordIdentifier(
      final DataRecordIdentifier dataRecordIdentifier)
      throws HeapException {
    final DataRecordIdentifier dr1 = firstDataManager
        .nextDataRecordIdentifier(dataRecordIdentifier);
    final DataRecordIdentifier dr2 = secondDataManager
        .nextDataRecordIdentifier(dataRecordIdentifier);
    if (dr1.value != dr2.value) {
      throw new HeapException(DATA_RECORD_MISMATCH + dr1.value + " "
          + dr2.value);
    }
View Full Code Here

    return dr1;
  }

  @Override
  public DataRecordIdentifier lastDataRecordIdentifier() throws HeapException {
    final DataRecordIdentifier dr1 = firstDataManager
        .lastDataRecordIdentifier();
    final DataRecordIdentifier dr2 = secondDataManager
        .lastDataRecordIdentifier();
    if (dr1.value != dr2.value) {
      throw new HeapException(DATA_RECORD_MISMATCH + dr1.value + " "
          + dr2.value);
    }
View Full Code Here

    final HeapRecordableManager recordableManager = new HeapRecordableManager(
        dataManager);

    Recordable recordable0 = new Recordable(recordableManager, (byte) 0,
        helperBinaryConversion);
    final DataRecordIdentifier id0 = new DataRecordIdentifier(0);
    recordable0.setDataRecordIdentifier(id0, true);
    assertFalse("read must failed",
        recordableManager.readAndSetState(recordable0));
    recordableManager.attach(recordable0);
    recordable0.setStateHaveChanged();
    /*
     * simulate record added by other data manager users
     */
    assertEquals("must alloc #1", new DataRecordIdentifier(1),
        allocHeapFileRecord(50));
    assertEquals("must alloc #2", new DataRecordIdentifier(2),
        allocHeapFileRecord(50));

    Recordable recordable3 = new Recordable(recordableManager, (byte) 3,
        helperBinaryConversion);
    recordableManager.attach(recordable3);
    recordable3.setStateHaveChanged();

    recordableManager.save();

    final DataRecordIdentifier id3 = new DataRecordIdentifier(3);
    assertEquals("must be write in #3", id3,
        recordable3.getDataRecordIdentifier());

    recordable0 = new Recordable(recordableManager, helperBinaryConversion);
    recordable0.setDataRecordIdentifier(id0, true);
View Full Code Here

        recordable3.getValue());
  }

  private DataRecordIdentifier allocHeapFileRecord(final int size)
      throws HeapException {
    final DataRecordIdentifier identifier = dataManager
        .getNewDataRecordIdentifier();
    final byte[] data = new byte[size];
    dataManager.writeDataRecord(identifier, data);
    return identifier;
  }
View Full Code Here

    logger.info("get root");
    refToNode = (RefToNode) store.readAndGetRoot();

    logger.info("root as current");
    current = refToNode.getRoot();// it is node 0
    final DataRecordIdentifier currentIdentifier = getIdentifier(current);
    assertEquals(BAD_VALUE, 0, current.getValue());
    logger.info("get next of current");
    next = current.getNext();// it is node 1
    logger.info("get previous of next");
    previous = next.getPrevious();// it is node 0
    final DataRecordIdentifier previousIdentifier = getIdentifier(current);
    assertEquals("must be same identifier", currentIdentifier,
        previousIdentifier);
    logger.info("current id=" + currentIdentifier);
    assertSame("bad link", current, previous);
    current = next;// it is node 1
View Full Code Here

TOP

Related Classes of net.sf.joafip.kvstore.record.entity.DataRecordIdentifier

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.