|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Object | +--moses.member.ExMember
This class represent the communication interface between an LGI agent and an external (non-LGI) agent. The communication between an LGI agent and a non-LGI agent is achieved by two mechanism:
Beside the generic_receive_lg(), and send() methods, there are few other methods designed to provide means of authentication between the ExMember and the controller.
Generally an interaction session follows the pattern:
ExMember xmember = new ExMember(sport,cport);
xmember.send(msg, dest);
Answer ans = xmember.generic_receive_lg();
xmember.close();
The handling of the communication channel between the ExMember and the controller is significantly more complicated than the case of the Member communication. Both the ExMember and the controller can initiate a connection to each other (release/submitted scenario) or both can passively wait for incoming connection. As a consequence, the ExMember implements a TCP/Ip server that waits for incoming connections from the controller. All the connections an ExMember holds are kept together, in a pool of connections. This connection pool maintains both connections initiated by the controller, and self-initiated connections. In order to maintain the optimal number of connections, this class provides a method called close_connection() that will explicitly close a certain connection. A connection can expire either when it's closed by the controller (the controller has its own mechanism of tearing down connections in a "Last Recently Used" manner) or when this ExMember explicitly calls close_connection().
An ExMember initiate a connection towards a controller implicitly, whenever a send() method is invoked and there is no such connection in place towards the destination.
Since an ExMember can receive messages coming from multiple connections, it employs a common buffer for storing the messages from all the connections. The messages are deposited at the end of the buffer and read from the beginning of the buffer in a FIFO manner. Every connection implements a daemon reading from that connection and storing the messages in the buffer. The method generic_receive_lg() simply returns the messages from this buffer.
Member| Field Summary | |
int |
auth_method
This is the authentication method used by this ExMember when submitting messages for the controller. |
moses.security.LGICert |
cert
This variable holds the certificate to be submitted when the chosen authentication method is Const.A_CERT. |
java.util.Hashtable |
connections
|
int |
cport
This variable maintains the default port used by the infrastructure of controllers for communication In general, the default controller expects communication on port 9000. |
java.util.LinkedList |
messages
|
java.lang.String |
pwd
This variable holds the password to be submitted if the authentication method is Const.A_PWD. |
java.lang.String |
shost
This variable maintain the host name of the machine where the ExMember is running at a particular instance. |
byte[] |
sign
This variable holds the signature to be submitted along with a certificate when the chosen authentication method is Const.A_CERT. |
int |
sport
This variable holds the master port number, the port used by this ExMember to wait for incoming connections from a controller. |
java.net.ServerSocket |
ss
|
| Constructor Summary | |
ExMember(int sport,
int cport)
The constructor of this class is mainly responsible for instantiating an ExMember variable. |
|
| Method Summary | |
void |
append_message(moses.member.Answer ar)
Internal method used by the generic_receive_lg for handling the implicit message queue. |
void |
close_connection(java.lang.String host,
int port)
This method is exposed in order to give the user a minimal control over what connections should be terminated explicitly. |
void |
close()
This method gracefully terminates the interaction session for this ExMember object. |
moses.member.Answer |
generic_receive_lg()
This method is the method used in receiving incoming messages. |
static java.lang.String |
hnp(java.lang.String host,
int port)
|
static void |
main(java.lang.String[] args)
|
moses.member.ExConnection |
make(java.lang.String host,
int port,
java.lang.String dest)
Internal method designed to create or retrieve a connection from the connection pool, based on the host and port of the controller. |
void |
remove_connection(moses.member.ExConnection exc)
Internal method used for handling of the implicit connections. |
void |
run()
This method represent the background server daemon responsible for accepting connections from the controller. |
boolean |
send(byte[] bmsg,
java.lang.String dest)
A byte array method used for sending messages to a controller (and subsequently to an LGI agent). |
boolean |
send(moses.message.Message m,
java.lang.String host,
int port)
Method used internally for sending messages to the controller. |
boolean |
send(java.lang.Object omsg,
java.lang.String dest)
An object method used for sending messages to a controller (and subsequently to an LGI agent). |
boolean |
send(java.lang.String msg,
java.lang.String dest)
The main method (in a set of 3 methods) used for sending messages to a controller (and subsequently to an LGI agent). |
void |
setAuthenticationCert(moses.security.LGICert cert,
byte[] sign)
This method sets the authentication mechanism to be certificate oriented. |
void |
setAuthenticationNone()
This method resets any authentication mechanism to the Const.A_NONE. |
void |
setAuthenticationPwd(java.lang.String pwd)
This method sets the authentication mechanism to be password oriented. |
void |
setControllerDefaultPort(int cport)
This method sets the controller port of contact to the value specified in the argument. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
public java.util.Hashtable connections
public java.util.LinkedList messages
public java.net.ServerSocket ss
public int sport
public java.lang.String shost
public int cport
public int auth_method
public moses.security.LGICert cert
public byte[] sign
public java.lang.String pwd
| Constructor Detail |
public ExMember(int sport,
int cport)
sport - specifies the port used by this ExMember to wait for incoming connections.cport - specifies the port to contact the controller on, when sending a message. Generally,
a message's destination contains the name of the agent and the host name of the controller.
This parameter is required to fully specify the address of the destination.Member| Method Detail |
public void setAuthenticationPwd(java.lang.String pwd)
pwd - represents the password used by this ExMember to authenticate itself against the
law of the destination;setAuthenticationNone(),
setAuthenticationCert(LGICert, byte[])
public void setAuthenticationCert(moses.security.LGICert cert,
byte[] sign)
cert - represents the certificate used by this ExMember to authenticate itself against the
law of the destination;sign - represents the signature performed over the certificate used by this
ExMember to authenticate itself against the law of the destination. The details of
the certificate-signature method of authentication are described at large in the
moses.member.Member class.setAuthenticationNone(),
setAuthenticationPwd(String)public void setAuthenticationNone()
setAuthenticationPwd(String),
setAuthenticationCert(LGICert, byte[])public void setControllerDefaultPort(int cport)
cport - represents the port on which to contact the controller
public boolean send(java.lang.String msg,
java.lang.String dest)
msg - represents the String message to be submitteddest - represent a moses formed agent destination name ("agent-name@controller.fully.qualified.name")
send(Object, String),
send(byte[], String)
public boolean send(byte[] bmsg,
java.lang.String dest)
dest - represent a moses formed agent destination name ("agent-name@controller.fully.qualified.name")
send(String, String),
send(Object, String)
public boolean send(java.lang.Object omsg,
java.lang.String dest)
dest - represent a moses formed agent destination name ("agent-name@controller.fully.qualified.name")
send(String, String),
send(byte[], String)public void close()
public boolean send(moses.message.Message m,
java.lang.String host,
int port)
public moses.member.ExConnection make(java.lang.String host,
int port,
java.lang.String dest)
public moses.member.Answer generic_receive_lg()
Member.generic_receive_lg(),
Answerpublic void append_message(moses.member.Answer ar)
public void remove_connection(moses.member.ExConnection exc)
public void close_connection(java.lang.String host,
int port)
host - represents the host of the controllerport - represent the port of the controller for the targeted connection victimpublic void run()
run in interface java.lang.Runnable
public static java.lang.String hnp(java.lang.String host,
int port)
public static void main(java.lang.String[] args)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||