use of javax.transaction.xa.XAResource 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();
}
use of javax.transaction.xa.XAResource 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();
}
use of javax.transaction.xa.XAResource 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();
}
use of javax.transaction.xa.XAResource 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));
}
use of javax.transaction.xa.XAResource in project graphdb by neo4j-attic.
the class TestXa method testBrokenDone.
@Test
public void testBrokenDone() 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);
xaRes.commit(xid, false);
copyLogicalLog(path());
ds.close();
deleteLogicalLogIfExist();
renameCopiedLogicalLog(path());
// master (w/ shortstring) says 171
truncateLogicalLog(224);
ds = newNeoStore();
// ds = new NeoStoreXaDataSource( file( "neo" ), file( "nioneo_logical.log" ),
// lockManager, lockReleaser );
xaCon = (NeoStoreXaConnection) ds.getXaConnection();
xaRes = xaCon.getXaResource();
assertEquals(1, xaRes.recover(XAResource.TMNOFLAGS).length);
xaCon.clearAllTransactions();
}
Aggregations