incubator-blur-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From amccu...@apache.org
Subject [1/2] git commit: Removing ZooKeeper tracing storage because it can cause ZooKeeper to become unstable.
Date Thu, 13 Feb 2014 14:20:24 GMT
Updated Branches:
  refs/heads/apache-blur-0.2 77e65aed2 -> 5acb82524


Removing ZooKeeper tracing storage because it can cause ZooKeeper to become unstable.


Project: http://git-wip-us.apache.org/repos/asf/incubator-blur/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-blur/commit/0947c5c3
Tree: http://git-wip-us.apache.org/repos/asf/incubator-blur/tree/0947c5c3
Diff: http://git-wip-us.apache.org/repos/asf/incubator-blur/diff/0947c5c3

Branch: refs/heads/apache-blur-0.2
Commit: 0947c5c3a9c33e66c01baef6728b12b0eb0525a3
Parents: 77e65ae
Author: Aaron McCurry <amccurry@gmail.com>
Authored: Thu Feb 13 09:06:19 2014 -0500
Committer: Aaron McCurry <amccurry@gmail.com>
Committed: Thu Feb 13 09:06:19 2014 -0500

----------------------------------------------------------------------
 .../org/apache/blur/thrift/ThriftServer.java    |   5 +-
 .../blur/trace/ZooKeeperTraceStorage.java       | 234 -------------------
 .../src/main/resources/blur-default.properties  |   3 -
 3 files changed, 1 insertion(+), 241 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/0947c5c3/blur-core/src/main/java/org/apache/blur/thrift/ThriftServer.java
----------------------------------------------------------------------
diff --git a/blur-core/src/main/java/org/apache/blur/thrift/ThriftServer.java b/blur-core/src/main/java/org/apache/blur/thrift/ThriftServer.java
index caf8ab8..6957e9b 100644
--- a/blur-core/src/main/java/org/apache/blur/thrift/ThriftServer.java
+++ b/blur-core/src/main/java/org/apache/blur/thrift/ThriftServer.java
@@ -57,7 +57,6 @@ import org.apache.blur.thrift.server.TThreadedSelectorServer;
 import org.apache.blur.thrift.server.TThreadedSelectorServer.Args.AcceptPolicy;
 import org.apache.blur.trace.LogTraceStorage;
 import org.apache.blur.trace.TraceStorage;
-import org.apache.blur.trace.ZooKeeperTraceStorage;
 import org.apache.blur.trace.hdfs.HdfsTraceStorage;
 
 import com.yammer.metrics.Metrics;
