You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@accumulo.apache.org by ct...@apache.org on 2015/07/18 02:08:01 UTC
[6/8] accumulo git commit: Merge branch '1.6' into 1.7
Merge branch '1.6' into 1.7
Conflicts:
shell/src/test/java/org/apache/accumulo/shell/ShellConfigTest.java
Project: http://git-wip-us.apache.org/repos/asf/accumulo/repo
Commit: http://git-wip-us.apache.org/repos/asf/accumulo/commit/e8df6f0f
Tree: http://git-wip-us.apache.org/repos/asf/accumulo/tree/e8df6f0f
Diff: http://git-wip-us.apache.org/repos/asf/accumulo/diff/e8df6f0f
Branch: refs/heads/master
Commit: e8df6f0f22f39f825ee0ea2d54659358353bfebb
Parents: 4911f85 967100d
Author: Christopher Tubbs <ct...@apache.org>
Authored: Fri Jul 17 19:48:29 2015 -0400
Committer: Christopher Tubbs <ct...@apache.org>
Committed: Fri Jul 17 19:48:29 2015 -0400
----------------------------------------------------------------------
.../accumulo/core/client/mapreduce/RangeInputSplit.java | 2 +-
.../core/client/mapreduce/AccumuloInputFormatTest.java | 12 +++++-------
.../java/org/apache/accumulo/shell/ShellConfigTest.java | 10 +++++-----
3 files changed, 11 insertions(+), 13 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/accumulo/blob/e8df6f0f/core/src/main/java/org/apache/accumulo/core/client/mapreduce/RangeInputSplit.java
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/accumulo/blob/e8df6f0f/core/src/test/java/org/apache/accumulo/core/client/mapreduce/AccumuloInputFormatTest.java
----------------------------------------------------------------------
diff --cc core/src/test/java/org/apache/accumulo/core/client/mapreduce/AccumuloInputFormatTest.java
index a14560c,1801b37..83662e8
--- a/core/src/test/java/org/apache/accumulo/core/client/mapreduce/AccumuloInputFormatTest.java
+++ b/core/src/test/java/org/apache/accumulo/core/client/mapreduce/AccumuloInputFormatTest.java
@@@ -300,29 -301,9 +300,29 @@@ public class AccumuloInputFormatTest
}
@Test
+ public void testMapWithBatchScanner() throws Exception {
+ final String INSTANCE_NAME = PREFIX + "_mapreduce_instance";
+ final String TEST_TABLE_2 = PREFIX + "_mapreduce_table_2";
+
+ MockInstance mockInstance = new MockInstance(INSTANCE_NAME);
+ Connector c = mockInstance.getConnector("root", new PasswordToken(""));
+ c.tableOperations().create(TEST_TABLE_2);
+ BatchWriter bw = c.createBatchWriter(TEST_TABLE_2, new BatchWriterConfig());
+ for (int i = 0; i < 100; i++) {
+ Mutation m = new Mutation(new Text(String.format("%09x", i + 1)));
+ m.put(new Text(), new Text(), new Value(String.format("%09x", i).getBytes()));
+ bw.addMutation(m);
+ }
+ bw.close();
+
- Assert.assertEquals(0, MRTester.main(new String[] {"root", "", TEST_TABLE_2, INSTANCE_NAME, AccumuloInputFormat.class.getCanonicalName(), "True"}));
++ Assert.assertEquals(0, MRTester.main(new String[] {"root", "", TEST_TABLE_2, INSTANCE_NAME, AccumuloInputFormat.class.getName(), "True"}));
+ assertNull(e1);
+ assertNull(e2);
+ }
+
+ @Test
public void testCorrectRangeInputSplits() throws Exception {
- @SuppressWarnings("deprecation")
- Job job = new Job(new Configuration(), this.getClass().getSimpleName() + "_" + System.currentTimeMillis());
+ Job job = Job.getInstance(new Configuration(), this.getClass().getSimpleName() + "_" + System.currentTimeMillis());
String username = "user", table = "table", instance = "mapreduce_testCorrectRangeInputSplits";
PasswordToken password = new PasswordToken("password");
@@@ -383,10 -364,10 +383,8 @@@
}
bw.close();
-- Assert.assertEquals(
-- 0,
-- MRTester.main(new String[] {user, "", "testtable", "testPartialInputSplitDelegationToConfiguration",
- EmptySplitsAccumuloInputFormat.class.getCanonicalName()}));
- EmptySplitsAccumuloInputFormat.class.getName()}));
++ Assert.assertEquals(0,
++ MRTester.main(new String[] {user, "", "testtable", "testPartialInputSplitDelegationToConfiguration", EmptySplitsAccumuloInputFormat.class.getName()}));
assertNull(e1);
assertNull(e2);
}
http://git-wip-us.apache.org/repos/asf/accumulo/blob/e8df6f0f/shell/src/test/java/org/apache/accumulo/shell/ShellConfigTest.java
----------------------------------------------------------------------
diff --cc shell/src/test/java/org/apache/accumulo/shell/ShellConfigTest.java
index bbeef56,0000000..64bad82
mode 100644,000000..100644
--- a/shell/src/test/java/org/apache/accumulo/shell/ShellConfigTest.java
+++ b/shell/src/test/java/org/apache/accumulo/shell/ShellConfigTest.java
@@@ -1,150 -1,0 +1,150 @@@
+/*
+ * 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.accumulo.shell;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+import java.io.File;
+import java.io.FileDescriptor;
+import java.io.FileInputStream;
+import java.io.PrintStream;
+import java.io.PrintWriter;
+import java.nio.file.Files;
+import java.util.HashMap;
+import java.util.Map;
+
+import jline.console.ConsoleReader;
+
+import org.apache.accumulo.core.client.ClientConfiguration;
+import org.apache.accumulo.core.client.security.tokens.PasswordToken;
+import org.apache.accumulo.core.conf.AccumuloConfiguration;
+import org.apache.accumulo.core.conf.ConfigurationCopy;
+import org.apache.accumulo.core.conf.Property;
+import org.apache.accumulo.shell.ShellTest.TestOutputStream;
+import org.apache.log4j.Level;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.beust.jcommander.ParameterException;
+
+public class ShellConfigTest {
+ TestOutputStream output;
+ Shell shell;
+ PrintStream out;
+ File config;
+ private static final Logger log = LoggerFactory.getLogger(ShellConfigTest.class);
+
+ @Before
+ public void setUp() throws Exception {
+ Shell.log.setLevel(Level.ERROR);
+
+ out = System.out;
+ output = new TestOutputStream();
+ System.setOut(new PrintStream(output));
+ config = Files.createTempFile(null, null).toFile();
+
+ shell = new Shell(new ConsoleReader(new FileInputStream(FileDescriptor.in), output), new PrintWriter(output));
+ shell.setLogErrorsToConsole();
+ }
+
+ @After
+ public void teardown() throws Exception {
+ shell.shutdown();
+ output.clear();
+ System.setOut(out);
+ if (config.exists()) {
+ if (!config.delete()) {
+ log.error("Unable to delete {}", config);
+ }
+ }
+ }
+
+ public String[] args(String... args) {
+ // Avoid a locally installed client configuration file from breaking the test
+ String[] finalArgs = new String[args.length + 2];
+ int i = 0;
+ finalArgs[i++] = "--config-file";
+ finalArgs[i++] = config.toString();
+ for (String arg : args) {
+ finalArgs[i++] = arg;
+ }
+ return finalArgs;
+ }
+
+ @Test
+ public void testHelp() {
+ assertFalse(shell.config(args("--help")));
+ assertTrue("Did not print usage", output.get().startsWith("Usage"));
+ }
+
+ @Test
+ public void testBadArg() {
+ assertFalse(shell.config(args("--bogus")));
+ assertTrue("Did not print usage", output.get().startsWith("Usage"));
+ }
+
+ @Test
+ public void testTokenWithoutOptions() {
- assertFalse(shell.config(args("--fake", "-tc", PasswordToken.class.getCanonicalName())));
- assertFalse(output.get().contains(ParameterException.class.getCanonicalName()));
++ assertFalse(shell.config(args("--fake", "-tc", PasswordToken.class.getName())));
++ assertFalse(output.get().contains(ParameterException.class.getName()));
+ }
+
+ @Test
+ public void testTokenAndOption() {
- assertTrue(shell.config(args("--fake", "-tc", PasswordToken.class.getCanonicalName(), "-u", "foo", "-l", "password=foo")));
++ assertTrue(shell.config(args("--fake", "-tc", PasswordToken.class.getName(), "-u", "foo", "-l", "password=foo")));
+ }
+
+ @Test
+ public void testTokenAndOptionAndPassword() {
- assertFalse(shell.config(args("--fake", "-tc", PasswordToken.class.getCanonicalName(), "-l", "password=foo", "-p", "bar")));
- assertTrue(output.get().contains(ParameterException.class.getCanonicalName()));
++ assertFalse(shell.config(args("--fake", "-tc", PasswordToken.class.getName(), "-l", "password=foo", "-p", "bar")));
++ assertTrue(output.get().contains(ParameterException.class.getName()));
+ }
+
+ @Test
+ public void testZooKeeperHostFallBackToSite() throws Exception {
+ ClientConfiguration clientConfig = new ClientConfiguration();
+ Map<String,String> data = new HashMap<>();
+ data.put(Property.INSTANCE_ZK_HOST.getKey(), "site_hostname");
+ AccumuloConfiguration conf = new ConfigurationCopy(data);
+ assertEquals("site_hostname", Shell.getZooKeepers(null, clientConfig, conf));
+ }
+
+ @Test
+ public void testZooKeeperHostFromClientConfig() throws Exception {
+ ClientConfiguration clientConfig = new ClientConfiguration();
+ clientConfig.withZkHosts("cc_hostname");
+ Map<String,String> data = new HashMap<>();
+ data.put(Property.INSTANCE_ZK_HOST.getKey(), "site_hostname");
+ AccumuloConfiguration conf = new ConfigurationCopy(data);
+ assertEquals("cc_hostname", Shell.getZooKeepers(null, clientConfig, conf));
+ }
+
+ @Test
+ public void testZooKeeperHostFromOption() throws Exception {
+ ClientConfiguration clientConfig = new ClientConfiguration();
+ clientConfig.withZkHosts("cc_hostname");
+ Map<String,String> data = new HashMap<>();
+ data.put(Property.INSTANCE_ZK_HOST.getKey(), "site_hostname");
+ AccumuloConfiguration conf = new ConfigurationCopy(data);
+ assertEquals("opt_hostname", Shell.getZooKeepers("opt_hostname", clientConfig, conf));
+ }
+}