Show exception
@@ -36,7 +36,7 @@ public class Infinispan110FailureEmbeddedService extends Infinispan110EmbeddedSe
bridgeChannel.getProtocolStack().insertProtocol(discard, ProtocolStack.Position.ABOVE, TP.class);
}
} catch (Exception e) {
- throw new IllegalStateException("Cannot createFailure");
+ throw new IllegalStateException("Cannot createFailure", e);
}
}
@@ -47,12 +47,15 @@ public class Infinispan110FailureEmbeddedService extends Infinispan110EmbeddedSe
bridgeChannel.getProtocolStack().removeProtocol(DISCARD.class);
}
} catch (Exception e) {
- throw new IllegalStateException("Cannot solveFailure");
+ throw new IllegalStateException("Cannot solveFailure", e);
}
}
@Override
public boolean checkIfFailurePresent(String action, Object expectedValue) {
+ RELAY2 relay2 = getRELAY2();
+
+ if (relay2.isSiteMaster()) {
int total = Integer.valueOf(expectedValue.toString());
boolean match = false;
long max = 60000;
@@ -70,23 +73,27 @@ public class Infinispan110FailureEmbeddedService extends Infinispan110EmbeddedSe
}
}
return match;
+ } else {
+ return true;
+ }
}
private List<JChannel> getBridgeChannels() throws NoSuchFieldException, IllegalAccessException {
- JGroupsTransport transport = (JGroupsTransport) cacheManager.getTransport();
- RELAY2 relay2 = transport.getChannel().getProtocolStack().findProtocol("RELAY2");
+ List<JChannel> bridgeChannels = new ArrayList<>();
+
+ RELAY2 relay2 = getRELAY2();
+
+ if (relay2.isSiteMaster()) {
+
Field field = relay2.getClass().getDeclaredField("relayer");
field.setAccessible(true);
Relayer relayer = (Relayer) field.get(relay2);
-
field = relayer.getClass().getDeclaredField("bridges");
field.setAccessible(true);
Queue<Object> bridges = (Queue<Object>) field.get(relayer);
Iterator<Object> iterator = bridges.iterator();
- List<JChannel> bridgeChannels = new ArrayList<>();
-
while (iterator.hasNext()) {
Object object = iterator.next();
field = object.getClass().getDeclaredField("channel");
@@ -95,9 +102,16 @@ public class Infinispan110FailureEmbeddedService extends Infinispan110EmbeddedSe
JChannel jChannel = (JChannel) field.get(object);
bridgeChannels.add(jChannel);
}
+ }
return bridgeChannels;
}
+
+ private RELAY2 getRELAY2() {
+ JGroupsTransport transport = (JGroupsTransport) cacheManager.getTransport();
+ RELAY2 relay2 = transport.getChannel().getProtocolStack().findProtocol("RELAY2");
+ return relay2;
+ }
};
}
}
