org.neo4j.com
Class Server<M,R>

java.lang.Object
  extended by org.neo4j.com.Protocol
      extended by org.neo4j.com.Server<M,R>
All Implemented Interfaces:
org.jboss.netty.channel.ChannelPipelineFactory
Direct Known Subclasses:
MasterServer

public abstract class Server<M,R>
extends Protocol
implements org.jboss.netty.channel.ChannelPipelineFactory

Sits on the master side, receiving serialized requests from slaves (via Client). Delegates actual work to an instance of a specified communication interface, injected in the constructor.


Nested Class Summary
 
Nested classes/interfaces inherited from class org.neo4j.com.Protocol
Protocol.FileStreamsDeserializer
 
Field Summary
static int DEFAULT_BACKUP_PORT
           
static int DEFAULT_MAX_NUMBER_OF_CONCURRENT_TRANSACTIONS
           
 
Fields inherited from class org.neo4j.com.Protocol
DEFAULT_FRAME_LENGTH, EMPTY_SERIALIZER, INTEGER_DESERIALIZER, INTEGER_SERIALIZER, LONG_SERIALIZER, MEGA, PORT, VOID_DESERIALIZER, VOID_SERIALIZER
 
Constructor Summary
Server(M realMaster, int port, String storeDir, int frameLength, byte applicationProtocolVersion, int maxNumberOfConcurrentTransactions, int oldChannelThreshold, TxChecksumVerifier txVerifier)
           
 
Method Summary
protected abstract  void finishOffChannel(org.jboss.netty.channel.Channel channel, SlaveContext context)
           
 Map<org.jboss.netty.channel.Channel,SlaveContext> getConnectedSlaveChannels()
           
protected  byte getInternalProtocolVersion()
          Only exposed so that tests can control it.
protected  M getMaster()
           
 org.jboss.netty.channel.ChannelPipeline getPipeline()
           
protected abstract  RequestType<M> getRequestContext(byte id)
           
protected  void handleRequest(org.jboss.netty.buffer.ChannelBuffer buffer, org.jboss.netty.channel.Channel channel)
           
protected  org.jboss.netty.buffer.ChannelBuffer mapSlave(org.jboss.netty.channel.Channel channel, SlaveContext slave, RequestType<M> type)
           
protected  SlaveContext readContext(org.jboss.netty.buffer.ChannelBuffer buffer)
           
protected  void responseWritten(RequestType<M> type, org.jboss.netty.channel.Channel channel, SlaveContext context)
           
protected  boolean shouldLogFailureToFinishOffChannel(Throwable failure)
           
 void shutdown()
           
protected  void tryToFinishOffChannel(org.jboss.netty.channel.Channel channel)
           
protected  void tryToFinishOffChannel(org.jboss.netty.channel.Channel channel, SlaveContext slave)
           
protected  void unmapSlave(org.jboss.netty.channel.Channel channel, SlaveContext slave)
           
protected  void writeFailureResponse(Throwable exception, ChunkingChannelBuffer buffer)
           
 
Methods inherited from class org.neo4j.com.Protocol
addLengthFieldPipes, readBoolean, readString, readString, writeChars, writeString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_BACKUP_PORT

public static final int DEFAULT_BACKUP_PORT
See Also:
Constant Field Values

DEFAULT_MAX_NUMBER_OF_CONCURRENT_TRANSACTIONS

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

Server

public Server(M realMaster,
              int port,
              String storeDir,
              int frameLength,
              byte applicationProtocolVersion,
              int maxNumberOfConcurrentTransactions,
              int oldChannelThreshold,
              TxChecksumVerifier txVerifier)
Method Detail

getInternalProtocolVersion

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


getPipeline

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

tryToFinishOffChannel

protected void tryToFinishOffChannel(org.jboss.netty.channel.Channel channel)

tryToFinishOffChannel

protected void tryToFinishOffChannel(org.jboss.netty.channel.Channel channel,
                                     SlaveContext slave)

shouldLogFailureToFinishOffChannel

protected boolean shouldLogFailureToFinishOffChannel(Throwable failure)

handleRequest

protected void handleRequest(org.jboss.netty.buffer.ChannelBuffer buffer,
                             org.jboss.netty.channel.Channel channel)
                      throws IOException
Throws:
IOException

writeFailureResponse

protected void writeFailureResponse(Throwable exception,
                                    ChunkingChannelBuffer buffer)

responseWritten

protected void responseWritten(RequestType<M> type,
                               org.jboss.netty.channel.Channel channel,
                               SlaveContext context)

readContext

protected SlaveContext readContext(org.jboss.netty.buffer.ChannelBuffer buffer)

getRequestContext

protected abstract RequestType<M> getRequestContext(byte id)

mapSlave

protected org.jboss.netty.buffer.ChannelBuffer mapSlave(org.jboss.netty.channel.Channel channel,
                                                        SlaveContext slave,
                                                        RequestType<M> type)

unmapSlave

protected void unmapSlave(org.jboss.netty.channel.Channel channel,
                          SlaveContext slave)

getMaster

protected M getMaster()

shutdown

public void shutdown()

finishOffChannel

protected abstract void finishOffChannel(org.jboss.netty.channel.Channel channel,
                                         SlaveContext context)

getConnectedSlaveChannels

public Map<org.jboss.netty.channel.Channel,SlaveContext> getConnectedSlaveChannels()


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