use of org.apache.geode.distributed.internal.membership.gms.Services in project geode by apache.
the class StatRecorderJUnitTest method recorderHandlesRejectedExecution.
@Test
public void recorderHandlesRejectedExecution() throws Exception {
Message msg = mock(Message.class);
when(msg.getHeader(any(Short.class))).thenReturn(Header.createDataHeader(1L, (short) 1, true));
when(msg.size()).thenReturn(150L);
// GEODE-1178, the TP protocol may throw a RejectedExecutionException & StatRecorder should
// retry
when(mockDownProtocol.down(any(Event.class))).thenThrow(new RejectedExecutionException());
// after the first down() throws an exception we want StatRecorder to retry, so
// we set the Manager to say no shutdown is in progress the first time and then say
// one IS in progress so we can break out of the StatRecorder exception handling loop
when(services.getCancelCriterion()).thenReturn(new Services().getCancelCriterion());
Manager manager = mock(Manager.class);
when(services.getManager()).thenReturn(manager);
when(manager.shutdownInProgress()).thenReturn(Boolean.FALSE, Boolean.TRUE);
verify(mockDownProtocol, never()).down(isA(Event.class));
Event evt = new Event(Event.MSG, msg);
recorder.down(evt);
verify(mockDownProtocol, times(2)).down(isA(Event.class));
}
use of org.apache.geode.distributed.internal.membership.gms.Services in project geode by apache.
the class StatRecorderJUnitTest method messengerStackHoldsStatRecorder.
/**
* Ensure that the messenger JGroups configuration XML strings contain the statistics recorder
* protocol
*/
@Test
public void messengerStackHoldsStatRecorder() throws Exception {
Services mockServices = mock(Services.class);
ServiceConfig mockConfig = mock(ServiceConfig.class);
when(mockServices.getConfig()).thenReturn(mockConfig);
// first test to see if the non-multicast stack has the recorder installed
Properties nonDefault = new Properties();
nonDefault.put(MCAST_PORT, "0");
nonDefault.put(LOCATORS, "localhost[12345]");
DistributionConfigImpl config = new DistributionConfigImpl(nonDefault);
when(mockConfig.getDistributionConfig()).thenReturn(config);
RemoteTransportConfig transport = new RemoteTransportConfig(config, DistributionManager.NORMAL_DM_TYPE);
when(mockConfig.getTransport()).thenReturn(transport);
JGroupsMessenger messenger = new JGroupsMessenger();
messenger.init(mockServices);
String jgroupsConfig = messenger.getJGroupsStackConfig();
System.out.println(jgroupsConfig);
assertTrue(jgroupsConfig.contains("gms.messenger.StatRecorder"));
// now test to see if the multicast stack has the recorder installed
nonDefault.put(MCAST_PORT, "12345");
config = new DistributionConfigImpl(nonDefault);
transport = new RemoteTransportConfig(config, DistributionManager.NORMAL_DM_TYPE);
when(mockConfig.getDistributionConfig()).thenReturn(config);
when(mockConfig.getTransport()).thenReturn(transport);
messenger = new JGroupsMessenger();
messenger.init(mockServices);
assertTrue(jgroupsConfig.contains("gms.messenger.StatRecorder"));
}
use of org.apache.geode.distributed.internal.membership.gms.Services in project geode by apache.
the class GMSEncryptJUnitTest method initMocks.
private void initMocks(String algo) throws Exception {
Properties nonDefault = new Properties();
nonDefault.put(ConfigurationProperties.SECURITY_UDP_DHALGO, algo);
DistributionConfigImpl config = new DistributionConfigImpl(nonDefault);
RemoteTransportConfig tconfig = new RemoteTransportConfig(config, DistributionManager.NORMAL_DM_TYPE);
ServiceConfig serviceConfig = new ServiceConfig(tconfig, config);
services = mock(Services.class);
when(services.getConfig()).thenReturn(serviceConfig);
mockMembers = new InternalDistributedMember[4];
for (int i = 0; i < mockMembers.length; i++) {
mockMembers[i] = new InternalDistributedMember("localhost", 8888 + i);
}
int viewId = 1;
List<InternalDistributedMember> mbrs = new LinkedList<>();
mbrs.add(mockMembers[0]);
mbrs.add(mockMembers[1]);
mbrs.add(mockMembers[2]);
// prepare the view
netView = new NetView(mockMembers[0], viewId, mbrs);
}
use of org.apache.geode.distributed.internal.membership.gms.Services in project geode by apache.
the class GMSJoinLeaveJUnitTest method initMocks.
public void initMocks(boolean enableNetworkPartition, boolean useTestGMSJoinLeave) throws UnknownHostException {
mockDistConfig = mock(DistributionConfig.class);
when(mockDistConfig.getEnableNetworkPartitionDetection()).thenReturn(enableNetworkPartition);
when(mockDistConfig.getLocators()).thenReturn("localhost[8888]");
when(mockDistConfig.getSecurityUDPDHAlgo()).thenReturn("");
mockConfig = mock(ServiceConfig.class);
when(mockDistConfig.getStartLocator()).thenReturn("localhost[12345]");
when(mockConfig.getDistributionConfig()).thenReturn(mockDistConfig);
when(mockDistConfig.getLocators()).thenReturn("localhost[12345]");
when(mockDistConfig.getMcastPort()).thenReturn(0);
when(mockDistConfig.getMemberTimeout()).thenReturn(2000);
authenticator = mock(Authenticator.class);
gmsJoinLeaveMemberId = new InternalDistributedMember("localhost", 8887);
messenger = mock(Messenger.class);
when(messenger.getMemberID()).thenReturn(gmsJoinLeaveMemberId);
stopper = mock(Stopper.class);
when(stopper.isCancelInProgress()).thenReturn(false);
manager = mock(Manager.class);
healthMonitor = mock(HealthMonitor.class);
when(healthMonitor.getFailureDetectionPort()).thenReturn(Integer.valueOf(-1));
services = mock(Services.class);
when(services.getAuthenticator()).thenReturn(authenticator);
when(services.getConfig()).thenReturn(mockConfig);
when(services.getMessenger()).thenReturn(messenger);
when(services.getCancelCriterion()).thenReturn(stopper);
when(services.getManager()).thenReturn(manager);
when(services.getHealthMonitor()).thenReturn(healthMonitor);
Timer t = new Timer(true);
when(services.getTimer()).thenReturn(t);
mockMembers = new InternalDistributedMember[4];
for (int i = 0; i < mockMembers.length; i++) {
mockMembers[i] = new InternalDistributedMember("localhost", 8888 + i);
}
mockOldMember = new InternalDistributedMember("localhost", 8700, Version.GFE_56);
if (useTestGMSJoinLeave) {
gmsJoinLeave = new GMSJoinLeaveTest();
} else {
gmsJoinLeave = new GMSJoinLeave();
}
gmsJoinLeave.init(services);
gmsJoinLeave.start();
gmsJoinLeave.started();
}
use of org.apache.geode.distributed.internal.membership.gms.Services in project geode by apache.
the class GMSJoinLeaveTestHelper method getGmsJoinLeave.
private static GMSJoinLeave getGmsJoinLeave() {
InternalDistributedSystem distributedSystem = getInternalDistributedSystem();
DM dm = distributedSystem.getDM();
GMSMembershipManager membershipManager = (GMSMembershipManager) dm.getMembershipManager();
Services services = membershipManager.getServices();
return (GMSJoinLeave) services.getJoinLeave();
}
Aggregations