Search in sources :

Example 6 with XidImpl

use of org.neo4j.kernel.impl.transaction.XidImpl in project graphdb by neo4j-attic.

the class TestXa method testApplyLogicalLog.

@Test
public void testApplyLogicalLog() throws Exception {
    ds.keepLogicalLogs(true);
    Xid xid = new XidImpl(new byte[1], new byte[1]);
    XAResource xaRes = xaCon.getXaResource();
    xaRes.start(xid, XAResource.TMNOFLAGS);
    long node1 = ds.nextId(Node.class);
    xaCon.getNodeConsumer().createNode(node1);
    long node2 = ds.nextId(Node.class);
    xaCon.getNodeConsumer().createNode(node2);
    long n1prop1 = ds.nextId(PropertyStore.class);
    xaCon.getNodeConsumer().addProperty(node1, n1prop1, index("prop1"), "string1");
    xaCon.getNodeConsumer().getProperties(node1, false);
    int relType1 = (int) ds.nextId(RelationshipType.class);
    xaCon.getRelationshipTypeConsumer().addRelationshipType(relType1, "relationshiptype1");
    long rel1 = ds.nextId(Relationship.class);
    xaCon.getRelationshipConsumer().createRelationship(rel1, node1, node2, relType1);
    long r1prop1 = ds.nextId(PropertyStore.class);
    xaCon.getRelationshipConsumer().addProperty(rel1, r1prop1, index("prop1"), "string1");
    xaCon.getNodeConsumer().changeProperty(node1, n1prop1, "string2");
    xaCon.getRelationshipConsumer().changeProperty(rel1, r1prop1, "string2");
    xaCon.getNodeConsumer().removeProperty(node1, n1prop1);
    xaCon.getRelationshipConsumer().removeProperty(rel1, r1prop1);
    xaCon.getRelationshipConsumer().deleteRelationship(rel1);
    xaCon.getNodeConsumer().deleteNode(node1);
    xaCon.getNodeConsumer().deleteNode(node2);
    xaRes.end(xid, XAResource.TMSUCCESS);
    xaRes.commit(xid, true);
    long currentVersion = ds.getCurrentLogVersion();
    ds.keepLogicalLogs(true);
    ds.rotateLogicalLog();
    ds.rotateLogicalLog();
    ds.rotateLogicalLog();
    ds.setCurrentLogVersion(currentVersion);
    ds.setLastCommittedTxId(0);
    ds.makeBackupSlave();
    ds.applyLog(ds.getLogicalLog(currentVersion));
    ds.applyLog(ds.getLogicalLog(currentVersion + 1));
    ds.applyLog(ds.getLogicalLog(currentVersion + 2));
    ds.keepLogicalLogs(false);
}
Also used : Xid(javax.transaction.xa.Xid) XAResource(javax.transaction.xa.XAResource) XidImpl(org.neo4j.kernel.impl.transaction.XidImpl) RelationshipType(org.neo4j.graphdb.RelationshipType) Test(org.junit.Test)

Example 7 with XidImpl

use of org.neo4j.kernel.impl.transaction.XidImpl in project graphdb by neo4j-attic.

the class TestXa method testBrokenNodeCommand.

@Test
public void testBrokenNodeCommand() throws Exception {
    Xid xid = new XidImpl(new byte[4], new byte[4]);
    XAResource xaRes = xaCon.getXaResource();
    xaRes.start(xid, XAResource.TMNOFLAGS);
    long node1 = ds.nextId(Node.class);
    xaCon.getNodeConsumer().createNode(node1);
    xaRes.end(xid, XAResource.TMSUCCESS);
    xaRes.prepare(xid);
    xaCon.clearAllTransactions();
    copyLogicalLog(path());
    xaCon.clearAllTransactions();
    ds.close();
    deleteLogicalLogIfExist();
    renameCopiedLogicalLog(path());
    truncateLogicalLog(40);
    ds = newNeoStore();
    //        ds = new NeoStoreXaDataSource( file( "neo" ), file( "nioneo_logical.log" ),
    //            lockManager, lockReleaser );
    xaCon = (NeoStoreXaConnection) ds.getXaConnection();
    xaRes = xaCon.getXaResource();
    assertEquals(0, xaRes.recover(XAResource.TMNOFLAGS).length);
    xaCon.clearAllTransactions();
}
Also used : Xid(javax.transaction.xa.Xid) XAResource(javax.transaction.xa.XAResource) XidImpl(org.neo4j.kernel.impl.transaction.XidImpl) Test(org.junit.Test)

Example 8 with XidImpl

use of org.neo4j.kernel.impl.transaction.XidImpl in project graphdb by neo4j-attic.

the class TestXa method testBrokenPrepare.

