better logging

This commit is contained in:
Fangjin Yang 2013-03-01 19:25:25 -08:00
parent 49e61d00fd
commit cbe0555d00
1 changed files with 6 additions and 3 deletions

View File

@ -408,9 +408,12 @@ public class RemoteTaskRunner implements TaskRunner
public void childEvent(CuratorFramework client, PathChildrenCacheEvent event) throws Exception public void childEvent(CuratorFramework client, PathChildrenCacheEvent event) throws Exception
{ {
try { try {
if (event.getData() != null) {
log.info("Event[%s]: %s", event.getType(), event.getData().getPath());
}
if (event.getType().equals(PathChildrenCacheEvent.Type.CHILD_ADDED) || if (event.getType().equals(PathChildrenCacheEvent.Type.CHILD_ADDED) ||
event.getType().equals(PathChildrenCacheEvent.Type.CHILD_UPDATED)) { event.getType().equals(PathChildrenCacheEvent.Type.CHILD_UPDATED)) {
log.info("Event[%s]: %s", event.getType(), event.getData().getPath());
final String taskId = ZKPaths.getNodeFromPath(event.getData().getPath()); final String taskId = ZKPaths.getNodeFromPath(event.getData().getPath());
final TaskStatus taskStatus; final TaskStatus taskStatus;
@ -471,8 +474,8 @@ public class RemoteTaskRunner implements TaskRunner
cleanup(worker.getHost(), taskId); cleanup(worker.getHost(), taskId);
runPendingTasks(); runPendingTasks();
} }
} else if (event.getType().equals(PathChildrenCacheEvent.Type.CHILD_REMOVED)) { } else if (event.getType().equals(PathChildrenCacheEvent.Type.CHILD_REMOVED)
log.info("Event[%s]: %s", event.getType(), event.getData().getPath()); || event.getType().equals(PathChildrenCacheEvent.Type.CONNECTION_LOST)) {
final String taskId = ZKPaths.getNodeFromPath(event.getData().getPath()); final String taskId = ZKPaths.getNodeFromPath(event.getData().getPath());
if (runningTasks.containsKey(taskId)) { if (runningTasks.containsKey(taskId)) {
log.info("Task %s just disappeared!", taskId); log.info("Task %s just disappeared!", taskId);