openr66.protocol.networkhandler
Class NetworkTransaction

java.lang.Object
  extended by openr66.protocol.networkhandler.NetworkTransaction

public class NetworkTransaction
extends Object

This class handles Network Transaction connections

Author:
frederic bregier

Constructor Summary
NetworkTransaction()
           
 
Method Summary
static void addClient(org.jboss.netty.channel.Channel channel, String requester)
          Add a requester channel (so call only by requested host)
static void addLocalChannelToNetworkChannel(org.jboss.netty.channel.Channel networkChannel, org.jboss.netty.channel.Channel localChannel)
          Add a LocalChannel to a NetworkChannel
static void addNetworkChannel(org.jboss.netty.channel.Channel channel)
           
 void closeAll()
          Close all Network Ttransaction
static void closeRetrieveExecutors()
          Stop all Retrieve Executors
 LocalChannelReference createConnection(SocketAddress socketAddress, boolean isSSL, R66Future futureRequest)
          Create a connection to the specified socketAddress
static LocalChannelReference createConnectionFromNetworkChannelStartup(org.jboss.netty.channel.Channel channel, NetworkPacket packet)
          Create the LocalChannelReference when a remote local channel starts its connection
 LocalChannelReference createConnectionWithRetry(SocketAddress socketAddress, boolean isSSL, R66Future futureRequest)
          Create a connection to the specified socketAddress with multiple retries
static int existConnection(SocketAddress address, String host)
           
static int getNbLocalChannel(org.jboss.netty.channel.Channel channel)
           
static NetworkChannel getNetworkChannel(org.jboss.netty.channel.Channel channel)
           
static int getNumberClients(String requester)
           
static ExecutorService getRetrieveExecutor()
           
static ConcurrentHashMap<Integer,RetrieveRunner> getRetrieveRunnerConcurrentHashMap()
           
static boolean isShuttingdownNetworkChannel(SocketAddress address)
           
static void normalEndRetrieve(LocalChannelReference localChannelReference)
          Normal end of a Retrieve Operation
static void removeClient(String requester, NetworkChannel networkChannel)
          Remove of requester
static int removeForceNetworkChannel(SocketAddress address)
          Force remove of NetworkChannel when it is closed
static int removeNetworkChannel(org.jboss.netty.channel.Channel channel, org.jboss.netty.channel.Channel localChannel, String requester)
           
static void runRetrieve(R66Session session, org.jboss.netty.channel.Channel channel)
          Start retrieve operation
static void shuttingdownNetworkChannel(org.jboss.netty.channel.Channel channel)
          Shutdown one Network Channel
static boolean shuttingdownNetworkChannel(SocketAddress address, org.jboss.netty.channel.Channel channel)
          Shutdown one Network Channel according to its SocketAddress
static boolean shuttingdownNetworkChannels(String requester)
          Get NetworkChannel as client
static void stopRetrieve(LocalChannelReference localChannelReference)
          Stop a retrieve operation
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

NetworkTransaction

public NetworkTransaction()
Method Detail

createConnectionWithRetry

public LocalChannelReference createConnectionWithRetry(SocketAddress socketAddress,
                                                       boolean isSSL,
                                                       R66Future futureRequest)
Create a connection to the specified socketAddress with multiple retries

Parameters:
socketAddress -
isSSL -
futureRequest -
Returns:
the LocalChannelReference

createConnection

public LocalChannelReference createConnection(SocketAddress socketAddress,
                                              boolean isSSL,
                                              R66Future futureRequest)
                                       throws OpenR66ProtocolNetworkException,
                                              OpenR66ProtocolRemoteShutdownException,
                                              OpenR66ProtocolNoConnectionException
Create a connection to the specified socketAddress

Parameters:
socketAddress -
isSSL -
futureRequest -
Returns:
the LocalChannelReference
Throws:
OpenR66ProtocolNetworkException
OpenR66ProtocolRemoteShutdownException
OpenR66ProtocolNoConnectionException

createConnectionFromNetworkChannelStartup

public static LocalChannelReference createConnectionFromNetworkChannelStartup(org.jboss.netty.channel.Channel channel,
                                                                              NetworkPacket packet)
                                                                       throws OpenR66ProtocolRemoteShutdownException,
                                                                              OpenR66ProtocolSystemException
Create the LocalChannelReference when a remote local channel starts its connection

