try { Thread.sleep(1000); } catch( InterruptedException i) {} // Wait some time
assertTrue(assertInUpdate, assertInUpdate == null);
assertInUpdate = null;
System.err.println("->Check if the message has reached the master node heron ...");
GetKey gk = new GetKey(glob, oid);
MsgUnit[] msgs = heronCon.get(gk.toXml(), null);
assertTrue("Invalid msgs returned", msgs != null);
assertEquals("Invalid number of messages returned", 1, msgs.length);
assertTrue("Invalid message oid returned", msgs[0].getKey().indexOf(oid) > 0);
log.info("SUCCESS: Got message:" + msgs[0].getKey());
System.err.println("->Check if the message is available at the slave node bilbo ...");
gk = new GetKey(glob, oid);
gk.setDomain(domain);
msgs = bilboCon.get(gk.toXml(), null);
assertTrue("Invalid msgs returned", msgs != null);
assertEquals("Invalid number of messages returned", 1, msgs.length);
log.info("SUCCESS: Got message:" + msgs[0].getKey());
System.err.println("->Trying to erase the message at the slave node ...");
EraseKey ek = new EraseKey(glob, oid);
ek.setDomain(domain);
EraseQos eq = new EraseQos(glob);
bilboCon.erase(ek.toXml(), eq.toXml());
// Check if erased ...
gk = new GetKey(glob, oid);
msgs = heronCon.get(gk.toXml(), null);
assertTrue("Invalid msgs returned", msgs != null);
assertEquals("Invalid number of messages returned", 0, msgs.length);
log.info("SUCCESS: Got no message after erase");
System.err.println("***PublishTest: Publish a message to a cluster slave - frodo is offline ...");
System.err.println("->Subscribe from heron, the message is currently erased ...");
SubscribeKey sk = new SubscribeKey(glob, oid);
sk.setDomain(domain);
SubscribeQos sq = new SubscribeQos(glob);
SubscribeReturnQos srq = heronCon.subscribe(sk.toXml(), sq.toXml(), new I_Callback() {
public String update(String cbSessionId, UpdateKey updateKey, byte[] content, UpdateQos updateQos) {
assertInUpdate = serverHelper.getHeronGlob().getId() + ": Receiving unexpected asynchronous update message";
assertEquals(assertInUpdate, oid, updateKey.getOid());
assertInUpdate = serverHelper.getHeronGlob().getId() + ": Receiving corrupted asynchronous update message";
assertEquals(assertInUpdate, contentStr, new String(content));
log.info("heronCon - Receiving asynchronous message '" + updateKey.getOid() + "' in " + oid + " handler, state=" + updateQos.getState());
updateCounterHeron++;
assertInUpdate = null;
return "";
}
}); // subscribe with our specific update handler
try { Thread.sleep(1000); } catch( InterruptedException i) {} // Wait some time
assertTrue(assertInUpdate, assertInUpdate == null);
assertInUpdate = null;
serverHelper.stopFrodo();
System.err.println("->Check: heron hasn't got the message ...");
gk = new GetKey(glob, oid);
msgs = heronCon.get(gk.toXml(), null);
assertTrue("Invalid msgs returned", msgs != null);
assertEquals("Invalid number of messages returned", 0, msgs.length);
log.info("SUCCESS: Got no message after erase");
// publish again ...