Search in sources :

Example 1 with ToaHeader

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

the class TOA_UnitTest method testMessageFromPreviousViewAlive.

public void testMessageFromPreviousViewAlive() {
    Address b = Util.createRandomAddress("B");
    // view {4|A,B}
    setView(localAddress, 4, localAddress, b);
    ToaHeader header = ToaHeader.newDataMessageHeader(new MessageID(b, 1), 3);
    Message message = newMessage(header, b, localAddress);
    // message from node B to A from view 3.
    // message is accepted
    toa.up(message);
    assertProposedMessageSent(0);
    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 2 with ToaHeader

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

the class TOA_UnitTest method testMessageBeforeFirstView.

public void testMessageBeforeFirstView() {
    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);
    header = ToaHeader.newFinalMessageHeader(new MessageID(b, 1), 1);
    message = newMessage(header, b, localAddress);
    // final message
    // no view installed yet
    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 3 with ToaHeader

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

the class TOA_UnitTest method testSameSequenceNumberMessage.

public void testSameSequenceNumberMessage() {
    Address b = Util.createRandomAddress("B");
    setInitialView(localAddress, localAddress, b);
    // it increments it to 10
    sequenceNumberManager().update(9);
    ToaHeader header = ToaHeader.newDataMessageHeader(new MessageID(b, 1), 1);
    header.setSequencerNumber(10);
    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(10, false);
    assertEquals(11, sequenceNumberManager().get());
    assertProposedMessageSent(10);
    header = ToaHeader.newFinalMessageHeader(new MessageID(b, 1), 15);
    message = newMessage(header, b, localAddress);
    toa.up(message);
    assertFirstMessage(15, true);
    assertEquals(16, 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 4 with ToaHeader

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

the class TOA_UnitTest method testMessageFromNewView.

public void testMessageFromNewView() {
    Address b = Util.createRandomAddress("B");
    // view {1|A}
    setInitialView(localAddress, localAddress);
    ToaHeader header = ToaHeader.newDataMessageHeader(new MessageID(b, 1), 2);
    Message message = newMessage(header, b, localAddress);
    // message from node B to A from view 2.
    // B isn't in the view but the message is accepted
    toa.up(message);
    assertProposedMessageSent(0);
    assertFirstMessage(0, false);
    // view {2|A,B}
    // message is kept
    setView(localAddress, 2, localAddress, b);
    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 5 with ToaHeader

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

the class TOA_UnitTest method testDataMessageFromNonMember.

public void testDataMessageFromNonMember() {
    Address b = Util.createRandomAddress("B");
    Address c = Util.createRandomAddress("C");
    setInitialView(localAddress, localAddress, b);
    ToaHeader header = ToaHeader.newDataMessageHeader(new MessageID(c, 1), 1);
    Message message = newMessage(header, c, localAddress);
    // Message from member C. it isn't in the view and the message should be discarded.
    toa.up(message);
    assertEquals("Deliver Manager doesn't have an empty list", Collections.emptyList(), deliveryManager().getAllMessages());
    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

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