From e09d927f9e9f8c0547650c451390b04a751f4631 Mon Sep 17 00:00:00 2001 From: Andrew Sorensen Date: Sun, 19 Jan 2020 12:09:45 -0800 Subject: [PATCH] Minor cleanup --- .../cluster/zookeeper/ZookeeperClusterServiceDao.java | 6 ++---- .../iris/platform/cluster/zookeeper/ZookeeperMonitor.java | 2 +- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/platform/arcus-lib/src/main/java/com/iris/platform/cluster/zookeeper/ZookeeperClusterServiceDao.java b/platform/arcus-lib/src/main/java/com/iris/platform/cluster/zookeeper/ZookeeperClusterServiceDao.java index 42df2eb5..bb4e37ad 100644 --- a/platform/arcus-lib/src/main/java/com/iris/platform/cluster/zookeeper/ZookeeperClusterServiceDao.java +++ b/platform/arcus-lib/src/main/java/com/iris/platform/cluster/zookeeper/ZookeeperClusterServiceDao.java @@ -82,7 +82,7 @@ public ClusterServiceRecord register() throws ClusterIdUnavailableException { .collect(Collectors.toList()); try (Timer.Context timer = ZookeeperClusterServiceDao.ClusterServiceMetrics.registerTimer.time()) { Instant heartbeat = clock.instant(); - // try to grab an empty first + // grab an empty cluster id, or wait for (int i = 0; i < members; i++) { if (others.contains(i)) { continue; @@ -96,8 +96,6 @@ public ClusterServiceRecord register() throws ClusterIdUnavailableException { ZookeeperClusterServiceDao.ClusterServiceMetrics.clusterRegistrationMissCounter.inc(); } } - // try to grab an existing one then - // TODO: is this actually needed? ZookeeperClusterServiceDao.ClusterServiceMetrics.clusterRegistrationFailedCounter.inc(); throw new ClusterIdUnavailableException("No cluster ids for service [" + service + "] were available"); @@ -135,6 +133,7 @@ private ClusterServiceRecord tryInsert(int memberId, Instant heartbeat) { @Override public ClusterServiceRecord heartbeat(ClusterServiceRecord service) throws ClusterServiceDaoException { + // Not required for this implementation - ZooKeeper will automatically expire ephemeral nodes. return null; } @@ -183,7 +182,6 @@ public void process(WatchedEvent event) { private static class ClusterServiceMetrics { static final Timer registerTimer = DaoMetrics.upsertTimer(ClusterServiceDao.class, "register"); - static final Timer heartbeatTimer = DaoMetrics.updateTimer(ClusterServiceDao.class, "heartbeat"); static final Timer deregisterTimer = DaoMetrics.deleteTimer(ClusterServiceDao.class, "deregister"); static final Timer listByServiceTimer = DaoMetrics.readTimer(ClusterServiceDao.class, "listMembersByService"); static final Counter clusterIdRegisteredCounter = DaoMetrics.counter(ClusterServiceDao.class, "clusterid.registered"); diff --git a/platform/arcus-lib/src/main/java/com/iris/platform/cluster/zookeeper/ZookeeperMonitor.java b/platform/arcus-lib/src/main/java/com/iris/platform/cluster/zookeeper/ZookeeperMonitor.java index 8acee6a8..2831798f 100644 --- a/platform/arcus-lib/src/main/java/com/iris/platform/cluster/zookeeper/ZookeeperMonitor.java +++ b/platform/arcus-lib/src/main/java/com/iris/platform/cluster/zookeeper/ZookeeperMonitor.java @@ -34,12 +34,12 @@ public ZookeeperMonitor(ZooKeeper zk) { @Override public void process(WatchedEvent event) { - String path = event.getPath(); if (event.getType() == Event.EventType.None) { switch (event.getState()) { case SyncConnected: break; case Expired: + // TODO: move this elsewhere? logger.error("SHUTTING DOWN -- zookeeper session has been marked as expired"); System.err.println("SHUTTING DOWN -- zookeeper session has been marked as expired"); System.exit(-1);