You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@helix.apache.org by lx...@apache.org on 2018/03/23 18:58:11 UTC
[2/6] helix git commit: Including version number in Participant and
Controller history, and add additional logs.
Including version number in Participant and Controller history, and add additional logs.
Project: http://git-wip-us.apache.org/repos/asf/helix/repo
Commit: http://git-wip-us.apache.org/repos/asf/helix/commit/fb0b6747
Tree: http://git-wip-us.apache.org/repos/asf/helix/tree/fb0b6747
Diff: http://git-wip-us.apache.org/repos/asf/helix/diff/fb0b6747
Branch: refs/heads/master
Commit: fb0b67471112e44b9fd416dca51a185359369308
Parents: a5de29c
Author: Lei Xia <lx...@linkedin.com>
Authored: Fri Feb 16 23:05:49 2018 -0800
Committer: Lei Xia <lx...@linkedin.com>
Committed: Fri Mar 23 11:57:06 2018 -0700
----------------------------------------------------------------------
.../apache/helix/common/caches/CurrentStateCache.java | 14 ++++++--------
.../helix/controller/stages/ClusterDataCache.java | 3 +--
.../org/apache/helix/manager/zk/CallbackHandler.java | 11 ++++-------
.../helix/manager/zk/DistributedLeaderElection.java | 2 +-
.../apache/helix/manager/zk/ParticipantManager.java | 4 +++-
.../org/apache/helix/manager/zk/ZKHelixManager.java | 5 ++++-
.../apache/helix/manager/zk/ZkBaseDataAccessor.java | 11 ++++++-----
.../java/org/apache/helix/model/LeaderHistory.java | 4 +++-
.../org/apache/helix/model/ParticipantHistory.java | 8 +++++---
9 files changed, 33 insertions(+), 29 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/helix/blob/fb0b6747/helix-core/src/main/java/org/apache/helix/common/caches/CurrentStateCache.java
----------------------------------------------------------------------
diff --git a/helix-core/src/main/java/org/apache/helix/common/caches/CurrentStateCache.java b/helix-core/src/main/java/org/apache/helix/common/caches/CurrentStateCache.java
index d921512..5e69c1d 100644
--- a/helix-core/src/main/java/org/apache/helix/common/caches/CurrentStateCache.java
+++ b/helix-core/src/main/java/org/apache/helix/common/caches/CurrentStateCache.java
@@ -138,7 +138,7 @@ public class CurrentStateCache {
reloadKeys.add(key);
}
} else {
- LOG.debug("stat is null for key: " + key);
+ LOG.warn("stat is null for key: " + key);
reloadKeys.add(key);
}
}
@@ -150,18 +150,16 @@ public class CurrentStateCache {
if (currentState != null) {
currentStatesMap.put(key, currentState);
} else {
- LOG.debug("CurrentState null for key: " + key);
+ LOG.warn("CurrentState null for key: " + key);
}
}
_currentStateCache = Collections.unmodifiableMap(currentStatesMap);
- if (LOG.isDebugEnabled()) {
- LOG.debug("# of CurrentState paths read from ZooKeeper " + reloadKeys.size());
- LOG.debug("# of CurrentState paths skipped reading from ZK: " + (currentStateKeys.size()
- - reloadKeys.size()));
- }
- LOG.info("Takes " + (System.currentTimeMillis() - start) + " ms to reload new current states!");
+ LOG.info("# of CurrentStates reload: " + reloadKeys.size() + ", skipped:" + (currentStateKeys.size()
+ - reloadKeys.size()));
+ LOG.info("Takes " + (System.currentTimeMillis() - start) + " ms to reload new current states for cluster: "
+ + _clusterName);
}
/**
http://git-wip-us.apache.org/repos/asf/helix/blob/fb0b6747/helix-core/src/main/java/org/apache/helix/controller/stages/ClusterDataCache.java
----------------------------------------------------------------------
diff --git a/helix-core/src/main/java/org/apache/helix/controller/stages/ClusterDataCache.java b/helix-core/src/main/java/org/apache/helix/controller/stages/ClusterDataCache.java
index 4fa0c8c..e946a9d 100644
--- a/helix-core/src/main/java/org/apache/helix/controller/stages/ClusterDataCache.java
+++ b/helix-core/src/main/java/org/apache/helix/controller/stages/ClusterDataCache.java
@@ -19,7 +19,6 @@ package org.apache.helix.controller.stages;
* under the License.
*/
-import com.google.common.collect.Maps;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
@@ -192,7 +191,7 @@ public class ClusterDataCache {
_instanceMessagesCache
.refresh(accessor, _liveInstanceMap);
_currentStateCache.refresh(accessor, _liveInstanceMap);
-
+
// current state must be refreshed before refreshing relay messages
// because we need to use current state to validate all relay messages.
_instanceMessagesCache
http://git-wip-us.apache.org/repos/asf/helix/blob/fb0b6747/helix-core/src/main/java/org/apache/helix/manager/zk/CallbackHandler.java
----------------------------------------------------------------------
diff --git a/helix-core/src/main/java/org/apache/helix/manager/zk/CallbackHandler.java b/helix-core/src/main/java/org/apache/helix/manager/zk/CallbackHandler.java
index 42adade..c5a035f 100644
--- a/helix-core/src/main/java/org/apache/helix/manager/zk/CallbackHandler.java
+++ b/helix-core/src/main/java/org/apache/helix/manager/zk/CallbackHandler.java
@@ -530,7 +530,7 @@ public class CallbackHandler implements IZkChildListener, IZkDataListener {
@Override
public void handleDataChange(String dataPath, Object data) {
- logger.debug("Data change callback: paths changed: " + dataPath);
+ logger.info("Data change callback: paths changed: " + dataPath);
try {
updateNotificationTime(System.nanoTime());
@@ -548,10 +548,7 @@ public class CallbackHandler implements IZkChildListener, IZkDataListener {
}
@Override public void handleDataDeleted(String dataPath) {
- logger.debug("Data change callback: path deleted: " + dataPath);
- if (_changeType == IDEAL_STATE || _changeType == LIVE_INSTANCE) {
- logger.info("Data deleted callback, deleted path: " + dataPath);
- }
+ logger.info("Data change callback: path deleted: " + dataPath);
try {
updateNotificationTime(System.nanoTime());
@@ -576,8 +573,8 @@ public class CallbackHandler implements IZkChildListener, IZkDataListener {
@Override
public void handleChildChange(String parentPath, List<String> currentChilds) {
- logger.debug("Data change callback: child changed, path: " + parentPath + ", current childs: "
- + currentChilds);
+ logger.info("Data change callback: child changed, path: " + parentPath + ", current child count: "
+ + currentChilds.size());
try {
updateNotificationTime(System.nanoTime());
http://git-wip-us.apache.org/repos/asf/helix/blob/fb0b6747/helix-core/src/main/java/org/apache/helix/manager/zk/DistributedLeaderElection.java
----------------------------------------------------------------------
diff --git a/helix-core/src/main/java/org/apache/helix/manager/zk/DistributedLeaderElection.java b/helix-core/src/main/java/org/apache/helix/manager/zk/DistributedLeaderElection.java
index 6022edd..c676925 100644
--- a/helix-core/src/main/java/org/apache/helix/manager/zk/DistributedLeaderElection.java
+++ b/helix-core/src/main/java/org/apache/helix/manager/zk/DistributedLeaderElection.java
@@ -155,7 +155,7 @@ public class DistributedLeaderElection implements ControllerChangeListener {
if (history == null) {
history = new LeaderHistory(PropertyType.HISTORY.toString());
}
- history.updateHistory(manager.getClusterName(), manager.getInstanceName());
+ history.updateHistory(manager.getClusterName(), manager.getInstanceName(), manager.getVersion());
if(!accessor.setProperty(keyBuilder.controllerLeaderHistory(), history)) {
LOG.error("Failed to persist leader history to ZK!");
}
http://git-wip-us.apache.org/repos/asf/helix/blob/fb0b6747/helix-core/src/main/java/org/apache/helix/manager/zk/ParticipantManager.java
----------------------------------------------------------------------
diff --git a/helix-core/src/main/java/org/apache/helix/manager/zk/ParticipantManager.java b/helix-core/src/main/java/org/apache/helix/manager/zk/ParticipantManager.java
index 880607a..db236b8 100644
--- a/helix-core/src/main/java/org/apache/helix/manager/zk/ParticipantManager.java
+++ b/helix-core/src/main/java/org/apache/helix/manager/zk/ParticipantManager.java
@@ -181,6 +181,7 @@ public class ParticipantManager {
retry = false;
try {
_zkclient.createEphemeral(liveInstancePath, liveInstance.getRecord());
+ LOG.info("LiveInstance created, path: " + liveInstancePath + ", sessionId: " + liveInstance.getSessionId());
} catch (ZkNodeExistsException e) {
LOG.warn("found another instance with same instanceName: " + _instanceName + " in cluster "
+ _clusterName);
@@ -238,6 +239,7 @@ public class ParticipantManager {
if (retry) {
try {
_zkclient.createEphemeral(liveInstancePath, liveInstance.getRecord());
+ LOG.info("LiveInstance created, path: " + liveInstancePath + ", sessionId: " + liveInstance.getSessionId());
} catch (Exception e) {
String errorMessage =
"instance: " + _instanceName + " already has a live-instance in cluster "
@@ -248,7 +250,7 @@ public class ParticipantManager {
}
ParticipantHistory history = getHistory();
- history.reportOnline(_sessionId);
+ history.reportOnline(_sessionId, _manager.getVersion());
persistHistory(history);
}
http://git-wip-us.apache.org/repos/asf/helix/blob/fb0b6747/helix-core/src/main/java/org/apache/helix/manager/zk/ZKHelixManager.java
----------------------------------------------------------------------
diff --git a/helix-core/src/main/java/org/apache/helix/manager/zk/ZKHelixManager.java b/helix-core/src/main/java/org/apache/helix/manager/zk/ZKHelixManager.java
index dee9adf..d156c88 100644
--- a/helix-core/src/main/java/org/apache/helix/manager/zk/ZKHelixManager.java
+++ b/helix-core/src/main/java/org/apache/helix/manager/zk/ZKHelixManager.java
@@ -938,7 +938,8 @@ public class ZKHelixManager implements HelixManager, IZkStateListener {
switch (state) {
case SyncConnected:
ZkConnection zkConnection = (ZkConnection) _zkclient.getConnection();
- LOG.info("KeeperState: " + state + ", zookeeper:" + zkConnection.getZookeeper());
+ LOG.info("KeeperState: " + state + ", instance: "
+ + _instanceName + ", type: " + _instanceType + ", zookeeper:" + zkConnection.getZookeeper());
break;
case Disconnected:
LOG.info("KeeperState:" + state + ", disconnectedSessionId: " + _sessionId + ", instance: "
@@ -978,6 +979,8 @@ public class ZKHelixManager implements HelixManager, IZkStateListener {
@Override
public void handleNewSession() throws Exception {
+ LOG.info(
+ "Handle new session, sessionId: " + _sessionId + ", instance: " + _instanceName + ", type: " + _instanceType);
waitUntilConnected();
/**
http://git-wip-us.apache.org/repos/asf/helix/blob/fb0b6747/helix-core/src/main/java/org/apache/helix/manager/zk/ZkBaseDataAccessor.java
----------------------------------------------------------------------
diff --git a/helix-core/src/main/java/org/apache/helix/manager/zk/ZkBaseDataAccessor.java b/helix-core/src/main/java/org/apache/helix/manager/zk/ZkBaseDataAccessor.java
index f8678e5..9525103 100644
--- a/helix-core/src/main/java/org/apache/helix/manager/zk/ZkBaseDataAccessor.java
+++ b/helix-core/src/main/java/org/apache/helix/manager/zk/ZkBaseDataAccessor.java
@@ -22,8 +22,10 @@ package org.apache.helix.manager.zk;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
+import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
+import java.util.Map;
import org.I0Itec.zkclient.DataUpdater;
import org.I0Itec.zkclient.IZkChildListener;
import org.I0Itec.zkclient.IZkDataListener;
@@ -373,7 +375,7 @@ public class ZkBaseDataAccessor<T> implements BaseDataAccessor<T> {
// construct return results
List<T> records = new ArrayList<T>(Collections.<T> nCopies(paths.size(), null));
- StringBuilder nodeFailToRead = new StringBuilder();
+ Map<String, Integer> pathFailToRead = new HashMap<>();
for (int i = 0; i < paths.size(); i++) {
if (!needRead[i])
continue;
@@ -389,12 +391,11 @@ public class ZkBaseDataAccessor<T> implements BaseDataAccessor<T> {
} else if (Code.get(cb.getRc()) != Code.NONODE && throwException) {
throw new HelixException(String.format("Failed to read node %s", paths.get(i)));
} else {
- nodeFailToRead.append(paths + ",");
+ pathFailToRead.put(paths.get(i), cb.getRc());
}
}
- if (nodeFailToRead.length() > 0) {
- LOG.warn(String.format("Fail to read nodes for paths : %s",
- nodeFailToRead.toString().substring(nodeFailToRead.length() - 1)));
+ if (pathFailToRead.size() > 0) {
+ LOG.warn("Fail to read record for paths: " + pathFailToRead);
}
return records;
} finally {
http://git-wip-us.apache.org/repos/asf/helix/blob/fb0b6747/helix-core/src/main/java/org/apache/helix/model/LeaderHistory.java
----------------------------------------------------------------------
diff --git a/helix-core/src/main/java/org/apache/helix/model/LeaderHistory.java b/helix-core/src/main/java/org/apache/helix/model/LeaderHistory.java
index 5e7bdcd..31d125f 100644
--- a/helix-core/src/main/java/org/apache/helix/model/LeaderHistory.java
+++ b/helix-core/src/main/java/org/apache/helix/model/LeaderHistory.java
@@ -41,6 +41,7 @@ public class LeaderHistory extends HelixProperty {
HISTORY,
TIME,
DATE,
+ VERSION,
CONTROLLER
}
@@ -57,7 +58,7 @@ public class LeaderHistory extends HelixProperty {
* @param clusterName the cluster the instance leads
* @param instanceName the name of the leader instance
*/
- public void updateHistory(String clusterName, String instanceName) {
+ public void updateHistory(String clusterName, String instanceName, String version) {
/* keep this for back-compatible */
// TODO: remove this in future when we confirmed no one consumes it
List<String> list = _record.getListField(clusterName);
@@ -92,6 +93,7 @@ public class LeaderHistory extends HelixProperty {
historyEntry.put(ConfigProperty.CONTROLLER.name(), instanceName);
historyEntry.put(ConfigProperty.TIME.name(), String.valueOf(currentTime));
historyEntry.put(ConfigProperty.DATE.name(), dateTime);
+ historyEntry.put(ConfigProperty.VERSION.name(), version);
historyList.add(historyEntry.toString());
}
http://git-wip-us.apache.org/repos/asf/helix/blob/fb0b6747/helix-core/src/main/java/org/apache/helix/model/ParticipantHistory.java
----------------------------------------------------------------------
diff --git a/helix-core/src/main/java/org/apache/helix/model/ParticipantHistory.java b/helix-core/src/main/java/org/apache/helix/model/ParticipantHistory.java
index 2955ba5..e56c3e3 100644
--- a/helix-core/src/main/java/org/apache/helix/model/ParticipantHistory.java
+++ b/helix-core/src/main/java/org/apache/helix/model/ParticipantHistory.java
@@ -46,6 +46,7 @@ public class ParticipantHistory extends HelixProperty {
SESSION,
HISTORY,
OFFLINE,
+ VERSION,
LAST_OFFLINE_TIME
}
@@ -74,8 +75,8 @@ public class ParticipantHistory extends HelixProperty {
*
* @return
*/
- public void reportOnline(String sessionId) {
- updateSessionHistory(sessionId);
+ public void reportOnline(String sessionId, String version) {
+ updateSessionHistory(sessionId, version);
_record.setSimpleField(ConfigProperty.LAST_OFFLINE_TIME.name(), String.valueOf(ONLINE));
}
@@ -102,7 +103,7 @@ public class ParticipantHistory extends HelixProperty {
/**
* Add record to session online history list
*/
- private void updateSessionHistory(String sessionId) {
+ private void updateSessionHistory(String sessionId, String version) {
List<String> list = _record.getListField(ConfigProperty.HISTORY.name());
if (list == null) {
list = new ArrayList<>();
@@ -124,6 +125,7 @@ public class ParticipantHistory extends HelixProperty {
df.setTimeZone(TimeZone.getTimeZone("UTC"));
String dateTime = df.format(new Date(timeMillis));
sessionEntry.put(ConfigProperty.DATE.name(), dateTime);
+ sessionEntry.put(ConfigProperty.VERSION.name(), version);
list.add(sessionEntry.toString());
}