@Test
public void testBrokenPrepare() throws Exception {
    Xid xid = new XidImpl(new byte[4], new byte[4]);
    XAResource xaRes = xaCon.getXaResource();
    xaRes.start(xid, XAResource.TMNOFLAGS);
    long node1 = ds.nextId(Node.class);
    xaCon.getNodeConsumer().createNode(node1);
    long node2 = ds.nextId(Node.class);
    xaCon.getNodeConsumer().createNode(node2);
    long n1prop1 = ds.nextId(PropertyStore.class);
    xaCon.getNodeConsumer().addProperty(node1, n1prop1, index("prop1"), "string value 1");
    xaRes.end(xid, XAResource.TMSUCCESS);
    xaRes.prepare(xid);
    copyLogicalLog(path());
    xaCon.clearAllTransactions();
    ds.close();
    deleteLogicalLogIfExist();
    renameCopiedLogicalLog(path());
    // master (w/ shortstring) says 155
    truncateLogicalLog(188);
    ds = newNeoStore();
    //        ds = new NeoStoreXaDataSource( file( "neo" ), file( "nioneo_logical.log" ),
    //            lockManager, lockReleaser );
    xaCon = (NeoStoreXaConnection) ds.getXaConnection();
    xaRes = xaCon.getXaResource();
    assertEquals(0, xaRes.recover(XAResource.TMNOFLAGS).length);
    xaCon.clearAllTransactions();
}
Also used : Xid(javax.transaction.xa.Xid) XAResource(javax.transaction.xa.XAResource) XidImpl(org.neo4j.kernel.impl.transaction.XidImpl) Test(org.junit.Test)

Example 9 with XidImpl

use of org.neo4j.kernel.impl.transaction.XidImpl in project graphdb by neo4j-attic.

the class TestXa method testBrokenCommand.

@Test
public void testBrokenCommand() throws Exception {
    Xid xid = new XidImpl(new byte[4], new byte[4]);
    XAResource xaRes = xaCon.getXaResource();
    xaRes.start(xid, XAResource.TMNOFLAGS);
    long node1 = ds.nextId(Node.class);
    xaCon.getNodeConsumer().createNode(node1);
    xaRes.end(xid, XAResource.TMSUCCESS);
    xaRes.prepare(xid);
    xaCon.clearAllTransactions();
    copyLogicalLog(path());
    xaCon.clearAllTransactions();
    ds.close();
    deleteLogicalLogIfExist();
    renameCopiedLogicalLog(path());
    truncateLogicalLog(37);
    ds = newNeoStore();
    //        ds = new NeoStoreXaDataSource( file( "neo" ), file( "nioneo_logical.log" ),
    //            lockManager, lockReleaser );
    xaCon = (NeoStoreXaConnection) ds.getXaConnection();
    xaRes = xaCon.getXaResource();
    assertEquals(0, xaRes.recover(XAResource.TMNOFLAGS).length);
    xaCon.clearAllTransactions();
}
Also used : Xid(javax.transaction.xa.Xid) XAResource(javax.transaction.xa.XAResource) XidImpl(org.neo4j.kernel.impl.transaction.XidImpl) Test(org.junit.Test)

Example 10 with XidImpl

use of org.neo4j.kernel.impl.transaction.XidImpl in project graphdb by neo4j-attic.

the class TestXa method testLogicalLogRotation.

@Test
public void testLogicalLogRotation() throws Exception {
    ds.keepLogicalLogs(true);
    Xid xid = new XidImpl(new byte[1], new byte[1]);
    XAResource xaRes = xaCon.getXaResource();
    xaRes.start(xid, XAResource.TMNOFLAGS);
    long node1 = ds.nextId(Node.class);
    xaCon.getNodeConsumer().createNode(node1);
    long node2 = ds.nextId(Node.class);
    xaCon.getNodeConsumer().createNode(node2);
    long n1prop1 = ds.nextId(PropertyStore.class);
    xaCon.getNodeConsumer().addProperty(node1, n1prop1, index("prop1"), "string1");
    xaCon.getNodeConsumer().getProperties(node1, false);
    int relType1 = (int) ds.nextId(RelationshipType.class);
    xaCon.getRelationshipTypeConsumer().addRelationshipType(relType1, "relationshiptype1");
    long rel1 = ds.nextId(Relationship.class);
    xaCon.getRelationshipConsumer().createRelationship(rel1, node1, node2, relType1);
    long r1prop1 = ds.nextId(PropertyStore.class);
    xaCon.getRelationshipConsumer().addProperty(rel1, r1prop1, index("prop1"), "string1");
    xaCon.getNodeConsumer().changeProperty(node1, n1prop1, "string2");
    xaCon.getRelationshipConsumer().changeProperty(rel1, r1prop1, "string2");
    xaCon.getNodeConsumer().removeProperty(node1, n1prop1);
    xaCon.getRelationshipConsumer().removeProperty(rel1, r1prop1);
    xaCon.getRelationshipConsumer().deleteRelationship(rel1);
    xaCon.getNodeConsumer().deleteNode(node1);
    xaCon.getNodeConsumer().deleteNode(node2);
    xaRes.end(xid, XAResource.TMSUCCESS);
    xaRes.commit(xid, true);
    long currentVersion = ds.getCurrentLogVersion();
    ds.rotateLogicalLog();
    assertTrue(logicalLogExists(currentVersion));
    ds.rotateLogicalLog();
    assertTrue(logicalLogExists(currentVersion));
    assertTrue(logicalLogExists(currentVersion + 1));
}
Also used : Xid(javax.transaction.xa.Xid) XAResource(javax.transaction.xa.XAResource) XidImpl(org.neo4j.kernel.impl.transaction.XidImpl) RelationshipType(org.neo4j.graphdb.RelationshipType) Test(org.junit.Test)

Aggregations

XidImpl (org.neo4j.kernel.impl.transaction.XidImpl)12 Xid (javax.transaction.xa.Xid)11 XAResource (javax.transaction.xa.XAResource)9 Test (org.junit.Test)9 RelationshipType (org.neo4j.graphdb.RelationshipType)5