Search in sources :

Example 1 with TxExtractor

use of org.neo4j.com.TxExtractor in project graphdb by neo4j-attic.

the class SlaveTxIdGenerator method generate.

public long generate(final XaDataSource dataSource, final int identifier) {
    try {
        final int eventIdentifier = txManager.getEventIdentifier();
        Response<Long> response = broker.getMaster().first().commitSingleResourceTransaction(receiver.getSlaveContext(eventIdentifier), dataSource.getName(), new TxExtractor() {

            public void extract(LogBuffer buffer) {
                try {
                    dataSource.getPreparedTransaction(identifier, buffer);
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }

            public ReadableByteChannel extract() {
                try {
                    return dataSource.getPreparedTransaction(identifier);
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
        });
        return receiver.receive(response);
    } catch (ZooKeeperException e) {
        receiver.newMaster(null, e);
        throw e;
    } catch (ComException e) {
        receiver.newMaster(null, e);
        throw e;
    }
}
Also used : ZooKeeperException(org.neo4j.kernel.ha.zookeeper.ZooKeeperException) ComException(org.neo4j.com.ComException) LogBuffer(org.neo4j.kernel.impl.transaction.xaframework.LogBuffer) ReadableByteChannel(java.nio.channels.ReadableByteChannel) TxExtractor(org.neo4j.com.TxExtractor) IOException(java.io.IOException)

Aggregations

IOException (java.io.IOException)1 ReadableByteChannel (java.nio.channels.ReadableByteChannel)1 ComException (org.neo4j.com.ComException)1 TxExtractor (org.neo4j.com.TxExtractor)1 ZooKeeperException (org.neo4j.kernel.ha.zookeeper.ZooKeeperException)1 LogBuffer (org.neo4j.kernel.impl.transaction.xaframework.LogBuffer)1