Permalink
Browse files

Waiting until we have a bridge view of 2 members at X

  • Loading branch information...
1 parent 9c895d8 commit 1188671abad3cd21609907bb78b9caa69f109e06 Bela Ban committed Oct 16, 2012
@@ -91,6 +91,10 @@ public RELAY2 addSite(String site_name, RelayConfig.SiteConfig cfg) {
return this;
}
+ public View getBridgeView(String cluster_name) {
+ Relayer tmp=relayer;
+ return tmp != null? tmp.getBridgeView(cluster_name) : null;
+ }
public void init() throws Exception {
super.init();
@@ -142,6 +142,16 @@ protected synchronized Route getRoute(short site) {
return retval;
}
+ protected View getBridgeView(String cluster_name) {
+ if(cluster_name == null)
+ return null;
+ for(Bridge bridge: bridges) {
+ if(bridge.cluster_name != null && bridge.cluster_name.equals(cluster_name))
+ return bridge.view;
+ }
+ return null;
+ }
+
protected static boolean isExcluded(Route route, short... excluded_sites) {
if(excluded_sites == null)
return false;
@@ -30,6 +30,8 @@
protected JChannel a, b, c; // members in site "lon"
protected JChannel x, y, z; // members in site "sfo"
+ protected static final String BRIDGE_CLUSTER="global";
+
@AfterMethod protected void destroy() {Util.close(z,y,x,c,b,a);}
@@ -80,6 +82,9 @@ public void testMissingRouteAfterMerge() throws Exception {
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(Util.createView(a.getAddress(), 5, a.getAddress()),
@@ -92,6 +97,13 @@ public void testMissingRouteAfterMerge() throws Exception {
Util.waitUntilAllChannelsHaveSameSize(30000, 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=xr.getRoute("lon");
System.out.println("Route at sfo to lon: " + route);
assert route != null;
@@ -119,8 +131,8 @@ protected RELAY2 createRELAY2(String site_name) {
RelayConfig.SiteConfig lon_cfg=new RelayConfig.SiteConfig("lon", (short)0),
sfo_cfg=new RelayConfig.SiteConfig("sfo", (short)1);
- lon_cfg.addBridge(new RelayConfig.ProgrammaticBridgeConfig("global", createBridgeStack()));
- sfo_cfg.addBridge(new RelayConfig.ProgrammaticBridgeConfig("global", createBridgeStack()));
+ 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;

0 comments on commit 1188671

Please sign in to comment.