Adding test for cancelling commands.
Project: http://git-wip-us.apache.org/repos/asf/incubator-blur/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-blur/commit/d9fd6953 Tree: http://git-wip-us.apache.org/repos/asf/incubator-blur/tree/d9fd6953 Diff: http://git-wip-us.apache.org/repos/asf/incubator-blur/diff/d9fd6953 Branch: refs/heads/master Commit: d9fd6953e08b2d24654b77bae4205b985fa15ee1 Parents: f60c19c Author: Aaron McCurry <amccu...@gmail.com> Authored: Tue Jan 19 14:16:25 2016 -0500 Committer: Aaron McCurry <amccu...@gmail.com> Committed: Tue Jan 19 14:16:25 2016 -0500 ---------------------------------------------------------------------- .../blur/manager/writer/CreateSnapshot.java | 37 ++++++++++++++++++++ .../apache/blur/thrift/BlurClusterTestBase.java | 34 ++++++++++++++++++ .../services/org.apache.blur.command.Commands | 1 + 3 files changed, 72 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/d9fd6953/blur-core/src/main/java/org/apache/blur/manager/writer/CreateSnapshot.java ---------------------------------------------------------------------- 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 + + } + +} http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/d9fd6953/blur-core/src/test/java/org/apache/blur/thrift/BlurClusterTestBase.java ---------------------------------------------------------------------- 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.MiniCluster; 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.BlurResult; 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 @@ public abstract class BlurClusterTestBase { 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()); + } } http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/d9fd6953/blur-core/src/test/resources/META-INF/services/org.apache.blur.command.Commands ---------------------------------------------------------------------- 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.WaitForSeconds org.apache.blur.command.ThrowException org.apache.blur.command.RunSlowForTesting org.apache.blur.command.UserCurrentUser +org.apache.blur.command.InfiniteLoopCommand