Search in sources :

Example 6 with HighPriorityAckedMessage

use of org.apache.geode.distributed.internal.HighPriorityAckedMessage in project geode by apache.

the class GMSMembershipManagerJUnitTest method testSendMessage.

@Test
public void testSendMessage() throws Exception {
    HighPriorityAckedMessage m = new HighPriorityAckedMessage();
    m.setRecipient(mockMembers[0]);
    manager.start();
    manager.started();
    manager.installView(new NetView(myMemberId, 1, members));
    Set<InternalDistributedMember> failures = manager.send(m);
    verify(messenger).send(m);
    if (failures != null) {
        assertEquals(0, failures.size());
    }
}
Also used : HighPriorityAckedMessage(org.apache.geode.distributed.internal.HighPriorityAckedMessage) InternalDistributedMember(org.apache.geode.distributed.internal.membership.InternalDistributedMember) NetView(org.apache.geode.distributed.internal.membership.NetView) Test(org.junit.Test) MembershipTest(org.apache.geode.test.junit.categories.MembershipTest) IntegrationTest(org.apache.geode.test.junit.categories.IntegrationTest)

Example 7 with HighPriorityAckedMessage

use of org.apache.geode.distributed.internal.HighPriorityAckedMessage in project geode by apache.

the class GMSMembershipManagerJUnitTest method testDirectChannelSendFailureToOneRecipient.

@Test
public void testDirectChannelSendFailureToOneRecipient() throws Exception {
    setUpDirectChannelMock();
    HighPriorityAckedMessage m = new HighPriorityAckedMessage();
    InternalDistributedMember[] recipients = new InternalDistributedMember[] { mockMembers[2], mockMembers[3] };
    m.setRecipients(Arrays.asList(recipients));
    Set<InternalDistributedMember> failures = manager.directChannelSend(recipients, m, null);
    ConnectExceptions exception = new ConnectExceptions();
    exception.addFailure(recipients[0], new Exception("testing"));
    when(dc.send(any(GMSMembershipManager.class), any(mockMembers.getClass()), any(DistributionMessage.class), anyInt(), anyInt())).thenThrow(exception);
    failures = manager.directChannelSend(recipients, m, null);
    assertTrue(failures != null);
    assertEquals(1, failures.size());
    assertEquals(recipients[0], failures.iterator().next());
}
Also used : HighPriorityAckedMessage(org.apache.geode.distributed.internal.HighPriorityAckedMessage) InternalDistributedMember(org.apache.geode.distributed.internal.membership.InternalDistributedMember) ConnectExceptions(org.apache.geode.internal.tcp.ConnectExceptions) DistributionMessage(org.apache.geode.distributed.internal.DistributionMessage) DistributedSystemDisconnectedException(org.apache.geode.distributed.DistributedSystemDisconnectedException) Test(org.junit.Test) MembershipTest(org.apache.geode.test.junit.categories.MembershipTest) IntegrationTest(org.apache.geode.test.junit.categories.IntegrationTest)

Example 8 with HighPriorityAckedMessage

use of org.apache.geode.distributed.internal.HighPriorityAckedMessage in project geode by apache.

the class GMSMembershipManagerJUnitTest method testSendToEmptyListIsRejected.

@Test
public void testSendToEmptyListIsRejected() throws Exception {
    InternalDistributedMember[] emptyList = new InternalDistributedMember[0];
    HighPriorityAckedMessage m = new HighPriorityAckedMessage();
    m.setRecipient(mockMembers[0]);
    manager.start();
    manager.started();
    manager.installView(new NetView(myMemberId, 1, members));
    Set<InternalDistributedMember> failures = manager.send(null, m, null);
    verify(messenger, never()).send(m);
    reset(messenger);
    failures = manager.send(emptyList, m, null);
    verify(messenger, never()).send(m);
}
Also used : InternalDistributedMember(org.apache.geode.distributed.internal.membership.InternalDistributedMember) HighPriorityAckedMessage(org.apache.geode.distributed.internal.HighPriorityAckedMessage) NetView(org.apache.geode.distributed.internal.membership.NetView) Test(org.junit.Test) MembershipTest(org.apache.geode.test.junit.categories.MembershipTest) IntegrationTest(org.apache.geode.test.junit.categories.IntegrationTest)

Example 9 with HighPriorityAckedMessage

use of org.apache.geode.distributed.internal.HighPriorityAckedMessage in project geode by apache.

the class GMSMembershipManagerJUnitTest method testDirectChannelSendFailureToAll.

@Test
public void testDirectChannelSendFailureToAll() throws Exception {
    setUpDirectChannelMock();
    HighPriorityAckedMessage m = new HighPriorityAckedMessage();
    InternalDistributedMember[] recipients = new InternalDistributedMember[] { mockMembers[2], mockMembers[3] };
    m.setRecipients(Arrays.asList(recipients));
    Set<InternalDistributedMember> failures = manager.directChannelSend(recipients, m, null);
    when(dc.send(any(GMSMembershipManager.class), any(mockMembers.getClass()), any(DistributionMessage.class), anyInt(), anyInt())).thenReturn(0);
    when(stopper.isCancelInProgress()).thenReturn(Boolean.TRUE);
    try {
        manager.directChannelSend(recipients, m, null);
        fail("expected directChannelSend to throw an exception");
    } catch (DistributedSystemDisconnectedException expected) {
    }
}
Also used : DistributedSystemDisconnectedException(org.apache.geode.distributed.DistributedSystemDisconnectedException) HighPriorityAckedMessage(org.apache.geode.distributed.internal.HighPriorityAckedMessage) InternalDistributedMember(org.apache.geode.distributed.internal.membership.InternalDistributedMember) DistributionMessage(org.apache.geode.distributed.internal.DistributionMessage) Test(org.junit.Test) MembershipTest(org.apache.geode.test.junit.categories.MembershipTest) IntegrationTest(org.apache.geode.test.junit.categories.IntegrationTest)

Aggregations

HighPriorityAckedMessage (org.apache.geode.distributed.internal.HighPriorityAckedMessage)9 InternalDistributedMember (org.apache.geode.distributed.internal.membership.InternalDistributedMember)9 MembershipTest (org.apache.geode.test.junit.categories.MembershipTest)9 Test (org.junit.Test)9 IntegrationTest (org.apache.geode.test.junit.categories.IntegrationTest)8 DistributionMessage (org.apache.geode.distributed.internal.DistributionMessage)5 DistributedSystemDisconnectedException (org.apache.geode.distributed.DistributedSystemDisconnectedException)3 NetView (org.apache.geode.distributed.internal.membership.NetView)3 ConnectExceptions (org.apache.geode.internal.tcp.ConnectExceptions)2 File (java.io.File)1 IOException (java.io.IOException)1 Properties (java.util.Properties)1 LogWriter (org.apache.geode.LogWriter)1 DistributionManager (org.apache.geode.distributed.internal.DistributionManager)1 InternalDistributedSystem (org.apache.geode.distributed.internal.InternalDistributedSystem)1 InternalLocator (org.apache.geode.distributed.internal.InternalLocator)1 SuspectMember (org.apache.geode.distributed.internal.membership.gms.SuspectMember)1 StartupEvent (org.apache.geode.distributed.internal.membership.gms.mgr.GMSMembershipManager.StartupEvent)1 InternalLogWriter (org.apache.geode.internal.logging.InternalLogWriter)1 LocalLogWriter (org.apache.geode.internal.logging.LocalLogWriter)1