use of com.navercorp.pinpoint.collector.cluster.ClusterPointRepository in project pinpoint by naver.
the class ZookeeperJobWorkerTest method test1.
@Test
public void test1() throws Exception {
InMemoryZookeeperClient zookeeperClient = new InMemoryZookeeperClient(true);
zookeeperClient.connect();
ZookeeperProfilerClusterManager manager = new ZookeeperProfilerClusterManager(zookeeperClient, PATH, new ClusterPointRepository());
manager.start();
ClusterPointStateChangedEventHandler clusterPointStateChangedEventHandler = new ClusterPointStateChangedEventHandler(channelPropertiesFactory, manager);
try {
int random = ThreadLocalRandom.current().nextInt(10, 20);
for (int i = 0; i < random; i++) {
PinpointServer mockServer = createMockPinpointServer("app" + i, "agent" + i, System.currentTimeMillis());
clusterPointStateChangedEventHandler.stateUpdated(mockServer, SocketStateCode.RUN_DUPLEX);
}
waitZookeeperServerData(random, zookeeperClient);
Assert.assertEquals(random, manager.getClusterData().size());
} finally {
manager.stop();
}
}
use of com.navercorp.pinpoint.collector.cluster.ClusterPointRepository in project pinpoint by naver.
the class GrpcCommandServiceTest method creteMemoryClusterManager.
private ZookeeperProfilerClusterManager creteMemoryClusterManager() throws PinpointZookeeperException {
InMemoryZookeeperClient zookeeperClient = new InMemoryZookeeperClient();
zookeeperClient.connect();
String path = ZKPaths.makePath(ZookeeperConstants.DEFAULT_CLUSTER_ZNODE_ROOT_PATH, ZookeeperConstants.COLLECTOR_LEAF_PATH, this.getClass().getSimpleName());
ZookeeperProfilerClusterManager manager = new ZookeeperProfilerClusterManager(zookeeperClient, path, new ClusterPointRepository());
manager.start();
return manager;
}
use of com.navercorp.pinpoint.collector.cluster.ClusterPointRepository in project pinpoint by naver.
the class ZookeeperJobWorkerTest method test3.
@Test
public void test3() throws Exception {
InMemoryZookeeperClient zookeeperClient = new InMemoryZookeeperClient(true);
zookeeperClient.connect();
ZookeeperProfilerClusterManager manager = new ZookeeperProfilerClusterManager(zookeeperClient, PATH, new ClusterPointRepository());
manager.start();
ClusterPointStateChangedEventHandler clusterPointStateChangedEventHandler = new ClusterPointStateChangedEventHandler(channelPropertiesFactory, manager);
try {
PinpointServer mockServer = createMockPinpointServer("app", "agent", System.currentTimeMillis());
clusterPointStateChangedEventHandler.stateUpdated(mockServer, SocketStateCode.RUN_DUPLEX);
waitZookeeperServerData(1, zookeeperClient);
Assert.assertEquals(1, manager.getClusterData().size());
zookeeperClient.createPath(PATH);
CreateNodeMessage createNodeMessage = new CreateNodeMessage(PATH, new byte[0]);
try {
zookeeperClient.createOrSetNode(createNodeMessage);
} catch (Exception ignore) {
}
try {
zookeeperClient.createOrSetNode(createNodeMessage);
} catch (Exception ignore) {
}
waitZookeeperServerData(0, zookeeperClient);
Assert.assertEquals(0, manager.getClusterData().size());
manager.refresh();
waitZookeeperServerData(1, zookeeperClient);
Assert.assertEquals(1, manager.getClusterData().size());
} finally {
manager.stop();
}
}
use of com.navercorp.pinpoint.collector.cluster.ClusterPointRepository in project pinpoint by naver.
the class ZookeeperJobWorkerTest method test2.
@Test
public void test2() throws Exception {
InMemoryZookeeperClient zookeeperClient = new InMemoryZookeeperClient(true);
zookeeperClient.connect();
ZookeeperProfilerClusterManager manager = new ZookeeperProfilerClusterManager(zookeeperClient, PATH, new ClusterPointRepository());
manager.start();
ClusterPointStateChangedEventHandler clusterPointStateChangedEventHandler = new ClusterPointStateChangedEventHandler(channelPropertiesFactory, manager);
try {
PinpointServer mockServer = createMockPinpointServer("app", "agent", System.currentTimeMillis());
clusterPointStateChangedEventHandler.stateUpdated(mockServer, SocketStateCode.RUN_DUPLEX);
waitZookeeperServerData(1, zookeeperClient);
Assert.assertEquals(1, manager.getClusterData().size());
clusterPointStateChangedEventHandler.stateUpdated(mockServer, SocketStateCode.CLOSED_BY_CLIENT);
waitZookeeperServerData(0, zookeeperClient);
Assert.assertEquals(0, manager.getClusterData().size());
} finally {
manager.stop();
}
}
use of com.navercorp.pinpoint.collector.cluster.ClusterPointRepository in project pinpoint by naver.
the class ZookeeperJobWorkerTest method test4.
@Test
public void test4() throws Exception {
InMemoryZookeeperClient zookeeperClient = new InMemoryZookeeperClient(true);
zookeeperClient.connect();
ZookeeperProfilerClusterManager manager = new ZookeeperProfilerClusterManager(zookeeperClient, PATH, new ClusterPointRepository());
manager.start();
ClusterPointStateChangedEventHandler clusterPointStateChangedEventHandler = new ClusterPointStateChangedEventHandler(channelPropertiesFactory, manager);
try {
PinpointServer mockServer1 = createMockPinpointServer("app", "agent", System.currentTimeMillis());
clusterPointStateChangedEventHandler.stateUpdated(mockServer1, SocketStateCode.RUN_DUPLEX);
PinpointServer mockServer2 = createMockPinpointServer("app", "agent", System.currentTimeMillis() + 1000);
clusterPointStateChangedEventHandler.stateUpdated(mockServer2, SocketStateCode.RUN_DUPLEX);
waitZookeeperServerData(2, zookeeperClient);
Assert.assertEquals(2, manager.getClusterData().size());
clusterPointStateChangedEventHandler.stateUpdated(mockServer1, SocketStateCode.CLOSED_BY_SERVER);
waitZookeeperServerData(1, zookeeperClient);
Assert.assertEquals(1, manager.getClusterData().size());
} finally {
manager.stop();
}
}
Aggregations