http://git-wip-us.apache.org/repos/asf/accumulo/blob/cfbdef13/shell/src/test/java/org/apache/accumulo/shell/ShellUtilTest.java ---------------------------------------------------------------------- diff --cc shell/src/test/java/org/apache/accumulo/shell/ShellUtilTest.java index 934a41d,0000000..c3af70a mode 100644,000000..100644 --- a/shell/src/test/java/org/apache/accumulo/shell/ShellUtilTest.java +++ b/shell/src/test/java/org/apache/accumulo/shell/ShellUtilTest.java @@@ -1,67 -1,0 +1,67 @@@ +/* + * 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 java.nio.charset.StandardCharsets.UTF_8; +import static org.junit.Assert.*; + +import java.io.File; +import java.io.FileNotFoundException; +import java.io.IOException; - import java.nio.charset.StandardCharsets; +import java.util.List; + +import org.apache.accumulo.core.util.Base64; +import org.apache.accumulo.shell.ShellUtil; +import org.apache.commons.io.FileUtils; +import org.apache.hadoop.io.Text; +import org.junit.Rule; +import org.junit.Test; +import org.junit.rules.TemporaryFolder; + +import com.google.common.collect.ImmutableList; + +public class ShellUtilTest { + + @Rule + public TemporaryFolder folder = new TemporaryFolder(new File(System.getProperty("user.dir") + "/target")); + + // String with 3 lines, with one empty line + private static final String FILEDATA = "line1\n\nline2"; + + @Test + public void testWithoutDecode() throws IOException { + File testFile = new File(folder.getRoot(), "testFileNoDecode.txt"); + FileUtils.writeStringToFile(testFile, FILEDATA); + List<Text> output = ShellUtil.scanFile(testFile.getAbsolutePath(), false); + assertEquals(ImmutableList.of(new Text("line1"), new Text("line2")), output); + } + + @Test + public void testWithDecode() throws IOException { + File testFile = new File(folder.getRoot(), "testFileWithDecode.txt"); + FileUtils.writeStringToFile(testFile, FILEDATA); + List<Text> output = ShellUtil.scanFile(testFile.getAbsolutePath(), true); + assertEquals( - ImmutableList.of(new Text(Base64.decodeBase64("line1".getBytes(StandardCharsets.UTF_8))), new Text(Base64.decodeBase64("line2".getBytes(StandardCharsets.UTF_8)))), ++ ImmutableList.of(new Text(Base64.decodeBase64("line1".getBytes(UTF_8))), new Text(Base64.decodeBase64("line2".getBytes(UTF_8)))), + output); + } + + @Test(expected = FileNotFoundException.class) + public void testWithMissingFile() throws FileNotFoundException { + ShellUtil.scanFile("missingFile.txt", false); + } +}
http://git-wip-us.apache.org/repos/asf/accumulo/blob/cfbdef13/shell/src/test/java/org/apache/accumulo/shell/format/DeleterFormatterTest.java ---------------------------------------------------------------------- diff --cc shell/src/test/java/org/apache/accumulo/shell/format/DeleterFormatterTest.java index e5b7394,0000000..0229cee mode 100644,000000..100644 --- a/shell/src/test/java/org/apache/accumulo/shell/format/DeleterFormatterTest.java +++ b/shell/src/test/java/org/apache/accumulo/shell/format/DeleterFormatterTest.java @@@ -1,177 -1,0 +1,177 @@@ +/* + * 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.format; + ++import static java.nio.charset.StandardCharsets.UTF_8; +import static org.easymock.EasyMock.anyObject; +import static org.easymock.EasyMock.createMock; +import static org.easymock.EasyMock.createNiceMock; +import static org.easymock.EasyMock.expect; +import static org.easymock.EasyMock.expectLastCall; +import static org.easymock.EasyMock.replay; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertTrue; + +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.InputStream; - import java.nio.charset.StandardCharsets; +import java.util.Collections; +import java.util.Map; +import java.util.TreeMap; + +import jline.UnsupportedTerminal; +import jline.console.ConsoleReader; + +import org.apache.accumulo.core.client.BatchWriter; +import org.apache.accumulo.core.client.MutationsRejectedException; +import org.apache.accumulo.core.data.Key; +import org.apache.accumulo.core.data.Mutation; +import org.apache.accumulo.core.data.Value; +import org.apache.accumulo.shell.Shell; +import org.apache.accumulo.shell.format.DeleterFormatter; +import org.junit.Before; +import org.junit.Test; + +public class DeleterFormatterTest { + DeleterFormatter formatter; + Map<Key,Value> data; + BatchWriter writer; + BatchWriter exceptionWriter; + Shell shellState; + + ByteArrayOutputStream baos; + ConsoleReader reader; + + SettableInputStream input; + + class SettableInputStream extends InputStream { + ByteArrayInputStream bais; + + @Override + public int read() throws IOException { + return bais.read(); + } + + public void set(String in) { - bais = new ByteArrayInputStream(in.getBytes(StandardCharsets.UTF_8)); ++ bais = new ByteArrayInputStream(in.getBytes(UTF_8)); + } + }; + + @Before + public void setUp() throws IOException, MutationsRejectedException { + input = new SettableInputStream(); + baos = new ByteArrayOutputStream(); + + MutationsRejectedException mre = createMock(MutationsRejectedException.class); + + writer = createNiceMock(BatchWriter.class); + exceptionWriter = createNiceMock(BatchWriter.class); + exceptionWriter.close(); + expectLastCall().andThrow(mre); + exceptionWriter.addMutation(anyObject(Mutation.class)); + expectLastCall().andThrow(mre); + + shellState = createNiceMock(Shell.class); + + reader = new ConsoleReader(input, baos, new UnsupportedTerminal()); + expect(shellState.getReader()).andReturn(reader).anyTimes(); + + replay(writer, exceptionWriter, shellState); + + data = new TreeMap<Key,Value>(); - data.put(new Key("r", "cf", "cq"), new Value("value".getBytes(StandardCharsets.UTF_8))); ++ data.put(new Key("r", "cf", "cq"), new Value("value".getBytes(UTF_8))); + } + + @Test + public void testEmpty() { + formatter = new DeleterFormatter(writer, Collections.<Key,Value> emptyMap().entrySet(), true, shellState, true); + assertFalse(formatter.hasNext()); + } + + @Test + public void testSingle() throws IOException { + formatter = new DeleterFormatter(writer, data.entrySet(), true, shellState, true); + + assertTrue(formatter.hasNext()); + assertNull(formatter.next()); + + verify("[DELETED]", " r ", "cf", "cq", "value"); + } + + @Test + public void testNo() throws IOException { + input.set("no\n"); - data.put(new Key("z"), new Value("v2".getBytes(StandardCharsets.UTF_8))); ++ data.put(new Key("z"), new Value("v2".getBytes(UTF_8))); + formatter = new DeleterFormatter(writer, data.entrySet(), true, shellState, false); + + assertTrue(formatter.hasNext()); + assertNull(formatter.next()); + + verify("[SKIPPED]", " r ", "cf", "cq", "value"); + + assertTrue(formatter.hasNext()); + } + + @Test + public void testNoConfirmation() throws IOException { + input.set(""); - data.put(new Key("z"), new Value("v2".getBytes(StandardCharsets.UTF_8))); ++ data.put(new Key("z"), new Value("v2".getBytes(UTF_8))); + formatter = new DeleterFormatter(writer, data.entrySet(), true, shellState, false); + + assertTrue(formatter.hasNext()); + assertNull(formatter.next()); + + verify("[SKIPPED]", " r ", "cf", "cq", "value"); + + assertFalse(formatter.hasNext()); + } + + @Test + public void testYes() throws IOException { + input.set("y\nyes\n"); - data.put(new Key("z"), new Value("v2".getBytes(StandardCharsets.UTF_8))); ++ data.put(new Key("z"), new Value("v2".getBytes(UTF_8))); + formatter = new DeleterFormatter(writer, data.entrySet(), true, shellState, false); + + assertTrue(formatter.hasNext()); + assertNull(formatter.next()); + verify("[DELETED]", " r ", "cf", "cq", "value"); + + assertTrue(formatter.hasNext()); + assertNull(formatter.next()); + verify("[DELETED]", " z ", "v2"); + } + + @Test + public void testMutationException() { + formatter = new DeleterFormatter(exceptionWriter, data.entrySet(), true, shellState, true); + + assertTrue(formatter.hasNext()); + assertNull(formatter.next()); + assertFalse(formatter.hasNext()); + } + + private void verify(String... chunks) throws IOException { + reader.flush(); + + String output = baos.toString(); + for (String chunk : chunks) { + assertTrue(output.contains(chunk)); + } + } +} http://git-wip-us.apache.org/repos/asf/accumulo/blob/cfbdef13/test/src/main/java/org/apache/accumulo/test/BulkImportDirectory.java ---------------------------------------------------------------------- diff --cc test/src/main/java/org/apache/accumulo/test/BulkImportDirectory.java index 93c2e98,b6f5214..8693d03 --- a/test/src/main/java/org/apache/accumulo/test/BulkImportDirectory.java +++ b/test/src/main/java/org/apache/accumulo/test/BulkImportDirectory.java @@@ -16,8 -16,9 +16,9 @@@ */ package org.apache.accumulo.test; -import static com.google.common.base.Charsets.UTF_8; ++import static java.nio.charset.StandardCharsets.UTF_8; + import java.io.IOException; - import java.nio.charset.StandardCharsets; import java.util.ArrayList; import java.util.List; http://git-wip-us.apache.org/repos/asf/accumulo/blob/cfbdef13/test/src/main/java/org/apache/accumulo/test/NativeMapConcurrencyTest.java ---------------------------------------------------------------------- diff --cc test/src/main/java/org/apache/accumulo/test/NativeMapConcurrencyTest.java index abf31d2,10ee8a4..c9d18e1 --- a/test/src/main/java/org/apache/accumulo/test/NativeMapConcurrencyTest.java +++ b/test/src/main/java/org/apache/accumulo/test/NativeMapConcurrencyTest.java @@@ -16,7 -16,8 +16,8 @@@ */ package org.apache.accumulo.test; - import java.nio.charset.StandardCharsets; -import static com.google.common.base.Charsets.UTF_8; ++import static java.nio.charset.StandardCharsets.UTF_8; + import java.util.Iterator; import java.util.Map.Entry; http://git-wip-us.apache.org/repos/asf/accumulo/blob/cfbdef13/test/src/main/java/org/apache/accumulo/test/NativeMapPerformanceTest.java ---------------------------------------------------------------------- diff --cc test/src/main/java/org/apache/accumulo/test/NativeMapPerformanceTest.java index d9527c5,c52ed29..1e1006b --- a/test/src/main/java/org/apache/accumulo/test/NativeMapPerformanceTest.java +++ b/test/src/main/java/org/apache/accumulo/test/NativeMapPerformanceTest.java @@@ -16,7 -16,8 +16,8 @@@ */ package org.apache.accumulo.test; - import java.nio.charset.StandardCharsets; -import static com.google.common.base.Charsets.UTF_8; ++import static java.nio.charset.StandardCharsets.UTF_8; + import java.util.Collections; import java.util.Iterator; import java.util.Map.Entry; http://git-wip-us.apache.org/repos/asf/accumulo/blob/cfbdef13/test/src/main/java/org/apache/accumulo/test/NativeMapStressTest.java ---------------------------------------------------------------------- diff --cc test/src/main/java/org/apache/accumulo/test/NativeMapStressTest.java index a73199c,51405db..c8e821b --- a/test/src/main/java/org/apache/accumulo/test/NativeMapStressTest.java +++ b/test/src/main/java/org/apache/accumulo/test/NativeMapStressTest.java @@@ -16,7 -16,8 +16,8 @@@ */ package org.apache.accumulo.test; - import java.nio.charset.StandardCharsets; -import static com.google.common.base.Charsets.UTF_8; ++import static java.nio.charset.StandardCharsets.UTF_8; + import java.util.ArrayList; import java.util.HashMap; import java.util.Iterator; http://git-wip-us.apache.org/repos/asf/accumulo/blob/cfbdef13/test/src/main/java/org/apache/accumulo/test/TestBinaryRows.java ---------------------------------------------------------------------- diff --cc test/src/main/java/org/apache/accumulo/test/TestBinaryRows.java index a5ac0e8,3c20858..7b373c4 --- a/test/src/main/java/org/apache/accumulo/test/TestBinaryRows.java +++ b/test/src/main/java/org/apache/accumulo/test/TestBinaryRows.java @@@ -16,7 -16,8 +16,8 @@@ */ package org.apache.accumulo.test; - import java.nio.charset.StandardCharsets; -import static com.google.common.base.Charsets.UTF_8; ++import static java.nio.charset.StandardCharsets.UTF_8; + import java.util.Iterator; import java.util.Map.Entry; import java.util.Random; @@@ -83,9 -84,9 +84,9 @@@ public class TestBinaryRows public static void runTest(Connector connector, Opts opts, BatchWriterOpts bwOpts, ScannerOpts scanOpts) throws Exception { final Text CF = new Text("cf"), CQ = new Text("cq"); - final byte[] CF_BYTES = "cf".getBytes(StandardCharsets.UTF_8), CQ_BYTES = "cq".getBytes(StandardCharsets.UTF_8); + final byte[] CF_BYTES = "cf".getBytes(UTF_8), CQ_BYTES = "cq".getBytes(UTF_8); if (opts.mode.equals("ingest") || opts.mode.equals("delete")) { - BatchWriter bw = connector.createBatchWriter(opts.tableName, bwOpts.getBatchWriterConfig()); + BatchWriter bw = connector.createBatchWriter(opts.getTableName(), bwOpts.getBatchWriterConfig()); boolean delete = opts.mode.equals("delete"); for (long i = 0; i < opts.num; i++) { http://git-wip-us.apache.org/repos/asf/accumulo/blob/cfbdef13/test/src/main/java/org/apache/accumulo/test/TestIngest.java ---------------------------------------------------------------------- diff --cc test/src/main/java/org/apache/accumulo/test/TestIngest.java index 0548f4c,c3e77af..7f6c514 --- a/test/src/main/java/org/apache/accumulo/test/TestIngest.java +++ b/test/src/main/java/org/apache/accumulo/test/TestIngest.java @@@ -16,8 -16,9 +16,9 @@@ */ package org.apache.accumulo.test; -import static com.google.common.base.Charsets.UTF_8; ++import static java.nio.charset.StandardCharsets.UTF_8; + import java.io.IOException; - import java.nio.charset.StandardCharsets; import java.util.Map.Entry; import java.util.Random; import java.util.Set; http://git-wip-us.apache.org/repos/asf/accumulo/blob/cfbdef13/test/src/main/java/org/apache/accumulo/test/TestMultiTableIngest.java ---------------------------------------------------------------------- diff --cc test/src/main/java/org/apache/accumulo/test/TestMultiTableIngest.java index 133a5a5,16f0b3f..c5fcf34 --- a/test/src/main/java/org/apache/accumulo/test/TestMultiTableIngest.java +++ b/test/src/main/java/org/apache/accumulo/test/TestMultiTableIngest.java @@@ -16,7 -16,8 +16,8 @@@ */ package org.apache.accumulo.test; - import java.nio.charset.StandardCharsets; -import static com.google.common.base.Charsets.UTF_8; ++import static java.nio.charset.StandardCharsets.UTF_8; + import java.util.ArrayList; import java.util.List; import java.util.Map.Entry; http://git-wip-us.apache.org/repos/asf/accumulo/blob/cfbdef13/test/src/main/java/org/apache/accumulo/test/continuous/ContinuousIngest.java ---------------------------------------------------------------------- diff --cc test/src/main/java/org/apache/accumulo/test/continuous/ContinuousIngest.java index d6a16df,4404e2b..b986330 --- a/test/src/main/java/org/apache/accumulo/test/continuous/ContinuousIngest.java +++ b/test/src/main/java/org/apache/accumulo/test/continuous/ContinuousIngest.java @@@ -16,6 -16,8 +16,8 @@@ */ package org.apache.accumulo.test.continuous; -import static com.google.common.base.Charsets.UTF_8; ++import static java.nio.charset.StandardCharsets.UTF_8; + import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; http://git-wip-us.apache.org/repos/asf/accumulo/blob/cfbdef13/test/src/main/java/org/apache/accumulo/test/continuous/ContinuousMoru.java ---------------------------------------------------------------------- diff --cc test/src/main/java/org/apache/accumulo/test/continuous/ContinuousMoru.java index 9bf6343,cb32b6e..797413f --- a/test/src/main/java/org/apache/accumulo/test/continuous/ContinuousMoru.java +++ b/test/src/main/java/org/apache/accumulo/test/continuous/ContinuousMoru.java @@@ -16,8 -16,9 +16,9 @@@ */ package org.apache.accumulo.test.continuous; -import static com.google.common.base.Charsets.UTF_8; ++import static java.nio.charset.StandardCharsets.UTF_8; + import java.io.IOException; - import java.nio.charset.StandardCharsets; import java.util.Random; import java.util.Set; import java.util.UUID; http://git-wip-us.apache.org/repos/asf/accumulo/blob/cfbdef13/test/src/main/java/org/apache/accumulo/test/continuous/ContinuousQuery.java ---------------------------------------------------------------------- diff --cc test/src/main/java/org/apache/accumulo/test/continuous/ContinuousQuery.java index f7393d9,9f2ba34..dcc3e49 --- a/test/src/main/java/org/apache/accumulo/test/continuous/ContinuousQuery.java +++ b/test/src/main/java/org/apache/accumulo/test/continuous/ContinuousQuery.java @@@ -16,7 -16,8 +16,8 @@@ */ package org.apache.accumulo.test.continuous; - import java.nio.charset.StandardCharsets; -import static com.google.common.base.Charsets.UTF_8; ++import static java.nio.charset.StandardCharsets.UTF_8; + import java.util.Map.Entry; import java.util.Random; http://git-wip-us.apache.org/repos/asf/accumulo/blob/cfbdef13/test/src/main/java/org/apache/accumulo/test/continuous/ContinuousScanner.java ---------------------------------------------------------------------- diff --cc test/src/main/java/org/apache/accumulo/test/continuous/ContinuousScanner.java index 77f74da,0e71bf3..60154df --- a/test/src/main/java/org/apache/accumulo/test/continuous/ContinuousScanner.java +++ b/test/src/main/java/org/apache/accumulo/test/continuous/ContinuousScanner.java @@@ -16,7 -16,8 +16,8 @@@ */ package org.apache.accumulo.test.continuous; - import java.nio.charset.StandardCharsets; -import static com.google.common.base.Charsets.UTF_8; ++import static java.nio.charset.StandardCharsets.UTF_8; + import java.util.Iterator; import java.util.Map.Entry; import java.util.Random; http://git-wip-us.apache.org/repos/asf/accumulo/blob/cfbdef13/test/src/main/java/org/apache/accumulo/test/continuous/ContinuousVerify.java ---------------------------------------------------------------------- diff --cc test/src/main/java/org/apache/accumulo/test/continuous/ContinuousVerify.java index 515d4a3,34ee9d0..049f9b8 --- a/test/src/main/java/org/apache/accumulo/test/continuous/ContinuousVerify.java +++ b/test/src/main/java/org/apache/accumulo/test/continuous/ContinuousVerify.java @@@ -16,9 -16,10 +16,10 @@@ */ package org.apache.accumulo.test.continuous; -import static com.google.common.base.Charsets.UTF_8; ++import static java.nio.charset.StandardCharsets.UTF_8; + import java.io.IOException; import java.lang.reflect.Method; - import java.nio.charset.StandardCharsets; import java.util.ArrayList; import java.util.HashMap; import java.util.HashSet; http://git-wip-us.apache.org/repos/asf/accumulo/blob/cfbdef13/test/src/main/java/org/apache/accumulo/test/continuous/ContinuousWalk.java ---------------------------------------------------------------------- diff --cc test/src/main/java/org/apache/accumulo/test/continuous/ContinuousWalk.java index 262f7b0,4f88c1b..680ca92 --- a/test/src/main/java/org/apache/accumulo/test/continuous/ContinuousWalk.java +++ b/test/src/main/java/org/apache/accumulo/test/continuous/ContinuousWalk.java @@@ -16,6 -16,8 +16,8 @@@ */ package org.apache.accumulo.test.continuous; -import static com.google.common.base.Charsets.UTF_8; ++import static java.nio.charset.StandardCharsets.UTF_8; + import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; http://git-wip-us.apache.org/repos/asf/accumulo/blob/cfbdef13/test/src/main/java/org/apache/accumulo/test/continuous/Histogram.java ---------------------------------------------------------------------- diff --cc test/src/main/java/org/apache/accumulo/test/continuous/Histogram.java index 4758aa0,17b8269..b3aae46 --- a/test/src/main/java/org/apache/accumulo/test/continuous/Histogram.java +++ b/test/src/main/java/org/apache/accumulo/test/continuous/Histogram.java @@@ -16,6 -16,8 +16,8 @@@ */ package org.apache.accumulo.test.continuous; -import static com.google.common.base.Charsets.UTF_8; ++import static java.nio.charset.StandardCharsets.UTF_8; + import java.io.BufferedOutputStream; import java.io.FileOutputStream; import java.io.IOException; http://git-wip-us.apache.org/repos/asf/accumulo/blob/cfbdef13/test/src/main/java/org/apache/accumulo/test/continuous/PrintScanTimeHistogram.java ---------------------------------------------------------------------- diff --cc test/src/main/java/org/apache/accumulo/test/continuous/PrintScanTimeHistogram.java index 82d8660,82f028f..cab3126 --- a/test/src/main/java/org/apache/accumulo/test/continuous/PrintScanTimeHistogram.java +++ b/test/src/main/java/org/apache/accumulo/test/continuous/PrintScanTimeHistogram.java @@@ -16,12 -16,14 +16,13 @@@ */ package org.apache.accumulo.test.continuous; -import static com.google.common.base.Charsets.UTF_8; ++import static java.nio.charset.StandardCharsets.UTF_8; + import java.io.BufferedReader; import java.io.FileNotFoundException; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; - import java.nio.charset.StandardCharsets; - import org.apache.log4j.Logger; public class PrintScanTimeHistogram { http://git-wip-us.apache.org/repos/asf/accumulo/blob/cfbdef13/test/src/main/java/org/apache/accumulo/test/continuous/TimeBinner.java ---------------------------------------------------------------------- diff --cc test/src/main/java/org/apache/accumulo/test/continuous/TimeBinner.java index 29800b6,8bf2d97..0824948 --- a/test/src/main/java/org/apache/accumulo/test/continuous/TimeBinner.java +++ b/test/src/main/java/org/apache/accumulo/test/continuous/TimeBinner.java @@@ -16,9 -16,10 +16,10 @@@ */ package org.apache.accumulo.test.continuous; -import static com.google.common.base.Charsets.UTF_8; ++import static java.nio.charset.StandardCharsets.UTF_8; + import java.io.BufferedReader; import java.io.InputStreamReader; - import java.nio.charset.StandardCharsets; import java.text.SimpleDateFormat; import java.util.Date; import java.util.HashMap; http://git-wip-us.apache.org/repos/asf/accumulo/blob/cfbdef13/test/src/main/java/org/apache/accumulo/test/continuous/UndefinedAnalyzer.java ---------------------------------------------------------------------- diff --cc test/src/main/java/org/apache/accumulo/test/continuous/UndefinedAnalyzer.java index ca17fc5,11d19c5..dffd6c3 --- a/test/src/main/java/org/apache/accumulo/test/continuous/UndefinedAnalyzer.java +++ b/test/src/main/java/org/apache/accumulo/test/continuous/UndefinedAnalyzer.java @@@ -16,6 -16,8 +16,8 @@@ */ package org.apache.accumulo.test.continuous; -import static com.google.common.base.Charsets.UTF_8; ++import static java.nio.charset.StandardCharsets.UTF_8; + import java.io.BufferedReader; import java.io.File; import java.io.FileInputStream; http://git-wip-us.apache.org/repos/asf/accumulo/blob/cfbdef13/test/src/main/java/org/apache/accumulo/test/functional/CacheTestReader.java ---------------------------------------------------------------------- diff --cc test/src/main/java/org/apache/accumulo/test/functional/CacheTestReader.java index 8d5cc16,348fb02..fdc704d --- a/test/src/main/java/org/apache/accumulo/test/functional/CacheTestReader.java +++ b/test/src/main/java/org/apache/accumulo/test/functional/CacheTestReader.java @@@ -16,6 -16,8 +16,8 @@@ */ package org.apache.accumulo.test.functional; -import static com.google.common.base.Charsets.UTF_8; ++import static java.nio.charset.StandardCharsets.UTF_8; + import java.io.File; import java.io.FileOutputStream; import java.io.ObjectOutputStream; http://git-wip-us.apache.org/repos/asf/accumulo/blob/cfbdef13/test/src/main/java/org/apache/accumulo/test/functional/CacheTestWriter.java ---------------------------------------------------------------------- diff --cc test/src/main/java/org/apache/accumulo/test/functional/CacheTestWriter.java index 5954171,e304ab6..e1be8e6 --- a/test/src/main/java/org/apache/accumulo/test/functional/CacheTestWriter.java +++ b/test/src/main/java/org/apache/accumulo/test/functional/CacheTestWriter.java @@@ -16,6 -16,8 +16,8 @@@ */ package org.apache.accumulo.test.functional; -import static com.google.common.base.Charsets.UTF_8; ++import static java.nio.charset.StandardCharsets.UTF_8; + import java.io.File; import java.io.FileInputStream; import java.io.IOException; http://git-wip-us.apache.org/repos/asf/accumulo/blob/cfbdef13/test/src/main/java/org/apache/accumulo/test/functional/ZombieTServer.java ---------------------------------------------------------------------- diff --cc test/src/main/java/org/apache/accumulo/test/functional/ZombieTServer.java index 3b1aeaf,949fc52..879128f --- a/test/src/main/java/org/apache/accumulo/test/functional/ZombieTServer.java +++ b/test/src/main/java/org/apache/accumulo/test/functional/ZombieTServer.java @@@ -16,7 -16,8 +16,8 @@@ */ package org.apache.accumulo.test.functional; - import java.nio.charset.StandardCharsets; -import static com.google.common.base.Charsets.UTF_8; ++import static java.nio.charset.StandardCharsets.UTF_8; + import java.util.HashMap; import java.util.Random; http://git-wip-us.apache.org/repos/asf/accumulo/blob/cfbdef13/test/src/main/java/org/apache/accumulo/test/performance/metadata/MetadataBatchScanTest.java ---------------------------------------------------------------------- diff --cc test/src/main/java/org/apache/accumulo/test/performance/metadata/MetadataBatchScanTest.java index e404749,72efee3..96eb214 --- a/test/src/main/java/org/apache/accumulo/test/performance/metadata/MetadataBatchScanTest.java +++ b/test/src/main/java/org/apache/accumulo/test/performance/metadata/MetadataBatchScanTest.java @@@ -16,7 -16,8 +16,8 @@@ */ package org.apache.accumulo.test.performance.metadata; - import java.nio.charset.StandardCharsets; -import static com.google.common.base.Charsets.UTF_8; ++import static java.nio.charset.StandardCharsets.UTF_8; + import java.util.ArrayList; import java.util.HashSet; import java.util.List; http://git-wip-us.apache.org/repos/asf/accumulo/blob/cfbdef13/test/src/main/java/org/apache/accumulo/test/randomwalk/Module.java ---------------------------------------------------------------------- diff --cc test/src/main/java/org/apache/accumulo/test/randomwalk/Module.java index 353a02b,e4ce3f3..93a8f61 --- a/test/src/main/java/org/apache/accumulo/test/randomwalk/Module.java +++ b/test/src/main/java/org/apache/accumulo/test/randomwalk/Module.java @@@ -16,8 -16,9 +16,9 @@@ */ package org.apache.accumulo.test.randomwalk; -import static com.google.common.base.Charsets.UTF_8; ++import static java.nio.charset.StandardCharsets.UTF_8; + import java.io.File; - import java.nio.charset.StandardCharsets; import java.util.ArrayList; import java.util.Collection; import java.util.HashMap; http://git-wip-us.apache.org/repos/asf/accumulo/blob/cfbdef13/test/src/main/java/org/apache/accumulo/test/randomwalk/bulk/BulkMinusOne.java ---------------------------------------------------------------------- diff --cc test/src/main/java/org/apache/accumulo/test/randomwalk/bulk/BulkMinusOne.java index 6338d29,67438d9..e13e7d2 --- a/test/src/main/java/org/apache/accumulo/test/randomwalk/bulk/BulkMinusOne.java +++ b/test/src/main/java/org/apache/accumulo/test/randomwalk/bulk/BulkMinusOne.java @@@ -16,20 -16,19 +16,20 @@@ */ package org.apache.accumulo.test.randomwalk.bulk; - import java.nio.charset.StandardCharsets; -import static com.google.common.base.Charsets.UTF_8; ++import static java.nio.charset.StandardCharsets.UTF_8; import org.apache.accumulo.core.data.Value; +import org.apache.accumulo.test.randomwalk.Environment; import org.apache.accumulo.test.randomwalk.State; public class BulkMinusOne extends BulkImportTest { - private static final Value negOne = new Value("-1".getBytes(StandardCharsets.UTF_8)); + private static final Value negOne = new Value("-1".getBytes(UTF_8)); @Override - protected void runLater(State state) throws Exception { + protected void runLater(State state, Environment env) throws Exception { log.info("Decrementing"); - BulkPlusOne.bulkLoadLots(log, state, negOne); + BulkPlusOne.bulkLoadLots(log, state, env, negOne); } } http://git-wip-us.apache.org/repos/asf/accumulo/blob/cfbdef13/test/src/main/java/org/apache/accumulo/test/randomwalk/bulk/Verify.java ---------------------------------------------------------------------- diff --cc test/src/main/java/org/apache/accumulo/test/randomwalk/bulk/Verify.java index 3c2be07,b4fa7ba..f7a727a --- a/test/src/main/java/org/apache/accumulo/test/randomwalk/bulk/Verify.java +++ b/test/src/main/java/org/apache/accumulo/test/randomwalk/bulk/Verify.java @@@ -16,7 -16,8 +16,8 @@@ */ package org.apache.accumulo.test.randomwalk.bulk; - import java.nio.charset.StandardCharsets; -import static com.google.common.base.Charsets.UTF_8; ++import static java.nio.charset.StandardCharsets.UTF_8; + import java.util.Arrays; import java.util.Iterator; import java.util.Map.Entry; http://git-wip-us.apache.org/repos/asf/accumulo/blob/cfbdef13/test/src/main/java/org/apache/accumulo/test/randomwalk/concurrent/BatchWrite.java ---------------------------------------------------------------------- diff --cc test/src/main/java/org/apache/accumulo/test/randomwalk/concurrent/BatchWrite.java index 9e50b61,3dcff6e..09bf883 --- a/test/src/main/java/org/apache/accumulo/test/randomwalk/concurrent/BatchWrite.java +++ b/test/src/main/java/org/apache/accumulo/test/randomwalk/concurrent/BatchWrite.java @@@ -16,7 -16,8 +16,8 @@@ */ package org.apache.accumulo.test.randomwalk.concurrent; - import java.nio.charset.StandardCharsets; -import static com.google.common.base.Charsets.UTF_8; ++import static java.nio.charset.StandardCharsets.UTF_8; + import java.util.List; import java.util.Properties; import java.util.Random; http://git-wip-us.apache.org/repos/asf/accumulo/blob/cfbdef13/test/src/main/java/org/apache/accumulo/test/randomwalk/concurrent/BulkImport.java ---------------------------------------------------------------------- diff --cc test/src/main/java/org/apache/accumulo/test/randomwalk/concurrent/BulkImport.java index eb60971,ade3e38..0a9d3b9 --- a/test/src/main/java/org/apache/accumulo/test/randomwalk/concurrent/BulkImport.java +++ b/test/src/main/java/org/apache/accumulo/test/randomwalk/concurrent/BulkImport.java @@@ -16,8 -16,9 +16,9 @@@ */ package org.apache.accumulo.test.randomwalk.concurrent; -import static com.google.common.base.Charsets.UTF_8; ++import static java.nio.charset.StandardCharsets.UTF_8; + import java.io.IOException; - import java.nio.charset.StandardCharsets; import java.util.List; import java.util.Properties; import java.util.Random; http://git-wip-us.apache.org/repos/asf/accumulo/blob/cfbdef13/test/src/main/java/org/apache/accumulo/test/randomwalk/concurrent/ChangeAuthorizations.java ---------------------------------------------------------------------- diff --cc test/src/main/java/org/apache/accumulo/test/randomwalk/concurrent/ChangeAuthorizations.java index 28da4f1,61d7c61..03f2f39 --- a/test/src/main/java/org/apache/accumulo/test/randomwalk/concurrent/ChangeAuthorizations.java +++ b/test/src/main/java/org/apache/accumulo/test/randomwalk/concurrent/ChangeAuthorizations.java @@@ -16,7 -16,8 +16,8 @@@ */ package org.apache.accumulo.test.randomwalk.concurrent; - import java.nio.charset.StandardCharsets; -import static com.google.common.base.Charsets.UTF_8; ++import static java.nio.charset.StandardCharsets.UTF_8; + import java.util.ArrayList; import java.util.List; import java.util.Properties; http://git-wip-us.apache.org/repos/asf/accumulo/blob/cfbdef13/test/src/main/java/org/apache/accumulo/test/randomwalk/concurrent/StopTabletServer.java ---------------------------------------------------------------------- diff --cc test/src/main/java/org/apache/accumulo/test/randomwalk/concurrent/StopTabletServer.java index 85340f5,b3519b6..c16160e --- a/test/src/main/java/org/apache/accumulo/test/randomwalk/concurrent/StopTabletServer.java +++ b/test/src/main/java/org/apache/accumulo/test/randomwalk/concurrent/StopTabletServer.java @@@ -16,7 -16,8 +16,8 @@@ */ package org.apache.accumulo.test.randomwalk.concurrent; - import java.nio.charset.StandardCharsets; -import static com.google.common.base.Charsets.UTF_8; ++import static java.nio.charset.StandardCharsets.UTF_8; + import java.util.ArrayList; import java.util.Collections; import java.util.HashSet; http://git-wip-us.apache.org/repos/asf/accumulo/blob/cfbdef13/test/src/main/java/org/apache/accumulo/test/randomwalk/image/Verify.java ---------------------------------------------------------------------- diff --cc test/src/main/java/org/apache/accumulo/test/randomwalk/image/Verify.java index a7669f8,7db2f04..6ca524a --- a/test/src/main/java/org/apache/accumulo/test/randomwalk/image/Verify.java +++ b/test/src/main/java/org/apache/accumulo/test/randomwalk/image/Verify.java @@@ -16,7 -16,8 +16,8 @@@ */ package org.apache.accumulo.test.randomwalk.image; - import java.nio.charset.StandardCharsets; -import static com.google.common.base.Charsets.UTF_8; ++import static java.nio.charset.StandardCharsets.UTF_8; + import java.security.MessageDigest; import java.util.Iterator; import java.util.Map.Entry; http://git-wip-us.apache.org/repos/asf/accumulo/blob/cfbdef13/test/src/main/java/org/apache/accumulo/test/randomwalk/image/Write.java ---------------------------------------------------------------------- diff --cc test/src/main/java/org/apache/accumulo/test/randomwalk/image/Write.java index a1731d1,d53658b..d239495 --- a/test/src/main/java/org/apache/accumulo/test/randomwalk/image/Write.java +++ b/test/src/main/java/org/apache/accumulo/test/randomwalk/image/Write.java @@@ -16,7 -16,8 +16,8 @@@ */ package org.apache.accumulo.test.randomwalk.image; - import java.nio.charset.StandardCharsets; -import static com.google.common.base.Charsets.UTF_8; ++import static java.nio.charset.StandardCharsets.UTF_8; + import java.security.MessageDigest; import java.util.Properties; import java.util.Random; http://git-wip-us.apache.org/repos/asf/accumulo/blob/cfbdef13/test/src/main/java/org/apache/accumulo/test/randomwalk/multitable/Write.java ---------------------------------------------------------------------- diff --cc test/src/main/java/org/apache/accumulo/test/randomwalk/multitable/Write.java index 4a0515c,5dd3f8b..c3c91c0 --- a/test/src/main/java/org/apache/accumulo/test/randomwalk/multitable/Write.java +++ b/test/src/main/java/org/apache/accumulo/test/randomwalk/multitable/Write.java @@@ -16,7 -16,8 +16,8 @@@ */ package org.apache.accumulo.test.randomwalk.multitable; - import java.nio.charset.StandardCharsets; -import static com.google.common.base.Charsets.UTF_8; ++import static java.nio.charset.StandardCharsets.UTF_8; + import java.security.MessageDigest; import java.util.ArrayList; import java.util.Properties; http://git-wip-us.apache.org/repos/asf/accumulo/blob/cfbdef13/test/src/main/java/org/apache/accumulo/test/randomwalk/security/SecurityHelper.java ---------------------------------------------------------------------- diff --cc test/src/main/java/org/apache/accumulo/test/randomwalk/security/SecurityHelper.java index f9ba5ba,07834b0..ba1893f --- a/test/src/main/java/org/apache/accumulo/test/randomwalk/security/SecurityHelper.java +++ b/test/src/main/java/org/apache/accumulo/test/randomwalk/security/SecurityHelper.java @@@ -16,8 -16,9 +16,9 @@@ */ package org.apache.accumulo.test.randomwalk.security; -import static com.google.common.base.Charsets.UTF_8; ++import static java.nio.charset.StandardCharsets.UTF_8; + import java.io.IOException; - import java.nio.charset.StandardCharsets; import java.util.Map; import org.apache.accumulo.core.client.Connector; http://git-wip-us.apache.org/repos/asf/accumulo/blob/cfbdef13/test/src/main/java/org/apache/accumulo/test/randomwalk/security/TableOp.java ---------------------------------------------------------------------- diff --cc test/src/main/java/org/apache/accumulo/test/randomwalk/security/TableOp.java index ef4593c,fa64e92..2499af2 --- a/test/src/main/java/org/apache/accumulo/test/randomwalk/security/TableOp.java +++ b/test/src/main/java/org/apache/accumulo/test/randomwalk/security/TableOp.java @@@ -16,7 -16,8 +16,8 @@@ */ package org.apache.accumulo.test.randomwalk.security; - import java.nio.charset.StandardCharsets; -import static com.google.common.base.Charsets.UTF_8; ++import static java.nio.charset.StandardCharsets.UTF_8; + import java.util.Iterator; import java.util.Map.Entry; import java.util.Properties; @@@ -91,8 -91,8 +92,8 @@@ public class TableOp extends Test } if (!canRead && !ambiguousZone) throw new AccumuloException("Was able to read when I shouldn't have had the perm with connection user " + conn.whoami() + " table " + tableName); - for (Entry<String,Integer> entry : WalkingSecurity.get(state).getAuthsMap().entrySet()) { + for (Entry<String,Integer> entry : WalkingSecurity.get(state,env).getAuthsMap().entrySet()) { - if (auths.contains(entry.getKey().getBytes(StandardCharsets.UTF_8))) + if (auths.contains(entry.getKey().getBytes(UTF_8))) seen = seen - entry.getValue(); } if (seen != 0 && !ambiguousAuths) @@@ -143,13 -143,13 +144,13 @@@ break; } case WRITE: - boolean canWrite = WalkingSecurity.get(state).canWrite(WalkingSecurity.get(state).getTabCredentials(), tableName, namespaceName); - boolean ambiguousZone = WalkingSecurity.get(state).inAmbiguousZone(conn.whoami(), tp); + boolean canWrite = WalkingSecurity.get(state,env).canWrite(WalkingSecurity.get(state,env).getTabCredentials(), tableName, namespaceName); + boolean ambiguousZone = WalkingSecurity.get(state,env).inAmbiguousZone(conn.whoami(), tp); - String key = WalkingSecurity.get(state).getLastKey() + "1"; + String key = WalkingSecurity.get(state,env).getLastKey() + "1"; Mutation m = new Mutation(new Text(key)); - for (String s : WalkingSecurity.get(state).getAuthsArray()) { + for (String s : WalkingSecurity.get(state,env).getAuthsArray()) { - m.put(new Text(), new Text(), new ColumnVisibility(s), new Value("value".getBytes(StandardCharsets.UTF_8))); + m.put(new Text(), new Text(), new ColumnVisibility(s), new Value("value".getBytes(UTF_8))); } BatchWriter writer = null; try { http://git-wip-us.apache.org/repos/asf/accumulo/blob/cfbdef13/test/src/main/java/org/apache/accumulo/test/randomwalk/sequential/Write.java ---------------------------------------------------------------------- diff --cc test/src/main/java/org/apache/accumulo/test/randomwalk/sequential/Write.java index a0fdd9d,1fc0850..1795434 --- a/test/src/main/java/org/apache/accumulo/test/randomwalk/sequential/Write.java +++ b/test/src/main/java/org/apache/accumulo/test/randomwalk/sequential/Write.java @@@ -16,7 -16,8 +16,8 @@@ */ package org.apache.accumulo.test.randomwalk.sequential; - import java.nio.charset.StandardCharsets; -import static com.google.common.base.Charsets.UTF_8; ++import static java.nio.charset.StandardCharsets.UTF_8; + import java.util.Properties; import org.apache.accumulo.core.client.BatchWriter; http://git-wip-us.apache.org/repos/asf/accumulo/blob/cfbdef13/test/src/main/java/org/apache/accumulo/test/randomwalk/shard/BulkInsert.java ---------------------------------------------------------------------- diff --cc test/src/main/java/org/apache/accumulo/test/randomwalk/shard/BulkInsert.java index 0f04afc,b607e8d..5959105 --- a/test/src/main/java/org/apache/accumulo/test/randomwalk/shard/BulkInsert.java +++ b/test/src/main/java/org/apache/accumulo/test/randomwalk/shard/BulkInsert.java @@@ -16,6 -16,8 +16,8 @@@ */ package org.apache.accumulo.test.randomwalk.shard; -import static com.google.common.base.Charsets.UTF_8; ++import static java.nio.charset.StandardCharsets.UTF_8; + import java.io.BufferedOutputStream; import java.io.IOException; import java.io.PrintStream; @@@ -162,11 -162,11 +163,11 @@@ public class BulkInsert extends Test } } - private void sort(State state, FileSystem fs, String tableName, String seqFile, String outputDir, String workDir, int maxSplits) throws Exception { + private void sort(State state, Environment env, FileSystem fs, String tableName, String seqFile, String outputDir, String workDir, int maxSplits) throws Exception { - PrintStream out = new PrintStream(new BufferedOutputStream(fs.create(new Path(workDir + "/splits.txt"))), false, StandardCharsets.UTF_8.name()); + PrintStream out = new PrintStream(new BufferedOutputStream(fs.create(new Path(workDir + "/splits.txt"))), false, UTF_8.name()); - Connector conn = state.getConnector(); + Connector conn = env.getConnector(); Collection<Text> splits = conn.tableOperations().listSplits(tableName, maxSplits); for (Text split : splits) http://git-wip-us.apache.org/repos/asf/accumulo/blob/cfbdef13/test/src/main/java/org/apache/accumulo/test/randomwalk/shard/ExportIndex.java ---------------------------------------------------------------------- diff --cc test/src/main/java/org/apache/accumulo/test/randomwalk/shard/ExportIndex.java index f625870,d9bd7f9..f5ede55 --- a/test/src/main/java/org/apache/accumulo/test/randomwalk/shard/ExportIndex.java +++ b/test/src/main/java/org/apache/accumulo/test/randomwalk/shard/ExportIndex.java @@@ -16,9 -16,10 +16,10 @@@ */ package org.apache.accumulo.test.randomwalk.shard; -import static com.google.common.base.Charsets.UTF_8; ++import static java.nio.charset.StandardCharsets.UTF_8; + import java.io.BufferedReader; import java.io.InputStreamReader; - import java.nio.charset.StandardCharsets; import java.util.HashMap; import java.util.HashSet; import java.util.Map.Entry; http://git-wip-us.apache.org/repos/asf/accumulo/blob/cfbdef13/test/src/main/java/org/apache/accumulo/test/scalability/Ingest.java ---------------------------------------------------------------------- diff --cc test/src/main/java/org/apache/accumulo/test/scalability/Ingest.java index 76a20a0,b34defe..238a88d --- a/test/src/main/java/org/apache/accumulo/test/scalability/Ingest.java +++ b/test/src/main/java/org/apache/accumulo/test/scalability/Ingest.java @@@ -16,7 -16,8 +16,8 @@@ */ package org.apache.accumulo.test.scalability; - import java.nio.charset.StandardCharsets; -import static com.google.common.base.Charsets.UTF_8; ++import static java.nio.charset.StandardCharsets.UTF_8; + import java.util.Random; import java.util.UUID; import java.util.concurrent.TimeUnit; http://git-wip-us.apache.org/repos/asf/accumulo/blob/cfbdef13/test/src/test/java/org/apache/accumulo/test/AuditMessageIT.java ---------------------------------------------------------------------- diff --cc test/src/test/java/org/apache/accumulo/test/AuditMessageIT.java index d496ded,49b5d70..a173f79 --- a/test/src/test/java/org/apache/accumulo/test/AuditMessageIT.java +++ b/test/src/test/java/org/apache/accumulo/test/AuditMessageIT.java @@@ -16,6 -16,7 +16,7 @@@ */ package org.apache.accumulo.test; -import static com.google.common.base.Charsets.UTF_8; ++import static java.nio.charset.StandardCharsets.UTF_8; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; http://git-wip-us.apache.org/repos/asf/accumulo/blob/cfbdef13/test/src/test/java/org/apache/accumulo/test/LargeSplitRowIT.java ---------------------------------------------------------------------- diff --cc test/src/test/java/org/apache/accumulo/test/LargeSplitRowIT.java index 85aec59,0000000..7ebcdd7 mode 100644,000000..100644 --- a/test/src/test/java/org/apache/accumulo/test/LargeSplitRowIT.java +++ b/test/src/test/java/org/apache/accumulo/test/LargeSplitRowIT.java @@@ -1,283 -1,0 +1,284 @@@ +/* + * 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.test; + - import java.nio.charset.StandardCharsets; ++import static java.nio.charset.StandardCharsets.UTF_8; ++ +import java.util.HashMap; +import java.util.Map.Entry; +import java.util.Map; +import java.util.SortedSet; +import java.util.TreeSet; + +import org.apache.accumulo.core.client.BatchWriter; +import org.apache.accumulo.core.client.BatchWriterConfig; +import org.apache.accumulo.core.client.Connector; +import org.apache.accumulo.core.client.Scanner; +import org.apache.accumulo.core.client.impl.AccumuloServerException; +import org.apache.accumulo.core.conf.Property; +import org.apache.accumulo.core.data.Key; +import org.apache.accumulo.core.data.Mutation; +import org.apache.accumulo.core.data.Value; +import org.apache.accumulo.core.security.Authorizations; +import org.apache.accumulo.minicluster.impl.MiniAccumuloConfigImpl; +import org.apache.accumulo.server.conf.TableConfiguration; +import org.apache.accumulo.test.functional.ConfigurableMacIT; +import org.apache.hadoop.conf.Configuration; +import org.apache.hadoop.io.Text; +import org.apache.log4j.Logger; +import org.junit.Assert; +import org.junit.Test; + +public class LargeSplitRowIT extends ConfigurableMacIT { + static private final Logger log = Logger.getLogger(LargeSplitRowIT.class); + + @Override + public void configure(MiniAccumuloConfigImpl cfg, Configuration hadoopCoreSite) { + cfg.setNumTservers(1); + + Map<String,String> siteConfig = new HashMap<String,String>(); + siteConfig.put(Property.TSERV_MAJC_DELAY.getKey(), "50ms"); + cfg.setSiteConfig(siteConfig); + } + + // User added split + @Test(timeout = 60 * 1000) + public void userAddedSplit() throws Exception { + + log.info("User added split"); + + // make a table and lower the TABLE_END_ROW_MAX_SIZE property + final String tableName = getUniqueNames(1)[0]; + final Connector conn = getConnector(); + conn.tableOperations().create(tableName); + conn.tableOperations().setProperty(tableName, Property.TABLE_MAX_END_ROW_SIZE.getKey(), "1000"); + + // Create a BatchWriter and add a mutation to the table + BatchWriter batchWriter = conn.createBatchWriter(tableName, new BatchWriterConfig()); + Mutation m = new Mutation("Row"); + m.put("cf", "cq", "value"); + batchWriter.addMutation(m); + batchWriter.close(); + + // Create a split point that is too large to be an end row and fill it with all 'm' + SortedSet<Text> partitionKeys = new TreeSet<Text>(); + byte data[] = new byte[(int) (TableConfiguration.getMemoryInBytes(Property.TABLE_MAX_END_ROW_SIZE.getDefaultValue()) + 2)]; + for (int i = 0; i < data.length; i++) { + data[i] = 'm'; + } + partitionKeys.add(new Text(data)); + + // try to add the split point that is too large, if the split point is created the test fails. + try { + conn.tableOperations().addSplits(tableName, partitionKeys); + Assert.fail(); + } catch (AccumuloServerException e) {} + + // Make sure that the information that was written to the table before we tried to add the split point is still correct + int counter = 0; + final Scanner scanner = conn.createScanner(tableName, Authorizations.EMPTY); + for (Entry<Key,Value> entry : scanner) { + counter++; + Key k = entry.getKey(); + Assert.assertEquals("Row", k.getRow().toString()); + Assert.assertEquals("cf", k.getColumnFamily().toString()); + Assert.assertEquals("cq", k.getColumnQualifier().toString()); + Assert.assertEquals("value", entry.getValue().toString()); + + } + // Make sure there is only one line in the table + Assert.assertEquals(1, counter); + } + + // Test tablet server split with 250 entries with all the same prefix + @Test(timeout = 60 * 1000) + public void automaticSplitWith250Same() throws Exception { + log.info("Automatic with 250 with same prefix"); + + // make a table and lower the configure properties + final String tableName = getUniqueNames(1)[0]; + final Connector conn = getConnector(); + conn.tableOperations().create(tableName); + conn.tableOperations().setProperty(tableName, Property.TABLE_SPLIT_THRESHOLD.getKey(), "10K"); + conn.tableOperations().setProperty(tableName, Property.TABLE_FILE_COMPRESSION_TYPE.getKey(), "none"); + conn.tableOperations().setProperty(tableName, Property.TABLE_FILE_COMPRESSED_BLOCK_SIZE.getKey(), "64"); + conn.tableOperations().setProperty(tableName, Property.TABLE_MAX_END_ROW_SIZE.getKey(), "1000"); + + // Create a BatchWriter and key for a table entry that is longer than the allowed size for an end row + // Fill this key with all m's except the last spot + BatchWriter batchWriter = conn.createBatchWriter(tableName, new BatchWriterConfig()); + byte data[] = new byte[(int) (TableConfiguration.getMemoryInBytes(Property.TABLE_MAX_END_ROW_SIZE.getDefaultValue()) + 2)]; + for (int i = 0; i < data.length - 1; i++) { + data[i] = (byte) 'm'; + } + + // Make the last place in the key different for every entry added to the table + for (int i = 0; i < 250; i++) { + data[data.length - 1] = (byte) i; + Mutation m = new Mutation(data); + m.put("cf", "cq", "value"); + batchWriter.addMutation(m); + } + // Flush the BatchWriter and table and sleep for a bit to make sure that there is enough time for the table to split if need be. + batchWriter.close(); + conn.tableOperations().flush(tableName, new Text(), new Text("z"), true); + Thread.sleep(500); + + // Make sure all the data that was put in the table is still correct + int count = 0; + final Scanner scanner = conn.createScanner(tableName, Authorizations.EMPTY); + for (Entry<Key,Value> entry : scanner) { + Key k = entry.getKey(); + data[data.length - 1] = (byte) count; - String expected = new String(data, StandardCharsets.UTF_8); ++ String expected = new String(data, UTF_8); + Assert.assertEquals(expected, k.getRow().toString()); + Assert.assertEquals("cf", k.getColumnFamily().toString()); + Assert.assertEquals("cq", k.getColumnQualifier().toString()); + Assert.assertEquals("value", entry.getValue().toString()); + count++; + } + Assert.assertEquals(250, count); + + // Make sure no splits occurred in the table + Assert.assertEquals(0, conn.tableOperations().listSplits(tableName).size()); + } + + // 10 0's; 10 2's; 10 4's... 10 30's etc + @Test(timeout = 60 * 1000) + public void automaticSplitWithGaps() throws Exception { + log.info("Automatic Split With Gaps"); + + automaticSplit(30, 2); + } + + // 10 0's; 10 1's; 10 2's... 10 15's etc + @Test(timeout = 60 * 1000) + public void automaticSplitWithoutGaps() throws Exception { + log.info("Automatic Split Without Gaps"); + + automaticSplit(15, 1); + } + + @Test(timeout = 60 * 1000) + public void automaticSplitLater() throws Exception { + log.info("Split later"); + automaticSplit(15, 1); + + final Connector conn = getConnector(); + + String tableName = new String(); + java.util.Iterator<String> iterator = conn.tableOperations().list().iterator(); + + while (iterator.hasNext()) { + String curr = iterator.next(); + if (!curr.equals("accumulo.metadata") && !curr.equals("accumulo.root")) { + tableName = curr; + } + } + + // Create a BatchWriter and key for a table entry that is longer than the allowed size for an end row + BatchWriter batchWriter = conn.createBatchWriter(tableName, new BatchWriterConfig()); + byte data[] = new byte[10]; + + // Fill key with all j's except for last spot which alternates through 1 through 10 for every j value + for (int j = 15; j < 150; j += 1) { + for (int i = 0; i < data.length - 1; i++) { + data[i] = (byte) j; + } + + for (int i = 0; i < 25; i++) { + data[data.length - 1] = (byte) i; + Mutation m = new Mutation(data); + m.put("cf", "cq", "value"); + batchWriter.addMutation(m); + } + } + // Flush the BatchWriter and table and sleep for a bit to make sure that there is enough time for the table to split if need be. + batchWriter.close(); + conn.tableOperations().flush(tableName, new Text(), new Text("z"), true); + + // Make sure a split occurs + while (conn.tableOperations().listSplits(tableName).size() == 0) { + Thread.sleep(250); + } + + Assert.assertTrue(0 < conn.tableOperations().listSplits(tableName).size()); + } + + private void automaticSplit(int max, int spacing) throws Exception { + // make a table and lower the configure properties + final String tableName = getUniqueNames(1)[0]; + final Connector conn = getConnector(); + conn.tableOperations().create(tableName); + conn.tableOperations().setProperty(tableName, Property.TABLE_SPLIT_THRESHOLD.getKey(), "10K"); + conn.tableOperations().setProperty(tableName, Property.TABLE_FILE_COMPRESSION_TYPE.getKey(), "none"); + conn.tableOperations().setProperty(tableName, Property.TABLE_FILE_COMPRESSED_BLOCK_SIZE.getKey(), "64"); + conn.tableOperations().setProperty(tableName, Property.TABLE_MAX_END_ROW_SIZE.getKey(), "1000"); + + // Create a BatchWriter and key for a table entry that is longer than the allowed size for an end row + BatchWriter batchWriter = conn.createBatchWriter(tableName, new BatchWriterConfig()); + byte data[] = new byte[(int) (TableConfiguration.getMemoryInBytes(Property.TABLE_MAX_END_ROW_SIZE.getDefaultValue()) + 2)]; + + // Fill key with all j's except for last spot which alternates through 1 through 10 for every j value + for (int j = 0; j < max; j += spacing) { + for (int i = 0; i < data.length - 1; i++) { + data[i] = (byte) j; + } + + for (int i = 0; i < 10; i++) { + data[data.length - 1] = (byte) i; + Mutation m = new Mutation(data); + m.put("cf", "cq", "value"); + batchWriter.addMutation(m); + } + } + // Flush the BatchWriter and table and sleep for a bit to make sure that there is enough time for the table to split if need be. + batchWriter.close(); + conn.tableOperations().flush(tableName, new Text(), new Text("z"), true); + Thread.sleep(500); + + // Make sure all the data that was put in the table is still correct + int count = 0; + int extra = 10; + final Scanner scanner = conn.createScanner(tableName, Authorizations.EMPTY); + for (Entry<Key,Value> entry : scanner) { + if (extra == 10) { + extra = 0; + for (int i = 0; i < data.length - 1; i++) { + data[i] = (byte) count; + } + count += spacing; + + } + Key k = entry.getKey(); + data[data.length - 1] = (byte) extra; - String expected = new String(data, StandardCharsets.UTF_8); ++ String expected = new String(data, UTF_8); + Assert.assertEquals(expected, k.getRow().toString()); + Assert.assertEquals("cf", k.getColumnFamily().toString()); + Assert.assertEquals("cq", k.getColumnQualifier().toString()); + Assert.assertEquals("value", entry.getValue().toString()); + extra++; + } + Assert.assertEquals(10, extra); + Assert.assertEquals(max, count); + + // Make sure no splits occured in the table + Assert.assertEquals(0, conn.tableOperations().listSplits(tableName).size()); + + } + +} http://git-wip-us.apache.org/repos/asf/accumulo/blob/cfbdef13/test/src/test/java/org/apache/accumulo/test/NamespacesIT.java ---------------------------------------------------------------------- diff --cc test/src/test/java/org/apache/accumulo/test/NamespacesIT.java index e9de27c,8188deb..5e885b5 --- a/test/src/test/java/org/apache/accumulo/test/NamespacesIT.java +++ b/test/src/test/java/org/apache/accumulo/test/NamespacesIT.java @@@ -16,6 -16,7 +16,7 @@@ */ package org.apache.accumulo.test; -import static com.google.common.base.Charsets.UTF_8; ++import static java.nio.charset.StandardCharsets.UTF_8; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotNull; http://git-wip-us.apache.org/repos/asf/accumulo/blob/cfbdef13/test/src/test/java/org/apache/accumulo/test/VolumeIT.java ---------------------------------------------------------------------- diff --cc test/src/test/java/org/apache/accumulo/test/VolumeIT.java index d58c263,d5c940d..6025cf2 --- a/test/src/test/java/org/apache/accumulo/test/VolumeIT.java +++ b/test/src/test/java/org/apache/accumulo/test/VolumeIT.java @@@ -16,6 -16,7 +16,7 @@@ */ package org.apache.accumulo.test; -import static com.google.common.base.Charsets.UTF_8; ++import static java.nio.charset.StandardCharsets.UTF_8; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; http://git-wip-us.apache.org/repos/asf/accumulo/blob/cfbdef13/test/src/test/java/org/apache/accumulo/test/functional/AddSplitIT.java ---------------------------------------------------------------------- diff --cc test/src/test/java/org/apache/accumulo/test/functional/AddSplitIT.java index 5901326,05de342..0d26445 --- a/test/src/test/java/org/apache/accumulo/test/functional/AddSplitIT.java +++ b/test/src/test/java/org/apache/accumulo/test/functional/AddSplitIT.java @@@ -16,7 -16,8 +16,8 @@@ */ package org.apache.accumulo.test.functional; - import java.nio.charset.StandardCharsets; -import static com.google.common.base.Charsets.UTF_8; ++import static java.nio.charset.StandardCharsets.UTF_8; + import java.util.Collection; import java.util.Iterator; import java.util.Map.Entry; http://git-wip-us.apache.org/repos/asf/accumulo/blob/cfbdef13/test/src/test/java/org/apache/accumulo/test/functional/BadIteratorMincIT.java ---------------------------------------------------------------------- diff --cc test/src/test/java/org/apache/accumulo/test/functional/BadIteratorMincIT.java index 1dfb3ce,9c4492e..311e354 --- a/test/src/test/java/org/apache/accumulo/test/functional/BadIteratorMincIT.java +++ b/test/src/test/java/org/apache/accumulo/test/functional/BadIteratorMincIT.java @@@ -16,9 -16,9 +16,9 @@@ */ package org.apache.accumulo.test.functional; -import static com.google.common.base.Charsets.UTF_8; ++import static java.nio.charset.StandardCharsets.UTF_8; import static org.junit.Assert.assertEquals; - import java.nio.charset.StandardCharsets; import java.util.EnumSet; import java.util.Map.Entry; http://git-wip-us.apache.org/repos/asf/accumulo/blob/cfbdef13/test/src/test/java/org/apache/accumulo/test/functional/BatchScanSplitIT.java ---------------------------------------------------------------------- diff --cc test/src/test/java/org/apache/accumulo/test/functional/BatchScanSplitIT.java index 3fabf49,688a326..9f00f74 --- a/test/src/test/java/org/apache/accumulo/test/functional/BatchScanSplitIT.java +++ b/test/src/test/java/org/apache/accumulo/test/functional/BatchScanSplitIT.java @@@ -16,7 -16,8 +16,8 @@@ */ package org.apache.accumulo.test.functional; - import java.nio.charset.StandardCharsets; -import static com.google.common.base.Charsets.UTF_8; ++import static java.nio.charset.StandardCharsets.UTF_8; + import java.util.ArrayList; import java.util.Collection; import java.util.Collections; http://git-wip-us.apache.org/repos/asf/accumulo/blob/cfbdef13/test/src/test/java/org/apache/accumulo/test/functional/BatchWriterFlushIT.java ---------------------------------------------------------------------- diff --cc test/src/test/java/org/apache/accumulo/test/functional/BatchWriterFlushIT.java index 3de5cda,465936e..6a9171a --- a/test/src/test/java/org/apache/accumulo/test/functional/BatchWriterFlushIT.java +++ b/test/src/test/java/org/apache/accumulo/test/functional/BatchWriterFlushIT.java @@@ -16,7 -16,8 +16,8 @@@ */ package org.apache.accumulo.test.functional; - import java.nio.charset.StandardCharsets; -import static com.google.common.base.Charsets.UTF_8; ++import static java.nio.charset.StandardCharsets.UTF_8; + import java.util.Iterator; import java.util.Map.Entry; import java.util.Random; http://git-wip-us.apache.org/repos/asf/accumulo/blob/cfbdef13/test/src/test/java/org/apache/accumulo/test/functional/BulkFileIT.java ---------------------------------------------------------------------- diff --cc test/src/test/java/org/apache/accumulo/test/functional/BulkFileIT.java index 4f5fc7d,ffe55bd..80ee990 --- a/test/src/test/java/org/apache/accumulo/test/functional/BulkFileIT.java +++ b/test/src/test/java/org/apache/accumulo/test/functional/BulkFileIT.java @@@ -16,7 -16,8 +16,8 @@@ */ package org.apache.accumulo.test.functional; - import java.nio.charset.StandardCharsets; -import static com.google.common.base.Charsets.UTF_8; ++import static java.nio.charset.StandardCharsets.UTF_8; + import java.util.Iterator; import java.util.Map.Entry; import java.util.SortedSet; http://git-wip-us.apache.org/repos/asf/accumulo/blob/cfbdef13/test/src/test/java/org/apache/accumulo/test/functional/ConcurrencyIT.java ---------------------------------------------------------------------- diff --cc test/src/test/java/org/apache/accumulo/test/functional/ConcurrencyIT.java index 355a7bf,92bd714..3e5fec4 --- a/test/src/test/java/org/apache/accumulo/test/functional/ConcurrencyIT.java +++ b/test/src/test/java/org/apache/accumulo/test/functional/ConcurrencyIT.java @@@ -16,7 -16,8 +16,8 @@@ */ package org.apache.accumulo.test.functional; - import java.nio.charset.StandardCharsets; -import static com.google.common.base.Charsets.UTF_8; ++import static java.nio.charset.StandardCharsets.UTF_8; + import java.util.Collections; import java.util.EnumSet; http://git-wip-us.apache.org/repos/asf/accumulo/blob/cfbdef13/test/src/test/java/org/apache/accumulo/test/functional/ConstraintIT.java ---------------------------------------------------------------------- diff --cc test/src/test/java/org/apache/accumulo/test/functional/ConstraintIT.java index b4067d3,7e5944e..b987dec --- a/test/src/test/java/org/apache/accumulo/test/functional/ConstraintIT.java +++ b/test/src/test/java/org/apache/accumulo/test/functional/ConstraintIT.java @@@ -16,7 -16,8 +16,8 @@@ */ package org.apache.accumulo.test.functional; - import java.nio.charset.StandardCharsets; -import static com.google.common.base.Charsets.UTF_8; ++import static java.nio.charset.StandardCharsets.UTF_8; + import java.util.HashMap; import java.util.Iterator; import java.util.List; http://git-wip-us.apache.org/repos/asf/accumulo/blob/cfbdef13/test/src/test/java/org/apache/accumulo/test/functional/CreateAndUseIT.java ---------------------------------------------------------------------- diff --cc test/src/test/java/org/apache/accumulo/test/functional/CreateAndUseIT.java index 67ecf10,5b5249b..0cdebeb --- a/test/src/test/java/org/apache/accumulo/test/functional/CreateAndUseIT.java +++ b/test/src/test/java/org/apache/accumulo/test/functional/CreateAndUseIT.java @@@ -16,7 -16,8 +16,8 @@@ */ package org.apache.accumulo.test.functional; - import java.nio.charset.StandardCharsets; -import static com.google.common.base.Charsets.UTF_8; ++import static java.nio.charset.StandardCharsets.UTF_8; + import java.util.ArrayList; import java.util.Iterator; import java.util.Map.Entry; http://git-wip-us.apache.org/repos/asf/accumulo/blob/cfbdef13/test/src/test/java/org/apache/accumulo/test/functional/DeleteEverythingIT.java ---------------------------------------------------------------------- diff --cc test/src/test/java/org/apache/accumulo/test/functional/DeleteEverythingIT.java index 3877e0e,0578ef4..f7f8700 --- a/test/src/test/java/org/apache/accumulo/test/functional/DeleteEverythingIT.java +++ b/test/src/test/java/org/apache/accumulo/test/functional/DeleteEverythingIT.java @@@ -16,9 -16,9 +16,9 @@@ */ package org.apache.accumulo.test.functional; -import static com.google.common.base.Charsets.UTF_8; ++import static java.nio.charset.StandardCharsets.UTF_8; import static org.junit.Assert.*; - import java.nio.charset.StandardCharsets; import java.util.Collections; import java.util.Map.Entry; http://git-wip-us.apache.org/repos/asf/accumulo/blob/cfbdef13/test/src/test/java/org/apache/accumulo/test/functional/DeleteRowsSplitIT.java ---------------------------------------------------------------------- diff --cc test/src/test/java/org/apache/accumulo/test/functional/DeleteRowsSplitIT.java index 02ab695,d35ba9f..ef64edc --- a/test/src/test/java/org/apache/accumulo/test/functional/DeleteRowsSplitIT.java +++ b/test/src/test/java/org/apache/accumulo/test/functional/DeleteRowsSplitIT.java @@@ -16,9 -16,9 +16,9 @@@ */ package org.apache.accumulo.test.functional; -import static com.google.common.base.Charsets.UTF_8; ++import static java.nio.charset.StandardCharsets.UTF_8; import static org.junit.Assert.assertTrue; - import java.nio.charset.StandardCharsets; import java.util.ArrayList; import java.util.Collections; import java.util.List; http://git-wip-us.apache.org/repos/asf/accumulo/blob/cfbdef13/test/src/test/java/org/apache/accumulo/test/functional/LargeRowIT.java ---------------------------------------------------------------------- diff --cc test/src/test/java/org/apache/accumulo/test/functional/LargeRowIT.java index f0e4643,d77d060..91b19f6 --- a/test/src/test/java/org/apache/accumulo/test/functional/LargeRowIT.java +++ b/test/src/test/java/org/apache/accumulo/test/functional/LargeRowIT.java @@@ -16,7 -16,8 +16,8 @@@ */ package org.apache.accumulo.test.functional; - import java.nio.charset.StandardCharsets; -import static com.google.common.base.Charsets.UTF_8; ++import static java.nio.charset.StandardCharsets.UTF_8; + import java.util.Collections; import java.util.Map.Entry; import java.util.Random; http://git-wip-us.apache.org/repos/asf/accumulo/blob/cfbdef13/test/src/test/java/org/apache/accumulo/test/functional/NativeMapIT.java ---------------------------------------------------------------------- diff --cc test/src/test/java/org/apache/accumulo/test/functional/NativeMapIT.java index 0512998,f4bee97..f4101de --- a/test/src/test/java/org/apache/accumulo/test/functional/NativeMapIT.java +++ b/test/src/test/java/org/apache/accumulo/test/functional/NativeMapIT.java @@@ -16,6 -16,7 +16,7 @@@ */ package org.apache.accumulo.test.functional; -import static com.google.common.base.Charsets.UTF_8; ++import static java.nio.charset.StandardCharsets.UTF_8; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotNull; http://git-wip-us.apache.org/repos/asf/accumulo/blob/cfbdef13/test/src/test/java/org/apache/accumulo/test/functional/ScanIteratorIT.java ---------------------------------------------------------------------- diff --cc test/src/test/java/org/apache/accumulo/test/functional/ScanIteratorIT.java index 9ae94a3,189a55c..df18ef8 --- a/test/src/test/java/org/apache/accumulo/test/functional/ScanIteratorIT.java +++ b/test/src/test/java/org/apache/accumulo/test/functional/ScanIteratorIT.java @@@ -16,7 -16,8 +16,8 @@@ */ package org.apache.accumulo.test.functional; - import java.nio.charset.StandardCharsets; -import static com.google.common.base.Charsets.UTF_8; ++import static java.nio.charset.StandardCharsets.UTF_8; + import java.util.ArrayList; import java.util.Collections; import java.util.HashSet; http://git-wip-us.apache.org/repos/asf/accumulo/blob/cfbdef13/test/src/test/java/org/apache/accumulo/test/functional/ScanRangeIT.java ---------------------------------------------------------------------- diff --cc test/src/test/java/org/apache/accumulo/test/functional/ScanRangeIT.java index 50267dc,90b881c..3514fb3 --- a/test/src/test/java/org/apache/accumulo/test/functional/ScanRangeIT.java +++ b/test/src/test/java/org/apache/accumulo/test/functional/ScanRangeIT.java @@@ -16,7 -16,8 +16,8 @@@ */ package org.apache.accumulo.test.functional; - import java.nio.charset.StandardCharsets; -import static com.google.common.base.Charsets.UTF_8; ++import static java.nio.charset.StandardCharsets.UTF_8; + import java.util.Map.Entry; import java.util.TreeSet; http://git-wip-us.apache.org/repos/asf/accumulo/blob/cfbdef13/test/src/test/java/org/apache/accumulo/test/functional/ScanSessionTimeOutIT.java ---------------------------------------------------------------------- diff --cc test/src/test/java/org/apache/accumulo/test/functional/ScanSessionTimeOutIT.java index 760fdf7,3547b68..d9c3c77 --- a/test/src/test/java/org/apache/accumulo/test/functional/ScanSessionTimeOutIT.java +++ b/test/src/test/java/org/apache/accumulo/test/functional/ScanSessionTimeOutIT.java @@@ -16,7 -16,8 +16,8 @@@ */ package org.apache.accumulo.test.functional; - import java.nio.charset.StandardCharsets; -import static com.google.common.base.Charsets.UTF_8; ++import static java.nio.charset.StandardCharsets.UTF_8; + import java.util.Collections; import java.util.Iterator; import java.util.Map.Entry; http://git-wip-us.apache.org/repos/asf/accumulo/blob/cfbdef13/test/src/test/java/org/apache/accumulo/test/functional/SplitRecoveryIT.java ---------------------------------------------------------------------- diff --cc test/src/test/java/org/apache/accumulo/test/functional/SplitRecoveryIT.java index 8deb51d,43d3a86..5223439 --- a/test/src/test/java/org/apache/accumulo/test/functional/SplitRecoveryIT.java +++ b/test/src/test/java/org/apache/accumulo/test/functional/SplitRecoveryIT.java @@@ -16,9 -16,9 +16,9 @@@ */ package org.apache.accumulo.test.functional; -import static com.google.common.base.Charsets.UTF_8; ++import static java.nio.charset.StandardCharsets.UTF_8; import static org.junit.Assert.assertEquals; - import java.nio.charset.StandardCharsets; import java.util.ArrayList; import java.util.HashMap; import java.util.HashSet; http://git-wip-us.apache.org/repos/asf/accumulo/blob/cfbdef13/test/src/test/java/org/apache/accumulo/test/functional/TabletIT.java ---------------------------------------------------------------------- diff --cc test/src/test/java/org/apache/accumulo/test/functional/TabletIT.java index 0dd511d,fccc79f..b75cccc --- a/test/src/test/java/org/apache/accumulo/test/functional/TabletIT.java +++ b/test/src/test/java/org/apache/accumulo/test/functional/TabletIT.java @@@ -16,9 -16,9 +16,9 @@@ */ package org.apache.accumulo.test.functional; -import static com.google.common.base.Charsets.UTF_8; ++import static java.nio.charset.StandardCharsets.UTF_8; import static org.junit.Assert.assertEquals; - import java.nio.charset.StandardCharsets; import java.util.HashMap; import java.util.Map; import java.util.Map.Entry; http://git-wip-us.apache.org/repos/asf/accumulo/blob/cfbdef13/test/src/test/java/org/apache/accumulo/test/functional/VisibilityIT.java ---------------------------------------------------------------------- diff --cc test/src/test/java/org/apache/accumulo/test/functional/VisibilityIT.java index be1a45f,f2460cf..e0d66ce --- a/test/src/test/java/org/apache/accumulo/test/functional/VisibilityIT.java +++ b/test/src/test/java/org/apache/accumulo/test/functional/VisibilityIT.java @@@ -16,7 -16,8 +16,8 @@@ */ package org.apache.accumulo.test.functional; - import java.nio.charset.StandardCharsets; -import static com.google.common.base.Charsets.UTF_8; ++import static java.nio.charset.StandardCharsets.UTF_8; + import java.util.ArrayList; import java.util.Collections; import java.util.HashMap; http://git-wip-us.apache.org/repos/asf/accumulo/blob/cfbdef13/test/src/test/java/org/apache/accumulo/test/replication/MultiTserverReplicationIT.java ---------------------------------------------------------------------- diff --cc test/src/test/java/org/apache/accumulo/test/replication/MultiTserverReplicationIT.java index 0f4cf5b,0000000..554b08e mode 100644,000000..100644 --- a/test/src/test/java/org/apache/accumulo/test/replication/MultiTserverReplicationIT.java +++ b/test/src/test/java/org/apache/accumulo/test/replication/MultiTserverReplicationIT.java @@@ -1,114 -1,0 +1,115 @@@ +/* + * 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.test.replication; + - import java.nio.charset.StandardCharsets; ++import static java.nio.charset.StandardCharsets.UTF_8; ++ +import java.util.HashSet; +import java.util.Set; + +import org.apache.accumulo.core.Constants; +import org.apache.accumulo.core.client.Connector; +import org.apache.accumulo.core.client.Instance; +import org.apache.accumulo.core.client.Scanner; +import org.apache.accumulo.core.replication.ReplicationConstants; +import org.apache.accumulo.core.security.Authorizations; +import org.apache.accumulo.core.zookeeper.ZooUtil; +import org.apache.accumulo.fate.zookeeper.ZooReader; +import org.apache.accumulo.minicluster.impl.MiniAccumuloConfigImpl; +import org.apache.accumulo.test.functional.ConfigurableMacIT; +import org.apache.hadoop.conf.Configuration; +import org.junit.Assert; +import org.junit.Test; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import com.google.common.collect.Iterables; +import com.google.common.net.HostAndPort; + +/** + * + */ +public class MultiTserverReplicationIT extends ConfigurableMacIT { + private static final Logger log = LoggerFactory.getLogger(MultiTserverReplicationIT.class); + + @Override + public void configure(MiniAccumuloConfigImpl cfg, Configuration hadoopCoreSite) { + cfg.setNumTservers(2); + } + + @Test + public void tserverReplicationServicePortsAreAdvertised() throws Exception { + // Wait for the cluster to be up + Connector conn = getConnector(); + Instance inst = conn.getInstance(); + + // Wait for a tserver to come up to fulfill this request + conn.tableOperations().create("foo"); + Scanner s = conn.createScanner("foo", Authorizations.EMPTY); + Assert.assertEquals(0, Iterables.size(s)); + + ZooReader zreader = new ZooReader(inst.getZooKeepers(), inst.getZooKeepersSessionTimeOut()); + Set<String> tserverHost = new HashSet<>(); + tserverHost.addAll(zreader.getChildren(ZooUtil.getRoot(inst) + Constants.ZTSERVERS)); + + Set<HostAndPort> replicationServices = new HashSet<>(); + + for (String tserver : tserverHost) { + try { + byte[] portData = zreader.getData(ZooUtil.getRoot(inst) + ReplicationConstants.ZOO_TSERVERS + "/" + tserver, null); - HostAndPort replAddress = HostAndPort.fromString(new String(portData, StandardCharsets.UTF_8)); ++ HostAndPort replAddress = HostAndPort.fromString(new String(portData, UTF_8)); + replicationServices.add(replAddress); + } catch (Exception e) { + log.error("Could not find port for {}", tserver, e); + Assert.fail("Did not find replication port advertisement for " + tserver); + } + } + + // Each tserver should also have equial replicaiton services running internally + Assert.assertEquals("Expected an equal number of replication servicers and tservers", tserverHost.size(), replicationServices.size()); + } + + @Test + public void masterReplicationServicePortsAreAdvertised() throws Exception { + // Wait for the cluster to be up + Connector conn = getConnector(); + Instance inst = conn.getInstance(); + + // Wait for a tserver to come up to fulfill this request + conn.tableOperations().create("foo"); + Scanner s = conn.createScanner("foo", Authorizations.EMPTY); + Assert.assertEquals(0, Iterables.size(s)); + + ZooReader zreader = new ZooReader(inst.getZooKeepers(), inst.getZooKeepersSessionTimeOut()); + + // Should have one master instance + Assert.assertEquals(1, inst.getMasterLocations().size()); + + // Get the master thrift service addr + String masterAddr = Iterables.getOnlyElement(inst.getMasterLocations()); + + // Get the master replication coordinator addr - String replCoordAddr = new String(zreader.getData(ZooUtil.getRoot(inst) + Constants.ZMASTER_REPLICATION_COORDINATOR_ADDR, null), StandardCharsets.UTF_8); ++ String replCoordAddr = new String(zreader.getData(ZooUtil.getRoot(inst) + Constants.ZMASTER_REPLICATION_COORDINATOR_ADDR, null), UTF_8); + + // They shouldn't be the same + Assert.assertNotEquals(masterAddr, replCoordAddr); + + // Neither should be zero as the port + Assert.assertNotEquals(0, HostAndPort.fromString(masterAddr).getPort()); + Assert.assertNotEquals(0, HostAndPort.fromString(replCoordAddr).getPort()); + } +}