diff --git a/app/carnival-core/src/main/groovy/carnival/core/Carnival.groovy b/app/carnival-core/src/main/groovy/carnival/core/Carnival.groovy index 8d2a949..5a39442 100644 --- a/app/carnival-core/src/main/groovy/carnival/core/Carnival.groovy +++ b/app/carnival-core/src/main/groovy/carnival/core/Carnival.groovy @@ -149,6 +149,24 @@ abstract class Carnival implements GremlinTrait { + /////////////////////////////////////////////////////////////////////////// + // ABSTRACT INTERFACE + /////////////////////////////////////////////////////////////////////////// + + /** + * Close this carnival. + * + */ + abstract void close() + + + /** + * Dispose of the resources of this carnival. + * + * */ + abstract void dispose() + + /////////////////////////////////////////////////////////////////////////// // INITIALIZATION /////////////////////////////////////////////////////////////////////////// diff --git a/app/carnival-core/src/main/groovy/carnival/core/CarnivalJanusBerkeley.groovy b/app/carnival-core/src/main/groovy/carnival/core/CarnivalJanusBerkeley.groovy index 9f8402d..a092bf2 100644 --- a/app/carnival-core/src/main/groovy/carnival/core/CarnivalJanusBerkeley.groovy +++ b/app/carnival-core/src/main/groovy/carnival/core/CarnivalJanusBerkeley.groovy @@ -78,6 +78,9 @@ class CarnivalJanusBerkeley extends Carnival { /** The names of the indexes created */ Set indexNames = new HashSet() + /** */ + boolean openedExisting = false + /////////////////////////////////////////////////////////////////////////// // FACTORY @@ -149,6 +152,7 @@ class CarnivalJanusBerkeley extends Carnival { if (graphDirExists) { + carnival.openedExisting = true carnival.initPropModelNoMgmt() carnival.initVertModelNoMgmt() carnival.initEdgeModelNoMgmt() @@ -755,6 +759,15 @@ class CarnivalJanusBerkeley extends Carnival { } + /** + * Dispose of the resources of this Carnival. + */ + public void dispose() { + this.close() + CarnivalJanusBerkeley.clearGraph(this.config) + } + + /////////////////////////////////////////////////////////////////////////// // CLASSES diff --git a/app/carnival-core/src/main/groovy/carnival/core/CarnivalTinker.groovy b/app/carnival-core/src/main/groovy/carnival/core/CarnivalTinker.groovy index dc6c17e..27f5f3e 100644 --- a/app/carnival-core/src/main/groovy/carnival/core/CarnivalTinker.groovy +++ b/app/carnival-core/src/main/groovy/carnival/core/CarnivalTinker.groovy @@ -72,4 +72,12 @@ class CarnivalTinker extends Carnival { graph.close() } + + /** + * Dispose of the resources of this Carnival. + */ + public void dispose() { + this.close() + } + } diff --git a/app/carnival-core/src/test/groovy/carnival/core/CarnivalInitSpec.groovy b/app/carnival-core/src/test/groovy/carnival/core/CarnivalInitSpec.groovy index 7bc06a2..a9bf572 100644 --- a/app/carnival-core/src/test/groovy/carnival/core/CarnivalInitSpec.groovy +++ b/app/carnival-core/src/test/groovy/carnival/core/CarnivalInitSpec.groovy @@ -73,7 +73,7 @@ class CarnivalInitSpec extends Specification { def g = graph.traversal() try { - carnival.initialize(graph, g) + carnival.initModel(graph, g) } finally { if (g) g.close() } diff --git a/app/carnival-core/src/test/groovy/carnival/core/CarnivalJanusBerkeleyFilesSpec.groovy b/app/carnival-core/src/test/groovy/carnival/core/CarnivalJanusBerkeleyFilesSpec.groovy index 118e58c..82263f4 100644 --- a/app/carnival-core/src/test/groovy/carnival/core/CarnivalJanusBerkeleyFilesSpec.groovy +++ b/app/carnival-core/src/test/groovy/carnival/core/CarnivalJanusBerkeleyFilesSpec.groovy @@ -118,6 +118,8 @@ class CarnivalJanusBerkeleyFilesSpec extends Specification { } then: + carnival + !carnival.openedExisting numVerts1 when: @@ -130,6 +132,7 @@ class CarnivalJanusBerkeleyFilesSpec extends Specification { then: carnival + carnival.openedExisting numVerts1 == numVerts2 cleanup: diff --git a/app/carnival-core/src/test/groovy/carnival/core/CarnivalModelSpec.groovy b/app/carnival-core/src/test/groovy/carnival/core/CarnivalModelSpec.groovy index 3381bce..92888e6 100644 --- a/app/carnival-core/src/test/groovy/carnival/core/CarnivalModelSpec.groovy +++ b/app/carnival-core/src/test/groovy/carnival/core/CarnivalModelSpec.groovy @@ -135,9 +135,10 @@ class CarnivalModelSpec extends Specification { expect: carnival.checkModel().size() == 0 - GraphModel.VX.DOG_CLASS.vertex == null when: + GraphModel.VX.DOG_CLASS.vertex = null + int numVerts1 carnival.withGremlin { graph, g -> numVerts1 = g.V().count().next()