Skip to content

Commit 2a7e898

Browse files
author
Yang Guo
committed
fix agent reconnect to zk logic
1 parent b26b301 commit 2a7e898

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

platform-agent/src/main/java/com/flow/platform/agent/AgentManager.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,12 +109,12 @@ public void childEvent(CuratorFramework client, TreeCacheEvent event) throws Exc
109109

110110
if (event.getType() == Type.CONNECTION_RECONNECTED) {
111111
LOGGER.traceMarker("ZK-Event", "========= Reconnect =========");
112+
registerZkNodeAndWatch();
112113
return;
113114
}
114115

115116
if (event.getType() == Type.CONNECTION_LOST) {
116117
LOGGER.traceMarker("ZK-Event", "========= Lost =========");
117-
registerZkNodeAndWatch();
118118
return;
119119
}
120120

@@ -172,10 +172,15 @@ private void onDataChanged(String path) {
172172
}
173173

174174
cmd = Jsonable.parse(rawData, Cmd.class);
175-
cmdHistory.add(cmd);
175+
if (cmd == null) {
176+
LOGGER.warn("Unable to parse cmd from zk node: " + new String(rawData));
177+
return;
178+
}
176179

180+
cmdHistory.add(cmd);
177181
LOGGER.trace("Received command: " + cmd.toString());
178182
CmdManager.getInstance().execute(cmd);
183+
179184
} catch (Throwable e) {
180185
LOGGER.error("Invalid cmd from server", e);
181186
// TODO: should report agent status directly...

0 commit comments

Comments
 (0)