fr.dyade.aaa.agent
Class HttpNetwork

java.lang.Object
  extended by fr.dyade.aaa.agent.Network
      extended by fr.dyade.aaa.agent.StreamNetwork
          extended by fr.dyade.aaa.agent.HttpNetwork
All Implemented Interfaces:
HttpNetworkMBean, 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.


Field Summary
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.
 
Fields inherited from class fr.dyade.aaa.agent.Network
bootTSFN, domain, idxLS, logmon, name, nbMessageIn, nbMessageOut, port, qout, servers, serversFN, sid
 
Constructor Summary
HttpNetwork()
          Creates a new network component.
 
Method Summary
 long getActivationPeriod()
          Gets the activationPeriod value.
 long getNbDaemon()
          Gets the NbDaemon value.
 java.lang.String getProxyhost()
          Gets the proxyhost value.
 long getProxyport()
          Gets the proxyport value.
protected  void getReply(java.io.InputStream is, fr.dyade.aaa.agent.HttpNetwork.NetworkInputStream nis, byte[] buf)
           
protected  short getRequest(java.io.InputStream is, fr.dyade.aaa.agent.HttpNetwork.NetworkInputStream nis, byte[] buf)
           
protected  int handle(fr.dyade.aaa.agent.Message msgout, fr.dyade.aaa.agent.HttpNetwork.NetworkInputStream nis)
           
 void init(java.lang.String name, int port, short[] servers)
          Initializes a new network component.
 boolean isRunning()
          Tests if the network component is alive.
protected  void sendReply(fr.dyade.aaa.agent.Message msg, java.io.OutputStream os, fr.dyade.aaa.agent.HttpNetwork.NetworkOutputStream nos, int ack, long currentTimeMillis)
           
protected  void sendRequest(fr.dyade.aaa.agent.Message msg, java.io.OutputStream os, fr.dyade.aaa.agent.HttpNetwork.NetworkOutputStream nos, int ack, long currentTimeMillis)
           
 void setActivationPeriod(long activationPeriod)
          Sets the activationPeriod value.
 void start()
          Causes this network component to begin execution.
 void stop()
          Forces the network component to stop executing.
 java.lang.String toString()
          Returns a string representation of this consumer, including the daemon's name and status.
 void wakeup()
          Wakes up the watch-dog thread.
 
Methods inherited from class fr.dyade.aaa.agent.StreamNetwork
setProperties
 
Methods inherited from class fr.dyade.aaa.agent.Network
addServer, delete, deliver, delServer, getAverageLoad1, getAverageLoad15, getAverageLoad5, getDomainName, getName, getNbMessageReceived, getNbMessageSent, getNbWaitingMessages, getPort, getQueue, getStamp, getWDActivationPeriod, getWDNbRetryLevel1, getWDNbRetryLevel2, getWDRetryPeriod1, getWDRetryPeriod2, getWDRetryPeriod3, index, insert, post, restore, save, setPort, setStamp, setWDActivationPeriod, setWDNbRetryLevel1, setWDNbRetryLevel2, setWDRetryPeriod1, setWDRetryPeriod2, setWDRetryPeriod3, validate
 
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

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 setting ActivationPeriod global property or for a particular network by setting \.ActivationPeriod specific property.

Theses properties can be fixed either from java launching command, or in a3servers.xml configuration file. By default, its value is 10000 (10s).

Constructor Detail

HttpNetwork

public HttpNetwork()
Creates a new network component.

Method Detail

getProxyhost

public java.lang.String getProxyhost()
Gets the proxyhost value.

Specified by:
getProxyhost in interface HttpNetworkMBean
Returns:
the proxyhost value

getProxyport

public long getProxyport()
Gets the proxyport value.

Specified by:
getProxyport in interface HttpNetworkMBean
Returns:
the proxyport value

getActivationPeriod

public long getActivationPeriod()
Gets the activationPeriod value.

Specified by:
getActivationPeriod in interface HttpNetworkMBean
Returns:
the activationPeriod value

setActivationPeriod

public void setActivationPeriod(long activationPeriod)
Sets the activationPeriod value.

Specified by:
setActivationPeriod in interface HttpNetworkMBean
Parameters:
activationPeriod - the activationPeriod value

getNbDaemon

public long getNbDaemon()
Gets the NbDaemon value.

Specified by:
getNbDaemon in interface HttpNetworkMBean
Returns:
the NbDaemon value

init

public void init(java.lang.String name,
                 int port,
                 short[] servers)
          throws java.lang.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 the Class.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:
init in class StreamNetwork
Parameters:
name - The domain name.
port - The listen port.
servers - The list of servers directly accessible from this network interface.
Throws:
java.lang.Exception
See Also:
Network

start

public void start()
           throws java.lang.Exception
Causes this network component to begin execution.

Specified by:
start in interface MessageConsumer
Specified by:
start in interface NetworkMBean
Throws:
java.lang.Exception
See Also:
stop

wakeup

public void wakeup()
Wakes up the watch-dog thread.


stop

public void stop()
Forces the network component to stop executing.

Specified by:
stop in interface MessageConsumer
Specified by:
stop in interface NetworkMBean
See Also:
start

isRunning

public boolean isRunning()
Tests if the network component is alive.

Specified by:
isRunning in interface MessageConsumer
Specified by:
isRunning in interface NetworkMBean
Returns:
true if this MessageConsumer is alive; false otherwise.

toString

public java.lang.String toString()
Returns a string representation of this consumer, including the daemon's name and status.

Specified by:
toString in interface NetworkMBean
Overrides:
toString in class Network
Returns:
A string representation of this consumer.

sendRequest

protected void sendRequest(fr.dyade.aaa.agent.Message msg,
                           java.io.OutputStream os,
                           fr.dyade.aaa.agent.HttpNetwork.NetworkOutputStream nos,
                           int ack,
                           long currentTimeMillis)
                    throws java.lang.Exception
Throws:
java.lang.Exception

getRequest

protected final short getRequest(java.io.InputStream is,
                                 fr.dyade.aaa.agent.HttpNetwork.NetworkInputStream nis,
                                 byte[] buf)
                          throws java.lang.Exception
Throws:
java.lang.Exception

sendReply

protected final void sendReply(fr.dyade.aaa.agent.Message msg,
                               java.io.OutputStream os,
                               fr.dyade.aaa.agent.HttpNetwork.NetworkOutputStream nos,
                               int ack,
                               long currentTimeMillis)
                        throws java.lang.Exception
Throws:
java.lang.Exception

getReply

protected void getReply(java.io.InputStream is,
                        fr.dyade.aaa.agent.HttpNetwork.NetworkInputStream nis,
                        byte[] buf)
                 throws java.lang.Exception
Throws:
java.lang.Exception

handle

protected int handle(fr.dyade.aaa.agent.Message msgout,
                     fr.dyade.aaa.agent.HttpNetwork.NetworkInputStream nis)
              throws java.lang.Exception
Throws:
java.lang.Exception


Copyright © 2011 ScalAgent D.T.. All Rights Reserved.