You are viewing an old version of this page. View the current version.

Compare with Current View Page History

Version 1 Next »

WORK IN PROGRESS

Summary

Geode uses UDP messaging through jgroups for it's peer to peer (P2P) messaging related to membership. Unfortunately, jgroups does not support rolling upgrades, which makes it more difficult to to upgrade jgroups versions. Configuring encryption for UDP adds an additional layer of complexity for securing P2P communications.

We would like to replace the UDP messaging for membership with a TCP messaging system.

Requirements

  • Set us up for removing jgroups as dependency in future versions by moving to a protocol that does not require jgroups
  • Support rolling upgrades from the old jgroups protocol to the new TCP based protocol
  • Be as reliable in the face of networking failures as the previous protocol

Design

 

All of messaging related to membership is handled by the JGroupsMessenger class, which implements the Messenger interface. We will create a new implementation of Messenger that uses TCP sockets, rather than jgroups and UDP sockets.

The key methods on messenger are below

/**
 * Start the server and start listening for messages.
 */
void start();

/**
 * returns the endpoint ID for this member
 */
InternalDistributedMember getMemberID();

/**
 * sends an asynchronous message. Returns destinations that did not receive the message due to no
 * longer being in the view
 */
Set<InternalDistributedMember> send(DistributionMessage m);

/**
 * adds a handler for the given class/interface of messages
 */
void addHandler(Class c, MessageHandler h);

 

The start method of the messenger is responsible for starting a server that is listening on a socket. The getMemberId() method returns an InternalDistributedMember. Currently the InternalDistributedMember contains the host and port that the Messenger is listening on in it's getHost and getPort methods.

The send method takes a DistributionMessage. DistributionMessage has a getRecipients method, which returns an array of InternalDistributedMember objects. The messenger can send messages to those recipients because they have the host and port information.

Discovery of the InternalDistributedMembers happens outside the Messenger (in GMSJoinLeave). We won't have to modify that functionality. The new messenger just needs to know how to start a TCP server, generate an InternalDistributedMember that contains the contact information for that server, and use InternalDistributedMember objects from other other members to send messages to them.

Implement a TCP Server Using Netty

Our proposal for the new Messenger is to start a Tcp server using Netty. We will implement a netty ChannelInboundAdapter that deserializes geode messages and passes them to handlers registered with addHandler. The host and port of the netty server can be included in InternalDistributedMember or shared other ways (see the Rolling Upgrade section, below).

The netty server will use the existing cluster SSL configuration, so if cluster SSL is enabled no additional properties will be required. See https://geode.apache.org/docs/guide/latest/managing/security/implementing_ssl.html for information on the relevant properties.

When sending a message, the Messenger will create a connection to all destinations if no connection exists yet. Once a connection is established, the connection will remain open as long as that member is still in the view. If IO errors or timeouts happen when writing messages, the Messenger will close the connection, reestablish a new connection, and retry. Messages will continue to be retried until ???.

Do messages need to be sent in the order they are generated, even with retries???

One concern about switching to a TCP based protocol is that network outages may result in TCP sockets hanging on read or write operations. We will use non-blocking IO whenever possible and test the new protocol with tools to simulate network outages.

Rolling upgrade concerns

We need to be able to do a rolling upgrade from the old jgroups based protocol to the new protocol. We will need to continue to support rolling upgrades for a certain range of versions before we can drop jgroups.

In order to accomplish this a member will actually need to be listening for connections on both protocols when it initially starts up. We will create a delegating Messenger that contains both a JgroupsMessenger and a NettyMessenger. It can install handlers in both of them, and decide which Messenger to use when sending a message based on the version of the recipient. If a member receives a view that contains no old members that don't support the old protocol it could shut down the jgroups based Messenger.

There is an issue here with the need to listen on two separate ports, because InternalDistributedMember currently only has support for a single port field. There are a few options we are evaluating:

  1. Just use the same port for jgroups and netty. Since one is a UDP port and the other is TCP port, they can both be open at the same time.
  2. Encode the second port in some other field in InternalDistributedMember, for example by using part of the UUID bytes. This is kindy hacky
  3. Pass the new membership port around outside of InternalDistributedMember. This would probably involve sending as part of the FindCoordinatorResponse, as well as including it in the NetView.
  • No labels