Adding test for cancelling commands.
diff --git a/blur-core/src/main/java/org/apache/blur/manager/writer/CreateSnapshot.java b/blur-core/src/main/java/org/apache/blur/manager/writer/CreateSnapshot.java
new file mode 100644
index 0000000..aa6fd35
--- /dev/null
+++ b/blur-core/src/main/java/org/apache/blur/manager/writer/CreateSnapshot.java
@@ -0,0 +1,37 @@
+/**
+ * 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.manager.writer;
+
+import java.io.IOException;
+
+import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.fs.FileSystem;
+import org.apache.hadoop.fs.Path;
+import org.apache.hadoop.hdfs.DistributedFileSystem;
+
+public class CreateSnapshot {
+
+ public static void main(String[] args) throws IOException {
+ Path path = new Path("hdfs://node-000/user/amccurry/snapshot");
+ Configuration configuration = new Configuration();
+ FileSystem fileSystem = path.getFileSystem(configuration);
+ DistributedFileSystem distributedFileSystem = (DistributedFileSystem) fileSystem;
+// distributedFileSystem.create
+
+ }
+
+}
diff --git a/blur-core/src/test/java/org/apache/blur/thrift/BlurClusterTestBase.java b/blur-core/src/test/java/org/apache/blur/thrift/BlurClusterTestBase.java
index 4a28153..7233ff5 100644
--- a/blur-core/src/test/java/org/apache/blur/thrift/BlurClusterTestBase.java
+++ b/blur-core/src/test/java/org/apache/blur/thrift/BlurClusterTestBase.java
@@ -47,6 +47,7 @@
import org.apache.blur.TestType;
import org.apache.blur.analysis.FieldManager;
import org.apache.blur.command.BlurObject;
+import org.apache.blur.command.InfiniteLoopCommand;
import org.apache.blur.command.RunSlowForTesting;
import org.apache.blur.command.Shard;
import org.apache.blur.command.UserCurrentUser;
@@ -61,6 +62,7 @@
import org.apache.blur.thrift.generated.BlurResults;
import org.apache.blur.thrift.generated.Column;
import org.apache.blur.thrift.generated.ColumnDefinition;
+import org.apache.blur.thrift.generated.CommandStatus;
import org.apache.blur.thrift.generated.ErrorType;
import org.apache.blur.thrift.generated.Facet;
import org.apache.blur.thrift.generated.FetchResult;
@@ -1057,4 +1059,36 @@
blurMutationBug.runTest(2, TimeUnit.MINUTES);
}
+ @Test
+ public void testCancelCommand() throws IOException, BlurException, TException, InterruptedException {
+ String table = "testCancelCommand";
+ createTable(table);
+ loadTable(table);
+ Iface client = getClient();
+ AtomicBoolean fail = new AtomicBoolean();
+ Thread thread = new Thread(new Runnable() {
+ @Override
+ public void run() {
+ InfiniteLoopCommand infiniteLoopCommand = new InfiniteLoopCommand();
+ infiniteLoopCommand.setTable(table);
+ try {
+ infiniteLoopCommand.run(getClient());
+ fail.set(true);
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+ });
+ thread.start();
+
+ Thread.sleep(2000);
+ List<String> commandStatusList = client.commandStatusList(0, (short) 100);
+ for (String s : commandStatusList) {
+ CommandStatus commandStatus = client.commandStatus(s);
+ System.out.println(commandStatus);
+ client.commandCancel(s);
+ }
+ thread.join();
+ assertFalse("The cancelled command failed to throw an exception.", fail.get());
+ }
}
diff --git a/blur-core/src/test/resources/META-INF/services/org.apache.blur.command.Commands b/blur-core/src/test/resources/META-INF/services/org.apache.blur.command.Commands
index 710bab0..efd34b0 100644
--- a/blur-core/src/test/resources/META-INF/services/org.apache.blur.command.Commands
+++ b/blur-core/src/test/resources/META-INF/services/org.apache.blur.command.Commands
@@ -17,3 +17,4 @@
org.apache.blur.command.ThrowException
org.apache.blur.command.RunSlowForTesting
org.apache.blur.command.UserCurrentUser
+org.apache.blur.command.InfiniteLoopCommand