Search in sources :

Example 76 with WritableGraph

use of au.gov.asd.tac.constellation.graph.WritableGraph in project constellation by constellation-app.

the class NestedLockingNGTest method unmodifiedRollbackControlTest.

@Test
public void unmodifiedRollbackControlTest() {
    final DualGraph g = new DualGraph(null);
    try {
        // Get the first write lock, modify the graph, then commit
        final WritableGraph wg2 = g.getWritableGraph("2", true);
        wg2.addVertex();
        wg2.commit();
        // Get the second write lock and immediately rollback
        final WritableGraph wg3 = g.getWritableGraph("3", true);
        final long modCount = wg3.getGlobalModificationCounter();
        wg3.rollBack();
        // Check that the modcount prior to rollingback the second write lock is the same as the current modcount in a new lock.
        final WritableGraph wg4 = g.getWritableGraph("4", true);
        assertEquals(modCount, wg4.getGlobalModificationCounter());
        wg4.commit();
    } catch (InterruptedException ex) {
    }
}
Also used : WritableGraph(au.gov.asd.tac.constellation.graph.WritableGraph) Test(org.testng.annotations.Test)

Example 77 with WritableGraph

use of au.gov.asd.tac.constellation.graph.WritableGraph in project constellation by constellation-app.

the class NestedLockingNGTest method unmodifiedCommitNestedTest.

@Test
public void unmodifiedCommitNestedTest() {
    final DualGraph g = new DualGraph(null);
    try {
        // Get an outer write lock
        final WritableGraph wg1 = g.getWritableGraph("1", true);
        // Get the first inner write lock, modify the graph, then commit
        final WritableGraph wg2 = g.getWritableGraph("2", true);
        wg2.addVertex();
        wg2.commit();
        // Get the second inner write lock and immediately commit
        final WritableGraph wg3 = g.getWritableGraph("3", true);
        final long modCount = wg3.getGlobalModificationCounter();
        wg3.commit();
        // Commit the outer write lock
        wg1.commit();
        // Check that the modcount prior to commiting the second inner write lock is the same as the current modcount in a new lock.
        final WritableGraph wg4 = g.getWritableGraph("4", true);
        assertEquals(modCount, wg4.getGlobalModificationCounter());
        wg4.commit();
    } catch (InterruptedException ex) {
        assertTrue("Locking Interrupted", false);
    }
}
Also used : WritableGraph(au.gov.asd.tac.constellation.graph.WritableGraph) Test(org.testng.annotations.Test)

Example 78 with WritableGraph

use of au.gov.asd.tac.constellation.graph.WritableGraph in project constellation by constellation-app.

the class NestedLockingNGTest method modifiedRollbackNestedTest.

@Test
public void modifiedRollbackNestedTest() {
    final DualGraph g = new DualGraph(null);
    try {
        // Get an outer write lock
        final WritableGraph wg1 = g.getWritableGraph("1", true);
        // Get the first inner write lock, modify the graph, then commit
        final WritableGraph wg2 = g.getWritableGraph("2", true);
        wg2.addVertex();
        wg2.commit();
        // Get the second inner write lock, modify the graph, then rollback
        final WritableGraph wg3 = g.getWritableGraph("3", true);
        final long modCount = wg3.getGlobalModificationCounter();
        wg3.addVertex();
        wg3.rollBack();
        // Commit the outer write lock
        wg1.commit();
        // Check that the modcount prior to modifying the second inner write lock is the same as the current modcount in a new lock.
        final WritableGraph wg4 = g.getWritableGraph("4", true);
        assertEquals(modCount, wg4.getGlobalModificationCounter());
        wg4.commit();
    } catch (InterruptedException ex) {
        assertTrue("Locking Interrupted", false);
    }
}
Also used : WritableGraph(au.gov.asd.tac.constellation.graph.WritableGraph) Test(org.testng.annotations.Test)

Example 79 with WritableGraph

use of au.gov.asd.tac.constellation.graph.WritableGraph in project constellation by constellation-app.

the class NestedLockingNGTest method modifiedCommitNestedTest.