Parameters:
channel -
packet -
Returns:
the LocalChannelReference
Throws:
OpenR66ProtocolRemoteShutdownException
OpenR66ProtocolSystemException

getRetrieveExecutor

public static ExecutorService getRetrieveExecutor()

getRetrieveRunnerConcurrentHashMap

public static ConcurrentHashMap<Integer,RetrieveRunner> getRetrieveRunnerConcurrentHashMap()

runRetrieve

public static void runRetrieve(R66Session session,
                               org.jboss.netty.channel.Channel channel)
Start retrieve operation

Parameters:
session -
channel -

stopRetrieve

public static void stopRetrieve(LocalChannelReference localChannelReference)
Stop a retrieve operation

Parameters:
localChannelReference -

normalEndRetrieve

public static void normalEndRetrieve(LocalChannelReference localChannelReference)
Normal end of a Retrieve Operation

Parameters:
localChannelReference -

closeRetrieveExecutors

public static void closeRetrieveExecutors()
Stop all Retrieve Executors


closeAll

public void closeAll()
Close all Network Ttransaction


addNetworkChannel

public static void addNetworkChannel(org.jboss.netty.channel.Channel channel)
                              throws OpenR66ProtocolRemoteShutdownException
Parameters:
channel -
Throws:
OpenR66ProtocolRemoteShutdownException

addLocalChannelToNetworkChannel

public static void addLocalChannelToNetworkChannel(org.jboss.netty.channel.Channel networkChannel,
                                                   org.jboss.netty.channel.Channel localChannel)
                                            throws OpenR66ProtocolRemoteShutdownException
Add a LocalChannel to a NetworkChannel

Parameters:
networkChannel -
localChannel -
Throws:
OpenR66ProtocolRemoteShutdownException

shuttingdownNetworkChannel

public static void shuttingdownNetworkChannel(org.jboss.netty.channel.Channel channel)
Shutdown one Network Channel

Parameters:
channel -

shuttingdownNetworkChannel

public static boolean shuttingdownNetworkChannel(SocketAddress address,
                                                 org.jboss.netty.channel.Channel channel)
Shutdown one Network Channel according to its SocketAddress

Parameters:
address -
channel - (can be null)
Returns:
True if the shutdown is starting, False if cannot be done (can be already done before)

isShuttingdownNetworkChannel

public static boolean isShuttingdownNetworkChannel(SocketAddress address)
Parameters:
address -
Returns:
True if this channel is currently in shutdown

removeClient

public static void removeClient(String requester,
                                NetworkChannel networkChannel)
Remove of requester

Parameters:
requester -
networkChannel -

shuttingdownNetworkChannels

public static boolean shuttingdownNetworkChannels(String requester)
Get NetworkChannel as client

Parameters:
requester -
Returns:
NetworkChannel associated with this host as client (only 1 allow even if more are available)

addClient

public static void addClient(org.jboss.netty.channel.Channel channel,
                             String requester)
Add a requester channel (so call only by requested host)

Parameters:
channel - (network channel)
requester -

getNumberClients

public static int getNumberClients(String requester)
Parameters:
requester -
Returns:
The number of NetworkChannels associated with this requester

removeForceNetworkChannel

public static int removeForceNetworkChannel(SocketAddress address)
Force remove of NetworkChannel when it is closed

Parameters:
address -
Returns:
the number of still connected Local Channels

removeNetworkChannel

public static int removeNetworkChannel(org.jboss.netty.channel.Channel channel,
                                       org.jboss.netty.channel.Channel localChannel,
                                       String requester)
Parameters:
channel - networkChannel
localChannel - localChannel
requester - Requester since call from LocalChannel close (might be null)
Returns:
the number of local channel still connected to this channel

existConnection

public static int existConnection(SocketAddress address,
                                  String host)
Parameters:
address -
host -
Returns:
True if a connection is still active on this socket or for this host

getNbLocalChannel

public static int getNbLocalChannel(org.jboss.netty.channel.Channel channel)
Parameters:
channel -
Returns:
the number of local channel associated with this channel

getNetworkChannel

public static NetworkChannel getNetworkChannel(org.jboss.netty.channel.Channel channel)
Parameters:
channel -
Returns:
the associated NetworkChannel if any (Null if none)


Copyright © 2009-2012 Frederic Bregier. All Rights Reserved.