Package fr.dyade.aaa.agent
Class HttpNetwork
- java.lang.Object
-
- fr.dyade.aaa.agent.Network
-
- fr.dyade.aaa.agent.StreamNetwork
-
- fr.dyade.aaa.agent.HttpNetwork
-
- All Implemented Interfaces:
HttpNetworkMBean,MessageComparator,MessageConsumer,NetworkMBean
- Direct Known Subclasses:
HttpsNetwork
public class HttpNetwork extends StreamNetwork implements HttpNetworkMBean
HttpNetwork is a simple implementation of StreamNetwork based on HTTP 1.1 protocol.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description (package private) classHttpNetwork.NetServerIn(package private) classHttpNetwork.NetServerOut(package private) classHttpNetwork.NetworkInputStreamClass used to read messages through a stream.(package private) classHttpNetwork.NetworkOutputStreamClass used to send messages through a stream.-
Nested classes/interfaces inherited from class fr.dyade.aaa.agent.Network
Network.NetworkAverageLoadTask
-
-
Field Summary
Fields Modifier and Type Field Description protected longactivationPeriodPeriod of time between two activation of NetServerOut, it matches to the time between two requests from the client to the server when there is no message to transmit from client to server.(package private) Daemon[]dmonDaemon component(package private) intNbDaemonNumber of listening daemon, this value is only valid for the server part of the HttpNetwork.private InetAddressproxyNetwork address of proxy server.(package private) StringproxyhostHostname (or IP dotted address) of proxy host, if not defined there is a direct connection between the client and the server.(package private) intproxyportPort number of proxy if any.(package private) ServerDescserverDescriptor of the listen server, it is used only on the client side (NetServerOut component).-
Fields inherited from class fr.dyade.aaa.agent.StreamNetwork
backlog, CnxRetry, ConnectTimeout, inLocalAddr, outLocalAddr, outLocalPort, serverSocketFactory, socketFactory, SoLinger, SoTimeout, TcpNoDelay
-
Fields inherited from class fr.dyade.aaa.agent.Network
ALREADY_DELIVERED, averageLoadTask, bootTSFN, DEBUG, DELIVER, domain, idxLS, logger, name, nbMessageIn, nbMessageOut, port, qout, servers, serversFN, sid, WDActivationPeriod, WDNbRetryLevel1, WDNbRetryLevel2, WDRetryPeriod1, WDRetryPeriod2, WDRetryPeriod3
-
-
Constructor Summary
Constructors Constructor Description HttpNetwork()Creates a new network component.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description longgetActivationPeriod()Gets the activationPeriod value.longgetNbDaemon()Gets the NbDaemon value.StringgetProxyhost()Gets the proxyhost value.longgetProxyport()Gets the proxyport value.protected voidgetReply(InputStream is, HttpNetwork.NetworkInputStream nis, byte[] buf)protected shortgetRequest(InputStream is, HttpNetwork.NetworkInputStream nis, byte[] buf)protected inthandle(Message msgout, HttpNetwork.NetworkInputStream nis)voidinit(String name, int port, short[] servers)Initializes a new network component.booleanisRunning()Tests if the network component is alive.(package private) StringreadLine(InputStream is, byte[] buf)protected voidsendReply(Message msg, OutputStream os, HttpNetwork.NetworkOutputStream nos, int ack, long currentTimeMillis)protected voidsendRequest(Message msg, OutputStream os, HttpNetwork.NetworkOutputStream nos, int ack, long currentTimeMillis)voidsetActivationPeriod(long activationPeriod)Sets the activationPeriod value.voidstart()Causes this network component to begin execution.voidstop()Forces the network component to stop executing.StringtoString()Returns a string representation of this consumer, including the daemon's name and status.voidwakeup()Wakes up the watch-dog thread.-
Methods inherited from class fr.dyade.aaa.agent.StreamNetwork
createServerSocket, createServerSocket, createSocket, createSocket, createSocket, setProperties, setSocketOption
-
Methods inherited from class fr.dyade.aaa.agent.Network
addServer, channelPostAndValidate, checkActive, delete, deleteMessage, deliver, delServer, getAverageLoad1, getAverageLoad15, getAverageLoad5, getBootTS, getDomainName, getMessageDest, getMessageSource, getName, getNbMessageReceived, getNbMessageSent, getNbWaitingMessages, getPort, getQueue, getStamp, getWDActivationPeriod, getWDNbRetryLevel1, getWDNbRetryLevel2, getWDRetryPeriod1, getWDRetryPeriod2, getWDRetryPeriod3, index, insert, isPrior, post, postAndValidate, postMessage, prepareMessage, prepareMessageWithoutStamp, resetServer, restore, save, saveChannel, setMessageSource, setPort, setStamp, setWDActivationPeriod, setWDNbRetryLevel1, setWDNbRetryLevel2, setWDRetryPeriod1, setWDRetryPeriod2, setWDRetryPeriod3, testBootTS, testRecvUpdate, validate, validateChannel
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface fr.dyade.aaa.agent.NetworkMBean
getAverageLoad1, getAverageLoad15, getAverageLoad5, getName, getNbMessageReceived, getNbMessageSent, getNbWaitingMessages, getWDActivationPeriod, getWDNbRetryLevel1, getWDNbRetryLevel2, getWDRetryPeriod1, getWDRetryPeriod2, getWDRetryPeriod3, setWDActivationPeriod, setWDNbRetryLevel1, setWDNbRetryLevel2, setWDRetryPeriod1, setWDRetryPeriod2, setWDRetryPeriod3
-
-
-
-
Field Detail
-
proxy
private InetAddress proxy
Network address of proxy server.
-
proxyhost
String proxyhost
Hostname (or IP dotted address) of proxy host, if not defined there is a direct connection between the client and the server. This value can be adjusted for all HttpNetwork components by settingproxyhostglobal property or for a particular network by setting<DomainName>.proxyhostspecific property.Theses properties can be fixed either from
javalaunching command, or ina3servers.xmlconfiguration file.
-
proxyport
int proxyport
Port number of proxy if any. This value can be adjusted for all HttpNetwork components by settingproxyportglobal property or for a particular network by setting<DomainName>.proxyportspecific property.Theses properties can be fixed either from
javalaunching command, or ina3servers.xmlconfiguration file.
-
activationPeriod
protected long activationPeriod
Period of time between two activation of NetServerOut, it matches to the time between two requests from the client to the server when there is no message to transmit from client to server. This value can be adjusted for all HttpNetwork components by settingActivationPeriodglobal property or for a particular network by setting<DomainName>.ActivationPeriodspecific property.Theses properties can be fixed either from
javalaunching command, or ina3servers.xmlconfiguration file. By default, its value is 10000 (10s).
-
NbDaemon
int NbDaemon
Number of listening daemon, this value is only valid for the server part of the HttpNetwork. This value can be adjusted for all HttpNetwork components by settingNbDaemonglobal property or for a particular network by setting<DomainName>.NbDaemonspecific property.Theses properties can be fixed either from
javalaunching command, or ina3servers.xmlconfiguration file.
-
server
ServerDesc server
Descriptor of the listen server, it is used only on the client side (NetServerOut component).
-
dmon
Daemon[] dmon
Daemon component
-
-
Method Detail
-
getProxyhost
public String getProxyhost()
Gets the proxyhost value.- Specified by:
getProxyhostin interfaceHttpNetworkMBean- Returns:
- the proxyhost value
-
getProxyport
public long getProxyport()
Gets the proxyport value.- Specified by:
getProxyportin interfaceHttpNetworkMBean- Returns:
- the proxyport value
-
getActivationPeriod
public long getActivationPeriod()
Gets the activationPeriod value.- Specified by:
getActivationPeriodin interfaceHttpNetworkMBean- Returns:
- the activationPeriod value
-
setActivationPeriod
public void setActivationPeriod(long activationPeriod)
Sets the activationPeriod value.- Specified by:
setActivationPeriodin interfaceHttpNetworkMBean- Parameters:
activationPeriod- the activationPeriod value
-
getNbDaemon
public long getNbDaemon()
Gets the NbDaemon value.- Specified by:
getNbDaemonin interfaceHttpNetworkMBean- Returns:
- the NbDaemon value
-
init
public void init(String name, int port, short[] servers) throws Exception
Initializes a new network component. This method is used in order to easily creates and configure a Network component from a class name. So we can use theClass.newInstance()method for create (whitout any parameter) the component, then we can initialize it with this method.
This method initializes the logical clock for the domain.- Overrides:
initin classStreamNetwork- Parameters:
name- The domain name.port- The listen port.servers- The list of servers directly accessible from this network interface.- Throws:
Exception- an error occurs.- See Also:
Network
-
start
public void start() throws ExceptionCauses this network component to begin execution.- Specified by:
startin interfaceMessageConsumer- Specified by:
startin interfaceNetworkMBean- Throws:
Exception- an error occurs.- See Also:
MessageConsumer.stop()
-
wakeup
public void wakeup()
Wakes up the watch-dog thread.
-
stop
public void stop()
Forces the network component to stop executing.- Specified by:
stopin interfaceMessageConsumer- Specified by:
stopin interfaceNetworkMBean- See Also:
MessageConsumer.start()
-
isRunning
public boolean isRunning()
Tests if the network component is alive.- Specified by:
isRunningin interfaceMessageConsumer- Specified by:
isRunningin interfaceNetworkMBean- Returns:
- true if this
MessageConsumeris alive; false otherwise.
-
toString
public String toString()
Returns a string representation of this consumer, including the daemon's name and status.- Specified by:
toStringin interfaceNetworkMBean- Overrides:
toStringin classNetwork- Returns:
- A string representation of this consumer.
-
readLine
String readLine(InputStream is, byte[] buf) throws IOException
- Throws:
IOException
-
sendRequest
protected void sendRequest(Message msg, OutputStream os, HttpNetwork.NetworkOutputStream nos, int ack, long currentTimeMillis) throws Exception
- Throws:
Exception
-
getRequest
protected final short getRequest(InputStream is, HttpNetwork.NetworkInputStream nis, byte[] buf) throws Exception
- Throws:
Exception
-
sendReply
protected final void sendReply(Message msg, OutputStream os, HttpNetwork.NetworkOutputStream nos, int ack, long currentTimeMillis) throws Exception
- Throws:
Exception
-
getReply
protected void getReply(InputStream is, HttpNetwork.NetworkInputStream nis, byte[] buf) throws Exception
- Throws:
Exception
-
handle
protected int handle(Message msgout, HttpNetwork.NetworkInputStream nis) throws Exception
- Throws:
Exception
-
-