@Test
public void modifiedCommitNestedTest() {
    final DualGraph g = new DualGraph(null);
    try {
        // Get an outer write lock
        final WritableGraph wg1 = g.getWritableGraph("1", true);
        // Get the first inner write lock, modify the graph, then commit
        final WritableGraph wg2 = g.getWritableGraph("2", true);
        wg2.addVertex();
        wg2.commit();
        // Get the second inner write lock, modify the graph, then commit
        final WritableGraph wg3 = g.getWritableGraph("3", true);
        wg3.addVertex();
        final long modCount = wg3.getGlobalModificationCounter();
        wg3.commit();
        // Commit the outer write lock
        wg1.commit();
        // Check that the modcount prior to commiting the second inner write lock is the same as the current modcount in a new lock.
        final WritableGraph wg4 = g.getWritableGraph("4", true);
        assertEquals(modCount, wg4.getGlobalModificationCounter());
        wg4.commit();
    } catch (InterruptedException ex) {
        assertTrue("Locking Interrupted", false);
    }
}
Also used : WritableGraph(au.gov.asd.tac.constellation.graph.WritableGraph) Test(org.testng.annotations.Test)

Example 80 with WritableGraph

use of au.gov.asd.tac.constellation.graph.WritableGraph in project constellation by constellation-app.

the class NestedLockingNGTest method unmodifiedRollbackNestedTest.

@Test
public void unmodifiedRollbackNestedTest() {
    final DualGraph g = new DualGraph(null);
    try {
        // Get an outer write lock
        final WritableGraph wg1 = g.getWritableGraph("1", true);
        // Get the first inner write lock, modify the graph, then commit
        final WritableGraph wg2 = g.getWritableGraph("2", true);
        wg2.addVertex();
        wg2.commit();
        // Get the second inner write lock and immediately rollback
        final WritableGraph wg3 = g.getWritableGraph("3", true);
        final long modCount = wg3.getGlobalModificationCounter();
        wg3.rollBack();
        // Commit the outer write lock
        wg1.commit();
        // Check that the modcount prior to rollingback the second inner write lock is the same as the current modcount in a new lock.
        final WritableGraph wg4 = g.getWritableGraph("4", true);
        assertEquals(modCount, wg4.getGlobalModificationCounter());
        wg4.commit();
    } catch (InterruptedException ex) {
        assertTrue("Locking Interrupted", false);
    }
}
Also used : WritableGraph(au.gov.asd.tac.constellation.graph.WritableGraph) Test(org.testng.annotations.Test)

Aggregations

WritableGraph (au.gov.asd.tac.constellation.graph.WritableGraph)116 Test (org.testng.annotations.Test)77 DualGraph (au.gov.asd.tac.constellation.graph.locking.DualGraph)39 ReadableGraph (au.gov.asd.tac.constellation.graph.ReadableGraph)37 Graph (au.gov.asd.tac.constellation.graph.Graph)20 ArrayList (java.util.ArrayList)14 PluginParameters (au.gov.asd.tac.constellation.plugins.parameters.PluginParameters)9 StoreGraph (au.gov.asd.tac.constellation.graph.StoreGraph)8 CompositeNodeState (au.gov.asd.tac.constellation.graph.schema.analytic.attribute.objects.CompositeNodeState)8 Plugin (au.gov.asd.tac.constellation.plugins.Plugin)7 BeforeMethod (org.testng.annotations.BeforeMethod)7 GraphElementType (au.gov.asd.tac.constellation.graph.GraphElementType)6 Schema (au.gov.asd.tac.constellation.graph.schema.Schema)6 PluginException (au.gov.asd.tac.constellation.plugins.PluginException)6 Attribute (au.gov.asd.tac.constellation.graph.Attribute)5 GraphAttribute (au.gov.asd.tac.constellation.graph.GraphAttribute)5 CopyToNewGraphPlugin (au.gov.asd.tac.constellation.graph.interaction.plugins.clipboard.CopyToNewGraphPlugin)5 ConstellationColor (au.gov.asd.tac.constellation.utilities.color.ConstellationColor)4 DuplicateKeyException (au.gov.asd.tac.constellation.graph.DuplicateKeyException)3 GraphRecordStore (au.gov.asd.tac.constellation.graph.processing.GraphRecordStore)3