void closeStore() throws DatabaseException {

    if (store != null) {
      store.close();
      store = null;
    }
  }
  void closeNewStore() throws DatabaseException {

    if (newStore != null) {
      newStore.close();
      newStore = null;
    }
  }
  /** Closes the store. */
  private void close() throws DatabaseException {

    store.close();
    store = null;
    rawStore.close();
    rawStore = null;
  }
示例#4
0
  @Override
  public void tearDown() throws Exception {

    if (store != null) {
      try {
        store.close();
      } catch (Throwable e) {
        System.out.println("tearDown: " + e);
      }
      store = null;
    }
    super.tearDown();
  }
  /** Closes all files and mediator classes related to the persistent hash table */
  public void close() {
    try {
      if (this.myDbEnvironment != null) {
        this.myDbEnvironment.cleanLog(); // Clean the log before closing
        dictStore.close();
        this.myDbEnvironment.close();
      }

      this.myDbEnvironment = null;
      this.dictStore = null;
      this.pidx = null;
    } catch (DatabaseException dbe) {
    }
  }
    public void close() {
      if (store != null) {
        try {
          store.close();
          store = null;
        } catch (Exception e) {
          e.printStackTrace();
        }
      }

      if (env != null) {
        try {
          env.close();
          env = null;
        } catch (Exception e) {
          e.printStackTrace();
        }
      }
    }
  /** The store must be closed before closing the environment. */
  @After
  public void tearDown() throws Exception {

    try {
      if (rawStore != null) {
        rawStore.close();
      }
    } catch (Throwable e) {
      System.out.println("During tearDown: " + e);
    }
    try {
      if (store != null) {
        store.close();
      }
    } catch (Throwable e) {
      System.out.println("During tearDown: " + e);
    }
    store = null;
    rawStore = null;
    super.tearDown();
  }
示例#8
0
  public void testSubclassIndex() throws DatabaseException {

    EnvironmentConfig envConfig = new EnvironmentConfig();
    envConfig.setAllowCreate(true);
    env = new Environment(envHome, envConfig);

    StoreConfig storeConfig = new StoreConfig();
    storeConfig.setAllowCreate(true);
    EntityStore store = new EntityStore(env, "foo", storeConfig);

    PrimaryIndex<String, Employee> employeesById =
        store.getPrimaryIndex(String.class, Employee.class);

    employeesById.put(new Employee("1"));
    employeesById.put(new Manager("2", "a"));
    employeesById.put(new Manager("3", "a"));
    employeesById.put(new Manager("4", "b"));

    Employee e;
    Manager m;

    e = employeesById.get("1");
    assertNotNull(e);
    assertTrue(!(e instanceof Manager));

    /* Ensure DB exists BEFORE calling getSubclassIndex. [#15247] */
    PersistTestUtils.assertDbExists(true, env, "foo", Employee.class.getName(), "dept");

    /* Normal use: Subclass index for a key in the subclass. */
    SecondaryIndex<String, String, Manager> managersByDept =
        store.getSubclassIndex(employeesById, Manager.class, String.class, "dept");

    m = managersByDept.get("a");
    assertNotNull(m);
    assertEquals("2", m.id);

    m = managersByDept.get("b");
    assertNotNull(m);
    assertEquals("4", m.id);

    EntityCursor<Manager> managers = managersByDept.entities();
    try {
      m = managers.next();
      assertNotNull(m);
      assertEquals("2", m.id);
      m = managers.next();
      assertNotNull(m);
      assertEquals("3", m.id);
      m = managers.next();
      assertNotNull(m);
      assertEquals("4", m.id);
      m = managers.next();
      assertNull(m);
    } finally {
      managers.close();
    }

    /* Getting a subclass index for the entity class is also allowed. */
    store.getSubclassIndex(employeesById, Employee.class, String.class, "other");

    /* Getting a subclass index for a base class key is not allowed. */
    try {
      store.getSubclassIndex(employeesById, Manager.class, String.class, "other");
      fail();
    } catch (IllegalArgumentException expected) {
    }

    store.close();
    env.close();
    env = null;
  }
示例#9
0
  private void close() throws DatabaseException {

    store.close();
    env.close();
  }
 private void closeGroup() {
   store.close();
   RepTestUtils.shutdownRepEnvs(repEnvInfo);
 }