Skip to content

Commit

Permalink
Minor cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
AndrewX192 committed Jan 19, 2020
1 parent fd2073b commit e09d927
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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");
Expand Down Expand Up @@ -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;
}

Expand Down Expand Up @@ -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");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit e09d927

Please sign in to comment.