use of org.jgroups.protocols.relay.RELAY2 in project wildfly by wildfly.
the class ProtocolResourceRegistrationHandler method execute.
@Override
public void execute(OperationContext context, ModelNode operation) throws OperationFailedException {
OverrideDescriptionProvider provider = new OverrideDescriptionProvider() {
@Override
public Map<String, ModelNode> getAttributeOverrideDescriptions(Locale locale) {
return Collections.emptyMap();
}
@Override
public Map<String, ModelNode> getChildTypeOverrideDescriptions(Locale locale) {
StandardResourceDescriptionResolver resolver = new JGroupsResourceDescriptionResolver();
String description = resolver.getChildTypeDescription(ProtocolResourceDefinition.WILDCARD_PATH.getKey(), locale, resolver.getResourceBundle(locale));
ModelNode result = new ModelNode();
result.get(ModelDescriptionConstants.DESCRIPTION).set(description);
return Collections.singletonMap(ProtocolResourceDefinition.WILDCARD_PATH.getKey(), result);
}
};
Resource resource = context.readResourceForUpdate(PathAddress.EMPTY_ADDRESS);
String stack = STACK.resolveModelAttribute(context, resource.getModel()).asString();
ManagementResourceRegistration registration = context.getResourceRegistrationForUpdate().registerOverrideModel(context.getCurrentAddressValue(), provider);
PathAddress stackAddress = context.getCurrentAddress().getParent().append(StackResourceDefinition.pathElement(stack));
Resource stackResource = context.readResourceFromRoot(stackAddress, false);
for (String name : stackResource.getChildrenNames(TransportResourceDefinition.WILDCARD_PATH.getKey())) {
PathAddress transportAddress = stackAddress.append(TransportResourceDefinition.pathElement(name));
ModelNode transport = context.readResourceFromRoot(transportAddress, false).getModel();
String moduleName = MODULE.resolveModelAttribute(context, transport).asString();
Class<? extends Protocol> transportClass = findProtocolClass(context, name, moduleName);
registration.registerSubModel(this.createProtocolResourceDefinition(name, transportClass));
resource.registerChild(ProtocolResourceDefinition.pathElement(name), PlaceholderResource.INSTANCE);
}
for (String name : stackResource.getChildrenNames(ProtocolResourceDefinition.WILDCARD_PATH.getKey())) {
Resource protocolResource = context.readResourceFromRoot(stackAddress.append(ProtocolResourceDefinition.pathElement(name)), false);
String moduleName = MODULE.resolveModelAttribute(context, protocolResource.getModel()).asString();
Class<? extends Protocol> protocolClass = findProtocolClass(context, name, moduleName);
registration.registerSubModel(this.createProtocolResourceDefinition(name, protocolClass));
resource.registerChild(ProtocolResourceDefinition.pathElement(name), PlaceholderResource.INSTANCE);
}
if (stackResource.hasChild(RelayResourceDefinition.PATH)) {
registration.registerSubModel(this.createProtocolResourceDefinition(RelayConfiguration.PROTOCOL_NAME, RELAY2.class));
resource.registerChild(ProtocolResourceDefinition.pathElement(RelayConfiguration.PROTOCOL_NAME), PlaceholderResource.INSTANCE);
}
}
use of org.jgroups.protocols.relay.RELAY2 in project JGroups by belaban.
the class Relay2RpcDispatcherTest method createRELAY2.
protected RELAY2 createRELAY2(String site_name) {
RELAY2 relay = new RELAY2().site(site_name).enableAddressTagging(false).asyncRelayCreation(true).relayMulticasts(true);
RelayConfig.SiteConfig lon_cfg = new RelayConfig.SiteConfig(LON), sfo_cfg = new RelayConfig.SiteConfig(SFO);
lon_cfg.addBridge(new RelayConfig.ProgrammaticBridgeConfig(BRIDGE_CLUSTER, createBridgeStack()));
sfo_cfg.addBridge(new RelayConfig.ProgrammaticBridgeConfig(BRIDGE_CLUSTER, createBridgeStack()));
relay.addSite(LON, lon_cfg).addSite(SFO, sfo_cfg);
return relay;
}
use of org.jgroups.protocols.relay.RELAY2 in project JGroups by belaban.
the class Relay2RpcDispatcherTest method waitForBridgeView.
protected void waitForBridgeView(int expected_size, long timeout, long interval, JChannel... channels) {
long deadline = System.currentTimeMillis() + timeout;
while (System.currentTimeMillis() < deadline) {
boolean views_correct = true;
for (JChannel ch : channels) {
RELAY2 relay = ch.getProtocolStack().findProtocol(RELAY2.class);
View bridge_view = relay.getBridgeView(BRIDGE_CLUSTER);
if (bridge_view == null || bridge_view.size() != expected_size) {
views_correct = false;
break;
}
}
if (views_correct)
break;
Util.sleep(interval);
}
System.out.println("Bridge views:\n");
for (JChannel ch : channels) {
RELAY2 relay = ch.getProtocolStack().findProtocol(RELAY2.class);
View bridge_view = relay.getBridgeView(BRIDGE_CLUSTER);
System.out.println(ch.getAddress() + ": " + bridge_view);
}
for (JChannel ch : channels) {
RELAY2 relay = ch.getProtocolStack().findProtocol(RELAY2.class);
View bridge_view = relay.getBridgeView(BRIDGE_CLUSTER);
assert bridge_view != null && bridge_view.size() == expected_size : ch.getAddress() + ": bridge view=" + bridge_view + ", expected=" + expected_size;
}
}
use of org.jgroups.protocols.relay.RELAY2 in project JGroups by belaban.
the class Relay2Test method createRELAY2.
protected RELAY2 createRELAY2(String site_name) {
RELAY2 relay = new RELAY2().site(site_name).enableAddressTagging(false).asyncRelayCreation(false);
RelayConfig.SiteConfig lon_cfg = new RelayConfig.SiteConfig(LON), sfo_cfg = new RelayConfig.SiteConfig(SFO);
lon_cfg.addBridge(new RelayConfig.ProgrammaticBridgeConfig(BRIDGE_CLUSTER, createBridgeStack()));
sfo_cfg.addBridge(new RelayConfig.ProgrammaticBridgeConfig(BRIDGE_CLUSTER, createBridgeStack()));
relay.addSite(LON, lon_cfg).addSite(SFO, sfo_cfg);
return relay;
}
use of org.jgroups.protocols.relay.RELAY2 in project JGroups by belaban.
the class Relay2Test method testMissingRouteAfterMerge.
/**
* Tests that routes are correctly registered after a partition and a subsequent merge
* (https://issues.jboss.org/browse/JGRP-1524)
*/
public void testMissingRouteAfterMerge() throws Exception {
a = createNode(LON, "A", LON_CLUSTER, null);
b = createNode(LON, "B", LON_CLUSTER, null);
Util.waitUntilAllChannelsHaveSameView(30000, 1000, a, b);
x = createNode(SFO, "X", SFO_CLUSTER, null);
assert x.getView().size() == 1;
RELAY2 ar = a.getProtocolStack().findProtocol(RELAY2.class), xr = x.getProtocolStack().findProtocol(RELAY2.class);
assert ar != null && xr != null;
JChannel a_bridge = null, x_bridge = null;
for (int i = 0; i < 20; i++) {
a_bridge = ar.getBridge(SFO);
x_bridge = xr.getBridge(LON);
if (a_bridge != null && x_bridge != null && a_bridge.getView().size() == 2 && x_bridge.getView().size() == 2)
break;
Util.sleep(500);
}
assert a_bridge != null && x_bridge != null;
System.out.println("A's bridge channel: " + a_bridge.getView());
System.out.println("X's bridge channel: " + x_bridge.getView());
assert a_bridge.getView().size() == 2 : "bridge view is " + a_bridge.getView();
assert x_bridge.getView().size() == 2 : "bridge view is " + x_bridge.getView();
Route route = getRoute(x, LON);
System.out.println("Route at sfo to lon: " + route);
assert route != null;
// Now inject a partition into site LON
System.out.println("Creating partition between A and B:");
createPartition(a, b);
System.out.println("A's view: " + a.getView() + "\nB's view: " + b.getView());
assert a.getView().size() == 1 && b.getView().size() == 1;
route = getRoute(x, LON);
System.out.println("Route at sfo to lon: " + route);
assert route != null;
View bridge_view = xr.getBridgeView(BRIDGE_CLUSTER);
System.out.println("bridge_view = " + bridge_view);
// Now make A and B form a cluster again:
View merge_view = new MergeView(a.getAddress(), 10, Arrays.asList(a.getAddress(), b.getAddress()), Arrays.asList(View.create(a.getAddress(), 5, a.getAddress()), View.create(b.getAddress(), 5, b.getAddress())));
GMS gms = a.getProtocolStack().findProtocol(GMS.class);
gms.installView(merge_view, null);
gms = b.getProtocolStack().findProtocol(GMS.class);
gms.installView(merge_view, null);
Util.waitUntilAllChannelsHaveSameView(20000, 500, a, b);
System.out.println("A's view: " + a.getView() + "\nB's view: " + b.getView());
for (int i = 0; i < 20; i++) {
bridge_view = xr.getBridgeView(BRIDGE_CLUSTER);
if (bridge_view != null && bridge_view.size() == 2)
break;
Util.sleep(500);
}
route = getRoute(x, LON);
System.out.println("Route at sfo to lon: " + route);
assert route != null;
}
Aggregations