Search in sources :

Example 1 with Pacemaker

use of org.apache.storm.pacemaker.Pacemaker in project storm by apache.

the class PacemakerTest method testServerGetPulse.

@Test
public void testServerGetPulse() {
    Pacemaker handler = new Pacemaker(new ConcurrentHashMap());
    makeNode(handler, "/some-root/GET_PULSE");
    messageWithRandId(HBServerMessageType.GET_PULSE, HBMessageData.path("/some-root/GET_PULSE"));
    HBMessage badResponse = handler.handleMessage(hbMessage, false);
    HBMessage goodResponse = handler.handleMessage(hbMessage, true);
    HBPulse goodPulse = goodResponse.get_data().get_pulse();
    Assert.assertEquals(mid, badResponse.get_message_id());
    Assert.assertEquals(HBServerMessageType.NOT_AUTHORIZED, badResponse.get_type());
    Assert.assertNull(badResponse.get_data());
    Assert.assertEquals(mid, goodResponse.get_message_id());
    Assert.assertEquals(HBServerMessageType.GET_PULSE_RESPONSE, goodResponse.get_type());
    Assert.assertEquals("/some-root/GET_PULSE", goodPulse.get_id());
    Assert.assertEquals("nothing", Utils.javaDeserialize(goodPulse.get_details(), String.class));
}
Also used : HBPulse(org.apache.storm.generated.HBPulse) Pacemaker(org.apache.storm.pacemaker.Pacemaker) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) HBMessage(org.apache.storm.generated.HBMessage) Test(org.junit.Test)

Example 2 with Pacemaker

use of org.apache.storm.pacemaker.Pacemaker in project storm by apache.

the class PacemakerTest method testServerGetAllNodesForPath.

@Test
public void testServerGetAllNodesForPath() {
    Pacemaker handler = new Pacemaker(new ConcurrentHashMap());
    makeNode(handler, "/some-root-path/foo");
    makeNode(handler, "/some-root-path/bar");
    makeNode(handler, "/some-root-path/baz");
    makeNode(handler, "/some-root-path/boo");
    messageWithRandId(HBServerMessageType.GET_ALL_NODES_FOR_PATH, HBMessageData.path("/some-root-path"));
    HBMessage badResponse = handler.handleMessage(hbMessage, false);
    HBMessage goodResponse = handler.handleMessage(hbMessage, true);
    List<String> pulseIds = goodResponse.get_data().get_nodes().get_pulseIds();
    Assert.assertEquals(mid, badResponse.get_message_id());
    Assert.assertEquals(HBServerMessageType.NOT_AUTHORIZED, badResponse.get_type());
    Assert.assertEquals(mid, goodResponse.get_message_id());
    Assert.assertEquals(HBServerMessageType.GET_ALL_NODES_FOR_PATH_RESPONSE, goodResponse.get_type());
    Assert.assertTrue(pulseIds.contains("foo"));
    Assert.assertTrue(pulseIds.contains("bar"));
    Assert.assertTrue(pulseIds.contains("baz"));
    Assert.assertTrue(pulseIds.contains("boo"));
    makeNode(handler, "/some/deeper/path/foo");
    makeNode(handler, "/some/deeper/path/bar");
    makeNode(handler, "/some/deeper/path/baz");
    messageWithRandId(HBServerMessageType.GET_ALL_NODES_FOR_PATH, HBMessageData.path("/some/deeper/path"));
    badResponse = handler.handleMessage(hbMessage, false);
    goodResponse = handler.handleMessage(hbMessage, true);
    pulseIds = goodResponse.get_data().get_nodes().get_pulseIds();
    Assert.assertEquals(mid, badResponse.get_message_id());
    Assert.assertEquals(HBServerMessageType.NOT_AUTHORIZED, badResponse.get_type());
    Assert.assertEquals(mid, goodResponse.get_message_id());
    Assert.assertEquals(HBServerMessageType.GET_ALL_NODES_FOR_PATH_RESPONSE, goodResponse.get_type());
    Assert.assertTrue(pulseIds.contains("foo"));
    Assert.assertTrue(pulseIds.contains("bar"));
    Assert.assertTrue(pulseIds.contains("baz"));
}
Also used : Pacemaker(org.apache.storm.pacemaker.Pacemaker) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) HBMessage(org.apache.storm.generated.HBMessage) Test(org.junit.Test)

