incubator-blur-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From amccu...@apache.org
Subject git commit: Adding an optimize command.
Date Sun, 23 Mar 2014 19:38:28 GMT
Repository: incubator-blur
Updated Branches:
  refs/heads/apache-blur-0.2 831d22f38 -> 2b068fe60


Adding an optimize command.


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

Branch: refs/heads/apache-blur-0.2
Commit: 2b068fe60d5b57f13086cc08058482d71bf8a8b9
Parents: 831d22f
Author: Aaron McCurry <amccurry@gmail.com>
Authored: Sun Mar 23 15:38:27 2014 -0400
Committer: Aaron McCurry <amccurry@gmail.com>
Committed: Sun Mar 23 15:38:27 2014 -0400

----------------------------------------------------------------------
 .../manager/writer/BlurIndexSimpleWriter.java   |  2 +-
 .../main/java/org/apache/blur/shell/Main.java   |  3 +-
 .../apache/blur/shell/OptimizeTableCommand.java | 53 ++++++++++++++++++++
 docs/using-blur.html                            |  4 ++
 4 files changed, 60 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/2b068fe6/blur-core/src/main/java/org/apache/blur/manager/writer/BlurIndexSimpleWriter.java
----------------------------------------------------------------------
diff --git a/blur-core/src/main/java/org/apache/blur/manager/writer/BlurIndexSimpleWriter.java
b/blur-core/src/main/java/org/apache/blur/manager/writer/BlurIndexSimpleWriter.java
index 651dd10..91806c1 100644
--- a/blur-core/src/main/java/org/apache/blur/manager/writer/BlurIndexSimpleWriter.java
+++ b/blur-core/src/main/java/org/apache/blur/manager/writer/BlurIndexSimpleWriter.java
@@ -248,7 +248,7 @@ public class BlurIndexSimpleWriter extends BlurIndex {
   public synchronized void optimize(final int numberOfSegmentsPerShard) throws IOException
{
     final String table = _tableContext.getTable();
     final String shard = _shardContext.getShard();
-    if (_optimizeThread == null || _optimizeThread.isAlive()) {
+    if (_optimizeThread != null && _optimizeThread.isAlive()) {
       LOG.info("Already running an optimize on table [{0}] shard [{1}]", table, shard);
       return;
     }

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/2b068fe6/blur-shell/src/main/java/org/apache/blur/shell/Main.java
----------------------------------------------------------------------
diff --git a/blur-shell/src/main/java/org/apache/blur/shell/Main.java b/blur-shell/src/main/java/org/apache/blur/shell/Main.java
index f9df7ed..7c912c1 100644
--- a/blur-shell/src/main/java/org/apache/blur/shell/Main.java
+++ b/blur-shell/src/main/java/org/apache/blur/shell/Main.java
@@ -399,7 +399,7 @@ public class Main {
   }
 
   public static String[] tableCommands = { "create", "enable", "disable", "remove", "truncate",
"describe", "list",
-      "schema", "stats", "layout", "parse", "definecolumn" };
+      "schema", "stats", "layout", "parse", "definecolumn", "optimize" };
   public static String[] dataCommands = { "query", "get", "mutate", "delete", "highlight",
"selector", "terms",
       "create-snapshot", "remove-snapshot", "list-snapshots" };
   public static String[] clusterCommands = { "controllers", "shards", "clusterlist", "cluster",
"safemodewait", "top" };
@@ -695,6 +695,7 @@ public class Main {
     register(builder, new LogCommand());
     register(builder, new LogResetCommand());
     register(builder, new RemoveShardServerCommand());
+    register(builder, new OptimizeTableCommand());
     commands = builder.build();
   }
 

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/2b068fe6/blur-shell/src/main/java/org/apache/blur/shell/OptimizeTableCommand.java
----------------------------------------------------------------------
diff --git a/blur-shell/src/main/java/org/apache/blur/shell/OptimizeTableCommand.java b/blur-shell/src/main/java/org/apache/blur/shell/OptimizeTableCommand.java
new file mode 100644
index 0000000..ce26bec
--- /dev/null
+++ b/blur-shell/src/main/java/org/apache/blur/shell/OptimizeTableCommand.java
@@ -0,0 +1,53 @@
+/**
+ * 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.shell;
+
+import java.io.PrintWriter;
+
+import org.apache.blur.thirdparty.thrift_0_9_0.TException;
+import org.apache.blur.thrift.generated.Blur;
+import org.apache.blur.thrift.generated.BlurException;
+
+public class OptimizeTableCommand extends Command implements TableFirstArgCommand {
+  @Override
+  public void doit(PrintWriter out, Blur.Iface client, String[] args) throws CommandException,
TException,
+      BlurException {
+    if (args.length != 3) {
+      throw new CommandException("Invalid args: " + help());
+    }
+    String tablename = args[1];
+    int numberOfSegmentsPerShard = Integer.parseInt(args[2]);
+    client.optimize(tablename, numberOfSegmentsPerShard);
+  }
+
+  @Override
+  public String description() {
+    return "Optimize the named table.";
+  }
+
+  @Override
+  public String usage() {
+    return "<tablename> <number of segments per shard>";
+  }
+
+  @Override
+  public String name() {
+    return "optimize";
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/2b068fe6/docs/using-blur.html
----------------------------------------------------------------------
diff --git a/docs/using-blur.html b/docs/using-blur.html
index 830c4bf..717c462 100644
--- a/docs/using-blur.html
+++ b/docs/using-blur.html
@@ -86,6 +86,7 @@
 <li><a href="#shell_command_layout">&nbsp;&nbsp;layout</a></li>
 <li><a href="#shell_command_parse">&nbsp;&nbsp;parse</a></li>
 <li><a href="#shell_command_definecolumn">&nbsp;&nbsp;definecolumn</a></li>
+<li><a href="#shell_command_optimize">&nbsp;&nbsp;optimize</a></li>
 </ul></li>
 <li><a href="#shell_data_commands">Data Commands</a>
 <ul class="nav">
@@ -443,6 +444,9 @@ The following rules are used when interacting with the shell:
 <h4 id="shell_command_definecolumn">definecolumn</h4>
 <p>Description: Defines a new column in the named table. '-F' option is for fieldless
searching and the '-S' is for sortability.<br/>
 <pre><code class="bash">definecolumn &lt;table name&gt; &lt;family&gt;
&lt;column name&gt; &lt;type&gt; [-s &lt;sub column name&gt;] [-F]
[-S] [-p name value]*</code></pre></p>
+<h4 id="shell_command_optimize">optimize</h4>
+<p>Description: Optimize the named table.<br/>
+<pre><code class="bash">optimize &lt;tablename&gt; &lt;number of
segments per shard&gt;</code></pre></p>
 <h3 id="shell_data_commands">Data Commands</h3>
 <h4 id="shell_command_query">query</h4>
 <p>Description: Query the named table.<br/>


Mime
View raw message