incubator-blur-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From amccu...@apache.org
Subject [2/4] git commit: Cleanup of some old code.
Date Tue, 30 Apr 2013 03:17:24 GMT
Cleanup of some old code.


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

Branch: refs/heads/0.1.5
Commit: 9092cb8ab2baf0bdc327ff2dc4265c62d80f87cb
Parents: 1bcec18
Author: Aaron McCurry <amccurry@gmail.com>
Authored: Mon Apr 29 23:15:53 2013 -0400
Committer: Aaron McCurry <amccurry@gmail.com>
Committed: Mon Apr 29 23:15:53 2013 -0400

----------------------------------------------------------------------
 .../indexserver/DistributedIndexServer.java        |   78 +++------------
 .../src/main/resources/blur-default.properties     |    2 +-
 2 files changed, 16 insertions(+), 64 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/9092cb8a/src/blur-core/src/main/java/org/apache/blur/manager/indexserver/DistributedIndexServer.java
----------------------------------------------------------------------
diff --git a/src/blur-core/src/main/java/org/apache/blur/manager/indexserver/DistributedIndexServer.java
b/src/blur-core/src/main/java/org/apache/blur/manager/indexserver/DistributedIndexServer.java
index 71ab719..c35af15 100644
--- a/src/blur-core/src/main/java/org/apache/blur/manager/indexserver/DistributedIndexServer.java
+++ b/src/blur-core/src/main/java/org/apache/blur/manager/indexserver/DistributedIndexServer.java
@@ -55,6 +55,9 @@ import org.apache.blur.manager.BlurFilterCache;
 import org.apache.blur.manager.clusterstatus.ClusterStatus;
 import org.apache.blur.manager.clusterstatus.ZookeeperPathConstants;
 import org.apache.blur.manager.writer.BlurIndex;
+import org.apache.blur.manager.writer.BlurIndexCloser;
+import org.apache.blur.manager.writer.BlurIndexReader;
+import org.apache.blur.manager.writer.BlurIndexRefresher;
 import org.apache.blur.manager.writer.BlurNRTIndex;
 import org.apache.blur.manager.writer.SharedMergeScheduler;
 import org.apache.blur.metrics.AtomicLongGauge;
@@ -85,7 +88,6 @@ import org.apache.zookeeper.CreateMode;
 import org.apache.zookeeper.KeeperException;
 import org.apache.zookeeper.ZooDefs.Ids;
 import org.apache.zookeeper.ZooKeeper;
-import org.apache.zookeeper.data.Stat;
 
 import com.yammer.metrics.Metrics;
 import com.yammer.metrics.core.MetricName;
