use of org.neo4j.kernel.impl.nioneo.store.StoreId in project graphdb by neo4j-attic.
the class MasterUtil method packResponseWithoutTransactionStream.
public static <T> Response<T> packResponseWithoutTransactionStream(GraphDatabaseService graphDb, SlaveContext context, T response) {
XaDataSource ds = ((AbstractGraphDatabase) graphDb).getConfig().getTxModule().getXaDataSourceManager().getXaDataSource(Config.DEFAULT_DATA_SOURCE_NAME);
StoreId storeId = ((NeoStoreXaDataSource) ds).getStoreId();
return new Response<T>(response, storeId, TransactionStream.EMPTY);
}
use of org.neo4j.kernel.impl.nioneo.store.StoreId in project graphdb by neo4j-attic.
the class Client method sendRequest.
protected <R> Response<R> sendRequest(RequestType<M> type, SlaveContext context, Serializer serializer, Deserializer<R> deserializer) {
Triplet<Channel, ChannelBuffer, ByteBuffer> channelContext = null;
try {
// Send 'em over the wire
channelContext = getChannel();
Channel channel = channelContext.first();
channelContext.second().clear();
ChunkingChannelBuffer chunkingBuffer = new ChunkingChannelBuffer(channelContext.second(), channel, Protocol.MAX_FRAME_LENGTH);
chunkingBuffer.writeByte(type.id());
writeContext(type, context, chunkingBuffer);
serializer.write(chunkingBuffer, channelContext.third());
chunkingBuffer.done();
// Read the response
@SuppressWarnings("unchecked") BlockingReadHandler<ChannelBuffer> reader = (BlockingReadHandler<ChannelBuffer>) channel.getPipeline().get("blockingHandler");
final Triplet<Channel, ChannelBuffer, ByteBuffer> finalChannelContext = channelContext;
DechunkingChannelBuffer dechunkingBuffer = new DechunkingChannelBuffer(reader, DEFAULT_READ_RESPONSE_TIMEOUT_SECONDS) {
@Override
protected ChannelBuffer readNext() {
ChannelBuffer result = super.readNext();
if (result == null) {
channelPool.dispose(finalChannelContext);
throw new ComException("Channel has been closed");
}
return result;
}
};
R response = deserializer.read(dechunkingBuffer, channelContext.third());
StoreId storeId = readStoreId(dechunkingBuffer, channelContext.third());
if (shouldCheckStoreId(type)) {
assertCorrectStoreId(storeId);
}
TransactionStream txStreams = readTransactionStreams(dechunkingBuffer);
return new Response<R>(response, storeId, txStreams);
} catch (ClosedChannelException e) {
channelPool.dispose(channelContext);
throw new ComException(e);
} catch (IOException e) {
throw new ComException(e);
} catch (InterruptedException e) {
throw new ComException(e);
} catch (Exception e) {
throw new ComException(e);
} finally {
releaseChannel();
}
}
use of org.neo4j.kernel.impl.nioneo.store.StoreId in project graphdb by neo4j-attic.
the class MadeUpServerProcess method startup.
@Override
protected void startup(Long[] creationTimeAndStoreId) throws Throwable {
MadeUpCommunicationInterface implementation = new MadeUpImplementation(new StoreId(creationTimeAndStoreId[0], creationTimeAndStoreId[1]));
server = new MadeUpServer(implementation, 8888);
}
use of org.neo4j.kernel.impl.nioneo.store.StoreId in project graphdb by neo4j-attic.
the class TestCommunication method makeSureServerStoreIdsMustMatch.
@Test
public void makeSureServerStoreIdsMustMatch() throws Exception {
MadeUpImplementation serverImplementation = new MadeUpImplementation(new StoreId(10, 10));
MadeUpServer server = new MadeUpServer(serverImplementation, PORT);
MadeUpClient client = new MadeUpClient(PORT, storeIdToUse);
try {
client.multiply(1, 2);
fail();
} catch (ComException e) {
// Good
} finally {
client.shutdown();
server.shutdown();
}
}
use of org.neo4j.kernel.impl.nioneo.store.StoreId in project graphdb by neo4j-attic.
the class TestCommunication method makeSureClientStoreIdsMustMatch.
@Test
public void makeSureClientStoreIdsMustMatch() throws Exception {
MadeUpImplementation serverImplementation = new MadeUpImplementation(storeIdToUse);
MadeUpServer server = new MadeUpServer(serverImplementation, PORT);
MadeUpClient client = new MadeUpClient(PORT, new StoreId(10, 10));
try {
client.multiply(1, 2);
fail();
} catch (ComException e) {
// Good
} finally {
client.shutdown();
server.shutdown();
}
}
Aggregations