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

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


    DATA_MANAGER_INTEGRITY_CHECKER.checkIntegrity(dataManager);
    // ?

    bob1 = (Bob1) store.readAndGetRoot();
    assertNotNull("root object must exist", bob1);
    DataRecordIdentifier id1 = store
        .getDataRecordIdentifierAssociatedToObject(bob1);
    assertNotNull(BOB1_MUST_HAVE_DATA_RECORD_IDENTIFIER, id1);
    assertObjectLink(Bob1.class, id1, new DataRecordIdentifier[] {});

    Bob2 bob2 = new Bob2();
    bob1.setBob2(bob2);
    store.save(true, false);

    DATA_MANAGER_INTEGRITY_CHECKER.checkIntegrity(dataManager);

    bob1 = (Bob1) store.readAndGetRoot();
    id1 = store.getDataRecordIdentifierAssociatedToObject(bob1);
    assertNotNull(BOB1_MUST_HAVE_DATA_RECORD_IDENTIFIER, id1);
    bob2 = bob1.getBob2();
    assertNotNull("bob1 must reference bob2", bob2);
    DataRecordIdentifier id2 = store
        .getDataRecordIdentifierAssociatedToObject(bob2);
    assertNotNull(BOB2_MUST_HAVE_DATA_RECORD_IDENTIFIER, id2);
    assertObjectLink(Bob1.class, id1, new DataRecordIdentifier[] { id2 });
    assertObjectLink(Bob2.class, id2, new DataRecordIdentifier[] {});

    bob2.setBob1(bob1);
    store.save(true, false);

    DATA_MANAGER_INTEGRITY_CHECKER.checkIntegrity(dataManager);

    bob1 = (Bob1) store.readAndGetRoot();
    id1 = store.getDataRecordIdentifierAssociatedToObject(bob1);
    assertNotNull(BOB1_MUST_HAVE_DATA_RECORD_IDENTIFIER, id1);
    bob2 = bob1.getBob2();
    id2 = store.getDataRecordIdentifierAssociatedToObject(bob2);
    assertNotNull(BOB2_MUST_HAVE_DATA_RECORD_IDENTIFIER, id2);
    assertObjectLink(Bob1.class, id1, new DataRecordIdentifier[] { id2 });
    assertObjectLink(Bob2.class, id2, new DataRecordIdentifier[] { id1 });

    Bob3 bob3 = new Bob3();
    bob2.setBob3(bob3);
    store.save(true, false);

    DATA_MANAGER_INTEGRITY_CHECKER.checkIntegrity(dataManager);

    bob1 = (Bob1) store.readAndGetRoot();
    id1 = store.getDataRecordIdentifierAssociatedToObject(bob1);
    assertNotNull(BOB1_MUST_HAVE_DATA_RECORD_IDENTIFIER, id1);
    bob2 = bob1.getBob2();
    id2 = store.getDataRecordIdentifierAssociatedToObject(bob2);
    assertNotNull(BOB2_MUST_HAVE_DATA_RECORD_IDENTIFIER, id2);
    bob3 = bob2.getBob3();
    final DataRecordIdentifier id3 = store
        .getDataRecordIdentifierAssociatedToObject(bob3);
    assertNotNull("bob3 must have data record identifier", id3);

    assertObjectLink(Bob1.class, id1, new DataRecordIdentifier[] { id2 });
    assertObjectLink(Bob2.class, id2,
View Full Code Here


    store.save(true, false);

    DATA_MANAGER_INTEGRITY_CHECKER.checkIntegrity(dataManager);

    bobContainer = (BobContainer) store.readAndGetRoot();
    DataRecordIdentifier idc = store
        .getDataRecordIdentifierAssociatedToObject(bobContainer);
    assertNotNull(BOB_CONTAINER_MUST_HAVE_DATA_RECORD_IDENTIFIER, idc);
    assertObjectLink(BobContainer.class, idc, new DataRecordIdentifier[] {});

    Bob1 bob1 = new Bob1();
    bobContainer.setObject1(bob1);
    store.save(true, false);

    bobContainer = (BobContainer) store.readAndGetRoot();
    idc = store.getDataRecordIdentifierAssociatedToObject(bobContainer);
    assertNotNull(BOB_CONTAINER_MUST_HAVE_DATA_RECORD_IDENTIFIER, idc);
    bob1 = (Bob1) bobContainer.getObject1();
    assertNotNull("bobContainer must reference bob1", bob1);
    DataRecordIdentifier id1 = store
        .getDataRecordIdentifierAssociatedToObject(bob1);
    assertNotNull(BOB1_MUST_HAVE_DATA_RECORD_IDENTIFIER, id1);

    assertObjectLink(BobContainer.class, idc,
        new DataRecordIdentifier[] { id1 });
View Full Code Here

    BobObjectArray bobObjectArray = new BobObjectArray();
    store.setRoot(bobObjectArray);
    store.save(true, false);
    DATA_MANAGER_INTEGRITY_CHECKER.checkIntegrity(dataManager);
    bobObjectArray = (BobObjectArray) store.readAndGetRoot();
    DataRecordIdentifier idObjectArray = store
        .getDataRecordIdentifierAssociatedToObject(bobObjectArray);
    assertNotNull("bobObjectArray must have data record identifier",
        idObjectArray);
    Object[] objects = bobObjectArray.getValues();
    assertNull("no values must be setted", objects);
    assertObjectLink(BobObjectArray.class, idObjectArray,
        new DataRecordIdentifier[] {});

    Bob1 bob1 = new Bob1();
    Bob2 bob2 = new Bob2();
    objects = new Object[] { bob1, bob2, bob1 };
    bobObjectArray.setValues(objects);
    store.save(true, false);
    DATA_MANAGER_INTEGRITY_CHECKER.checkIntegrity(dataManager);

    bobObjectArray = (BobObjectArray) store.readAndGetRoot();
    idObjectArray = store
        .getDataRecordIdentifierAssociatedToObject(bobObjectArray);
    assertNotNull("bobObjectArray must have data record identifier",
        idObjectArray);
    objects = bobObjectArray.getValues();
    assertNotNull("values be setted", objects);
    final DataRecordIdentifier idArray = store
        .getDataRecordIdentifierAssociatedToObject(objects);
    assertNotNull("array must have data record identifier", idArray);
    bob1 = (Bob1) objects[0];
    final DataRecordIdentifier id1 = store
        .getDataRecordIdentifierAssociatedToObject(bob1);
    assertNotNull(BOB1_MUST_HAVE_DATA_RECORD_IDENTIFIER, id1);
    bob2 = (Bob2) objects[1];
    final DataRecordIdentifier id2 = store
        .getDataRecordIdentifierAssociatedToObject(bob2);
    assertNotNull(BOB2_MUST_HAVE_DATA_RECORD_IDENTIFIER, id2);
    final Bob1 bob1Bis = (Bob1) objects[2];
    assertSame("bob1 must be uniq", bob1, bob1Bis);
View Full Code Here

    DATA_MANAGER_INTEGRITY_CHECKER.checkIntegrity(dataManager);

    bobContainer = (BobContainer) store.readAndGetRoot();
    assertNotNull("root must be defined", bobContainer);
    DataRecordIdentifier idc = store
        .getDataRecordIdentifierAssociatedToObject(bobContainer);
    assertNotNull(BOB_CONTAINER_MUST_HAVE_DATA_RECORD_IDENTIFIER, idc);
    enumForTest = (EnumForTest) bobContainer.getObject1();
    DataRecordIdentifier idEnum = store
        .getDataRecordIdentifierAssociatedToObject(enumForTest);
    assertNotNull("enum must have data record identifier", idEnum);

    assertObjectLink(BobContainer.class, idc,
        new DataRecordIdentifier[] { idEnum });

    Bob1 bob1 = new Bob1();
    enumForTest.setObject(bob1);
    store.save(true, false);

    DATA_MANAGER_INTEGRITY_CHECKER.checkIntegrity(dataManager);

    bobContainer = (BobContainer) store.readAndGetRoot();
    assertNotNull("must has a root object", bobContainer);
    idc = store.getDataRecordIdentifierAssociatedToObject(bobContainer);
    assertNotNull(BOB_CONTAINER_MUST_HAVE_DATA_RECORD_IDENTIFIER, idc);
    enumForTest = (EnumForTest) bobContainer.getObject1();
    idEnum = store.getDataRecordIdentifierAssociatedToObject(enumForTest);
    assertNotNull("enul must have data record identifier", idEnum);
    bob1 = (Bob1) enumForTest.getObject();
    final DataRecordIdentifier id1 = store
        .getDataRecordIdentifierAssociatedToObject(bob1);
    assertNotNull(BOB1_MUST_HAVE_DATA_RECORD_IDENTIFIER, id1);

    assertObjectLink(EnumForTest.class, idEnum,
        new DataRecordIdentifier[] { id1 });
View Full Code Here

    /*
     * read, check data record identifier, detach object, save
     */
    bobContainer = (BobContainer) store.readAndGetRoot();
    final DataRecordIdentifier idBobContainer = store
        .getDataRecordIdentifierAssociatedToObject(bobContainer);
    logger.debug("id bob container " + idBobContainer);
    assertNotNull("bobContainer must have associated data record",
        idBobContainer);

    bob1 = (Bob1) bobContainer.getObject1();
    final DataRecordIdentifier idBob1 = store
        .getDataRecordIdentifierAssociatedToObject(bob1);
    logger.debug("id bob1 " + idBob1);
    assertNotNull("bob1 must have associated data record", idBob1);

    bob2 = bob1.getBob2();
    final DataRecordIdentifier idBob2 = store
        .getDataRecordIdentifierAssociatedToObject(bob2);
    logger.debug("id bob2 " + idBob2);
    assertNotNull("bob2 must have associated data record", idBob2);

    assertDataRecord(new DataRecordIdentifier[] {
View Full Code Here

   * take 187 seconds Intel Core 2 Duo E6320 1.86GHz with sun 32 bits jvm<br>
   */
  public void test() throws HeapException { // NOPMD
    helperMemoryUse.log("start");
    for (int i = 0; i < 1000; i++) {
      final DataRecordIdentifier identifier = heapDataManager
          .getNewDataRecordIdentifier();
      final byte[] data = new byte[100];// NOPMD
      heapDataManager.writeDataRecord(identifier, data);

      heapDataManager.flush();
View Full Code Here

   *
   */
  private void checkContent() throws HeapException {
    createHeap(false/* remove file */);
    checkIntegrity();
    DataRecordIdentifier identifier = new DataRecordIdentifier(0);
    checkDataRecord(50, identifier);
    identifier = new DataRecordIdentifier(1);
    checkDataRecord(100, identifier);
    identifier = new DataRecordIdentifier(2);
    checkDataRecord(500, identifier);
  }
View Full Code Here

  protected void tearDown() throws Exception {// NOPMD
    super.tearDown();
  }

  protected DataRecordIdentifier newDataRecordIdentifier(final int identifier) {
    return new DataRecordIdentifier(identifier);
  }
View Full Code Here

    return createRecord(data, expectedIdentifier);
  }

  protected byte[] createRecord(final byte[] data,
      final int expectedIdentifier) throws HeapException {
    final DataRecordIdentifier identifier = heapDataManager
        .getNewDataRecordIdentifier();
    assertEquals("bad record identifier", expectedIdentifier,
        identifier.value);
    heapDataManager.writeDataRecord(identifier, data);
    return data;
View Full Code Here

  }

  public DataRecordIdentifier getOrCreateDataRecordIdentifierAssociatedToObject(
      final ObjectAndPersistInfo objectAndItsClassInfo)
      throws ObjectIOException, ObjectIODataCorruptedException {
    DataRecordIdentifier dataRecordIdentifier = objectAndItsClassInfo.dataRecordIdentifier;
    if (dataRecordIdentifier == null) {
      dataRecordIdentifier = currentDataRecordIdentifier;
      currentDataRecordIdentifier = new DataRecordIdentifier(
          currentDataRecordIdentifier);
      setDataRecordIdentifierAssociatedToObject(dataRecordIdentifier,
          objectAndItsClassInfo);
    }
    return dataRecordIdentifier;
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.