private void closeSession() { try { session.close(); } finally { session = null; } }
private void closeSession() { try { session.close(); } finally { session = null; } }
private void closeNativeSessionIfPossible() { if (nativeSession.isOpen()) { nativeSession.close(); } } }
private void closeNativeSessionIfPossible() { if (nativeSession.isOpen()) { nativeSession.close(); } } }
@Override protected void shutDown() { try { if (session != null) session.close(); } catch (Throwable e) { // do nothing } try { if (driver != null) driver.close(); } catch (Throwable e) { // do nothing } }
private int getTotalNodes() { Session session = this.driver.session(); int count = session.run("MATCH (n) RETURN count(n) AS count").peek().get("count").asInt(); session.close(); return count; // return this.session.run("MATCH (n) RETURN count(n) AS count").peek().get("count").asInt(); }
private int getTotalOntologyRelationships() { Session session = this.driver.session(); int count = session.run("MATCH (n)-[r:" + RelTypes.ONTOLOGY + "|" + RelTypes.CELLOC_ONTOLOGY + "]->(m:" + NodeTypes.ONTOLOGY + ") RETURN count(r) AS count").peek().get("count").asInt(); session.close(); return count; // return this.session.run("MATCH (n)-[r:" + RelTypes.ONTOLOGY + "|" + RelTypes.CELLOC_ONTOLOGY // + "]->(m:" + NodeTypes.ONTOLOGY + ") RETURN count(r) AS count").peek().get("count").asInt(); }
private int getTotalRelationships() { Session session = this.driver.session(); int count = session.run("MATCH ()-[r]-() RETURN count(r) AS count").peek().get("count").asInt(); session.close(); return count; // return this.session.run("MATCH ()-[r]-() RETURN count(r) AS count").peek().get("count").asInt(); }
private int getTotalXrefRelationships() { Session session = this.driver.session(); int count = session.run("MATCH (n:" + NodeTypes.PHYSICAL_ENTITY + ")-[r:" + RelTypes.XREF + "]->(m:" + NodeTypes.XREF + ") RETURN count(r) AS count").peek().get("count").asInt(); session.close(); return count; // return this.session.run("MATCH (n:" // + NodeTypes.PHYSICAL_ENTITY + ")-[r:" + RelTypes.XREF + "]->(m:" // + NodeTypes.XREF + ") RETURN count(r) AS count").peek().get("count").asInt(); }
private int getTotalCelLocationNodes() { Session session = this.driver.session(); int count = session.run("MATCH (n:" + NodeTypes.CELLULAR_LOCATION + ") RETURN count(n) AS count") .peek().get("count").asInt(); session.close(); return count; // return this.session.run("MATCH (n:" + NodeTypes.CELLULAR_LOCATION + ") RETURN count(n) AS count") // .peek().get("count").asInt(); }
private int getTotalXrefNodes() { Session session = this.driver.session(); int count = session.run("MATCH (n:" + NodeTypes.XREF + ") RETURN count(n) AS count") .peek().get("count").asInt(); session.close(); return count; // return this.session.run("MATCH (n:" + NodeTypes.XREF + ") RETURN count(n) AS count") // .peek().get("count").asInt(); }
private int getTotalOntologyNodes() { Session session = this.driver.session(); int count = session.run("MATCH (n:" + NodeTypes.ONTOLOGY + ") RETURN count(n) AS count") .peek().get("count").asInt(); session.close(); return count; // return this.session.run("MATCH (n:" + NodeTypes.ONTOLOGY + ") RETURN count(n) AS count") // .peek().get("count").asInt(); }
private int getTotalCelLocationRelationships() { Session session = this.driver.session(); int count = session.run("MATCH (n:" + NodeTypes.PHYSICAL_ENTITY + ")-[r:" + RelTypes.CELLULAR_LOCATION + "]->(m:" + NodeTypes.CELLULAR_LOCATION + ") RETURN count(r) AS count").peek().get("count").asInt(); session.close(); return count; // return this.session.run("MATCH (n:" + NodeTypes.PHYSICAL_ENTITY // + ")-[r:" + RelTypes.CELLULAR_LOCATION + "]->(m:" + NodeTypes.CELLULAR_LOCATION // + ") RETURN count(r) AS count").peek().get("count").asInt(); }
@Test public void commitShouldCloseSessionWhenTransactionCloseThrows() { Transaction nativeTx = openTransactionMock(); doThrow(new RuntimeException("Close failed")).when(nativeTx).close(); Session nativeSession = openSessionMock(); BoltTransaction boltTx = new BoltTransaction(committingTxManager(), nativeTx, nativeSession, READ_ONLY); try { boltTx.commit(); fail("Exception expected"); } catch (Exception e) { assertThat(e.getMessage()).isEqualTo("Close failed"); } verify(nativeSession).close(); }
@Test public void rollbackShouldCloseSessionWhenTransactionCloseThrows() { Transaction nativeTx = openTransactionMock(); doThrow(new RuntimeException("Close failed")).when(nativeTx).close(); Session nativeSession = openSessionMock(); BoltTransaction boltTx = new BoltTransaction(rollingBackTxManager(), nativeTx, nativeSession, READ_ONLY); try { boltTx.rollback(); fail("Exception expected"); } catch (Exception e) { assertThat(e.getMessage()).isEqualTo("Close failed"); } verify(nativeSession).close(); }
private void reconnect() { String bookmark = null; if (session != null) { bookmark = session.lastBookmark(); session.close(); } session = driver.session(AccessMode.WRITE, bookmark); StatementResult run = session.run("RETURN 1"); this.version = run.summary().server().version(); run.consume(); }
@Test public void commitShouldCloseTransactionAndSession() { Transaction nativeTx = openTransactionMock(); Session nativeSession = openSessionMock(); BoltTransaction boltTx = new BoltTransaction(committingTxManager(), nativeTx, nativeSession, READ_ONLY); boltTx.commit(); InOrder inOrder = inOrder(nativeSession, nativeTx); inOrder.verify(nativeTx).close(); inOrder.verify(nativeSession).close(); }
@Test public void rollbackShouldCloseSessionWhenTransactionIsClosed() { Transaction nativeTx = closedTransactionMock(); Session nativeSession = openSessionMock(); BoltTransaction boltTx = new BoltTransaction(rollingBackTxManager(), nativeTx, nativeSession, READ_ONLY); boltTx.rollback(); verify(nativeTx, never()).close(); verify(nativeSession).close(); }
@Test public void rollbackShouldCloseTransactionAndSession() { Transaction nativeTx = openTransactionMock(); Session nativeSession = openSessionMock(); BoltTransaction boltTx = new BoltTransaction(rollingBackTxManager(), nativeTx, nativeSession, READ_ONLY); boltTx.rollback(); InOrder inOrder = inOrder(nativeSession, nativeTx); inOrder.verify(nativeTx).close(); inOrder.verify(nativeSession).close(); }
@Test public void commitShouldCloseSessionWhenTransactionIsClosed() { Transaction nativeTx = closedTransactionMock(); Session nativeSession = openSessionMock(); BoltTransaction boltTx = new BoltTransaction(committingTxManager(), nativeTx, nativeSession, READ_ONLY); try { boltTx.commit(); } catch (Exception ignore) { // do not care about exceptions, native session should just get closed at the end } verify(nativeTx, never()).close(); verify(nativeSession).close(); }