Examples of IFilePersistence


Examples of net.sf.joafip.service.IFilePersistence

    builder.setPathName(RUNTIME_DIR);
    builder.setRemoveFiles(removeFiles);
    builder.setFileCache(PAGE_SIZE, NUMBER_OF_PAGE);
    builder.setGarbageManagement(GARBAGE);
    builder.setCrashSafeMode(CRASH_SAFE_MODE);
    final IFilePersistence filePersistence = builder.build();
    // filePersistence = new FilePersistence(1, null, RUNTIME_DIR,
    // /**/removeFiles,
    // /**/PAGE_SIZE, NUMBER_OF_PAGE,
    // /**/GARBAGE,
    // /**/CRASH_SAFE_MODE);
 
View Full Code Here

Examples of net.sf.joafip.service.IFilePersistence

      FilePersistenceNotSerializableException,
      FilePersistenceClassNotFoundException,
      FilePersistenceDataCorruptedException, StoreClassNotFoundException,
      FilePersistenceTooBigForSerializationException {
    /* create file persistence manager */
    final IFilePersistence filePersistence =
    /**/createFilePersistence(true/* remove files */);
    /* create a data access session */
    final IDataAccessSession session = filePersistence
        .createDataAccessSession();
    /* get operation start time */
    final long startTime = System.currentTimeMillis();
    /* create reference list of object currently in memory */
    memInspector.inspect(this, false/* mark new */);
    /* starting open session */
    session.open();
    /*
     * create the map in memory and add it to persisted object
     */
    Map<Integer, String> map = new PTreeMap<Integer, String>();
    session.setObject("map", map);
    int packet = 0;
    /*
     * add one million of entry in the persisted map
     */
    for (int index = 0; index < 1000000; index++) {
      /* get the persisted map */
      map = getMap(session);
      /* add an entry */
      map.put(index, String.valueOf(index));
      /*
       * for each 10000 append: close the session saving data, then reopen
       * session
       */
      if (index / 10000 > packet) {
        /*
         * after 1000 add, save in file. Object in memory will be
         * detached
         */
        final int numberOfObjectStateBeforeSave = filePersistence
            .getNumberOfObjectState();

        /*
         * saving close of data access session
         */
        session.closeAndWait(EnumFilePersistenceCloseAction.SAVE);

        /*
         * log information about persistent objects
         */
        final int modified = filePersistence.getNumberOfModified();
        final int visited = filePersistence.getNumberOfVisited();
        /*
         * to show that for appends all the map is not loaded in memory
         */
        System.out.println(// NOPMD
            (index + 1) + " appened, "
                + (System.currentTimeMillis() - startTime)
                + " mS elapsed, "
                + numberOfObjectStateBeforeSave
                + " object loaded\n" + visited + " visited, "
                + modified + " modified, ");

        /* unreference the map => will be garbaged by VM */
        map = null;// NOPMD

        /* re open for next append */
        session.open();
        packet++;
      }
    }
    /* ending saving close */
    session.closeAndWait(EnumFilePersistenceCloseAction.SAVE);

    /*
     * check if no memory leak, must not have object added in memory
     */
    memInspector.inspect(this, true/* mar added */);
    if (!memInspector.added()) {
      memInspector.log(System.err);
    }

    filePersistence.close();
  }
View Full Code Here

Examples of net.sf.joafip.service.IFilePersistence

      FilePersistenceNotSerializableException,
      FilePersistenceClassNotFoundException,
      FilePersistenceDataCorruptedException, StoreClassNotFoundException,
      FilePersistenceTooBigForSerializationException {
    /* create file persistence manager */
    final IFilePersistence filePersistence =
    /**/createFilePersistence(false/* do not remove files */);
    /* create a data access session */
    final IDataAccessSession session = filePersistence
        .createDataAccessSession();
    /* get operation start time */
    final long startTime = System.currentTimeMillis();
    /* open the data access session to make able to access to persisted data */
    session.open();
    /* get the map */
    Map<Integer, String> map = getMap(session);
    /* search for a value */
    final String value = map.get(50000);
    final long duration = System.currentTimeMillis() - startTime;
    final int numberOfObjectStateBeforeSave = filePersistence
        .getNumberOfObjectState();
    /*
     * for a read only it is possible to do
     * session.closeAndWait(EnumFilePersistenceCloseAction.DO_NOT_SAVE);
     */
    session.closeAndWait(EnumFilePersistenceCloseAction.SAVE);
    /*
     * log information about persistent objects
     */
    final int modified = filePersistence.getNumberOfModified();
    final int visited = filePersistence.getNumberOfVisited();
    /*
     * to show how many object loaded in memory for a simple search on one
     * million entries
     */
    System.out.println(// NOPMD
        value + " " + duration + " mS elapsed, "
            + numberOfObjectStateBeforeSave + " object loaded\n"
            + visited + " visited, " + modified + " modified");

    /* unreference the map => will be garbaged */
    map = null;// NOPMD
    filePersistence.close();
  }
View Full Code Here

Examples of net.sf.joafip.service.IFilePersistence

    builder.setPathName("runtime");
    builder.setProxyMode(true);
    builder.setRemoveFiles(true);
    builder.setGarbageManagement(false);
    builder.setCrashSafeMode(false);
    final IFilePersistence filePersistence = builder.build();
    Map<String, String> map = new HashMap<String, String>();
    map.put("key1", "value1");
    map.put("key2", "value2");
    final IDataAccessSession dataAccessSession = filePersistence
        .createDataAccessSession();
    dataAccessSession.open();
    dataAccessSession.setObject("data", map);
    dataAccessSession.close(EnumFilePersistenceCloseAction.SAVE);

    dataAccessSession.open();
    map = (Map<String, String>) dataAccessSession.getObject("data");
    System.out.println(map.get("key1"));// NOPMD
    System.out.println(map.get("key2"));// NOPMD
    dataAccessSession.close(EnumFilePersistenceCloseAction.SAVE);
    filePersistence.close();
  }
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.