Adding logging statements.
Project: http://git-wip-us.apache.org/repos/asf/incubator-blur/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-blur/commit/333cd354 Tree: http://git-wip-us.apache.org/repos/asf/incubator-blur/tree/333cd354 Diff: http://git-wip-us.apache.org/repos/asf/incubator-blur/diff/333cd354 Branch: refs/heads/master Commit: 333cd35416d9804e1f81fa25d4682458b9dbcf43 Parents: 46efc29 Author: Aaron McCurry <[email protected]> Authored: Tue Jul 23 21:37:38 2013 -0400 Committer: Aaron McCurry <[email protected]> Committed: Tue Jul 23 21:37:38 2013 -0400 ---------------------------------------------------------------------- .../apache/blur/store/hdfs/HdfsDirectory.java | 55 +++----------------- .../apache/blur/zookeeper/ZooKeeperClient.java | 11 ++++ 2 files changed, 19 insertions(+), 47 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/333cd354/blur-store/src/main/java/org/apache/blur/store/hdfs/HdfsDirectory.java ---------------------------------------------------------------------- diff --git a/blur-store/src/main/java/org/apache/blur/store/hdfs/HdfsDirectory.java b/blur-store/src/main/java/org/apache/blur/store/hdfs/HdfsDirectory.java index 6804a44..b030bee 100644 --- a/blur-store/src/main/java/org/apache/blur/store/hdfs/HdfsDirectory.java +++ b/blur-store/src/main/java/org/apache/blur/store/hdfs/HdfsDirectory.java @@ -27,7 +27,6 @@ import java.util.Collection; import java.util.Map; import java.util.WeakHashMap; import java.util.concurrent.TimeUnit; -import java.util.concurrent.atomic.AtomicLong; import org.apache.blur.log.Log; import org.apache.blur.log.LogFactory; @@ -55,43 +54,6 @@ public class HdfsDirectory extends Directory { private static final Log LOG = LogFactory.getLog(HdfsDirectory.class); - private static AtomicLong deleteCounter = new AtomicLong(); - private static AtomicLong existsCounter = new AtomicLong(); - private static AtomicLong fileStatusCounter = new AtomicLong(); - private static AtomicLong renameCounter = new AtomicLong(); - private static AtomicLong listCounter = new AtomicLong(); - private static AtomicLong createCounter = new AtomicLong(); - private static AtomicLong isFileCounter = new AtomicLong(); - - private static final boolean debug = false; - - static { - if (debug) { - Thread thread = new Thread(new Runnable() { - @Override - public void run() { - while (true) { - LOG.debug("Delete Counter [" + deleteCounter + "]"); - LOG.debug("Exists Counter [" + existsCounter + "]"); - LOG.debug("File Status Counter [" + fileStatusCounter + "]"); - LOG.debug("Rename Counter [" + renameCounter + "]"); - LOG.debug("List Counter [" + listCounter + "]"); - LOG.debug("Create Counter [" + createCounter + "]"); - LOG.debug("IsFile Counter [" + isFileCounter + "]"); - try { - Thread.sleep(5000); - } catch (InterruptedException e) { - return; - } - } - } - }); - thread.setName("HDFS dir counter logger"); - thread.setDaemon(true); - thread.start(); - } - } - private final Path path; private final FileSystem fileSystem; private final MetricsGroup metricsGroup; @@ -200,11 +162,11 @@ public class HdfsDirectory extends Directory { @Override public IndexOutput createOutput(String name, IOContext context) throws IOException { + LOG.debug("createOutput [{0}] [{1}] [{2}]", name, context, path); if (fileExists(name)) { throw new IOException("File [" + name + "] already exists found."); } final FSDataOutputStream outputStream = fileSystem.create(getPath(name)); - createCounter.incrementAndGet(); return new BufferedIndexOutput() { @Override @@ -236,6 +198,7 @@ public class HdfsDirectory extends Directory { @Override public IndexInput openInput(String name, IOContext context) throws IOException { + LOG.debug("openInput [{0}] [{1}] [{2}]", name, context, path); if (!fileExists(name)) { throw new FileNotFoundException("File [" + name + "] not found."); } @@ -245,12 +208,11 @@ public class HdfsDirectory extends Directory { @Override public String[] listAll() throws IOException { - listCounter.incrementAndGet(); + LOG.debug("listAll [{0}]", path); FileStatus[] files = fileSystem.listStatus(path, new PathFilter() { @Override public boolean accept(Path path) { try { - isFileCounter.incrementAndGet(); return fileSystem.isFile(path); } catch (IOException e) { throw new RuntimeException(e); @@ -266,14 +228,14 @@ public class HdfsDirectory extends Directory { @Override public boolean fileExists(String name) throws IOException { - existsCounter.incrementAndGet(); + LOG.debug("fileExists [{0}] [{1}]", name, path); return fileSystem.exists(getPath(name)); } @Override public void deleteFile(String name) throws IOException { + LOG.debug("deleteFile [{0}] [{1}]", name, path); if (fileExists(name)) { - deleteCounter.incrementAndGet(); fileSystem.delete(getPath(name), true); } else { throw new FileNotFoundException("File [" + name + "] not found"); @@ -282,7 +244,7 @@ public class HdfsDirectory extends Directory { @Override public long fileLength(String name) throws IOException { - fileStatusCounter.incrementAndGet(); + LOG.debug("fileLength [{0}] [{1}]", name, path); FileStatus fileStatus = fileSystem.getFileStatus(getPath(name)); return fileStatus.getLen(); } @@ -296,7 +258,7 @@ public class HdfsDirectory extends Directory { public void close() throws IOException { } - + public Path getPath() { return path; } @@ -310,12 +272,12 @@ public class HdfsDirectory extends Directory { throw new FileNotFoundException("File [" + name + "] not found"); } Path file = getPath(name); - fileStatusCounter.incrementAndGet(); return fileSystem.getFileStatus(file).getModificationTime(); } @Override public void copy(Directory to, String src, String dest, IOContext context) throws IOException { + LOG.debug("copy [{0}] [{1}] [{2}] [{3}] [{4}]", to, src, dest, context, path); if (to instanceof DirectoryDecorator) { copy(((DirectoryDecorator) to).getOriginalDirectory(), src, dest, context); } else if (to instanceof HdfsDirectory) { @@ -332,7 +294,6 @@ public class HdfsDirectory extends Directory { if (ifSameCluster(simpleTo, this)) { Path newDest = simpleTo.getPath(dest); Path oldSrc = getPath(src); - renameCounter.incrementAndGet(); return fileSystem.rename(oldSrc, newDest); } return false; http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/333cd354/blur-util/src/main/java/org/apache/blur/zookeeper/ZooKeeperClient.java ---------------------------------------------------------------------- diff --git a/blur-util/src/main/java/org/apache/blur/zookeeper/ZooKeeperClient.java b/blur-util/src/main/java/org/apache/blur/zookeeper/ZooKeeperClient.java index 62ad5c7..f67c1d0 100644 --- a/blur-util/src/main/java/org/apache/blur/zookeeper/ZooKeeperClient.java +++ b/blur-util/src/main/java/org/apache/blur/zookeeper/ZooKeeperClient.java @@ -89,6 +89,7 @@ public class ZooKeeperClient extends ZooKeeper { return execute(new ZKExecutor<String>() { @Override String execute() throws KeeperException, InterruptedException { + LOG.debug("ZK Call - create [{0}] [{1}] [{2}] [{3}]", path, data, acl, createMode); return ZooKeeperClient.super.create(path, data, acl, createMode); } }); @@ -99,6 +100,7 @@ public class ZooKeeperClient extends ZooKeeper { execute(new ZKExecutor<Void>() { @Override Void execute() throws KeeperException, InterruptedException { + LOG.debug("ZK Call - delete [{0}] [{1}]", path, version); ZooKeeperClient.super.delete(path, version); return null; } @@ -120,6 +122,7 @@ public class ZooKeeperClient extends ZooKeeper { return execute(new ZKExecutor<Stat>() { @Override Stat execute() throws KeeperException, InterruptedException { + LOG.debug("ZK Call - exists [{0}] [{1}]", path, watcher); return ZooKeeperClient.super.exists(path, watcher); } }); @@ -130,6 +133,7 @@ public class ZooKeeperClient extends ZooKeeper { return execute(new ZKExecutor<Stat>() { @Override Stat execute() throws KeeperException, InterruptedException { + LOG.debug("ZK Call - exists [{0}] [{1}]", path, watch); return ZooKeeperClient.super.exists(path, watch); } }); @@ -141,6 +145,7 @@ public class ZooKeeperClient extends ZooKeeper { return execute(new ZKExecutor<byte[]>() { @Override byte[] execute() throws KeeperException, InterruptedException { + LOG.debug("ZK Call - getData [{0}] [{1}] [{2}]", path, watcher, stat); return ZooKeeperClient.super.getData(path, watcher, stat); } }); @@ -152,6 +157,7 @@ public class ZooKeeperClient extends ZooKeeper { return execute(new ZKExecutor<byte[]>() { @Override byte[] execute() throws KeeperException, InterruptedException { + LOG.debug("ZK Call - getData [{0}] [{1}] [{2}]", path, watch, stat); return ZooKeeperClient.super.getData(path, watch, stat); } }); @@ -163,6 +169,7 @@ public class ZooKeeperClient extends ZooKeeper { return execute(new ZKExecutor<Stat>() { @Override Stat execute() throws KeeperException, InterruptedException { + LOG.debug("ZK Call - setData [{0}] [{1}] [{2}]", path, data, version); return ZooKeeperClient.super.setData(path, data, version); } }); @@ -195,6 +202,7 @@ public class ZooKeeperClient extends ZooKeeper { return execute(new ZKExecutor<List<String>>() { @Override List<String> execute() throws KeeperException, InterruptedException { + LOG.debug("ZK Call - getChildren [{0}] [{1}]", path, watcher); return ZooKeeperClient.super.getChildren(path, watcher); } }); @@ -205,6 +213,7 @@ public class ZooKeeperClient extends ZooKeeper { return execute(new ZKExecutor<List<String>>() { @Override List<String> execute() throws KeeperException, InterruptedException { + LOG.debug("ZK Call - getChildren [{0}] [{1}]", path, watch); return ZooKeeperClient.super.getChildren(path, watch); } }); @@ -216,6 +225,7 @@ public class ZooKeeperClient extends ZooKeeper { return execute(new ZKExecutor<List<String>>() { @Override List<String> execute() throws KeeperException, InterruptedException { + LOG.debug("ZK Call - getChildren [{0}] [{1}] [{2}]", path, watcher, stat); return ZooKeeperClient.super.getChildren(path, watcher, stat); } }); @@ -227,6 +237,7 @@ public class ZooKeeperClient extends ZooKeeper { return execute(new ZKExecutor<List<String>>() { @Override List<String> execute() throws KeeperException, InterruptedException { + LOG.debug("ZK Call - getChildren [{0}] [{1}] [{2}]", path, watch, stat); return ZooKeeperClient.super.getChildren(path, watch, stat); } });
