org.neo4j.com
Class Client<M>

java.lang.Object
  extended by org.neo4j.com.Client<M>
All Implemented Interfaces:
org.jboss.netty.channel.ChannelPipelineFactory
Direct Known Subclasses:
MasterClient

public abstract class Client<M>
extends Object
implements org.jboss.netty.channel.ChannelPipelineFactory

A means for a client to communicate with a Server. It serializes requests and sends them to the server and waits for a response back.


Nested Class Summary
static interface Client.ConnectionLostHandler
           
 
Field Summary
static int DEFAULT_MAX_NUMBER_OF_CONCURRENT_CHANNELS_PER_CLIENT
           
static int DEFAULT_READ_RESPONSE_TIMEOUT_SECONDS
           
 
Constructor Summary
Client(String hostNameOrIp, int port, GraphDatabaseService graphDb, int frameLength, byte applicationProtocolVersion, int readTimeout, int maxConcurrentChannels, int maxUnusedPoolSize)
           
Client(String hostNameOrIp, int port, GraphDatabaseService graphDb, int frameLength, byte applicationProtocolVersion, int readTimeout, int maxConcurrentChannels, int maxUnusedPoolSize, Client.ConnectionLostHandler connectionLostHandler)
           
 
Method Summary
protected  void closeChannel(Triplet<org.jboss.netty.channel.Channel,org.jboss.netty.buffer.ChannelBuffer,ByteBuffer> channel)
           
protected  byte getInternalProtocolVersion()
          Only exposed so that tests can control it.
protected  StoreId getMyStoreId()
           
 org.jboss.netty.channel.ChannelPipeline getPipeline()
           
protected  int getReadTimeout(RequestType<M> type, int readTimeout)
           
protected static String[] readTransactionStreamHeader(org.jboss.netty.buffer.ChannelBuffer buffer)
           
protected static TransactionStream readTransactionStreams(org.jboss.netty.buffer.ChannelBuffer buffer, ResourcePool<Triplet<org.jboss.netty.channel.Channel,org.jboss.netty.buffer.ChannelBuffer,ByteBuffer>> resourcePool)
           
protected  void releaseChannel(RequestType<M> type, Triplet<org.jboss.netty.channel.Channel,org.jboss.netty.buffer.ChannelBuffer,ByteBuffer> channel)
           
protected
<R> Response<R>
sendRequest(RequestType<M> type, SlaveContext context, Serializer serializer, Deserializer<R> deserializer)
           
protected
<R> Response<R>
sendRequest(RequestType<M> type, SlaveContext context, Serializer serializer, Deserializer<R> deserializer, StoreId specificStoreId)
           
protected  boolean shouldCheckStoreId(RequestType<M> type)
           
 void shutdown()
           
 String toString()
           
protected  void writeContext(RequestType<M> type, SlaveContext context, org.jboss.netty.buffer.ChannelBuffer targetBuffer)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

DEFAULT_MAX_NUMBER_OF_CONCURRENT_CHANNELS_PER_CLIENT

public static final int DEFAULT_MAX_NUMBER_OF_CONCURRENT_CHANNELS_PER_CLIENT
See Also:
Constant Field Values

DEFAULT_READ_RESPONSE_TIMEOUT_SECONDS

public static final int DEFAULT_READ_RESPONSE_TIMEOUT_SECONDS
See Also:
Constant Field Values
Constructor Detail

Client

public Client(String hostNameOrIp,
              int port,
              GraphDatabaseService graphDb,
              int frameLength,
              byte applicationProtocolVersion,
              int readTimeout,
              int maxConcurrentChannels,
              int maxUnusedPoolSize)

Client

public Client(String hostNameOrIp,
              int port,
              GraphDatabaseService graphDb,
              int frameLength,
              byte applicationProtocolVersion,
              int readTimeout,
              int maxConcurrentChannels,
              int maxUnusedPoolSize,
              Client.ConnectionLostHandler connectionLostHandler)
Method Detail

getInternalProtocolVersion

protected byte getInternalProtocolVersion()
Only exposed so that tests can control it. It's not configurable really.


sendRequest

protected <R> Response<R> sendRequest(RequestType<M> type,
                                      SlaveContext context,
                                      Serializer serializer,
                                      Deserializer<R> deserializer)

sendRequest

protected <R> Response<R> sendRequest(RequestType<M> type,
                                      SlaveContext context,
                                      Serializer serializer,
                                      Deserializer<R> deserializer,
                                      StoreId specificStoreId)

getReadTimeout

protected int getReadTimeout(RequestType<M> type,
                             int readTimeout)

shouldCheckStoreId

protected boolean shouldCheckStoreId(RequestType<M> type)

getMyStoreId

protected StoreId getMyStoreId()

writeContext

protected void writeContext(RequestType<M> type,
                            SlaveContext context,
                            org.jboss.netty.buffer.ChannelBuffer targetBuffer)

releaseChannel

protected void releaseChannel(RequestType<M> type,
                              Triplet<org.jboss.netty.channel.Channel,org.jboss.netty.buffer.ChannelBuffer,ByteBuffer> channel)

closeChannel

protected void closeChannel(Triplet<org.jboss.netty.channel.Channel,org.jboss.netty.buffer.ChannelBuffer,ByteBuffer> channel)

getPipeline

public org.jboss.netty.channel.ChannelPipeline getPipeline()
                                                    throws Exception
Specified by:
getPipeline in interface org.jboss.netty.channel.ChannelPipelineFactory
Throws:
Exception

shutdown

public void shutdown()

toString

public String toString()
Overrides:
toString in class Object

readTransactionStreams

protected static TransactionStream readTransactionStreams(org.jboss.netty.buffer.ChannelBuffer buffer,
                                                          ResourcePool<Triplet<org.jboss.netty.channel.Channel,org.jboss.netty.buffer.ChannelBuffer,ByteBuffer>> resourcePool)

readTransactionStreamHeader

protected static String[] readTransactionStreamHeader(org.jboss.netty.buffer.ChannelBuffer buffer)


Copyright © 2002-2012 The Neo4j Graph Database Project. All Rights Reserved.