Search in sources :

Example 6 with MessageID

use of org.jgroups.protocols.tom.MessageID in project JGroups by belaban.

the class TOA_UnitTest method testLowerSequenceNumberMessage.

public void testLowerSequenceNumberMessage() {
    Address b = Util.createRandomAddress("B");
    setInitialView(localAddress, localAddress, b);
    // next message will have 11
    sequenceNumberManager().update(10);
    ToaHeader header = ToaHeader.newDataMessageHeader(new MessageID(b, 1), 1);
    header.setSequencerNumber(2);
    Message message = newMessage(header, b, localAddress);
    // Message from member C. it isn't in the view and the message should be discarded.
    toa.up(message);
    assertFirstMessage(11, false);
    assertEquals(12, sequenceNumberManager().get());
    assertProposedMessageSent(11);
    header = ToaHeader.newFinalMessageHeader(new MessageID(b, 1), 11);
    message = newMessage(header, b, localAddress);
    toa.up(message);
    assertFirstMessage(11, true);
    assertEquals(12, sequenceNumberManager().get());
    assertDownMessagesEmpty();
    assertUpMessagesEmpty();
}
Also used : Address(org.jgroups.Address) Message(org.jgroups.Message) ToaHeader(org.jgroups.protocols.tom.ToaHeader) MessageID(org.jgroups.protocols.tom.MessageID)

Example 7 with MessageID

use of org.jgroups.protocols.tom.MessageID in project JGroups by belaban.

the class TOA_UnitTest method testMessageBeforeFirstViewAlive.

public void testMessageBeforeFirstViewAlive() {
    Address b = Util.createRandomAddress("B");
    ToaHeader header = ToaHeader.newDataMessageHeader(new MessageID(b, 1), 1);
    Message message = newMessage(header, b, localAddress);
    // message from node B to A.
    // no view is installed yet.
    // message should be accepted
    toa.up(message);
    assertProposedMessageSent(0);
    assertFirstMessage(0, false);
    // view {2|A,B}
    setView(localAddress, 2, localAddress, b);
    // message is kept
    assertFirstMessage(0, false);
    header = ToaHeader.newFinalMessageHeader(new MessageID(b, 1), 1);
    message = newMessage(header, b, localAddress);
    // final message
    toa.up(message);
    assertFirstMessage(1, true);
    assertDownMessagesEmpty();
    assertUpMessagesEmpty();
}
Also used : Address(org.jgroups.Address) Message(org.jgroups.Message) ToaHeader(org.jgroups.protocols.tom.ToaHeader) MessageID(org.jgroups.protocols.tom.MessageID)

Example 8 with MessageID

use of org.jgroups.protocols.tom.MessageID in project JGroups by belaban.

the class TOA_UnitTest method testMessageFromPreviousViewDead.

public void testMessageFromPreviousViewDead() {
    Address b = Util.createRandomAddress("B");
    // view {4|A}
    setView(localAddress, 4, localAddress);
    ToaHeader header = ToaHeader.newDataMessageHeader(new MessageID(b, 1), 3);
    Message message = newMessage(header, b, localAddress);
    // message from node B to A from view 3.
    // B isn't in the view and the message should be discarded
    toa.up(message);
    assertNoMessageToDeliver();
    assertDownMessagesEmpty();
    assertUpMessagesEmpty();
}
Also used : Address(org.jgroups.Address) Message(org.jgroups.Message) ToaHeader(org.jgroups.protocols.tom.ToaHeader) MessageID(org.jgroups.protocols.tom.MessageID)

Example 9 with MessageID

use of org.jgroups.protocols.tom.MessageID in project JGroups by belaban.

the class TOA_UnitTest method testMessageBeforeFirstViewDead.

public void testMessageBeforeFirstViewDead() {
    Address b = Util.createRandomAddress("B");
    ToaHeader header = ToaHeader.newDataMessageHeader(new MessageID(b, 1), 1);
    Message message = newMessage(header, b, localAddress);
    // message from node B to A.
    // no view is installed yet.
    // message should be accepted
    toa.up(message);
    assertProposedMessageSent(0);
    assertFirstMessage(0, false);
    // view {2|A}
    setView(localAddress, 2, localAddress);
    // message dropped. member no longer belongs to the view.
    assertNoMessageToDeliver();
    assertDownMessagesEmpty();
    assertUpMessagesEmpty();
}
Also used : Address(org.jgroups.Address) Message(org.jgroups.Message) ToaHeader(org.jgroups.protocols.tom.ToaHeader) MessageID(org.jgroups.protocols.tom.MessageID)

Example 10 with MessageID

use of org.jgroups.protocols.tom.MessageID in project JGroups by belaban.

the class TOA_UnitTest method testHigherSequenceNumberMessage.

public void testHigherSequenceNumberMessage() {
    Address b = Util.createRandomAddress("B");
    setInitialView(localAddress, localAddress, b);
    // next message will have 11
    sequenceNumberManager().update(10);
    ToaHeader header = ToaHeader.newDataMessageHeader(new MessageID(b, 1), 1);
    header.setSequencerNumber(20);
    Message message = newMessage(header, b, localAddress);
    // Message from member C. it isn't in the view and the message should be discarded.
    toa.up(message);
    assertFirstMessage(20, false);
    assertEquals(21, sequenceNumberManager().get());
    assertProposedMessageSent(20);
    header = ToaHeader.newFinalMessageHeader(new MessageID(b, 1), 20);
    message = newMessage(header, b, localAddress);
    toa.up(message);
    assertFirstMessage(20, true);
    assertEquals(21, sequenceNumberManager().get());
    assertDownMessagesEmpty();
    assertUpMessagesEmpty();
}
Also used : Address(org.jgroups.Address) Message(org.jgroups.Message) ToaHeader(org.jgroups.protocols.tom.ToaHeader) MessageID(org.jgroups.protocols.tom.MessageID)

Aggregations

Address (org.jgroups.Address)10 Message (org.jgroups.Message)10 MessageID (org.jgroups.protocols.tom.MessageID)10 ToaHeader (org.jgroups.protocols.tom.ToaHeader)10