use of org.jgroups.JChannel in project wildfly by wildfly.
the class RelayConfigurationBuilder method accept.
@Override
public void accept(RELAY2 protocol) {
String localSite = this.siteName;
List<RemoteSiteConfiguration> remoteSites = this.getRemoteSites();
List<String> sites = new ArrayList<>(remoteSites.size() + 1);
sites.add(localSite);
// Collect bridges, eliminating duplicates
Map<String, RelayConfig.BridgeConfig> bridges = new HashMap<>();
for (final RemoteSiteConfiguration remoteSite : remoteSites) {
String siteName = remoteSite.getName();
sites.add(siteName);
String clusterName = remoteSite.getClusterName();
RelayConfig.BridgeConfig bridge = new RelayConfig.BridgeConfig(clusterName) {
@Override
public JChannel createChannel() throws Exception {
JChannel channel = (JChannel) remoteSite.getChannelFactory().createChannel(siteName);
// Don't use FORK in bridge stack
channel.getProtocolStack().removeProtocol(FORK.class);
return channel;
}
};
bridges.put(clusterName, bridge);
}
protocol.site(localSite);
for (String site : sites) {
RelayConfig.SiteConfig siteConfig = new RelayConfig.SiteConfig(site);
protocol.addSite(site, siteConfig);
if (site.equals(localSite)) {
for (RelayConfig.BridgeConfig bridge : bridges.values()) {
siteConfig.addBridge(bridge);
}
}
}
}
use of org.jgroups.JChannel in project geode by apache.
the class JGroupsMessengerJUnitTest method testSendWhenChannelIsClosed.
@Test
public void testSendWhenChannelIsClosed() throws Exception {
for (int i = 0; i < 2; i++) {
initMocks(false);
JChannel mockChannel = mock(JChannel.class);
when(mockChannel.isConnected()).thenReturn(false);
doThrow(new RuntimeException()).when(mockChannel).send(any(Message.class));
JChannel realChannel = messenger.myChannel;
messenger.myChannel = mockChannel;
try {
InternalDistributedMember mbr = createAddress(8888);
DistributedCacheOperation.CacheOperationMessage msg = mock(DistributedCacheOperation.CacheOperationMessage.class);
when(msg.getRecipients()).thenReturn(new InternalDistributedMember[] { mbr });
when(msg.getMulticast()).thenReturn(false);
when(msg.getProcessorId()).thenReturn(1234);
try {
messenger.send(msg);
fail("expected a failure");
} catch (DistributedSystemDisconnectedException e) {
// success
}
verify(mockChannel, never()).send(isA(Message.class));
} finally {
messenger.myChannel = realChannel;
}
}
}
use of org.jgroups.JChannel in project geode by apache.
the class JGroupsMessengerJUnitTest method testJChannelErrorDuringDisconnect.
@Test
public void testJChannelErrorDuringDisconnect() throws Exception {
for (int i = 0; i < 4; i++) {
System.out.println("loop #" + i);
boolean enableMcast = (i % 2 == 1);
initMocks(enableMcast);
JChannel mockChannel = mock(JChannel.class);
when(mockChannel.isConnected()).thenReturn(true);
Exception ex, shutdownCause;
if (i < 2) {
ex = new RuntimeException("");
shutdownCause = new RuntimeException("shutdownCause");
} else {
shutdownCause = new ForcedDisconnectException("");
ex = new RuntimeException("", shutdownCause);
}
doThrow(ex).when(mockChannel).send(any(Message.class));
JChannel realChannel = messenger.myChannel;
messenger.myChannel = mockChannel;
when(services.getShutdownCause()).thenReturn(shutdownCause);
try {
InternalDistributedMember mbr = createAddress(8888);
DistributedCacheOperation.CacheOperationMessage msg = mock(DistributedCacheOperation.CacheOperationMessage.class);
when(msg.getRecipients()).thenReturn(new InternalDistributedMember[] { mbr });
when(msg.getMulticast()).thenReturn(enableMcast);
when(msg.getProcessorId()).thenReturn(1234);
when(msg.getDSFID()).thenReturn((int) DataSerializableFixedID.PUT_ALL_MESSAGE);
try {
messenger.send(msg);
fail("expected a failure");
} catch (DistributedSystemDisconnectedException e) {
// the ultimate cause should be the shutdownCause returned
// by Services.getShutdownCause()
Throwable cause = e;
while (cause.getCause() != null) {
cause = cause.getCause();
}
assertTrue(cause != e);
assertTrue(cause == shutdownCause);
}
verify(mockChannel).send(isA(Message.class));
} finally {
messenger.myChannel = realChannel;
}
}
}
use of org.jgroups.JChannel in project geode by apache.
the class JGroupsMessengerJUnitTest method testUseOldJChannel.
@Test
public void testUseOldJChannel() throws Exception {
initMocks(false);
JChannel channel = messenger.myChannel;
services.getConfig().getTransport().setOldDSMembershipInfo(channel);
JGroupsMessenger newMessenger = new JGroupsMessenger();
newMessenger.init(services);
newMessenger.start();
newMessenger.started();
newMessenger.stop();
assertTrue(newMessenger.myChannel == messenger.myChannel);
}
Aggregations