@@ -107,9 +106,7 @@ public class ThriftServer {
       throw new RuntimeException("Cannot have both [" + BLUR_ZOOKEEPER_TRACE_PATH + "] and
[" + BLUR_HDFS_TRACE_PATH
           + "] set.");
     }
-    if (zKpath != null) {
-      return new ZooKeeperTraceStorage(configuration);
-    } else if (hdfsPath != null) {
+    if (hdfsPath != null) {
       return new HdfsTraceStorage(configuration);
     } else {
       return new LogTraceStorage(configuration);

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/0947c5c3/blur-util/src/main/java/org/apache/blur/trace/ZooKeeperTraceStorage.java
----------------------------------------------------------------------
diff --git a/blur-util/src/main/java/org/apache/blur/trace/ZooKeeperTraceStorage.java b/blur-util/src/main/java/org/apache/blur/trace/ZooKeeperTraceStorage.java
deleted file mode 100644
index 751b95c..0000000
--- a/blur-util/src/main/java/org/apache/blur/trace/ZooKeeperTraceStorage.java
+++ /dev/null
@@ -1,234 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.blur.trace;
-
-import static org.apache.blur.utils.BlurConstants.BLUR_ZOOKEEPER_CONNECTION;
-import static org.apache.blur.utils.BlurConstants.BLUR_ZOOKEEPER_TRACE_PATH;
-
-import java.io.IOException;
-import java.io.UnsupportedEncodingException;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.concurrent.BlockingQueue;
-import java.util.concurrent.LinkedBlockingQueue;
-
-import org.apache.blur.BlurConfiguration;
-import org.apache.blur.log.Log;
-import org.apache.blur.log.LogFactory;
-import org.apache.blur.trace.Trace.TraceId;
-import org.apache.blur.zookeeper.ZkUtils;
-import org.apache.blur.zookeeper.ZooKeeperClient;
-import org.apache.zookeeper.CreateMode;
-import org.apache.zookeeper.KeeperException;
-import org.apache.zookeeper.KeeperException.Code;
-import org.apache.zookeeper.WatchedEvent;
-import org.apache.zookeeper.Watcher;
-import org.apache.zookeeper.ZooDefs.Ids;
-import org.apache.zookeeper.data.Stat;
-
-public class ZooKeeperTraceStorage extends TraceStorage {
-
-  private static final String UTF_8 = "UTF-8";
-
-  private static final String TRACE = "trace_";
-
-  private final static Log LOG = LogFactory.getLog(ZooKeeperTraceStorage.class);
-
-  private final String _zkConnectionStr;
-  private final ZooKeeperClient _zooKeeperClient;
-  private final String _storePath;
-  private final BlockingQueue<TraceCollector> _queue = new LinkedBlockingQueue<TraceCollector>();
-  private final Thread _daemon;
-
-  public ZooKeeperTraceStorage(BlurConfiguration configuration) throws IOException {
-    super(configuration);
-    _zkConnectionStr = configuration.get(BLUR_ZOOKEEPER_CONNECTION);
-    _storePath = configuration.get(BLUR_ZOOKEEPER_TRACE_PATH);
-    _zooKeeperClient = new ZooKeeperClient(_zkConnectionStr, 30000, new Watcher() {
-      @Override
-      public void process(WatchedEvent event) {
-
-      }
-    });
-    createIfMissing(_storePath);
-    _daemon = new Thread(new Runnable() {
-      @Override
-      public void run() {
-        while (true) {
-          TraceCollector collector;
-          try {
-            collector = _queue.take();
-          } catch (InterruptedException e) {
-            return;
-          }
-          try {
-            writeCollector(collector);
-          } catch (Throwable t) {
-            LOG.error("Unknown error while trying to write collector.", t);
-          }
-        }
-      }
-    });
-    _daemon.setDaemon(true);
-    _daemon.setName("ZooKeeper Trace Queue Writer");
-    _daemon.start();
-  }
-
-  @Override
-  public void store(TraceCollector collector) {
-    try {
-      _queue.put(collector);
-    } catch (InterruptedException e) {
-      LOG.error("Unknown error while trying to add collector on queue", e);
-    }
-  }
-
-  private void writeCollector(TraceCollector collector) {
-    TraceId id = collector.getId();
-    String storeId = id.getRootId();
-    String requestId = id.getRequestId();
-    if (requestId == null) {
-      requestId = "";
-    }
-    String storePath = getStorePath(storeId);
-    String json = collector.toJson();
-    storeJson(storePath, requestId, json);
-  }
-
-  public void storeJson(String storePath, String requestId, String json) {
-    try {
-      createIfMissing(storePath);
-      _zooKeeperClient.create(storePath + "/" + TRACE + requestId + "_", json.getBytes(UTF_8),
Ids.OPEN_ACL_UNSAFE,
-          CreateMode.PERSISTENT_SEQUENTIAL);
-    } catch (UnsupportedEncodingException e) {
-      throw new RuntimeException(e);
-    } catch (KeeperException e) {
-      throw new RuntimeException(e);
-    } catch (InterruptedException e) {
-      throw new RuntimeException(e);
-    }
-  }
-
-  private void createIfMissing(String storePath) {
-    try {
-      Stat stat = _zooKeeperClient.exists(storePath, false);
-      if (stat == null) {
-        _zooKeeperClient.create(storePath, null, Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT);
-      }
-    } catch (KeeperException e) {
-      if (e.code() == Code.NODEEXISTS) {
-        return;
-      }
-      throw new RuntimeException(e);
-    } catch (InterruptedException e) {
-      throw new RuntimeException(e);
-    }
-  }
-
-  private String getStorePath(String storeId) {
-    return _storePath + "/" + storeId;
-  }
-
-  @Override
-  public void close() throws IOException {
-    try {
-      _zooKeeperClient.close();
-    } catch (InterruptedException e) {
-      throw new IOException(e);
-    }
-  }
-
-  @Override
-  public List<String> getTraceIds() throws IOException {
-    try {
-      return _zooKeeperClient.getChildren(_storePath, false);
-    } catch (Exception e) {
-      throw new IOException(e);
-    }
-  }
-
-  @Override
-  public List<String> getRequestIds(String traceId) throws IOException {
-    String storePath = getStorePath(traceId);
-    try {
-      Stat stats = _zooKeeperClient.exists(storePath, false);
-      if (stats == null) {
-        throw new IOException("Trace [" + traceId + "] not found.");
-      }
-      List<String> children = _zooKeeperClient.getChildren(storePath, false);
-      List<String> requestIds = new ArrayList<String>();
-      for (String c : children) {
-        String requestId = getRequestId(c);
-        if (requestId != null) {
-          requestIds.add(requestId);
-        }
-      }
-      return requestIds;
-    } catch (Exception e) {
-      throw new IOException(e);
-    }
-  }
-
-  private String getRequestId(String s) {
-    if (s.startsWith(TRACE)) {
-      int lastIndexOf = s.lastIndexOf('_');
-      return s.substring(TRACE.length(), lastIndexOf);
-    }
-    return null;
-  }
-
-  @Override
-  public String getRequestContentsJson(String traceId, String requestId) throws IOException
{
-    String storePath = getStorePath(traceId);
-    try {
-      Stat stats = _zooKeeperClient.exists(storePath, false);
-      if (stats == null) {
-        throw new IOException("Trace [" + traceId + "] not found.");
-      }
-      String requestPath = getRequestStorePath(storePath, requestId);
-      if (requestPath == null) {
-        throw new IOException("Request [" + requestId + "] not found.");
-      }
-      Stat dataStat = _zooKeeperClient.exists(requestPath, false);
-      byte[] data = _zooKeeperClient.getData(requestPath, false, dataStat);
-      return new String(data, UTF_8);
-    } catch (Exception e) {
-      throw new IOException(e);
-    }
-  }
-
-  private String getRequestStorePath(String storePath, String requestId) throws KeeperException,
InterruptedException {
-    List<String> children = _zooKeeperClient.getChildren(storePath, false);
-    for (String c : children) {
-      if (c.startsWith(TRACE + requestId + "_")) {
-        return storePath + "/" + c;
-      }
-    }
-    return null;
-  }
-
-  @Override
-  public void removeTrace(String traceId) throws IOException {
-    String storePath = getStorePath(traceId);
-    try {
-      ZkUtils.rmr(_zooKeeperClient, storePath);
-    } catch (Exception e) {
-      throw new IOException(e);
-    }
-  }
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/0947c5c3/blur-util/src/main/resources/blur-default.properties
----------------------------------------------------------------------
diff --git a/blur-util/src/main/resources/blur-default.properties b/blur-util/src/main/resources/blur-default.properties
index 7e46952..9a0e60c 100644
--- a/blur-util/src/main/resources/blur-default.properties
+++ b/blur-util/src/main/resources/blur-default.properties
@@ -16,9 +16,6 @@
 # The zookeeper session timeout
 blur.zookeeper.timeout=90000
 
-# The path in ZooKeeper where the distributed traces will be stored, if blank trace output
will be written to the log or the HDFS store.
-blur.zookeeper.trace.path=/blur/traces
-
 # The path in HDFS where the distributed traces will be stored, if blank trace output will
be written to the log or the ZooKeeper store.
 blur.hdfs.trace.path=
 


Mime
View raw message