Example 3 with Pacemaker

use of org.apache.storm.pacemaker.Pacemaker in project storm by apache.

the class PacemakerTest method testServerDeletePulseId.

@Test
public void testServerDeletePulseId() {
    Pacemaker handler = new Pacemaker(new ConcurrentHashMap());
    makeNode(handler, "/some-root/DELETE_PULSE_ID/foo");
    makeNode(handler, "/some-root/DELETE_PULSE_ID/bar");
    makeNode(handler, "/some-root/DELETE_PULSE_ID/baz");
    makeNode(handler, "/some-root/DELETE_PULSE_ID/boo");
    messageWithRandId(HBServerMessageType.DELETE_PULSE_ID, HBMessageData.path("/some-root/DELETE_PULSE_ID/foo"));
    HBMessage response = handler.handleMessage(hbMessage, true);
    Assert.assertEquals(mid, response.get_message_id());
    Assert.assertEquals(HBServerMessageType.DELETE_PULSE_ID_RESPONSE, response.get_type());
    Assert.assertNull(response.get_data());
    messageWithRandId(HBServerMessageType.GET_ALL_NODES_FOR_PATH, HBMessageData.path("/some-root/DELETE_PULSE_ID"));
    response = handler.handleMessage(hbMessage, true);
    List<String> pulseIds = response.get_data().get_nodes().get_pulseIds();
    Assert.assertEquals(mid, response.get_message_id());
    Assert.assertEquals(HBServerMessageType.GET_ALL_NODES_FOR_PATH_RESPONSE, response.get_type());
    Assert.assertFalse(pulseIds.contains("foo"));
}
Also used : Pacemaker(org.apache.storm.pacemaker.Pacemaker) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) HBMessage(org.apache.storm.generated.HBMessage) Test(org.junit.Test)

Example 4 with Pacemaker

use of org.apache.storm.pacemaker.Pacemaker in project storm by apache.

the class PacemakerTest method testServerCreatePath.

@Test
public void testServerCreatePath() {
    Pacemaker handler = new Pacemaker(new ConcurrentHashMap());
    messageWithRandId(HBServerMessageType.CREATE_PATH, HBMessageData.path("/testpath"));
    HBMessage response = handler.handleMessage(hbMessage, true);
    Assert.assertEquals(mid, response.get_message_id());
    Assert.assertEquals(HBServerMessageType.CREATE_PATH_RESPONSE, response.get_type());
    Assert.assertNull(response.get_data());
}
Also used : Pacemaker(org.apache.storm.pacemaker.Pacemaker) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) HBMessage(org.apache.storm.generated.HBMessage) Test(org.junit.Test)

Example 5 with Pacemaker

use of org.apache.storm.pacemaker.Pacemaker in project storm by apache.

the class PacemakerTest method testServerExistsFalse.

@Test
public void testServerExistsFalse() {
    Pacemaker handler = new Pacemaker(new ConcurrentHashMap());
    messageWithRandId(HBServerMessageType.EXISTS, HBMessageData.path("/testpath"));
    HBMessage badResponse = handler.handleMessage(hbMessage, false);
    HBMessage goodResponse = handler.handleMessage(hbMessage, true);
    Assert.assertEquals(mid, badResponse.get_message_id());
    Assert.assertEquals(HBServerMessageType.NOT_AUTHORIZED, badResponse.get_type());
    Assert.assertEquals(mid, goodResponse.get_message_id());
    Assert.assertEquals(HBServerMessageType.EXISTS_RESPONSE, goodResponse.get_type());
    Assert.assertFalse(goodResponse.get_data().get_boolval());
}
Also used : Pacemaker(org.apache.storm.pacemaker.Pacemaker) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) HBMessage(org.apache.storm.generated.HBMessage) Test(org.junit.Test)

Aggregations

ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)9 HBMessage (org.apache.storm.generated.HBMessage)9 Pacemaker (org.apache.storm.pacemaker.Pacemaker)9 Test (org.junit.Test)9 HBPulse (org.apache.storm.generated.HBPulse)3