@@ -131,6 +133,8 @@ public class DistributedIndexServer extends AbstractIndexServer {
   private AtomicLong _indexCount = new AtomicLong();
   private AtomicLong _segmentCount = new AtomicLong();
   private AtomicLong _indexMemoryUsage = new AtomicLong();
+  private BlurIndexRefresher _refresher;
+  private BlurIndexCloser _indexCloser;
 
   public static interface ReleaseReader {
     void release() throws IOException;
@@ -156,12 +160,16 @@ public class DistributedIndexServer extends AbstractIndexServer {
     _searchExecutor = Executors.newThreadPool("internal-search", 16);
     _closer = new IndexInputCloser();
     _closer.init();
+    _refresher = new BlurIndexRefresher();
+    _refresher.init();
+    _indexCloser = new BlurIndexCloser();
+    _indexCloser.init();
     setupFlushCacheTimer();
     
     registerMyselfAsMemberOfCluster();
     String onlineShardsPath = ZookeeperPathConstants.getOnlineShardsPath(_cluster);
     String safemodePath = ZookeeperPathConstants.getSafemodePath(_cluster);
-    SafeMode safeMode = new SafeMode(_zookeeper, safemodePath, onlineShardsPath, TimeUnit.SECONDS,
5, TimeUnit.SECONDS, 60);
+    SafeMode safeMode = new SafeMode(_zookeeper, safemodePath, onlineShardsPath, TimeUnit.SECONDS,
_safeModeDelay, TimeUnit.SECONDS, 60);
     safeMode.registerNode(getNodeName(), BlurUtil.getVersion().getBytes());
 
     _running.set(true);
@@ -199,55 +207,6 @@ public class DistributedIndexServer extends AbstractIndexServer {
         });
   }
 
-  private void waitInSafeModeIfNeeded() throws KeeperException, InterruptedException {
-    String blurSafemodePath = ZookeeperPathConstants.getSafemodePath(_cluster);
-    Stat stat = _zookeeper.exists(blurSafemodePath, false);
-    if (stat == null) {
-      throw new RuntimeException("Safemode path missing [" + blurSafemodePath + "]");
-    }
-    byte[] data = _zookeeper.getData(blurSafemodePath, false, stat);
-    if (data == null) {
-      throw new RuntimeException("Safemode data missing [" + blurSafemodePath + "]");
-    }
-    long timestamp = Long.parseLong(new String(data));
-    long waitTime = timestamp - System.currentTimeMillis();
-    if (waitTime > 0) {
-      LOG.info("Waiting in safe mode for [{0}] seconds", waitTime / 1000.0);
-      Thread.sleep(waitTime);
-    }
-  }
-
-  private void setupSafeMode() throws KeeperException, InterruptedException {
-    String shardsPath = ZookeeperPathConstants.getOnlineShardsPath(_cluster);
-    List<String> children = _zookeeper.getChildren(shardsPath, false);
-    if (children.size() == 0) {
-      throw new RuntimeException("No shards registered!");
-    }
-    if (children.size() != 1) {
-      return;
-    }
-    LOG.info("First node online, setting up safe mode.");
-    long timestamp = System.currentTimeMillis() + _safeModeDelay;
-    String blurSafemodePath = ZookeeperPathConstants.getSafemodePath(_cluster);
-    Stat stat = _zookeeper.exists(blurSafemodePath, false);
-    if (stat == null) {
-      _zookeeper.create(blurSafemodePath, Long.toString(timestamp).getBytes(), Ids.OPEN_ACL_UNSAFE,
-          CreateMode.PERSISTENT);
-    } else {
-      _zookeeper.setData(blurSafemodePath, Long.toString(timestamp).getBytes(), -1);
-    }
-    setupAnyMissingPaths();
-  }
-
-  private void setupAnyMissingPaths() throws KeeperException, InterruptedException {
-    String tablesPath = ZookeeperPathConstants.getTablesPath(_cluster);
-    List<String> tables = _zookeeper.getChildren(tablesPath, false);
-    for (String table : tables) {
-      BlurUtil.createIfMissing(_zookeeper, ZookeeperPathConstants.getLockPath(_cluster, table));
-      BlurUtil.createIfMissing(_zookeeper, ZookeeperPathConstants.getTableFieldNamesPath(_cluster,
table));
-    }
-  }
-
   private void setupTableWarmer() {
     _timerTableWarmer = new Timer("Table-Warmer", true);
     _timerTableWarmer.schedule(new TimerTask() {
@@ -410,9 +369,12 @@ public class DistributedIndexServer extends AbstractIndexServer {
   @Override
   public void close() {
     if (_running.get()) {
+      
       _shardStateManager.close();
       _running.set(false);
       closeAllIndexes();
+      _refresher.close();
+      _indexCloser.close();
       _watchOnlineShards.close();
       _timerCacheFlush.purge();
       _timerCacheFlush.cancel();
@@ -519,18 +481,8 @@ public class DistributedIndexServer extends AbstractIndexServer {
 
     BlurIndex index;
     if (_clusterStatus.isReadOnly(true, _cluster, table)) {
-      // BlurIndexReader reader = new BlurIndexReader();
-      // reader.setCloser(_closer);
-      // reader.setAnalyzer(getAnalyzer(table));
-      // reader.setDirectory(dir);
-      // reader.setRefresher(_refresher);
-      // reader.setShard(shard);
-      // reader.setTable(table);
-      // reader.setIndexDeletionPolicy(_indexDeletionPolicy);
-      // reader.setSimilarity(getSimilarity(table));
-      // reader.init();
-      // index = reader;
-      throw new RuntimeException("not implemented yet");
+      BlurIndexReader reader = new BlurIndexReader(shardContext, directory, _refresher, _indexCloser);
+      index = reader;
     } else {
       BlurNRTIndex writer = new BlurNRTIndex(shardContext, _mergeScheduler, _closer, dir,
_gc, _searchExecutor);
       index = writer;

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/9092cb8a/src/blur-util/src/main/resources/blur-default.properties
----------------------------------------------------------------------
diff --git a/src/blur-util/src/main/resources/blur-default.properties b/src/blur-util/src/main/resources/blur-default.properties
index 4a7ddf0..6d0a97d 100644
--- a/src/blur-util/src/main/resources/blur-default.properties
+++ b/src/blur-util/src/main/resources/blur-default.properties
@@ -27,7 +27,7 @@ blur.shard.blockcache.direct.memory.allocation=true
 blur.shard.blockcache.slab.count=-1
 blur.shard.buffercache.1024=8192
 blur.shard.buffercache.8192=8192
-blur.shard.safemodedelay=30000
+blur.shard.safemodedelay=5000
 blur.shard.time.between.commits=30000
 blur.shard.time.between.refreshs=3000
 blur.max.clause.count=1024


Mime
View raw message