Sun Microsystems, Inc.
spacerspacer
spacer www.sun.com docs.sun.com |
spacer
black dot
 
 
12.  CRNP How a Client Registers With the Server How SC_CALLBACK_REG Messages Are Passed Between a Client and the Server  Previous   Contents   Next 
   
 

How the Server Replies to a Client

After processing the registration, the server sends the SC_REPLY message. The server sends this message on the open TCP connection from the client on which the server received the registration request. The server then closes the connection. The client must keep the TCP connection open until it receives the SC_REPLY message from the server.

For example, the client carries out the following actions:

  1. Opens a TCP connection to the server

  2. Waits for a connection to be "writeable"

  3. Sends an SC_CALLBACK_REG message (which contains an ADD_CLIENT message)

  4. Waits for an SC_REPLY message

  5. Receives an SC_REPLY message

  6. Receives an indicator that the server has closed the connection (reads 0 bytes from the socket)

  7. Closes the connection

At a later point in time, the client then carries out the following actions:
  1. Opens a TCP connection to the server

  2. Waits for a connection to be "writeable"

  3. Sends an SC_CALLBACK_REG message (which contains a REMOVE_CLIENT message)

  4. Waits for an SC_REPLY message

  5. Receives an SC_REPLY message

  6. Receives an indicator that the server has closed the connection (reads 0 bytes from the socket)

  7. Closes the connection

Each time that the server receives an SC_CALLBACK_REG message from a client, the server sends an SC_REPLY message on the same open connection. This message specifies whether the operation succeeded or failed. SC_REPLY XML DTD contains the XML document type definition of an SC_REPLY message, and the possible error messages that this message can include.

Contents of an SC_REPLY Message

An SC_REPLY message specifies whether an operation succeeded or failed. This message contains the version of the CRNP protocol message, a status code, and a status message, which describes the status code in more detail. The following table describes the possible values for the status code.

Status Code

Description

OK

The message was processed successfully.

RETRY

The registration of the client was rejected by the server due to a transient error (the client should try to register again, with different parameters).

LOW_RESOURCE

Cluster resources are low, and the client can only try again at a later time (the system administrator for the cluster can also increase the resources on the cluster).

SYSTEM_ERROR

A serious problem occurred. Contact the system administrator for the cluster.

FAIL

Authorization failed or another problem caused the registration to fail.

MALFORMED

The XML request was malformed and could not be parsed.

INVALID

The XML request was invalid (does not meet the XML specification).

VERSION_TOO_HIGH

The version of the message was too high to process the message successfully.

VERSION_TOO_LOW

The version of the message was too low to process the message successfully.

How a Client Is to Handle Error Conditions

Under normal conditions, a client that sends an SC_CALLBACK_REG message receives a reply that indicates that the registration succeeded or failed.

However, the server can experience an error condition when a client is registering that prohibits the server from sending an SC_REPLY message to the client. In this case, the registration could either have succeeded before the error condition occurred, could have failed, or could not yet have been processed.

Because the server must function as a failover, or highly available, server on the cluster, this error condition does not mean an end to the service. In fact, the server could soon begin sending events to the newly registered client.

To remedy these conditions, your client should both:

  • Impose an application-level time-out on a registration connection that is waiting for an SC_REPLY message, after which the client needs to retry registering.

  • Begin listening on its callback IP address and port number for event deliveries before it registers for the event callbacks. The client should wait for a registration confirmation message and for event deliveries in parallel. If the client begins to receive events before the client receives a confirmation message, the client should silently close the registration connection.

How the Server Delivers Events to a Client

As events are generated within the cluster, the CRNP server delivers them to all clients who requested events of those types. The delivery consists of sending an SC_EVENT message to the client's callback address. The delivery of each event occurs on a new TCP connection.

Immediately after a client registers for an event type, through an SC_CALLBACK_REG message that contains an ADD_CLIENT message or an ADD_EVENT message, the server sends the most recent event of that type to the client. The client can then discover the current state of the system from which the subsequent events come.

When the server initiates a TCP connection to the client, the server sends exactly one SC_EVENT message on the connection. The server then issues a full-duplex close.

For example, the client carries out the following actions:

  1. Waits for the server to initiate a TCP connection

  2. Accepts the incoming connection from the server

  3. Waits for an SC_EVENT message

  4. Reads an SC_EVENT message

  5. Receives an indicator that the server has closed the connection (reads 0 bytes from the socket)

  6. Closes the connection

When all clients have registered, they must listen at their callback address (the IP address and port number) at all times for an incoming event delivery connection.

If the server fails to contact the client to deliver an event, the server tries again to deliver the event the number of times and at the interval that you define. If all attempts fail, the client is removed from the server's list of clients. The client also needs to re-register by sending another SC_CALLBACK_REG message that contains an ADD_CLIENT message before the client can receive more events.

 
 
 
  Previous   Contents   Next