incubator-blur-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From amccu...@apache.org
Subject [4/8] git commit: Added a truncate command to the shell.
Date Sun, 03 Mar 2013 19:37:03 GMT
Added a truncate command to the shell.


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

Branch: refs/heads/0.2-dev
Commit: cb2e5c5fe607223bce354cbc4e3d747ea57b12c8
Parents: 436da8d
Author: Aaron McCurry <amccurry@gmail.com>
Authored: Sat Mar 2 18:30:44 2013 -0500
Committer: Aaron McCurry <amccurry@gmail.com>
Committed: Sat Mar 2 18:30:44 2013 -0500

----------------------------------------------------------------------
 .../apache/blur/shell/TruncateTableCommand.java    |   69 +++++++++++++++
 1 files changed, 69 insertions(+), 0 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/cb2e5c5f/src/blur-shell/src/main/java/org/apache/blur/shell/TruncateTableCommand.java
----------------------------------------------------------------------
diff --git a/src/blur-shell/src/main/java/org/apache/blur/shell/TruncateTableCommand.java
b/src/blur-shell/src/main/java/org/apache/blur/shell/TruncateTableCommand.java
new file mode 100644
index 0000000..0813a42
--- /dev/null
+++ b/src/blur-shell/src/main/java/org/apache/blur/shell/TruncateTableCommand.java
@@ -0,0 +1,69 @@
+/**
+ * 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 jline.console.ConsoleReader;
+
+import org.apache.blur.thrift.generated.Blur.Iface;
+import org.apache.blur.thrift.generated.BlurException;
+import org.apache.blur.thrift.generated.TableDescriptor;
+import org.apache.thrift.TException;
+
+public class TruncateTableCommand extends TableSingleArgumentCommand {
+  public TruncateTableCommand(Iface client) {
+    super(client);
+  }
+
+  @Override
+  public void doit(PrintWriter out, String[] args, ConsoleReader reader) throws CommandException,
TException, BlurException {
+    Iface client = getClient();
+    if (args.length != 2) {
+      throw new CommandException("Invalid args: " + help());
+    }
+    String tablename = args[1];
+    TableDescriptor describe = client.describe(tablename);
+    client.disableTable(tablename);
+    try {
+      // @TODO take this out once the disableTable call blocks
+      Thread.sleep(5000);
+    } catch (InterruptedException e) {
+      throw new RuntimeException(e);
+    }
+    client.removeTable(tablename, true);
+    try {
+      // @TODO take this out once the removeTable call blocks
+      Thread.sleep(5000);
+    } catch (InterruptedException e) {
+      throw new RuntimeException(e);
+    }
+    client.createTable(describe);
+  }
+
+  @Override
+  public String help() {
+    return "truncate the named table, args; tablename";
+  }
+
+  @Override
+  public String getName() {
+    return "truncate";
+  }
+}


Mime
View raw message