org.sdnplatform.sync.internal.remote
Class RemoteSyncManager

java.lang.Object
  extended by org.sdnplatform.sync.internal.AbstractSyncManager
      extended by org.sdnplatform.sync.internal.remote.RemoteSyncManager
All Implemented Interfaces:
IFloodlightModule, IFloodlightService, ISyncService

public class RemoteSyncManager
extends AbstractSyncManager

Implementation of a sync service that passes its functionality off to a remote sync manager over a TCP connection

Author:
readams

Nested Class Summary
 
Nested classes/interfaces inherited from interface org.sdnplatform.sync.ISyncService
ISyncService.Scope
 
Field Summary
protected  AuthScheme authScheme
           
protected  org.jboss.netty.channel.Channel channel
          Active connection to server
protected  org.jboss.netty.bootstrap.ClientBootstrap clientBootstrap
          Client bootstrap
protected  java.lang.String hostname
          The hostname of the server to connect to
protected  java.lang.String keyStorePassword
           
protected  java.lang.String keyStorePath
           
protected static org.slf4j.Logger logger
           
protected  int port
          Port to connect to
protected  boolean ready
           
protected  java.lang.Object readyNotify
           
protected  java.lang.Short remoteNodeId
          The remote node ID of the node we're connected to
protected  boolean shutdown
           
 
Constructor Summary
RemoteSyncManager()
           
 
Method Summary
 void addListener(java.lang.String storeName, MappingStoreListener listener)
          Add a listener to the specified store
protected  void channelDisconnected(SyncException why)
           
protected  boolean connect(java.lang.String hostname, int port)
           
 void dispatchReply(int xid, SyncReply reply)
           
protected  void ensureConnected()
           
 short getLocalNodeId()
          Get the local ID of the local node
 java.util.Collection<java.lang.Class<? extends IFloodlightService>> getModuleDependencies()
          Get a list of Modules that this module depends on.
 IStore<ByteArray,byte[]> getStore(java.lang.String storeName)
          Get a store object corresponding to the given store name
 int getTransactionId()
          Get a suitable transaction ID for sending a message
 void init(FloodlightModuleContext context)
          This is a hook for each module to do its internal initialization, e.g., call setService(context.getService("Service")) All module dependencies are resolved when this is called, but not every module is initialized.
 void registerPersistentStore(java.lang.String storeName, ISyncService.Scope scope)
          Create a store with the given store name and scope that will be persistent across reboots.
 void registerStore(java.lang.String storeName, ISyncService.Scope scope)
          Create a store with the given store name and scope
 java.util.concurrent.Future<SyncReply> sendRequest(int xid, SyncMessage request)
          Send a request to the server and generate a future for the eventual reply.
 void shutdown()
          Shut down the sync manager.
 void startUp(FloodlightModuleContext context)
          This is a hook for each module to do its external initializations, e.g., register for callbacks or query for state in other modules It is expected that this function will not block and that modules that want non-event driven CPU will spawn their own threads.
 
Methods inherited from class org.sdnplatform.sync.internal.AbstractSyncManager
getModuleServices, getServiceImpls, getStoreClient, getStoreClient, getStoreClient, getStoreClient, getStoreClient
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

logger

protected static final org.slf4j.Logger logger

channel

protected volatile org.jboss.netty.channel.Channel channel
Active connection to server


readyNotify

protected java.lang.Object readyNotify

ready

protected volatile boolean ready

shutdown

protected volatile boolean shutdown

remoteNodeId

protected java.lang.Short remoteNodeId
The remote node ID of the node we're connected to


clientBootstrap

protected org.jboss.netty.bootstrap.ClientBootstrap clientBootstrap
Client bootstrap


hostname

protected java.lang.String hostname
The hostname of the server to connect to


port

protected int port
Port to connect to


authScheme

protected AuthScheme authScheme

keyStorePath

protected java.lang.String keyStorePath

keyStorePassword

protected java.lang.String keyStorePassword
Constructor Detail

RemoteSyncManager

public RemoteSyncManager()
Method Detail

registerStore

public void registerStore(java.lang.String storeName,
                          ISyncService.Scope scope)
                   throws SyncException
Description copied from interface: ISyncService
Create a store with the given store name and scope

Parameters:
storeName - the name of the store
scope - the distribution scope for the data
Throws:
SyncException

registerPersistentStore

public void registerPersistentStore(java.lang.String storeName,
                                    ISyncService.Scope scope)
                             throws SyncException
Description copied from interface: ISyncService
Create a store with the given store name and scope that will be persistent across reboots. The performance will be dramatically slower

Parameters:
storeName - the name of the store
scope - the distribution scope for the data
Throws:
SyncException

addListener

public void addListener(java.lang.String storeName,
                        MappingStoreListener listener)
                 throws UnknownStoreException
Description copied from class: AbstractSyncManager
Add a listener to the specified store

Specified by:
addListener in class AbstractSyncManager
Parameters:
storeName - the name of the store
listener - the listener to add
Throws:
UnknownStoreException

getStore

public IStore<ByteArray,byte[]> getStore(java.lang.String storeName)
                                  throws UnknownStoreException
Description copied from class: AbstractSyncManager
Get a store object corresponding to the given store name

Specified by:
getStore in class AbstractSyncManager
Parameters:
storeName - the store name
Returns:
the IStore
Throws:
UnknownStoreException

getLocalNodeId

public short getLocalNodeId()
Description copied from class: AbstractSyncManager
Get the local ID of the local node

Specified by:
getLocalNodeId in class AbstractSyncManager
Returns:
the node ID

shutdown

public void shutdown()
Description copied from class: AbstractSyncManager
Shut down the sync manager. Tear down any communicating threads

Specified by:
shutdown in class AbstractSyncManager

init

public void init(FloodlightModuleContext context)
          throws FloodlightModuleException
Description copied from interface: IFloodlightModule
This is a hook for each module to do its internal initialization, e.g., call setService(context.getService("Service")) All module dependencies are resolved when this is called, but not every module is initialized.

Throws:
FloodlightModuleException

startUp

public void startUp(FloodlightModuleContext context)
             throws FloodlightModuleException
Description copied from interface: IFloodlightModule
This is a hook for each module to do its external initializations, e.g., register for callbacks or query for state in other modules It is expected that this function will not block and that modules that want non-event driven CPU will spawn their own threads.

Throws:
FloodlightModuleException

getModuleDependencies

public java.util.Collection<java.lang.Class<? extends IFloodlightService>> getModuleDependencies()
Description copied from interface: IFloodlightModule
Get a list of Modules that this module depends on. The module system will ensure that each these dependencies is resolved before the subsequent calls to init().

Returns:
The Collection of IFloodlightServices that this module depends on.

getTransactionId

public int getTransactionId()
Get a suitable transaction ID for sending a message

Returns:
the unique transaction iD

sendRequest

public java.util.concurrent.Future<SyncReply> sendRequest(int xid,
                                                          SyncMessage request)
                                                   throws RemoteStoreException
Send a request to the server and generate a future for the eventual reply. Note that this call can block if there is no active connection while a new connection is re-established or if the maximum number of requests is already pending

Parameters:
xid - the transaction ID for the request
request - the actual request to send
Returns:
A Future for the reply message
Throws:
java.lang.InterruptedException
RemoteStoreException

dispatchReply

public void dispatchReply(int xid,
                          SyncReply reply)

channelDisconnected

protected void channelDisconnected(SyncException why)

ensureConnected

protected void ensureConnected()

connect

protected boolean connect(java.lang.String hostname,
                          int port)