Search in sources :

Example 11 with XidImpl

use of org.neo4j.kernel.impl.transaction.XidImpl 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();
}
Also used : Xid(javax.transaction.xa.Xid) XAResource(javax.transaction.xa.XAResource) XidImpl(org.neo4j.kernel.impl.transaction.XidImpl) Test(org.junit.Test)

Example 12 with XidImpl

use of org.neo4j.kernel.impl.transaction.XidImpl in project neo4j-mobile-android by neo4j-contrib.

the class LogIoUtils method readTxStartEntry.

private static LogEntry.Start readTxStartEntry(ByteBuffer buf, ReadableByteChannel channel) throws IOException, ReadPastEndException {
    byte globalIdLength = readNextByte(buf, channel);
    byte branchIdLength = readNextByte(buf, channel);
    byte[] globalId = new byte[globalIdLength];
    readIntoBufferAndFlip(ByteBuffer.wrap(globalId), channel, globalIdLength);
    byte[] branchId = new byte[branchIdLength];
    readIntoBufferAndFlip(ByteBuffer.wrap(branchId), channel, branchIdLength);
    int identifier = readNextInt(buf, channel);
    int formatId = readNextInt(buf, channel);
    // re-create the transaction
    Xid xid = new XidImpl(globalId, branchId, formatId);
    return new LogEntry.Start(xid, identifier, -1);
}
Also used : Xid(javax.transaction.xa.Xid) XidImpl(org.neo4j.kernel.impl.transaction.XidImpl)

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