org.jgroups.protocols.pbcast.GMS Java Examples

The following examples show how to use org.jgroups.protocols.pbcast.GMS. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: NO_DUPES.java    From jgroups-raft with Apache License 2.0 6 votes vote down vote up
/**
 * @return True if the message should be passed up, false if it should be discarded
 */
protected boolean handleGmsHeader(GMS.GmsHeader hdr, Address sender) {
    switch(hdr.getType()) {
        case GMS.GmsHeader.JOIN_REQ:
        case GMS.GmsHeader.JOIN_REQ_WITH_STATE_TRANSFER:
            Address joiner=hdr.getMember();
            if(!(joiner instanceof ExtendedUUID)) {
                log.debug("joiner %s needs to have an ExtendedUUID but has a %s", sender, joiner.getClass().getSimpleName());
                break;
            }
            View v=view;
            if(contains(v, (ExtendedUUID)joiner)) {
                String msg=String.format("join of %s rejected as it would create a view with duplicate members (current view: %s)", joiner, v);
                log.warn(msg);
                sendJoinRejectedMessageTo(sender, msg);
                return false;
            }
            break;
        case GMS.GmsHeader.MERGE_REQ:
            // to be done later when we know how to handle merges in jgroups-raft
            break;
    }
    return true;
}
 
Example #2
Source File: RollingUpdateTest.java    From jgroups-kubernetes with Apache License 2.0 5 votes vote down vote up
private static void sendInitialDiscovery(KUBE_PING kubePingProtocol) throws Exception {
   new JChannel(
         new TCP().setValue("bind_addr", InetAddress.getLoopbackAddress()).setValue("bind_port", findFreePort()),
         kubePingProtocol,
         new NAKACK2(),
         new GMS().setValue("join_timeout", 1)
   ).connect("RollingUpdateTest").disconnect();
}
 
Example #3
Source File: NO_DUPES.java    From jgroups-raft with Apache License 2.0 5 votes vote down vote up
public void up(MessageBatch batch) {
    for(Message msg: batch) {
        GMS.GmsHeader hdr=msg.getHeader(gms_id);
        if(hdr != null && !handleGmsHeader(hdr, msg.src()))
            batch.remove(msg);
    }
    if(!batch.isEmpty())
        up_prot.up(batch);
}
 
Example #4
Source File: NO_DUPES.java    From jgroups-raft with Apache License 2.0 5 votes vote down vote up
protected void sendJoinRejectedMessageTo(Address joiner, String reject_message) {
    try {
        Buffer buffer=Util.streamableToBuffer(new JoinRsp(reject_message));
        Message msg=new Message(joiner, buffer).putHeader(gms_id, new GMS.GmsHeader(GMS.GmsHeader.JOIN_RSP));
        down_prot.down(msg);
    }
    catch(Exception ex) {
        log.error("failed sending JoinRsp to %s: %s", joiner, ex);
    }
}
 
Example #5
Source File: NO_DUPES.java    From jgroups-raft with Apache License 2.0 4 votes vote down vote up
public Object up(Message msg) {
    GMS.GmsHeader hdr=msg.getHeader(gms_id);
    if(hdr != null && !handleGmsHeader(hdr, msg.src()))
        return null;
    return up_prot.up(msg);
}