3 Message and Event Streams

3.1 Message stream

Since P2PS provides asynchronous message sending, the messages are available on a message stream, as they are received. One can access the message stream with the methods getMsgStrm, createNet and joinNet of class P2PServices (see Section 2.1). Each message is wrapped into a record of the following form:

rcvMsg(src:Src dst:Dst msg:Msg)

Msg is the message itself, as it was sent with the communication primitives of class P2PServices. Src denotes the source of the message, i.e., the Id of the node that initiated the send. Dst denotes the destination of the message. It designates either the node whose Id is equal with Dst, or the node which is responsible for the key equal to Dst. The former case applies when the message was intended to the node whose Id is equal to Dst, whereas th latter applies when the message was intended to the responsible of key equal to Dst.

3.2 Event stream

The events represent asynchronous actions that occur in P2PS. They are available on the event stream (see the methods getEvntStrm, createNet and joinNet of class P2PServices in Section 2.1). An application can watch the events and react accordingly. In the following we enumerate the supported events.

alone

Issued when the node remains alone in the network.

connected

Issued when the node becomes connected to a P2PS network. This event has the form connected(useProxy:B), where B is a boolean indicating whether the node can be (false) or not (true) accessed directly by other nodes in the network. In the latter case, the node uses its successor as a proxy to be part of the network.

new

Issued when there is a change in the connections of this node, i.e., new successor, predecessor, finger table, or successor list. The event has the form of a record with label new. For now, the record has only one feature denoting the event subtype. Below we enumerate the possible subtypes and the form of their corresponding values.

new(ft:FT)

Issued when the finger table (i.e., the set of neighbors) of this node has changed. FT has the form of a record with label ft. The record contains the node Ids of the fingers. The maximum number of fingers at a node depends on the maximum network size of the system (see NetConfig in Section 2.1). For the positions for which the value of a finger is determined, its node Id is provided, otherwise unit is provided.

new(pred:Pred)

Issued when the node has a new predecessor node. Pred represents the node Id of the node's predecessor.

new(succ:Succ)

Issued when the node has a new successor node. Succ represents the node Id of the node's successor.

new(succlist:SuccList)

Issued when there is a modification in the content of the node's successor list. SuccList has the form of a record with label succlist. The record contains the node Ids of the successors of this node. The maximum number of successors of a node is specified within NetConfig (see Section 2.1). The Id of a node may appear in its successor list if the network is smaller than the maximum size of the successor list.

clientjoined

Issued when a node is used as proxy by another node. This event has the form clientjoined(NId), where NId represents the Id of the other node (i.e., the client).

clientleft

Issued when a node using this node as proxy has disconnected from it. This event has the form clientleft(NId), where NId represents the client's Id.

rejected

Issued when the node has been rejected from the network because of a given reason. The event has the form rejected(reason:Reason), where Reason is an atom giving the rejection reason. Reason takes the following values. partiallyNotAccessible when the node can not be accessible by both, its successor and predecessor. Note that the application can reconnect to the network, but it is suggested to chnage the node's Id.

openconn

Issued when a reliable connection is opening to the other end. This event is generated at both nodes involved with the connection. It has the form openconn(peerId:NId)

closeconn

Issued when a reliable connection was teared down. This event is generated at both nodes involved with the connection. The remaining non acked messages (each message paired with the corresponding context) are available in the list RM. It has the form closeconn(peerId:NId rmnMsgs:RM)


Bruno Carton and Valentin Mesaros