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 2018/06/21 17:32:35 UTC
[accumulo] branch master updated: Remove Mock Accumulo (#536)
This is an automated email from the ASF dual-hosted git repository.
ctubbsii pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/accumulo.git
The following commit(s) were added to refs/heads/master by this push:
new 086d05a Remove Mock Accumulo (#536)
086d05a is described below
commit 086d05a8a95541dfa7b5472874e046683882c83e
Author: Christopher Tubbs <ct...@apache.org>
AuthorDate: Thu Jun 21 13:32:33 2018 -0400
Remove Mock Accumulo (#536)
* Remove Mock from Proxy (#452) and Shell
* Move ShellTest to ShellIT to use Mini (may be redundant with some of
ShellServerIT's tests)
* Make KerberosTokenEmbeddedKDCTest use a volatile to avoid a transient
build failure while testing this change
---
.../core/client/mapreduce/RangeInputSplit.java | 9 -
core/pom.xml | 1 -
core/src/main/findbugs/exclude-filter.xml | 1 -
.../accumulo/core/client/mock/IteratorAdapter.java | 33 --
.../accumulo/core/client/mock/MockAccumulo.java | 153 ------
.../core/client/mock/MockBatchDeleter.java | 76 ---
.../core/client/mock/MockBatchScanner.java | 79 ---
.../accumulo/core/client/mock/MockBatchWriter.java | 59 ---
.../core/client/mock/MockConfiguration.java | 54 --
.../accumulo/core/client/mock/MockConnector.java | 207 --------
.../accumulo/core/client/mock/MockInstance.java | 129 -----
.../core/client/mock/MockInstanceOperations.java | 103 ----
.../client/mock/MockMultiTableBatchWriter.java | 61 ---
.../accumulo/core/client/mock/MockNamespace.java | 58 ---
.../core/client/mock/MockNamespaceOperations.java | 145 ------
.../accumulo/core/client/mock/MockScanner.java | 127 -----
.../accumulo/core/client/mock/MockScannerBase.java | 163 ------
.../core/client/mock/MockSecurityOperations.java | 254 ---------
.../accumulo/core/client/mock/MockTable.java | 216 --------
.../core/client/mock/MockTableOperations.java | 573 ---------------------
.../apache/accumulo/core/client/mock/MockUser.java | 41 --
.../core/client/mock/impl/MockTabletLocator.java | 76 ---
.../accumulo/core/client/mock/package-info.java | 24 -
.../core/replication/ReplicationTable.java | 4 +-
.../apache/accumulo/core/util/DeprecationUtil.java | 47 --
.../core/client/mock/MockConnectorTest.java | 382 --------------
.../core/client/mock/MockNamespacesTest.java | 300 -----------
.../accumulo/core/client/mock/MockScannerTest.java | 105 ----
.../core/client/mock/MockTableOperationsTest.java | 357 -------------
.../core/client/mock/TestBatchScanner821.java | 78 ---
.../accumulo/core/security/CredentialsTest.java | 23 -
proxy/proxy.properties | 2 -
.../main/java/org/apache/accumulo/proxy/Proxy.java | 8 +-
.../org/apache/accumulo/proxy/ProxyServer.java | 12 +-
.../accumulo/server/AccumuloServerContext.java | 15 +-
.../main/java/org/apache/accumulo/shell/Shell.java | 27 +-
.../org/apache/accumulo/shell/ShellOptionsJC.java | 7 -
.../org/apache/accumulo/shell/mock/MockShell.java | 158 ------
.../org/apache/accumulo/shell/ShellConfigTest.java | 20 +-
.../accumulo/shell/ShellSetInstanceTest.java | 14 -
.../java/org/apache/accumulo/test/ShellIT.java | 42 +-
.../accumulo/test/functional/KerberosProxyIT.java | 1 -
.../test/proxy/TestProxyInstanceOperations.java | 1 -
.../test/proxy/TestProxyNamespaceOperations.java | 1 -
.../accumulo/test/proxy/TestProxyReadWrite.java | 1 -
.../test/proxy/TestProxySecurityOperations.java | 1 -
.../test/proxy/TestProxyTableOperations.java | 1 -
.../src/main/resources/shellit.txt | 0
.../security/KerberosTokenEmbeddedKDCTest.java | 2 +-
49 files changed, 71 insertions(+), 4180 deletions(-)
diff --git a/client/mapreduce/src/main/java/org/apache/accumulo/core/client/mapreduce/RangeInputSplit.java b/client/mapreduce/src/main/java/org/apache/accumulo/core/client/mapreduce/RangeInputSplit.java
index 3f289c3..95c6f85 100644
--- a/client/mapreduce/src/main/java/org/apache/accumulo/core/client/mapreduce/RangeInputSplit.java
+++ b/client/mapreduce/src/main/java/org/apache/accumulo/core/client/mapreduce/RangeInputSplit.java
@@ -144,12 +144,6 @@ public class RangeInputSplit extends InputSplit implements Writable {
localIterators = in.readBoolean();
}
- // ignore mock flag; it was removed
- if (in.readBoolean()) {
- throw new IllegalStateException(
- "Mock flag was set in serialized RangeInputSplit, but mock Accumulo was removed");
- }
-
if (in.readBoolean()) {
int numColumns = in.readInt();
List<String> columns = new ArrayList<>(numColumns);
@@ -201,9 +195,6 @@ public class RangeInputSplit extends InputSplit implements Writable {
out.writeBoolean(localIterators);
}
- // should be false to indicate that no mock flag was serialized; mock was removed
- out.writeBoolean(false);
-
out.writeBoolean(null != fetchedColumns);
if (null != fetchedColumns) {
String[] cols = InputConfigurator.serializeColumns(fetchedColumns);
diff --git a/core/pom.xml b/core/pom.xml
index 909ee48..cf45283 100644
--- a/core/pom.xml
+++ b/core/pom.xml
@@ -192,7 +192,6 @@
<exclude>.*[.]impl[.].*</exclude>
<exclude>.*[.]thrift[.].*</exclude>
<exclude>org[.]apache[.]accumulo[.]core[.]security[.]crypto[.].*</exclude>
- <exclude>org[.]apache[.]accumulo[.]core[.]client[.]mock[.].*</exclude>
</excludes>
<allows>
<!--Allow API data types to reference thrift types, but do not
diff --git a/core/src/main/findbugs/exclude-filter.xml b/core/src/main/findbugs/exclude-filter.xml
index a3db72f..c94a041 100644
--- a/core/src/main/findbugs/exclude-filter.xml
+++ b/core/src/main/findbugs/exclude-filter.xml
@@ -58,7 +58,6 @@
<Class name="org.apache.accumulo.core.util.AddressUtil" />
<Class name="org.apache.accumulo.core.zookeeper.ZooUtil" />
<Class name="org.apache.accumulo.core.security.VisibilityConstraint" />
- <Class name="org.apache.accumulo.core.client.mock.IteratorAdapter" />
</Or>
<Or>
<Bug code="NM" pattern="NM_SAME_SIMPLE_NAME_AS_SUPERCLASS" />
diff --git a/core/src/main/java/org/apache/accumulo/core/client/mock/IteratorAdapter.java b/core/src/main/java/org/apache/accumulo/core/client/mock/IteratorAdapter.java
deleted file mode 100644
index d88dac9..0000000
--- a/core/src/main/java/org/apache/accumulo/core/client/mock/IteratorAdapter.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * 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.core.client.mock;
-
-import org.apache.accumulo.core.data.Key;
-import org.apache.accumulo.core.data.Value;
-import org.apache.accumulo.core.iterators.SortedKeyValueIterator;
-
-/**
- * @deprecated since 1.8.0; use {@link org.apache.accumulo.core.iterators.IteratorAdapter} instead.
- */
-@Deprecated
-public class IteratorAdapter extends org.apache.accumulo.core.iterators.IteratorAdapter {
-
- public IteratorAdapter(SortedKeyValueIterator<Key,Value> inner) {
- super(inner);
- }
-
-}
diff --git a/core/src/main/java/org/apache/accumulo/core/client/mock/MockAccumulo.java b/core/src/main/java/org/apache/accumulo/core/client/mock/MockAccumulo.java
deleted file mode 100644
index b04b706..0000000
--- a/core/src/main/java/org/apache/accumulo/core/client/mock/MockAccumulo.java
+++ /dev/null
@@ -1,153 +0,0 @@
-/*
- * 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.core.client.mock;
-
-import java.util.Collection;
-import java.util.Collections;
-import java.util.EnumSet;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.SortedSet;
-import java.util.concurrent.atomic.AtomicInteger;
-
-import org.apache.accumulo.core.client.BatchScanner;
-import org.apache.accumulo.core.client.admin.TimeType;
-import org.apache.accumulo.core.client.impl.Namespace;
-import org.apache.accumulo.core.client.impl.Tables;
-import org.apache.accumulo.core.client.security.tokens.PasswordToken;
-import org.apache.accumulo.core.data.Mutation;
-import org.apache.accumulo.core.metadata.MetadataTable;
-import org.apache.accumulo.core.metadata.RootTable;
-import org.apache.accumulo.core.replication.ReplicationTable;
-import org.apache.accumulo.core.security.Authorizations;
-import org.apache.accumulo.core.security.NamespacePermission;
-import org.apache.accumulo.core.security.SystemPermission;
-import org.apache.accumulo.core.security.TablePermission;
-import org.apache.hadoop.fs.FileSystem;
-import org.apache.hadoop.io.Text;
-
-/**
- * @deprecated since 1.8.0; use MiniAccumuloCluster or a standard mock framework instead.
- */
-@Deprecated
-public class MockAccumulo {
- final Map<String,MockTable> tables = new HashMap<>();
- final Map<String,MockNamespace> namespaces = new HashMap<>();
- final Map<String,String> systemProperties = new HashMap<>();
- Map<String,MockUser> users = new HashMap<>();
- final FileSystem fs;
- final AtomicInteger tableIdCounter = new AtomicInteger(0);
-
- @Deprecated
- MockAccumulo(FileSystem fs) {
- MockUser root = new MockUser("root", new PasswordToken(new byte[0]), Authorizations.EMPTY);
- root.permissions.add(SystemPermission.SYSTEM);
- users.put(root.name, root);
- namespaces.put(Namespace.DEFAULT, new MockNamespace());
- namespaces.put(Namespace.ACCUMULO, new MockNamespace());
- createTable("root", RootTable.NAME, true, TimeType.LOGICAL);
- createTable("root", MetadataTable.NAME, true, TimeType.LOGICAL);
- createTable("root", ReplicationTable.NAME, true, TimeType.LOGICAL);
- this.fs = fs;
- }
-
- public FileSystem getFileSystem() {
- return fs;
- }
-
- void setProperty(String key, String value) {
- systemProperties.put(key, value);
- }
-
- String removeProperty(String key) {
- return systemProperties.remove(key);
- }
-
- public void addMutation(String table, Mutation m) {
- MockTable t = tables.get(table);
- t.addMutation(m);
- }
-
- public BatchScanner createBatchScanner(String tableName, Authorizations authorizations) {
- return new MockBatchScanner(tables.get(tableName), authorizations);
- }
-
- public void createTable(String username, String tableName, boolean useVersions,
- TimeType timeType) {
- Map<String,String> opts = Collections.emptyMap();
- createTable(username, tableName, useVersions, timeType, opts);
- }
-
- public void createTable(String username, String tableName, boolean useVersions, TimeType timeType,
- Map<String,String> properties) {
- String namespace = Tables.qualify(tableName).getFirst();
-
- if (!namespaceExists(namespace)) {
- return;
- }
-
- MockNamespace n = namespaces.get(namespace);
- MockTable t = new MockTable(n, useVersions, timeType,
- Integer.toString(tableIdCounter.incrementAndGet()), properties);
- t.userPermissions.put(username, EnumSet.allOf(TablePermission.class));
- t.setNamespaceName(namespace);
- t.setNamespace(n);
- tables.put(tableName, t);
- }
-
- public void createTable(String username, String tableName, TimeType timeType,
- Map<String,String> properties) {
- String namespace = Tables.qualify(tableName).getFirst();
- HashMap<String,String> props = new HashMap<>(properties);
-
- if (!namespaceExists(namespace)) {
- return;
- }
-
- MockNamespace n = namespaces.get(namespace);
- MockTable t = new MockTable(n, timeType, Integer.toString(tableIdCounter.incrementAndGet()),
- props);
- t.userPermissions.put(username, EnumSet.allOf(TablePermission.class));
- t.setNamespaceName(namespace);
- t.setNamespace(n);
- tables.put(tableName, t);
- }
-
- public void createNamespace(String username, String namespace) {
- if (!namespaceExists(namespace)) {
- MockNamespace n = new MockNamespace();
- n.userPermissions.put(username, EnumSet.allOf(NamespacePermission.class));
- namespaces.put(namespace, n);
- }
- }
-
- public void addSplits(String tableName, SortedSet<Text> partitionKeys) {
- tables.get(tableName).addSplits(partitionKeys);
- }
-
- public Collection<Text> getSplits(String tableName) {
- return tables.get(tableName).getSplits();
- }
-
- public void merge(String tableName, Text start, Text end) {
- tables.get(tableName).merge(start, end);
- }
-
- private boolean namespaceExists(String namespace) {
- return namespaces.containsKey(namespace);
- }
-}
diff --git a/core/src/main/java/org/apache/accumulo/core/client/mock/MockBatchDeleter.java b/core/src/main/java/org/apache/accumulo/core/client/mock/MockBatchDeleter.java
deleted file mode 100644
index 1b20380..0000000
--- a/core/src/main/java/org/apache/accumulo/core/client/mock/MockBatchDeleter.java
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
- * 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.core.client.mock;
-
-import java.util.Iterator;
-import java.util.Map.Entry;
-
-import org.apache.accumulo.core.client.BatchDeleter;
-import org.apache.accumulo.core.client.BatchWriter;
-import org.apache.accumulo.core.client.MutationsRejectedException;
-import org.apache.accumulo.core.client.TableNotFoundException;
-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.core.security.ColumnVisibility;
-
-/**
- * {@link BatchDeleter} for a {@link MockAccumulo} instance. Behaves similarly to a regular
- * {@link BatchDeleter}, with a few exceptions:
- * <ol>
- * <li>There is no waiting for memory to fill before flushing</li>
- * <li>Only one thread is used for writing</li>
- * </ol>
- *
- * Otherwise, it behaves as expected.
- *
- * @deprecated since 1.8.0; use MiniAccumuloCluster or a standard mock framework instead.
- */
-@Deprecated
-public class MockBatchDeleter extends MockBatchScanner implements BatchDeleter {
-
- private final MockAccumulo acc;
- private final String tableName;
-
- /**
- * Create a {@link BatchDeleter} for the specified instance on the specified table where the
- * writer uses the specified {@link Authorizations}.
- */
- public MockBatchDeleter(MockAccumulo acc, String tableName, Authorizations auths) {
- super(acc.tables.get(tableName), auths);
- this.acc = acc;
- this.tableName = tableName;
- }
-
- @Override
- public void delete() throws MutationsRejectedException, TableNotFoundException {
-
- try (BatchWriter writer = new MockBatchWriter(acc, tableName)) {
- Iterator<Entry<Key,Value>> iter = super.iterator();
- while (iter.hasNext()) {
- Entry<Key,Value> next = iter.next();
- Key k = next.getKey();
- Mutation m = new Mutation(k.getRow());
- m.putDelete(k.getColumnFamily(), k.getColumnQualifier(),
- new ColumnVisibility(k.getColumnVisibility()), k.getTimestamp());
- writer.addMutation(m);
- }
- }
- }
-
-}
diff --git a/core/src/main/java/org/apache/accumulo/core/client/mock/MockBatchScanner.java b/core/src/main/java/org/apache/accumulo/core/client/mock/MockBatchScanner.java
deleted file mode 100644
index 1ea27b5..0000000
--- a/core/src/main/java/org/apache/accumulo/core/client/mock/MockBatchScanner.java
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
- * 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.core.client.mock;
-
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map.Entry;
-
-import org.apache.accumulo.core.client.BatchScanner;
-import org.apache.accumulo.core.data.Key;
-import org.apache.accumulo.core.data.Range;
-import org.apache.accumulo.core.data.Value;
-import org.apache.accumulo.core.iterators.SortedKeyValueIterator;
-import org.apache.accumulo.core.iterators.SortedMapIterator;
-import org.apache.accumulo.core.security.Authorizations;
-import org.apache.commons.collections.iterators.IteratorChain;
-
-/**
- * @deprecated since 1.8.0; use MiniAccumuloCluster or a standard mock framework instead.
- */
-@Deprecated
-public class MockBatchScanner extends MockScannerBase implements BatchScanner {
-
- List<Range> ranges = null;
-
- public MockBatchScanner(MockTable mockTable, Authorizations authorizations) {
- super(mockTable, authorizations);
- }
-
- @Override
- public void setRanges(Collection<Range> ranges) {
- if (ranges == null || ranges.size() == 0) {
- throw new IllegalArgumentException("ranges must be non null and contain at least 1 range");
- }
-
- this.ranges = new ArrayList<>(ranges);
- }
-
- @SuppressWarnings("unchecked")
- @Override
- public Iterator<Entry<Key,Value>> iterator() {
- if (ranges == null) {
- throw new IllegalStateException("ranges not set");
- }
-
- IteratorChain chain = new IteratorChain();
- for (Range range : ranges) {
- SortedKeyValueIterator<Key,Value> i = new SortedMapIterator(table.table);
- try {
- i = createFilter(i);
- i.seek(range, createColumnBSS(fetchedColumns), !fetchedColumns.isEmpty());
- chain.addIterator(new IteratorAdapter(i));
- } catch (IOException e) {
- throw new RuntimeException(e);
- }
- }
- return chain;
- }
-
- @Override
- public void close() {}
-}
diff --git a/core/src/main/java/org/apache/accumulo/core/client/mock/MockBatchWriter.java b/core/src/main/java/org/apache/accumulo/core/client/mock/MockBatchWriter.java
deleted file mode 100644
index 53a0ddc..0000000
--- a/core/src/main/java/org/apache/accumulo/core/client/mock/MockBatchWriter.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * 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.core.client.mock;
-
-import static com.google.common.base.Preconditions.checkArgument;
-
-import org.apache.accumulo.core.client.BatchWriter;
-import org.apache.accumulo.core.client.MutationsRejectedException;
-import org.apache.accumulo.core.data.Mutation;
-
-/**
- * @deprecated since 1.8.0; use MiniAccumuloCluster or a standard mock framework instead.
- */
-@Deprecated
-public class MockBatchWriter implements BatchWriter {
-
- final String tablename;
- final MockAccumulo acu;
-
- MockBatchWriter(MockAccumulo acu, String tablename) {
- this.acu = acu;
- this.tablename = tablename;
- }
-
- @Override
- public void addMutation(Mutation m) throws MutationsRejectedException {
- checkArgument(m != null, "m is null");
- acu.addMutation(tablename, m);
- }
-
- @Override
- public void addMutations(Iterable<Mutation> iterable) throws MutationsRejectedException {
- checkArgument(iterable != null, "iterable is null");
- for (Mutation m : iterable) {
- acu.addMutation(tablename, m);
- }
- }
-
- @Override
- public void flush() throws MutationsRejectedException {}
-
- @Override
- public void close() throws MutationsRejectedException {}
-
-}
diff --git a/core/src/main/java/org/apache/accumulo/core/client/mock/MockConfiguration.java b/core/src/main/java/org/apache/accumulo/core/client/mock/MockConfiguration.java
deleted file mode 100644
index 38ed1df..0000000
--- a/core/src/main/java/org/apache/accumulo/core/client/mock/MockConfiguration.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * 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.core.client.mock;
-
-import java.util.Map;
-import java.util.Map.Entry;
-import java.util.function.Predicate;
-
-import org.apache.accumulo.core.conf.AccumuloConfiguration;
-import org.apache.accumulo.core.conf.Property;
-
-/**
- * @deprecated since 1.8.0; use MiniAccumuloCluster or a standard mock framework instead.
- */
-@Deprecated
-class MockConfiguration extends AccumuloConfiguration {
- Map<String,String> map;
-
- MockConfiguration(Map<String,String> settings) {
- map = settings;
- }
-
- public void put(String k, String v) {
- map.put(k, v);
- }
-
- @Override
- public String get(Property property) {
- return map.get(property.getKey());
- }
-
- @Override
- public void getProperties(Map<String,String> props, Predicate<String> filter) {
- for (Entry<String,String> entry : map.entrySet()) {
- if (filter.test(entry.getKey())) {
- props.put(entry.getKey(), entry.getValue());
- }
- }
- }
-}
diff --git a/core/src/main/java/org/apache/accumulo/core/client/mock/MockConnector.java b/core/src/main/java/org/apache/accumulo/core/client/mock/MockConnector.java
deleted file mode 100644
index b831110..0000000
--- a/core/src/main/java/org/apache/accumulo/core/client/mock/MockConnector.java
+++ /dev/null
@@ -1,207 +0,0 @@
-/*
- * 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.core.client.mock;
-
-import java.util.Properties;
-import java.util.concurrent.TimeUnit;
-
-import org.apache.accumulo.core.client.AccumuloSecurityException;
-import org.apache.accumulo.core.client.BatchDeleter;
-import org.apache.accumulo.core.client.BatchScanner;
-import org.apache.accumulo.core.client.BatchWriter;
-import org.apache.accumulo.core.client.BatchWriterConfig;
-import org.apache.accumulo.core.client.ClientInfo;
-import org.apache.accumulo.core.client.ConditionalWriter;
-import org.apache.accumulo.core.client.ConditionalWriterConfig;
-import org.apache.accumulo.core.client.Connector;
-import org.apache.accumulo.core.client.Instance;
-import org.apache.accumulo.core.client.MultiTableBatchWriter;
-import org.apache.accumulo.core.client.Scanner;
-import org.apache.accumulo.core.client.TableNotFoundException;
-import org.apache.accumulo.core.client.admin.InstanceOperations;
-import org.apache.accumulo.core.client.admin.NamespaceOperations;
-import org.apache.accumulo.core.client.admin.ReplicationOperations;
-import org.apache.accumulo.core.client.admin.SecurityOperations;
-import org.apache.accumulo.core.client.admin.TableOperations;
-import org.apache.accumulo.core.client.impl.ClientInfoImpl;
-import org.apache.accumulo.core.client.impl.Credentials;
-import org.apache.accumulo.core.client.impl.thrift.SecurityErrorCode;
-import org.apache.accumulo.core.client.security.tokens.NullToken;
-import org.apache.accumulo.core.conf.ClientProperty;
-import org.apache.accumulo.core.security.Authorizations;
-
-/**
- * @deprecated since 1.8.0; use MiniAccumuloCluster or a standard mock framework instead.
- */
-@Deprecated
-public class MockConnector extends Connector {
-
- String username;
- private final MockAccumulo acu;
- private final Instance instance;
-
- MockConnector(String username, MockInstance instance) throws AccumuloSecurityException {
- this(new Credentials(username, new NullToken()),
- new MockAccumulo(MockInstance.getDefaultFileSystem()), instance);
- }
-
- MockConnector(Credentials credentials, MockAccumulo acu, MockInstance instance)
- throws AccumuloSecurityException {
- if (credentials.getToken().isDestroyed())
- throw new AccumuloSecurityException(credentials.getPrincipal(),
- SecurityErrorCode.TOKEN_EXPIRED);
- this.username = credentials.getPrincipal();
- this.acu = acu;
- this.instance = instance;
- }
-
- @Override
- public BatchScanner createBatchScanner(String tableName, Authorizations authorizations,
- int numQueryThreads) throws TableNotFoundException {
- if (acu.tables.get(tableName) == null)
- throw new TableNotFoundException(tableName, tableName, "no such table");
- return acu.createBatchScanner(tableName, authorizations);
- }
-
- @Deprecated
- @Override
- public BatchDeleter createBatchDeleter(String tableName, Authorizations authorizations,
- int numQueryThreads, long maxMemory, long maxLatency, int maxWriteThreads)
- throws TableNotFoundException {
- if (acu.tables.get(tableName) == null)
- throw new TableNotFoundException(tableName, tableName, "no such table");
- return new MockBatchDeleter(acu, tableName, authorizations);
- }
-
- @Override
- public BatchDeleter createBatchDeleter(String tableName, Authorizations authorizations,
- int numQueryThreads, BatchWriterConfig config) throws TableNotFoundException {
- return createBatchDeleter(tableName, authorizations, numQueryThreads, config.getMaxMemory(),
- config.getMaxLatency(TimeUnit.MILLISECONDS), config.getMaxWriteThreads());
- }
-
- @Override
- public BatchDeleter createBatchDeleter(String tableName, Authorizations authorizations,
- int numQueryThreads) throws TableNotFoundException {
- return createBatchDeleter(tableName, authorizations, numQueryThreads, new BatchWriterConfig());
- }
-
- @Deprecated
- @Override
- public BatchWriter createBatchWriter(String tableName, long maxMemory, long maxLatency,
- int maxWriteThreads) throws TableNotFoundException {
- if (acu.tables.get(tableName) == null)
- throw new TableNotFoundException(tableName, tableName, "no such table");
- return new MockBatchWriter(acu, tableName);
- }
-
- @Override
- public BatchWriter createBatchWriter(String tableName, BatchWriterConfig config)
- throws TableNotFoundException {
- return createBatchWriter(tableName, config.getMaxMemory(),
- config.getMaxLatency(TimeUnit.MILLISECONDS), config.getMaxWriteThreads());
- }
-
- @Override
- public BatchWriter createBatchWriter(String tableName) throws TableNotFoundException {
- return createBatchWriter(tableName, new BatchWriterConfig());
- }
-
- @Deprecated
- @Override
- public MultiTableBatchWriter createMultiTableBatchWriter(long maxMemory, long maxLatency,
- int maxWriteThreads) {
- return new MockMultiTableBatchWriter(acu);
- }
-
- @Override
- public MultiTableBatchWriter createMultiTableBatchWriter(BatchWriterConfig config) {
- return createMultiTableBatchWriter(config.getMaxMemory(),
- config.getMaxLatency(TimeUnit.MILLISECONDS), config.getMaxWriteThreads());
- }
-
- @Override
- public MultiTableBatchWriter createMultiTableBatchWriter() {
- return createMultiTableBatchWriter(new BatchWriterConfig());
- }
-
- @Override
- public Scanner createScanner(String tableName, Authorizations authorizations)
- throws TableNotFoundException {
- MockTable table = acu.tables.get(tableName);
- if (table == null)
- throw new TableNotFoundException(tableName, tableName, "no such table");
- return new MockScanner(table, authorizations);
- }
-
- @Override
- public Instance getInstance() {
- return instance;
- }
-
- @Override
- public String whoami() {
- return username;
- }
-
- @Override
- public String getInstanceID() {
- return instance.getInstanceID();
- }
-
- @Override
- public TableOperations tableOperations() {
- return new MockTableOperations(acu, username);
- }
-
- @Override
- public SecurityOperations securityOperations() {
- return new MockSecurityOperations(acu);
- }
-
- @Override
- public InstanceOperations instanceOperations() {
- return new MockInstanceOperations(acu);
- }
-
- @Override
- public NamespaceOperations namespaceOperations() {
- return new MockNamespaceOperations(acu, username);
- }
-
- @Override
- public ConditionalWriter createConditionalWriter(String tableName, ConditionalWriterConfig config)
- throws TableNotFoundException {
- // TODO add implementation
- throw new UnsupportedOperationException();
- }
-
- @Override
- public ReplicationOperations replicationOperations() {
- // TODO add implementation
- throw new UnsupportedOperationException();
- }
-
- @Override
- public ClientInfo info() {
- Properties props = new Properties();
- props.setProperty(ClientProperty.INSTANCE_ZOOKEEPERS.getKey(), instance.getZooKeepers());
- props.setProperty(ClientProperty.INSTANCE_NAME.getKey(), instance.getInstanceName());
- props.setProperty(ClientProperty.AUTH_PRINCIPAL.getKey(), username);
- return new ClientInfoImpl(props);
- }
-}
diff --git a/core/src/main/java/org/apache/accumulo/core/client/mock/MockInstance.java b/core/src/main/java/org/apache/accumulo/core/client/mock/MockInstance.java
deleted file mode 100644
index 7e143e0..0000000
--- a/core/src/main/java/org/apache/accumulo/core/client/mock/MockInstance.java
+++ /dev/null
@@ -1,129 +0,0 @@
-/*
- * 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.core.client.mock;
-
-import java.io.IOException;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import org.apache.accumulo.core.client.AccumuloException;
-import org.apache.accumulo.core.client.AccumuloSecurityException;
-import org.apache.accumulo.core.client.Connector;
-import org.apache.accumulo.core.client.Instance;
-import org.apache.accumulo.core.client.impl.Credentials;
-import org.apache.accumulo.core.client.impl.thrift.SecurityErrorCode;
-import org.apache.accumulo.core.client.security.tokens.AuthenticationToken;
-import org.apache.accumulo.core.client.security.tokens.PasswordToken;
-import org.apache.accumulo.core.util.CachedConfiguration;
-import org.apache.hadoop.conf.Configuration;
-import org.apache.hadoop.fs.FileSystem;
-
-/**
- * Mock Accumulo provides an in memory implementation of the Accumulo client API. It is possible
- * that the behavior of this implementation may differ subtly from the behavior of Accumulo. This
- * could result in unit tests that pass on Mock Accumulo and fail on Accumulo or visa-versa.
- * Documenting the differences would be difficult and is not done.
- *
- * <p>
- * An alternative to Mock Accumulo called MiniAccumuloCluster was introduced in Accumulo 1.5.
- * MiniAccumuloCluster spins up actual Accumulo server processes, can be used for unit testing, and
- * its behavior should match Accumulo. The drawback of MiniAccumuloCluster is that it starts more
- * slowly than Mock Accumulo.
- *
- * @deprecated since 1.8.0; use MiniAccumuloCluster or a standard mock framework instead.
- */
-@Deprecated
-public class MockInstance implements Instance {
-
- static final String genericAddress = "localhost:1234";
- static final Map<String,MockAccumulo> instances = new HashMap<>();
- MockAccumulo acu;
- String instanceName;
-
- public MockInstance() {
- acu = new MockAccumulo(getDefaultFileSystem());
- instanceName = "mock-instance";
- }
-
- static FileSystem getDefaultFileSystem() {
- try {
- Configuration conf = CachedConfiguration.getInstance();
- conf.set("fs.file.impl", "org.apache.hadoop.fs.LocalFileSystem");
- conf.set("fs.default.name", "file:///");
- return FileSystem.get(CachedConfiguration.getInstance());
- } catch (IOException ex) {
- throw new RuntimeException(ex);
- }
- }
-
- public MockInstance(String instanceName) {
- this(instanceName, getDefaultFileSystem());
- }
-
- public MockInstance(String instanceName, FileSystem fs) {
- synchronized (instances) {
- if (instances.containsKey(instanceName))
- acu = instances.get(instanceName);
- else
- instances.put(instanceName, acu = new MockAccumulo(fs));
- }
- this.instanceName = instanceName;
- }
-
- @Override
- public String getRootTabletLocation() {
- return genericAddress;
- }
-
- @Override
- public List<String> getMasterLocations() {
- return Collections.singletonList(genericAddress);
- }
-
- @Override
- public String getInstanceID() {
- return "mock-instance-id";
- }
-
- @Override
- public String getInstanceName() {
- return instanceName;
- }
-
- @Override
- public String getZooKeepers() {
- return "localhost";
- }
-
- @Override
- public int getZooKeepersSessionTimeOut() {
- return 30 * 1000;
- }
-
- @Override
- public Connector getConnector(String principal, AuthenticationToken token)
- throws AccumuloException, AccumuloSecurityException {
- Connector conn = new MockConnector(new Credentials(principal, token), acu, this);
- if (!acu.users.containsKey(principal))
- conn.securityOperations().createLocalUser(principal, (PasswordToken) token);
- else if (!acu.users.get(principal).token.equals(token))
- throw new AccumuloSecurityException(principal, SecurityErrorCode.BAD_CREDENTIALS);
- return conn;
- }
-}
diff --git a/core/src/main/java/org/apache/accumulo/core/client/mock/MockInstanceOperations.java b/core/src/main/java/org/apache/accumulo/core/client/mock/MockInstanceOperations.java
deleted file mode 100644
index b86b67a..0000000
--- a/core/src/main/java/org/apache/accumulo/core/client/mock/MockInstanceOperations.java
+++ /dev/null
@@ -1,103 +0,0 @@
-/*
- * 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.core.client.mock;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-
-import org.apache.accumulo.core.client.AccumuloException;
-import org.apache.accumulo.core.client.AccumuloSecurityException;
-import org.apache.accumulo.core.client.admin.ActiveCompaction;
-import org.apache.accumulo.core.client.admin.ActiveScan;
-import org.apache.accumulo.core.client.admin.InstanceOperations;
-import org.apache.accumulo.start.classloader.vfs.AccumuloVFSClassLoader;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * @deprecated since 1.8.0; use MiniAccumuloCluster or a standard mock framework instead.
- */
-@Deprecated
-class MockInstanceOperations implements InstanceOperations {
- private static final Logger log = LoggerFactory.getLogger(MockInstanceOperations.class);
- MockAccumulo acu;
-
- public MockInstanceOperations(MockAccumulo acu) {
- this.acu = acu;
- }
-
- @Override
- public void setProperty(String property, String value)
- throws AccumuloException, AccumuloSecurityException {
- acu.setProperty(property, value);
- }
-
- @Override
- public void removeProperty(String property) throws AccumuloException, AccumuloSecurityException {
- acu.removeProperty(property);
- }
-
- @Override
- public Map<String,String> getSystemConfiguration()
- throws AccumuloException, AccumuloSecurityException {
- return acu.systemProperties;
- }
-
- @Override
- public Map<String,String> getSiteConfiguration()
- throws AccumuloException, AccumuloSecurityException {
- return acu.systemProperties;
- }
-
- @Override
- public List<String> getTabletServers() {
- return new ArrayList<>();
- }
-
- @Override
- public List<ActiveScan> getActiveScans(String tserver)
- throws AccumuloException, AccumuloSecurityException {
- return new ArrayList<>();
- }
-
- @Override
- public boolean testClassLoad(String className, String asTypeName)
- throws AccumuloException, AccumuloSecurityException {
- try {
- AccumuloVFSClassLoader.loadClass(className, Class.forName(asTypeName));
- } catch (ClassNotFoundException e) {
- log.warn("Could not find class named '" + className + "' in testClassLoad.", e);
- return false;
- }
- return true;
- }
-
- @Override
- public List<ActiveCompaction> getActiveCompactions(String tserver)
- throws AccumuloException, AccumuloSecurityException {
- return new ArrayList<>();
- }
-
- @Override
- public void ping(String tserver) throws AccumuloException {
-
- }
-
- @Override
- public void waitForBalance() throws AccumuloException {}
-}
diff --git a/core/src/main/java/org/apache/accumulo/core/client/mock/MockMultiTableBatchWriter.java b/core/src/main/java/org/apache/accumulo/core/client/mock/MockMultiTableBatchWriter.java
deleted file mode 100644
index 20b71aa..0000000
--- a/core/src/main/java/org/apache/accumulo/core/client/mock/MockMultiTableBatchWriter.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * 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.core.client.mock;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import org.apache.accumulo.core.client.AccumuloException;
-import org.apache.accumulo.core.client.AccumuloSecurityException;
-import org.apache.accumulo.core.client.BatchWriter;
-import org.apache.accumulo.core.client.MultiTableBatchWriter;
-import org.apache.accumulo.core.client.MutationsRejectedException;
-import org.apache.accumulo.core.client.TableNotFoundException;
-
-/**
- * @deprecated since 1.8.0; use MiniAccumuloCluster or a standard mock framework instead.
- */
-@Deprecated
-public class MockMultiTableBatchWriter implements MultiTableBatchWriter {
- MockAccumulo acu = null;
- Map<String,MockBatchWriter> bws = null;
-
- public MockMultiTableBatchWriter(MockAccumulo acu) {
- this.acu = acu;
- bws = new HashMap<>();
- }
-
- @Override
- public BatchWriter getBatchWriter(String table)
- throws AccumuloException, AccumuloSecurityException, TableNotFoundException {
- if (!bws.containsKey(table)) {
- bws.put(table, new MockBatchWriter(acu, table));
- }
- return bws.get(table);
- }
-
- @Override
- public void flush() throws MutationsRejectedException {}
-
- @Override
- public void close() throws MutationsRejectedException {}
-
- @Override
- public boolean isClosed() {
- throw new UnsupportedOperationException();
- }
-}
diff --git a/core/src/main/java/org/apache/accumulo/core/client/mock/MockNamespace.java b/core/src/main/java/org/apache/accumulo/core/client/mock/MockNamespace.java
deleted file mode 100644
index 4f57d50..0000000
--- a/core/src/main/java/org/apache/accumulo/core/client/mock/MockNamespace.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * 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.core.client.mock;
-
-import java.util.EnumSet;
-import java.util.HashMap;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
-import java.util.Map.Entry;
-
-import org.apache.accumulo.core.conf.DefaultConfiguration;
-import org.apache.accumulo.core.conf.Property;
-import org.apache.accumulo.core.security.NamespacePermission;
-
-/**
- * @deprecated since 1.8.0; use MiniAccumuloCluster or a standard mock framework instead.
- */
-@Deprecated
-public class MockNamespace {
-
- final HashMap<String,String> settings;
- Map<String,EnumSet<NamespacePermission>> userPermissions = new HashMap<>();
-
- public MockNamespace() {
- settings = new HashMap<>();
- for (Entry<String,String> entry : DefaultConfiguration.getInstance()) {
- String key = entry.getKey();
- if (key.startsWith(Property.TABLE_PREFIX.getKey())) {
- settings.put(key, entry.getValue());
- }
- }
- }
-
- public List<String> getTables(MockAccumulo acu) {
- List<String> l = new LinkedList<>();
- for (String t : acu.tables.keySet()) {
- if (acu.tables.get(t).getNamespace().equals(this)) {
- l.add(t);
- }
- }
- return l;
- }
-}
diff --git a/core/src/main/java/org/apache/accumulo/core/client/mock/MockNamespaceOperations.java b/core/src/main/java/org/apache/accumulo/core/client/mock/MockNamespaceOperations.java
deleted file mode 100644
index 65af2d7..0000000
--- a/core/src/main/java/org/apache/accumulo/core/client/mock/MockNamespaceOperations.java
+++ /dev/null
@@ -1,145 +0,0 @@
-/*
- * 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.core.client.mock;
-
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Map.Entry;
-import java.util.SortedSet;
-import java.util.TreeSet;
-
-import org.apache.accumulo.core.client.AccumuloException;
-import org.apache.accumulo.core.client.AccumuloSecurityException;
-import org.apache.accumulo.core.client.NamespaceExistsException;
-import org.apache.accumulo.core.client.NamespaceNotEmptyException;
-import org.apache.accumulo.core.client.NamespaceNotFoundException;
-import org.apache.accumulo.core.client.impl.NamespaceOperationsHelper;
-import org.apache.accumulo.core.client.impl.Namespaces;
-import org.apache.accumulo.core.client.impl.Tables;
-import org.apache.accumulo.start.classloader.vfs.AccumuloVFSClassLoader;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * @deprecated since 1.8.0; use MiniAccumuloCluster or a standard mock framework instead.
- */
-@Deprecated
-class MockNamespaceOperations extends NamespaceOperationsHelper {
-
- private static final Logger log = LoggerFactory.getLogger(MockNamespaceOperations.class);
-
- final private MockAccumulo acu;
- final private String username;
-
- MockNamespaceOperations(MockAccumulo acu, String username) {
- this.acu = acu;
- this.username = username;
- }
-
- @Override
- public SortedSet<String> list() {
- return new TreeSet<>(acu.namespaces.keySet());
- }
-
- @Override
- public boolean exists(String namespace) {
- return acu.namespaces.containsKey(namespace);
- }
-
- @Override
- public void create(String namespace)
- throws AccumuloException, AccumuloSecurityException, NamespaceExistsException {
- if (!namespace.matches(Namespaces.VALID_NAME_REGEX))
- throw new IllegalArgumentException();
-
- if (exists(namespace))
- throw new NamespaceExistsException(namespace, namespace, "");
- else
- acu.createNamespace(username, namespace);
- }
-
- @Override
- public void delete(String namespace) throws AccumuloException, AccumuloSecurityException,
- NamespaceNotFoundException, NamespaceNotEmptyException {
- if (acu.namespaces.get(namespace).getTables(acu).size() > 0) {
- throw new NamespaceNotEmptyException(null, namespace, null);
- }
- acu.namespaces.remove(namespace);
- }
-
- @Override
- public void rename(String oldNamespaceName, String newNamespaceName)
- throws AccumuloSecurityException, NamespaceNotFoundException, AccumuloException,
- NamespaceExistsException {
- if (!exists(oldNamespaceName))
- throw new NamespaceNotFoundException(oldNamespaceName, oldNamespaceName, "");
- if (exists(newNamespaceName))
- throw new NamespaceExistsException(newNamespaceName, newNamespaceName, "");
-
- MockNamespace n = acu.namespaces.get(oldNamespaceName);
- for (String t : n.getTables(acu)) {
- String tt = newNamespaceName + "." + Tables.qualify(t).getSecond();
- acu.tables.put(tt, acu.tables.remove(t));
- }
- acu.namespaces.put(newNamespaceName, acu.namespaces.remove(oldNamespaceName));
- }
-
- @Override
- public void setProperty(String namespace, String property, String value)
- throws AccumuloException, AccumuloSecurityException {
- acu.namespaces.get(namespace).settings.put(property, value);
- }
-
- @Override
- public void removeProperty(String namespace, String property)
- throws AccumuloException, AccumuloSecurityException {
- acu.namespaces.get(namespace).settings.remove(property);
- }
-
- @Override
- public Iterable<Entry<String,String>> getProperties(String namespace)
- throws NamespaceNotFoundException {
- if (!exists(namespace)) {
- throw new NamespaceNotFoundException(namespace, namespace, "");
- }
-
- return acu.namespaces.get(namespace).settings.entrySet();
- }
-
- @Override
- public Map<String,String> namespaceIdMap() {
- Map<String,String> result = new HashMap<>();
- for (String table : acu.tables.keySet()) {
- result.put(table, table);
- }
- return result;
- }
-
- @Override
- public boolean testClassLoad(String namespace, String className, String asTypeName)
- throws AccumuloException, AccumuloSecurityException, NamespaceNotFoundException {
-
- try {
- AccumuloVFSClassLoader.loadClass(className, Class.forName(asTypeName));
- } catch (ClassNotFoundException e) {
- log.warn("Could not load class '" + className + "' with type name '" + asTypeName
- + "' in testClassLoad()", e);
- return false;
- }
- return true;
- }
-}
diff --git a/core/src/main/java/org/apache/accumulo/core/client/mock/MockScanner.java b/core/src/main/java/org/apache/accumulo/core/client/mock/MockScanner.java
deleted file mode 100644
index 1e36964..0000000
--- a/core/src/main/java/org/apache/accumulo/core/client/mock/MockScanner.java
+++ /dev/null
@@ -1,127 +0,0 @@
-/*
- * 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.core.client.mock;
-
-import java.io.IOException;
-import java.util.Iterator;
-import java.util.Map.Entry;
-import java.util.concurrent.TimeUnit;
-
-import org.apache.accumulo.core.client.Scanner;
-import org.apache.accumulo.core.data.Key;
-import org.apache.accumulo.core.data.Range;
-import org.apache.accumulo.core.data.Value;
-import org.apache.accumulo.core.iterators.Filter;
-import org.apache.accumulo.core.iterators.SortedKeyValueIterator;
-import org.apache.accumulo.core.iterators.SortedMapIterator;
-import org.apache.accumulo.core.security.Authorizations;
-
-/**
- * @deprecated since 1.8.0; use MiniAccumuloCluster or a standard mock framework instead.
- */
-@Deprecated
-public class MockScanner extends MockScannerBase implements Scanner {
-
- int batchSize = 0;
- Range range = new Range();
-
- MockScanner(MockTable table, Authorizations auths) {
- super(table, auths);
- }
-
- @Deprecated
- @Override
- public void setTimeOut(int timeOut) {
- if (timeOut == Integer.MAX_VALUE)
- setTimeout(Long.MAX_VALUE, TimeUnit.MILLISECONDS);
- else
- setTimeout(timeOut, TimeUnit.SECONDS);
- }
-
- @Deprecated
- @Override
- public int getTimeOut() {
- long timeout = getTimeout(TimeUnit.SECONDS);
- if (timeout >= Integer.MAX_VALUE)
- return Integer.MAX_VALUE;
- return (int) timeout;
- }
-
- @Override
- public void setRange(Range range) {
- this.range = range;
- }
-
- @Override
- public Range getRange() {
- return this.range;
- }
-
- @Override
- public void setBatchSize(int size) {
- this.batchSize = size;
- }
-
- @Override
- public int getBatchSize() {
- return this.batchSize;
- }
-
- @Override
- public void enableIsolation() {}
-
- @Override
- public void disableIsolation() {}
-
- static class RangeFilter extends Filter {
- Range range;
-
- RangeFilter(SortedKeyValueIterator<Key,Value> i, Range range) {
- setSource(i);
- this.range = range;
- }
-
- @Override
- public boolean accept(Key k, Value v) {
- return range.contains(k);
- }
- }
-
- @Override
- public Iterator<Entry<Key,Value>> iterator() {
- SortedKeyValueIterator<Key,Value> i = new SortedMapIterator(table.table);
- try {
- i = new RangeFilter(createFilter(i), range);
- i.seek(range, createColumnBSS(fetchedColumns), !fetchedColumns.isEmpty());
- return new IteratorAdapter(i);
- } catch (IOException e) {
- throw new RuntimeException(e);
- }
-
- }
-
- @Override
- public long getReadaheadThreshold() {
- return 0;
- }
-
- @Override
- public void setReadaheadThreshold(long batches) {
-
- }
-
-}
diff --git a/core/src/main/java/org/apache/accumulo/core/client/mock/MockScannerBase.java b/core/src/main/java/org/apache/accumulo/core/client/mock/MockScannerBase.java
deleted file mode 100644
index 059821c..0000000
--- a/core/src/main/java/org/apache/accumulo/core/client/mock/MockScannerBase.java
+++ /dev/null
@@ -1,163 +0,0 @@
-/*
- * 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.core.client.mock;
-
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.Map.Entry;
-
-import org.apache.accumulo.core.client.SampleNotPresentException;
-import org.apache.accumulo.core.client.ScannerBase;
-import org.apache.accumulo.core.client.impl.ScannerOptions;
-import org.apache.accumulo.core.client.sample.SamplerConfiguration;
-import org.apache.accumulo.core.conf.AccumuloConfiguration;
-import org.apache.accumulo.core.conf.DefaultConfiguration;
-import org.apache.accumulo.core.data.ArrayByteSequence;
-import org.apache.accumulo.core.data.ByteSequence;
-import org.apache.accumulo.core.data.Column;
-import org.apache.accumulo.core.data.Key;
-import org.apache.accumulo.core.data.Value;
-import org.apache.accumulo.core.iterators.IteratorEnvironment;
-import org.apache.accumulo.core.iterators.IteratorUtil;
-import org.apache.accumulo.core.iterators.IteratorUtil.IteratorScope;
-import org.apache.accumulo.core.iterators.SortedKeyValueIterator;
-import org.apache.accumulo.core.iterators.system.ColumnFamilySkippingIterator;
-import org.apache.accumulo.core.iterators.system.ColumnQualifierFilter;
-import org.apache.accumulo.core.iterators.system.DeletingIterator;
-import org.apache.accumulo.core.iterators.system.MultiIterator;
-import org.apache.accumulo.core.iterators.system.VisibilityFilter;
-import org.apache.accumulo.core.security.Authorizations;
-import org.apache.commons.lang.NotImplementedException;
-
-/**
- * @deprecated since 1.8.0; use MiniAccumuloCluster or a standard mock framework instead.
- */
-@Deprecated
-public class MockScannerBase extends ScannerOptions implements ScannerBase {
-
- protected final MockTable table;
- protected final Authorizations auths;
-
- MockScannerBase(MockTable mockTable, Authorizations authorizations) {
- this.table = mockTable;
- this.auths = authorizations;
- }
-
- static HashSet<ByteSequence> createColumnBSS(Collection<Column> columns) {
- HashSet<ByteSequence> columnSet = new HashSet<>();
- for (Column c : columns) {
- columnSet.add(new ArrayByteSequence(c.getColumnFamily()));
- }
- return columnSet;
- }
-
- static class MockIteratorEnvironment implements IteratorEnvironment {
-
- private final Authorizations auths;
-
- MockIteratorEnvironment(Authorizations auths) {
- this.auths = auths;
- }
-
- @Override
- public SortedKeyValueIterator<Key,Value> reserveMapFileReader(String mapFileName)
- throws IOException {
- throw new NotImplementedException();
- }
-
- @Override
- public AccumuloConfiguration getConfig() {
- return DefaultConfiguration.getInstance();
- }
-
- @Override
- public IteratorScope getIteratorScope() {
- return IteratorScope.scan;
- }
-
- @Override
- public boolean isFullMajorCompaction() {
- return false;
- }
-
- private ArrayList<SortedKeyValueIterator<Key,Value>> topLevelIterators = new ArrayList<>();
-
- @Override
- public void registerSideChannel(SortedKeyValueIterator<Key,Value> iter) {
- topLevelIterators.add(iter);
- }
-
- @Override
- public Authorizations getAuthorizations() {
- return auths;
- }
-
- SortedKeyValueIterator<Key,Value> getTopLevelIterator(SortedKeyValueIterator<Key,Value> iter) {
- if (topLevelIterators.isEmpty())
- return iter;
- ArrayList<SortedKeyValueIterator<Key,Value>> allIters = new ArrayList<>(topLevelIterators);
- allIters.add(iter);
- return new MultiIterator(allIters, false);
- }
-
- @Override
- public boolean isSamplingEnabled() {
- return false;
- }
-
- @Override
- public SamplerConfiguration getSamplerConfiguration() {
- return null;
- }
-
- @Override
- public IteratorEnvironment cloneWithSamplingEnabled() {
- throw new SampleNotPresentException();
- }
- }
-
- public SortedKeyValueIterator<Key,Value> createFilter(SortedKeyValueIterator<Key,Value> inner)
- throws IOException {
- byte[] defaultLabels = {};
- inner = new ColumnFamilySkippingIterator(new DeletingIterator(inner, false));
- SortedKeyValueIterator<Key,Value> cqf = ColumnQualifierFilter.wrap(inner,
- new HashSet<>(fetchedColumns));
- SortedKeyValueIterator<Key,Value> vf = VisibilityFilter.wrap(cqf, auths, defaultLabels);
- AccumuloConfiguration conf = new MockConfiguration(table.settings);
- MockIteratorEnvironment iterEnv = new MockIteratorEnvironment(auths);
- return iterEnv.getTopLevelIterator(IteratorUtil.loadIterators(IteratorScope.scan, vf, null,
- conf, serverSideIteratorList, serverSideIteratorOptions, iterEnv, false));
- }
-
- @Override
- public Iterator<Entry<Key,Value>> iterator() {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public Authorizations getAuthorizations() {
- return auths;
- }
-
- @Override
- public void setClassLoaderContext(String context) {
- throw new UnsupportedOperationException();
- }
-}
diff --git a/core/src/main/java/org/apache/accumulo/core/client/mock/MockSecurityOperations.java b/core/src/main/java/org/apache/accumulo/core/client/mock/MockSecurityOperations.java
deleted file mode 100644
index 79ad2fc..0000000
--- a/core/src/main/java/org/apache/accumulo/core/client/mock/MockSecurityOperations.java
+++ /dev/null
@@ -1,254 +0,0 @@
-/*
- * 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.core.client.mock;
-
-import java.util.EnumSet;
-import java.util.Set;
-
-import org.apache.accumulo.core.client.AccumuloException;
-import org.apache.accumulo.core.client.AccumuloSecurityException;
-import org.apache.accumulo.core.client.admin.DelegationTokenConfig;
-import org.apache.accumulo.core.client.admin.SecurityOperations;
-import org.apache.accumulo.core.client.impl.thrift.SecurityErrorCode;
-import org.apache.accumulo.core.client.security.tokens.AuthenticationToken;
-import org.apache.accumulo.core.client.security.tokens.DelegationToken;
-import org.apache.accumulo.core.client.security.tokens.PasswordToken;
-import org.apache.accumulo.core.security.Authorizations;
-import org.apache.accumulo.core.security.NamespacePermission;
-import org.apache.accumulo.core.security.SystemPermission;
-import org.apache.accumulo.core.security.TablePermission;
-
-/**
- * @deprecated since 1.8.0; use MiniAccumuloCluster or a standard mock framework instead.
- */
-@Deprecated
-class MockSecurityOperations implements SecurityOperations {
-
- final private MockAccumulo acu;
-
- MockSecurityOperations(MockAccumulo acu) {
- this.acu = acu;
- }
-
- @Deprecated
- @Override
- public void createUser(String user, byte[] password, Authorizations authorizations)
- throws AccumuloException, AccumuloSecurityException {
- createLocalUser(user, new PasswordToken(password));
- changeUserAuthorizations(user, authorizations);
- }
-
- @Override
- public void createLocalUser(String principal, PasswordToken password)
- throws AccumuloException, AccumuloSecurityException {
- this.acu.users.put(principal, new MockUser(principal, password, new Authorizations()));
- }
-
- @Deprecated
- @Override
- public void dropUser(String user) throws AccumuloException, AccumuloSecurityException {
- dropLocalUser(user);
- }
-
- @Override
- public void dropLocalUser(String principal) throws AccumuloException, AccumuloSecurityException {
- this.acu.users.remove(principal);
- }
-
- @Deprecated
- @Override
- public boolean authenticateUser(String user, byte[] password)
- throws AccumuloException, AccumuloSecurityException {
- return authenticateUser(user, new PasswordToken(password));
- }
-
- @Override
- public boolean authenticateUser(String principal, AuthenticationToken token)
- throws AccumuloException, AccumuloSecurityException {
- MockUser user = acu.users.get(principal);
- if (user == null)
- return false;
- return user.token.equals(token);
- }
-
- @Deprecated
- @Override
- public void changeUserPassword(String user, byte[] password)
- throws AccumuloException, AccumuloSecurityException {
- changeLocalUserPassword(user, new PasswordToken(password));
- }
-
- @Override
- public void changeLocalUserPassword(String principal, PasswordToken token)
- throws AccumuloException, AccumuloSecurityException {
- MockUser user = acu.users.get(principal);
- if (user != null)
- user.token = token.clone();
- else
- throw new AccumuloSecurityException(principal, SecurityErrorCode.USER_DOESNT_EXIST);
- }
-
- @Override
- public void changeUserAuthorizations(String principal, Authorizations authorizations)
- throws AccumuloException, AccumuloSecurityException {
- MockUser user = acu.users.get(principal);
- if (user != null)
- user.authorizations = authorizations;
- else
- throw new AccumuloSecurityException(principal, SecurityErrorCode.USER_DOESNT_EXIST);
- }
-
- @Override
- public Authorizations getUserAuthorizations(String principal)
- throws AccumuloException, AccumuloSecurityException {
- MockUser user = acu.users.get(principal);
- if (user != null)
- return user.authorizations;
- else
- throw new AccumuloSecurityException(principal, SecurityErrorCode.USER_DOESNT_EXIST);
- }
-
- @Override
- public boolean hasSystemPermission(String principal, SystemPermission perm)
- throws AccumuloException, AccumuloSecurityException {
- MockUser user = acu.users.get(principal);
- if (user != null)
- return user.permissions.contains(perm);
- else
- throw new AccumuloSecurityException(principal, SecurityErrorCode.USER_DOESNT_EXIST);
- }
-
- @Override
- public boolean hasTablePermission(String principal, String tableName, TablePermission perm)
- throws AccumuloException, AccumuloSecurityException {
- MockTable table = acu.tables.get(tableName);
- if (table == null)
- throw new AccumuloSecurityException(tableName, SecurityErrorCode.TABLE_DOESNT_EXIST);
- EnumSet<TablePermission> perms = table.userPermissions.get(principal);
- if (perms == null)
- return false;
- return perms.contains(perm);
- }
-
- @Override
- public boolean hasNamespacePermission(String principal, String namespace,
- NamespacePermission permission) throws AccumuloException, AccumuloSecurityException {
- MockNamespace mockNamespace = acu.namespaces.get(namespace);
- if (mockNamespace == null)
- throw new AccumuloSecurityException(namespace, SecurityErrorCode.NAMESPACE_DOESNT_EXIST);
- EnumSet<NamespacePermission> perms = mockNamespace.userPermissions.get(principal);
- if (perms == null)
- return false;
- return perms.contains(permission);
- }
-
- @Override
- public void grantSystemPermission(String principal, SystemPermission permission)
- throws AccumuloException, AccumuloSecurityException {
- MockUser user = acu.users.get(principal);
- if (user != null)
- user.permissions.add(permission);
- else
- throw new AccumuloSecurityException(principal, SecurityErrorCode.USER_DOESNT_EXIST);
- }
-
- @Override
- public void grantTablePermission(String principal, String tableName, TablePermission permission)
- throws AccumuloException, AccumuloSecurityException {
- if (acu.users.get(principal) == null)
- throw new AccumuloSecurityException(principal, SecurityErrorCode.USER_DOESNT_EXIST);
- MockTable table = acu.tables.get(tableName);
- if (table == null)
- throw new AccumuloSecurityException(tableName, SecurityErrorCode.TABLE_DOESNT_EXIST);
- EnumSet<TablePermission> perms = table.userPermissions.get(principal);
- if (perms == null)
- table.userPermissions.put(principal, EnumSet.of(permission));
- else
- perms.add(permission);
- }
-
- @Override
- public void grantNamespacePermission(String principal, String namespace,
- NamespacePermission permission) throws AccumuloException, AccumuloSecurityException {
- if (acu.users.get(principal) == null)
- throw new AccumuloSecurityException(principal, SecurityErrorCode.USER_DOESNT_EXIST);
- MockNamespace mockNamespace = acu.namespaces.get(namespace);
- if (mockNamespace == null)
- throw new AccumuloSecurityException(namespace, SecurityErrorCode.NAMESPACE_DOESNT_EXIST);
- EnumSet<NamespacePermission> perms = mockNamespace.userPermissions.get(principal);
- if (perms == null)
- mockNamespace.userPermissions.put(principal, EnumSet.of(permission));
- else
- perms.add(permission);
- }
-
- @Override
- public void revokeSystemPermission(String principal, SystemPermission permission)
- throws AccumuloException, AccumuloSecurityException {
- MockUser user = acu.users.get(principal);
- if (user != null)
- user.permissions.remove(permission);
- else
- throw new AccumuloSecurityException(principal, SecurityErrorCode.USER_DOESNT_EXIST);
- }
-
- @Override
- public void revokeTablePermission(String principal, String tableName, TablePermission permission)
- throws AccumuloException, AccumuloSecurityException {
- if (acu.users.get(principal) == null)
- throw new AccumuloSecurityException(principal, SecurityErrorCode.USER_DOESNT_EXIST);
- MockTable table = acu.tables.get(tableName);
- if (table == null)
- throw new AccumuloSecurityException(tableName, SecurityErrorCode.TABLE_DOESNT_EXIST);
- EnumSet<TablePermission> perms = table.userPermissions.get(principal);
- if (perms != null)
- perms.remove(permission);
-
- }
-
- @Override
- public void revokeNamespacePermission(String principal, String namespace,
- NamespacePermission permission) throws AccumuloException, AccumuloSecurityException {
- if (acu.users.get(principal) == null)
- throw new AccumuloSecurityException(principal, SecurityErrorCode.USER_DOESNT_EXIST);
- MockNamespace mockNamespace = acu.namespaces.get(namespace);
- if (mockNamespace == null)
- throw new AccumuloSecurityException(namespace, SecurityErrorCode.NAMESPACE_DOESNT_EXIST);
- EnumSet<NamespacePermission> perms = mockNamespace.userPermissions.get(principal);
- if (perms != null)
- perms.remove(permission);
-
- }
-
- @Deprecated
- @Override
- public Set<String> listUsers() throws AccumuloException, AccumuloSecurityException {
- return listLocalUsers();
- }
-
- @Override
- public Set<String> listLocalUsers() throws AccumuloException, AccumuloSecurityException {
- return acu.users.keySet();
- }
-
- @Override
- public DelegationToken getDelegationToken(DelegationTokenConfig cfg)
- throws AccumuloException, AccumuloSecurityException {
- return null;
- }
-
-}
diff --git a/core/src/main/java/org/apache/accumulo/core/client/mock/MockTable.java b/core/src/main/java/org/apache/accumulo/core/client/mock/MockTable.java
deleted file mode 100644
index 30b1f07..0000000
--- a/core/src/main/java/org/apache/accumulo/core/client/mock/MockTable.java
+++ /dev/null
@@ -1,216 +0,0 @@
-/*
- * 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.core.client.mock;
-
-import java.util.Collection;
-import java.util.EnumSet;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.Map.Entry;
-import java.util.Set;
-import java.util.SortedMap;
-import java.util.SortedSet;
-import java.util.TreeMap;
-import java.util.concurrent.ConcurrentSkipListMap;
-import java.util.concurrent.ConcurrentSkipListSet;
-
-import org.apache.accumulo.core.client.admin.TimeType;
-import org.apache.accumulo.core.conf.DefaultConfiguration;
-import org.apache.accumulo.core.conf.Property;
-import org.apache.accumulo.core.data.ColumnUpdate;
-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.iterators.IteratorUtil;
-import org.apache.accumulo.core.security.TablePermission;
-import org.apache.hadoop.io.Text;
-
-/**
- * @deprecated since 1.8.0; use MiniAccumuloCluster or a standard mock framework instead.
- */
-@Deprecated
-public class MockTable {
-
- static class MockMemKey extends Key {
- private int count;
-
- MockMemKey(Key key, int count) {
- super(key);
- this.count = count;
- }
-
- @Override
- public int hashCode() {
- return super.hashCode() + count;
- }
-
- @Override
- public boolean equals(Object other) {
- return (other instanceof MockMemKey) && super.equals(other)
- && count == ((MockMemKey) other).count;
- }
-
- @Override
- public String toString() {
- return super.toString() + " count=" + count;
- }
-
- @Override
- public int compareTo(Key o) {
- int compare = super.compareTo(o);
- if (compare != 0)
- return compare;
- if (o instanceof MockMemKey) {
- MockMemKey other = (MockMemKey) o;
- if (count < other.count)
- return 1;
- if (count > other.count)
- return -1;
- } else {
- return 1;
- }
- return 0;
- }
- }
-
- final SortedMap<Key,Value> table = new ConcurrentSkipListMap<>();
- int mutationCount = 0;
- final Map<String,String> settings;
- Map<String,EnumSet<TablePermission>> userPermissions = new HashMap<>();
- private TimeType timeType;
- SortedSet<Text> splits = new ConcurrentSkipListSet<>();
- Map<String,Set<Text>> localityGroups = new TreeMap<>();
- private MockNamespace namespace;
- private String namespaceName;
- private String tableId;
-
- MockTable(boolean limitVersion, TimeType timeType, String tableId) {
- this.timeType = timeType;
- this.tableId = tableId;
- settings = IteratorUtil.generateInitialTableProperties(limitVersion);
- for (Entry<String,String> entry : DefaultConfiguration.getInstance()) {
- String key = entry.getKey();
- if (key.startsWith(Property.TABLE_PREFIX.getKey()))
- settings.put(key, entry.getValue());
- }
- }
-
- MockTable(MockNamespace namespace, boolean limitVersion, TimeType timeType, String tableId,
- Map<String,String> properties) {
- this(limitVersion, timeType, tableId);
- Set<Entry<String,String>> set = namespace.settings.entrySet();
- Iterator<Entry<String,String>> entries = set.iterator();
- while (entries.hasNext()) {
- Entry<String,String> entry = entries.next();
- String key = entry.getKey();
- if (key.startsWith(Property.TABLE_PREFIX.getKey()))
- settings.put(key, entry.getValue());
- }
-
- for (Entry<String,String> initialProp : properties.entrySet()) {
- settings.put(initialProp.getKey(), initialProp.getValue());
- }
- }
-
- public MockTable(MockNamespace namespace, TimeType timeType, String tableId,
- Map<String,String> properties) {
- this.timeType = timeType;
- this.tableId = tableId;
- settings = properties;
- for (Entry<String,String> entry : DefaultConfiguration.getInstance()) {
- String key = entry.getKey();
- if (key.startsWith(Property.TABLE_PREFIX.getKey()))
- settings.put(key, entry.getValue());
- }
-
- Set<Entry<String,String>> set = namespace.settings.entrySet();
- Iterator<Entry<String,String>> entries = set.iterator();
- while (entries.hasNext()) {
- Entry<String,String> entry = entries.next();
- String key = entry.getKey();
- if (key.startsWith(Property.TABLE_PREFIX.getKey()))
- settings.put(key, entry.getValue());
- }
- }
-
- synchronized void addMutation(Mutation m) {
- if (m.size() == 0)
- throw new IllegalArgumentException("Can not add empty mutations");
- long now = System.currentTimeMillis();
- mutationCount++;
- for (ColumnUpdate u : m.getUpdates()) {
- Key key = new Key(m.getRow(), 0, m.getRow().length, u.getColumnFamily(), 0,
- u.getColumnFamily().length, u.getColumnQualifier(), 0, u.getColumnQualifier().length,
- u.getColumnVisibility(), 0, u.getColumnVisibility().length, u.getTimestamp());
- if (u.isDeleted())
- key.setDeleted(true);
- if (!u.hasTimestamp())
- if (timeType.equals(TimeType.LOGICAL))
- key.setTimestamp(mutationCount);
- else
- key.setTimestamp(now);
-
- table.put(new MockMemKey(key, mutationCount), new Value(u.getValue()));
- }
- }
-
- public void addSplits(SortedSet<Text> partitionKeys) {
- splits.addAll(partitionKeys);
- }
-
- public Collection<Text> getSplits() {
- return splits;
- }
-
- public void setLocalityGroups(Map<String,Set<Text>> groups) {
- localityGroups = groups;
- }
-
- public Map<String,Set<Text>> getLocalityGroups() {
- return localityGroups;
- }
-
- public void merge(Text start, Text end) {
- boolean reAdd = false;
- if (splits.contains(start))
- reAdd = true;
- splits.removeAll(splits.subSet(start, end));
- if (reAdd)
- splits.add(start);
- }
-
- public void setNamespaceName(String n) {
- this.namespaceName = n;
- }
-
- public void setNamespace(MockNamespace n) {
- this.namespace = n;
- }
-
- public String getNamespaceName() {
- return this.namespaceName;
- }
-
- public MockNamespace getNamespace() {
- return this.namespace;
- }
-
- public String getTableId() {
- return this.tableId;
- }
-}
diff --git a/core/src/main/java/org/apache/accumulo/core/client/mock/MockTableOperations.java b/core/src/main/java/org/apache/accumulo/core/client/mock/MockTableOperations.java
deleted file mode 100644
index 36d11f1..0000000
--- a/core/src/main/java/org/apache/accumulo/core/client/mock/MockTableOperations.java
+++ /dev/null
@@ -1,573 +0,0 @@
-/*
- * 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.core.client.mock;
-
-import static com.google.common.base.Preconditions.checkArgument;
-
-import java.io.DataInputStream;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Map.Entry;
-import java.util.Set;
-import java.util.SortedSet;
-import java.util.TreeSet;
-import java.util.function.Predicate;
-
-import org.apache.accumulo.core.client.AccumuloException;
-import org.apache.accumulo.core.client.AccumuloSecurityException;
-import org.apache.accumulo.core.client.IteratorSetting;
-import org.apache.accumulo.core.client.NamespaceNotFoundException;
-import org.apache.accumulo.core.client.TableExistsException;
-import org.apache.accumulo.core.client.TableNotFoundException;
-import org.apache.accumulo.core.client.admin.CompactionConfig;
-import org.apache.accumulo.core.client.admin.DiskUsage;
-import org.apache.accumulo.core.client.admin.FindMax;
-import org.apache.accumulo.core.client.admin.Locations;
-import org.apache.accumulo.core.client.admin.NewTableConfiguration;
-import org.apache.accumulo.core.client.admin.SummaryRetriever;
-import org.apache.accumulo.core.client.admin.TimeType;
-import org.apache.accumulo.core.client.impl.TableOperationsHelper;
-import org.apache.accumulo.core.client.impl.Tables;
-import org.apache.accumulo.core.client.sample.SamplerConfiguration;
-import org.apache.accumulo.core.client.summary.SummarizerConfiguration;
-import org.apache.accumulo.core.conf.DefaultConfiguration;
-import org.apache.accumulo.core.data.Key;
-import org.apache.accumulo.core.data.Mutation;
-import org.apache.accumulo.core.data.Range;
-import org.apache.accumulo.core.data.Value;
-import org.apache.accumulo.core.file.FileOperations;
-import org.apache.accumulo.core.file.FileSKVIterator;
-import org.apache.accumulo.core.metadata.MetadataTable;
-import org.apache.accumulo.core.metadata.RootTable;
-import org.apache.accumulo.core.security.Authorizations;
-import org.apache.accumulo.core.security.ColumnVisibility;
-import org.apache.accumulo.start.classloader.vfs.AccumuloVFSClassLoader;
-import org.apache.commons.lang.NotImplementedException;
-import org.apache.hadoop.fs.FSDataOutputStream;
-import org.apache.hadoop.fs.FileStatus;
-import org.apache.hadoop.fs.FileSystem;
-import org.apache.hadoop.fs.Path;
-import org.apache.hadoop.io.Text;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * @deprecated since 1.8.0; use MiniAccumuloCluster or a standard mock framework instead.
- */
-@Deprecated
-class MockTableOperations extends TableOperationsHelper {
- private static final Logger log = LoggerFactory.getLogger(MockTableOperations.class);
- private static final byte[] ZERO = {0};
- private final MockAccumulo acu;
- private final String username;
-
- MockTableOperations(MockAccumulo acu, String username) {
- this.acu = acu;
- this.username = username;
- }
-
- @Override
- public SortedSet<String> list() {
- return new TreeSet<>(acu.tables.keySet());
- }
-
- @Override
- public boolean exists(String tableName) {
- return acu.tables.containsKey(tableName);
- }
-
- private boolean namespaceExists(String namespace) {
- return acu.namespaces.containsKey(namespace);
- }
-
- @Override
- public void create(String tableName)
- throws AccumuloException, AccumuloSecurityException, TableExistsException {
- create(tableName, new NewTableConfiguration());
- }
-
- @Override
- @Deprecated
- public void create(String tableName, boolean versioningIter)
- throws AccumuloException, AccumuloSecurityException, TableExistsException {
- create(tableName, versioningIter, TimeType.MILLIS);
- }
-
- @Override
- @Deprecated
- public void create(String tableName, boolean versioningIter, TimeType timeType)
- throws AccumuloException, AccumuloSecurityException, TableExistsException {
- NewTableConfiguration ntc = new NewTableConfiguration().setTimeType(timeType);
-
- if (versioningIter)
- create(tableName, ntc);
- else
- create(tableName, ntc.withoutDefaultIterators());
- }
-
- @Override
- public void create(String tableName, NewTableConfiguration ntc)
- throws AccumuloException, AccumuloSecurityException, TableExistsException {
- String namespace = Tables.qualify(tableName).getFirst();
-
- checkArgument(tableName.matches(Tables.VALID_NAME_REGEX));
- if (exists(tableName))
- throw new TableExistsException(tableName, tableName, "");
- checkArgument(namespaceExists(namespace),
- "Namespace (" + namespace + ") does not exist, create it first");
- acu.createTable(username, tableName, ntc.getTimeType(), ntc.getProperties());
- }
-
- @Override
- public void addSplits(String tableName, SortedSet<Text> partitionKeys)
- throws TableNotFoundException, AccumuloException, AccumuloSecurityException {
- if (!exists(tableName))
- throw new TableNotFoundException(tableName, tableName, "");
- acu.addSplits(tableName, partitionKeys);
- }
-
- @Deprecated
- @Override
- public Collection<Text> getSplits(String tableName) throws TableNotFoundException {
- return listSplits(tableName);
- }
-
- @Deprecated
- @Override
- public Collection<Text> getSplits(String tableName, int maxSplits) throws TableNotFoundException {
- return listSplits(tableName);
- }
-
- @Override
- public Collection<Text> listSplits(String tableName) throws TableNotFoundException {
- if (!exists(tableName))
- throw new TableNotFoundException(tableName, tableName, "");
- return acu.getSplits(tableName);
- }
-
- @Override
- public Collection<Text> listSplits(String tableName, int maxSplits)
- throws TableNotFoundException {
- return listSplits(tableName);
- }
-
- @Override
- public void delete(String tableName)
- throws AccumuloException, AccumuloSecurityException, TableNotFoundException {
- if (!exists(tableName))
- throw new TableNotFoundException(tableName, tableName, "");
- acu.tables.remove(tableName);
- }
-
- @Override
- public void rename(String oldTableName, String newTableName) throws AccumuloSecurityException,
- TableNotFoundException, AccumuloException, TableExistsException {
- if (!exists(oldTableName))
- throw new TableNotFoundException(oldTableName, oldTableName, "");
- if (exists(newTableName))
- throw new TableExistsException(newTableName, newTableName, "");
- MockTable t = acu.tables.remove(oldTableName);
- String namespace = Tables.qualify(newTableName).getFirst();
- MockNamespace n = acu.namespaces.get(namespace);
- if (n == null) {
- n = new MockNamespace();
- }
- t.setNamespaceName(namespace);
- t.setNamespace(n);
- acu.namespaces.put(namespace, n);
- acu.tables.put(newTableName, t);
- }
-
- @Deprecated
- @Override
- public void flush(String tableName) throws AccumuloException, AccumuloSecurityException {}
-
- @Override
- public void setProperty(String tableName, String property, String value)
- throws AccumuloException, AccumuloSecurityException {
- acu.tables.get(tableName).settings.put(property, value);
- }
-
- @Override
- public void removeProperty(String tableName, String property)
- throws AccumuloException, AccumuloSecurityException {
- acu.tables.get(tableName).settings.remove(property);
- }
-
- @Override
- public Iterable<Entry<String,String>> getProperties(String tableName)
- throws TableNotFoundException {
- String namespace = Tables.qualify(tableName).getFirst();
- if (!exists(tableName)) {
- if (!namespaceExists(namespace))
- throw new TableNotFoundException(tableName,
- new NamespaceNotFoundException(null, namespace, null));
- throw new TableNotFoundException(null, tableName, null);
- }
-
- Set<Entry<String,String>> props = new HashSet<>(
- acu.namespaces.get(namespace).settings.entrySet());
-
- Set<Entry<String,String>> tableProps = acu.tables.get(tableName).settings.entrySet();
- for (Entry<String,String> e : tableProps) {
- if (props.contains(e)) {
- props.remove(e);
- }
- props.add(e);
- }
- return props;
- }
-
- @Override
- public void setLocalityGroups(String tableName, Map<String,Set<Text>> groups)
- throws AccumuloException, AccumuloSecurityException, TableNotFoundException {
- if (!exists(tableName))
- throw new TableNotFoundException(tableName, tableName, "");
- acu.tables.get(tableName).setLocalityGroups(groups);
- }
-
- @Override
- public Map<String,Set<Text>> getLocalityGroups(String tableName)
- throws AccumuloException, TableNotFoundException {
- if (!exists(tableName))
- throw new TableNotFoundException(tableName, tableName, "");
- return acu.tables.get(tableName).getLocalityGroups();
- }
-
- @Override
- public Set<Range> splitRangeByTablets(String tableName, Range range, int maxSplits)
- throws AccumuloException, AccumuloSecurityException, TableNotFoundException {
- if (!exists(tableName))
- throw new TableNotFoundException(tableName, tableName, "");
- return Collections.singleton(range);
- }
-
- @Override
- public void importDirectory(String tableName, String dir, String failureDir, boolean setTime)
- throws IOException, AccumuloException, AccumuloSecurityException, TableNotFoundException {
- long time = System.currentTimeMillis();
- MockTable table = acu.tables.get(tableName);
- if (table == null) {
- throw new TableNotFoundException(null, tableName, "The table was not found");
- }
- Path importPath = new Path(dir);
- Path failurePath = new Path(failureDir);
-
- FileSystem fs = acu.getFileSystem();
- /*
- * check preconditions
- */
- // directories are directories
- if (fs.isFile(importPath)) {
- throw new IOException("Import path must be a directory.");
- }
- if (fs.isFile(failurePath)) {
- throw new IOException("Failure path must be a directory.");
- }
- // failures are writable
- Path createPath = failurePath.suffix("/.createFile");
- FSDataOutputStream createStream = null;
- try {
- createStream = fs.create(createPath);
- } catch (IOException e) {
- throw new IOException("Error path is not writable.");
- } finally {
- if (createStream != null) {
- createStream.close();
- }
- }
- fs.delete(createPath, false);
- // failures are empty
- FileStatus[] failureChildStats = fs.listStatus(failurePath);
- if (failureChildStats.length > 0) {
- throw new IOException("Error path must be empty.");
- }
- /*
- * Begin the import - iterate the files in the path
- */
- for (FileStatus importStatus : fs.listStatus(importPath)) {
- try {
- FileSKVIterator importIterator = FileOperations.getInstance().newReaderBuilder()
- .forFile(importStatus.getPath().toString(), fs, fs.getConf())
- .withTableConfiguration(DefaultConfiguration.getInstance()).seekToBeginning().build();
- while (importIterator.hasTop()) {
- Key key = importIterator.getTopKey();
- Value value = importIterator.getTopValue();
- if (setTime) {
- key.setTimestamp(time);
- }
- Mutation mutation = new Mutation(key.getRow());
- if (!key.isDeleted()) {
- mutation.put(key.getColumnFamily(), key.getColumnQualifier(),
- new ColumnVisibility(key.getColumnVisibilityData().toArray()), key.getTimestamp(),
- value);
- } else {
- mutation.putDelete(key.getColumnFamily(), key.getColumnQualifier(),
- new ColumnVisibility(key.getColumnVisibilityData().toArray()), key.getTimestamp());
- }
- table.addMutation(mutation);
- importIterator.next();
- }
- } catch (Exception e) {
- FSDataOutputStream failureWriter = null;
- DataInputStream failureReader = null;
- try {
- failureWriter = fs.create(failurePath.suffix("/" + importStatus.getPath().getName()));
- failureReader = fs.open(importStatus.getPath());
- int read = 0;
- byte[] buffer = new byte[1024];
- while (-1 != (read = failureReader.read(buffer))) {
- failureWriter.write(buffer, 0, read);
- }
- } finally {
- if (failureReader != null)
- failureReader.close();
- if (failureWriter != null)
- failureWriter.close();
- }
- }
- fs.delete(importStatus.getPath(), true);
- }
- }
-
- @Override
- public void offline(String tableName)
- throws AccumuloSecurityException, AccumuloException, TableNotFoundException {
- offline(tableName, false);
- }
-
- @Override
- public void offline(String tableName, boolean wait)
- throws AccumuloSecurityException, AccumuloException, TableNotFoundException {
- if (!exists(tableName))
- throw new TableNotFoundException(tableName, tableName, "");
- }
-
- @Override
- public void online(String tableName)
- throws AccumuloSecurityException, AccumuloException, TableNotFoundException {
- online(tableName, false);
- }
-
- @Override
- public void online(String tableName, boolean wait)
- throws AccumuloSecurityException, AccumuloException, TableNotFoundException {
- if (!exists(tableName))
- throw new TableNotFoundException(tableName, tableName, "");
- }
-
- @Override
- public void clearLocatorCache(String tableName) throws TableNotFoundException {
- if (!exists(tableName))
- throw new TableNotFoundException(tableName, tableName, "");
- }
-
- @Override
- public Map<String,String> tableIdMap() {
- Map<String,String> result = new HashMap<>();
- for (Entry<String,MockTable> entry : acu.tables.entrySet()) {
- String table = entry.getKey();
- if (RootTable.NAME.equals(table))
- result.put(table, RootTable.ID.canonicalID());
- else if (MetadataTable.NAME.equals(table))
- result.put(table, MetadataTable.ID.canonicalID());
- else
- result.put(table, entry.getValue().getTableId());
- }
- return result;
- }
-
- @Override
- public List<DiskUsage> getDiskUsage(Set<String> tables)
- throws AccumuloException, AccumuloSecurityException {
-
- List<DiskUsage> diskUsages = new ArrayList<>();
- diskUsages.add(new DiskUsage(new TreeSet<>(tables), 0L));
-
- return diskUsages;
- }
-
- @Override
- public void merge(String tableName, Text start, Text end)
- throws AccumuloException, AccumuloSecurityException, TableNotFoundException {
- if (!exists(tableName))
- throw new TableNotFoundException(tableName, tableName, "");
- acu.merge(tableName, start, end);
- }
-
- @Override
- public void deleteRows(String tableName, Text start, Text end)
- throws AccumuloException, AccumuloSecurityException, TableNotFoundException {
- if (!exists(tableName))
- throw new TableNotFoundException(tableName, tableName, "");
- MockTable t = acu.tables.get(tableName);
- Text startText = start != null ? new Text(start) : new Text();
- if (startText.getLength() == 0 && end == null) {
- t.table.clear();
- return;
- }
- Text endText = end != null ? new Text(end) : new Text(t.table.lastKey().getRow().getBytes());
- startText.append(ZERO, 0, 1);
- endText.append(ZERO, 0, 1);
- Set<Key> keep = new TreeSet<>(t.table.subMap(new Key(startText), new Key(endText)).keySet());
- t.table.keySet().removeAll(keep);
- }
-
- @Override
- public void compact(String tableName, Text start, Text end, boolean flush, boolean wait)
- throws AccumuloSecurityException, TableNotFoundException, AccumuloException {
- if (!exists(tableName))
- throw new TableNotFoundException(tableName, tableName, "");
- }
-
- @Override
- public void compact(String tableName, Text start, Text end, List<IteratorSetting> iterators,
- boolean flush, boolean wait)
- throws AccumuloSecurityException, TableNotFoundException, AccumuloException {
- if (!exists(tableName))
- throw new TableNotFoundException(tableName, tableName, "");
-
- if (iterators != null && iterators.size() > 0)
- throw new UnsupportedOperationException();
- }
-
- @Override
- public void compact(String tableName, CompactionConfig config)
- throws AccumuloSecurityException, TableNotFoundException, AccumuloException {
- if (!exists(tableName))
- throw new TableNotFoundException(tableName, tableName, "");
-
- if (config.getIterators().size() > 0 || config.getCompactionStrategy() != null)
- throw new UnsupportedOperationException(
- "Mock does not support iterators or compaction strategies for compactions");
- }
-
- @Override
- public void cancelCompaction(String tableName)
- throws AccumuloSecurityException, TableNotFoundException, AccumuloException {
- if (!exists(tableName))
- throw new TableNotFoundException(tableName, tableName, "");
- }
-
- @Override
- public void clone(String srcTableName, String newTableName, boolean flush,
- Map<String,String> propertiesToSet, Set<String> propertiesToExclude) throws AccumuloException,
- AccumuloSecurityException, TableNotFoundException, TableExistsException {
- throw new NotImplementedException();
- }
-
- @Override
- public void flush(String tableName, Text start, Text end, boolean wait)
- throws AccumuloException, AccumuloSecurityException, TableNotFoundException {
- if (!exists(tableName))
- throw new TableNotFoundException(tableName, tableName, "");
- }
-
- @Override
- public Text getMaxRow(String tableName, Authorizations auths, Text startRow,
- boolean startInclusive, Text endRow, boolean endInclusive)
- throws TableNotFoundException, AccumuloException, AccumuloSecurityException {
- MockTable table = acu.tables.get(tableName);
- if (table == null)
- throw new TableNotFoundException(tableName, tableName, "no such table");
-
- return FindMax.findMax(new MockScanner(table, auths), startRow, startInclusive, endRow,
- endInclusive);
- }
-
- @Override
- public void importTable(String tableName, String exportDir)
- throws TableExistsException, AccumuloException, AccumuloSecurityException {
- throw new NotImplementedException();
- }
-
- @Override
- public void exportTable(String tableName, String exportDir)
- throws TableNotFoundException, AccumuloException, AccumuloSecurityException {
- throw new NotImplementedException();
- }
-
- @Override
- public boolean testClassLoad(String tableName, String className, String asTypeName)
- throws AccumuloException, AccumuloSecurityException, TableNotFoundException {
-
- try {
- AccumuloVFSClassLoader.loadClass(className, Class.forName(asTypeName));
- } catch (ClassNotFoundException e) {
- log.warn("Could not load class '" + className + "' with type name '" + asTypeName
- + "' in testClassLoad().", e);
- return false;
- }
- return true;
- }
-
- @Override
- public void setSamplerConfiguration(String tableName, SamplerConfiguration samplerConfiguration)
- throws TableNotFoundException, AccumuloException, AccumuloSecurityException {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public void clearSamplerConfiguration(String tableName)
- throws TableNotFoundException, AccumuloException, AccumuloSecurityException {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public SamplerConfiguration getSamplerConfiguration(String tableName)
- throws TableNotFoundException, AccumuloException, AccumuloSecurityException {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public Locations locate(String tableName, Collection<Range> ranges)
- throws AccumuloException, AccumuloSecurityException, TableNotFoundException {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public SummaryRetriever summaries(String tableName)
- throws TableNotFoundException, AccumuloException, AccumuloSecurityException {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public void addSummarizers(String tableName, SummarizerConfiguration... summarizerConf)
- throws TableNotFoundException, AccumuloException, AccumuloSecurityException {
- throw new UnsupportedOperationException();
-
- }
-
- @Override
- public void removeSummarizers(String tableName, Predicate<SummarizerConfiguration> predicate)
- throws AccumuloException, TableNotFoundException, AccumuloSecurityException {
- throw new UnsupportedOperationException();
-
- }
-
- @Override
- public List<SummarizerConfiguration> listSummarizers(String tableName)
- throws AccumuloException, TableNotFoundException, AccumuloSecurityException {
- throw new UnsupportedOperationException();
- }
-}
diff --git a/core/src/main/java/org/apache/accumulo/core/client/mock/MockUser.java b/core/src/main/java/org/apache/accumulo/core/client/mock/MockUser.java
deleted file mode 100644
index e32edad..0000000
--- a/core/src/main/java/org/apache/accumulo/core/client/mock/MockUser.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * 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.core.client.mock;
-
-import java.util.EnumSet;
-
-import org.apache.accumulo.core.client.security.tokens.AuthenticationToken;
-import org.apache.accumulo.core.security.Authorizations;
-import org.apache.accumulo.core.security.SystemPermission;
-
-/**
- * @deprecated since 1.8.0; use MiniAccumuloCluster or a standard mock framework instead.
- */
-@Deprecated
-public class MockUser {
- final EnumSet<SystemPermission> permissions;
- final String name;
- AuthenticationToken token;
- Authorizations authorizations;
-
- MockUser(String principal, AuthenticationToken token, Authorizations auths) {
- this.name = principal;
- this.token = token.clone();
- this.authorizations = auths;
- this.permissions = EnumSet.noneOf(SystemPermission.class);
- }
-}
diff --git a/core/src/main/java/org/apache/accumulo/core/client/mock/impl/MockTabletLocator.java b/core/src/main/java/org/apache/accumulo/core/client/mock/impl/MockTabletLocator.java
deleted file mode 100644
index 915271f..0000000
--- a/core/src/main/java/org/apache/accumulo/core/client/mock/impl/MockTabletLocator.java
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
- * 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.core.client.mock.impl;
-
-import java.util.Collection;
-import java.util.Collections;
-import java.util.List;
-import java.util.Map;
-
-import org.apache.accumulo.core.client.AccumuloException;
-import org.apache.accumulo.core.client.AccumuloSecurityException;
-import org.apache.accumulo.core.client.Instance;
-import org.apache.accumulo.core.client.TableNotFoundException;
-import org.apache.accumulo.core.client.impl.ClientContext;
-import org.apache.accumulo.core.client.impl.TabletLocator;
-import org.apache.accumulo.core.data.Mutation;
-import org.apache.accumulo.core.data.Range;
-import org.apache.accumulo.core.data.impl.KeyExtent;
-import org.apache.hadoop.io.Text;
-
-/**
- * @deprecated since 1.8.0; use MiniAccumuloCluster or a standard mock framework instead.
- */
-@Deprecated
-public class MockTabletLocator extends TabletLocator {
-
- @Override
- public TabletLocation locateTablet(ClientContext context, Text row, boolean skipRow,
- boolean retry) throws AccumuloException, AccumuloSecurityException, TableNotFoundException {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public <T extends Mutation> void binMutations(ClientContext context, List<T> mutations,
- Map<String,TabletServerMutations<T>> binnedMutations, List<T> failures)
- throws AccumuloException, AccumuloSecurityException, TableNotFoundException {
- TabletServerMutations<T> tsm = new TabletServerMutations<>("5");
- for (T m : mutations)
- tsm.addMutation(new KeyExtent(), m);
- binnedMutations.put("", tsm);
- }
-
- @Override
- public List<Range> binRanges(ClientContext context, List<Range> ranges,
- Map<String,Map<KeyExtent,List<Range>>> binnedRanges)
- throws AccumuloException, AccumuloSecurityException, TableNotFoundException {
- binnedRanges.put("", Collections.singletonMap(new KeyExtent(), ranges));
- return Collections.emptyList();
- }
-
- @Override
- public void invalidateCache(KeyExtent failedExtent) {}
-
- @Override
- public void invalidateCache(Collection<KeyExtent> keySet) {}
-
- @Override
- public void invalidateCache() {}
-
- @Override
- public void invalidateCache(Instance instance, String server) {}
-}
diff --git a/core/src/main/java/org/apache/accumulo/core/client/mock/package-info.java b/core/src/main/java/org/apache/accumulo/core/client/mock/package-info.java
deleted file mode 100644
index 08e4251..0000000
--- a/core/src/main/java/org/apache/accumulo/core/client/mock/package-info.java
+++ /dev/null
@@ -1,24 +0,0 @@
-/*
- * 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.
- */
-/**
- * Mock framework for Accumulo
- *
- * <p>
- * Deprecated since 1.8.0; use MiniAccumuloCluster or a standard mock framework instead.
- */
-@Deprecated
-package org.apache.accumulo.core.client.mock;
diff --git a/core/src/main/java/org/apache/accumulo/core/replication/ReplicationTable.java b/core/src/main/java/org/apache/accumulo/core/replication/ReplicationTable.java
index b79a671..488c6e3 100644
--- a/core/src/main/java/org/apache/accumulo/core/replication/ReplicationTable.java
+++ b/core/src/main/java/org/apache/accumulo/core/replication/ReplicationTable.java
@@ -36,7 +36,6 @@ import org.apache.accumulo.core.master.state.tables.TableState;
import org.apache.accumulo.core.replication.ReplicationSchema.StatusSection;
import org.apache.accumulo.core.replication.ReplicationSchema.WorkSection;
import org.apache.accumulo.core.security.Authorizations;
-import org.apache.accumulo.core.util.DeprecationUtil;
import org.apache.hadoop.io.Text;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -90,8 +89,7 @@ public class ReplicationTable {
}
public static boolean isOnline(Connector conn) {
- return DeprecationUtil.isMockInstance(conn.getInstance())
- || TableState.ONLINE == Tables.getTableState(conn.getInstance(), ID);
+ return TableState.ONLINE == Tables.getTableState(conn.getInstance(), ID);
}
public static void setOnline(Connector conn) throws AccumuloSecurityException, AccumuloException {
diff --git a/core/src/main/java/org/apache/accumulo/core/util/DeprecationUtil.java b/core/src/main/java/org/apache/accumulo/core/util/DeprecationUtil.java
deleted file mode 100644
index 045da7c..0000000
--- a/core/src/main/java/org/apache/accumulo/core/util/DeprecationUtil.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * 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.core.util;
-
-import org.apache.accumulo.core.client.Instance;
-
-/**
- * A utility class for managing deprecated items. This avoids scattering private helper methods all
- * over the code with warnings suppression.
- *
- * <p>
- * This class will never be public API and methods will be removed as soon as they are no longer
- * needed. No methods in this class will, themselves, be deprecated, because that would propagate
- * the deprecation warning we are trying to avoid.
- *
- * <p>
- * This class should not be used as a substitute for deprecated classes. It should <b>only</b> be
- * used for implementation code which must remain to support the deprecated features, and
- * <b>only</b> until that feature is removed.
- */
-public class DeprecationUtil {
-
- @SuppressWarnings("deprecation")
- public static boolean isMockInstance(Instance instance) {
- return instance instanceof org.apache.accumulo.core.client.mock.MockInstance;
- }
-
- @SuppressWarnings("deprecation")
- public static Instance makeMockInstance(String instance) {
- return new org.apache.accumulo.core.client.mock.MockInstance(instance);
- }
-
-}
diff --git a/core/src/test/java/org/apache/accumulo/core/client/mock/MockConnectorTest.java b/core/src/test/java/org/apache/accumulo/core/client/mock/MockConnectorTest.java
deleted file mode 100644
index 2ed3bef..0000000
--- a/core/src/test/java/org/apache/accumulo/core/client/mock/MockConnectorTest.java
+++ /dev/null
@@ -1,382 +0,0 @@
-/*
- * 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.core.client.mock;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map.Entry;
-import java.util.Random;
-import java.util.concurrent.TimeUnit;
-
-import org.apache.accumulo.core.client.AccumuloException;
-import org.apache.accumulo.core.client.AccumuloSecurityException;
-import org.apache.accumulo.core.client.BatchDeleter;
-import org.apache.accumulo.core.client.BatchScanner;
-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.Instance;
-import org.apache.accumulo.core.client.IteratorSetting;
-import org.apache.accumulo.core.client.MultiTableBatchWriter;
-import org.apache.accumulo.core.client.Scanner;
-import org.apache.accumulo.core.client.security.tokens.PasswordToken;
-import org.apache.accumulo.core.data.Key;
-import org.apache.accumulo.core.data.Mutation;
-import org.apache.accumulo.core.data.Range;
-import org.apache.accumulo.core.data.Value;
-import org.apache.accumulo.core.iterators.Combiner;
-import org.apache.accumulo.core.iterators.user.SummingCombiner;
-import org.apache.accumulo.core.security.Authorizations;
-import org.apache.hadoop.io.Text;
-import org.junit.Assert;
-import org.junit.Test;
-
-import com.google.common.collect.Iterators;
-
-@Deprecated
-public class MockConnectorTest {
- Random random = new Random();
-
- static Text asText(int i) {
- return new Text(Integer.toHexString(i));
- }
-
- @Test
- public void testSunnyDay() throws Exception {
- Connector c = new MockConnector("root", new MockInstance());
- c.tableOperations().create("test");
- BatchWriter bw = c.createBatchWriter("test", new BatchWriterConfig());
- for (int i = 0; i < 100; i++) {
- int r = random.nextInt();
- Mutation m = new Mutation(asText(r));
- m.put(asText(random.nextInt()), asText(random.nextInt()),
- new Value(Integer.toHexString(r).getBytes()));
- bw.addMutation(m);
- }
- bw.close();
- BatchScanner s = c.createBatchScanner("test", Authorizations.EMPTY, 2);
- s.setRanges(Collections.singletonList(new Range()));
- Key key = null;
- int count = 0;
- for (Entry<Key,Value> entry : s) {
- if (key != null)
- assertTrue(key.compareTo(entry.getKey()) < 0);
- assertEquals(entry.getKey().getRow(), new Text(entry.getValue().get()));
- key = entry.getKey();
- count++;
- }
- assertEquals(100, count);
- }
-
- @Test
- public void testChangeAuths() throws Exception {
- Connector c = new MockConnector("root", new MockInstance());
- c.securityOperations().createLocalUser("greg", new PasswordToken(new byte[0]));
- assertTrue(c.securityOperations().getUserAuthorizations("greg").isEmpty());
- c.securityOperations().changeUserAuthorizations("greg", new Authorizations("A".getBytes()));
- assertTrue(c.securityOperations().getUserAuthorizations("greg").contains("A".getBytes()));
- c.securityOperations().changeUserAuthorizations("greg", new Authorizations("X", "Y", "Z"));
- assertTrue(c.securityOperations().getUserAuthorizations("greg").contains("X".getBytes()));
- assertFalse(c.securityOperations().getUserAuthorizations("greg").contains("A".getBytes()));
- }
-
- @Test
- public void testBadMutations() throws Exception {
- Connector c = new MockConnector("root", new MockInstance());
- c.tableOperations().create("test");
- BatchWriter bw = c.createBatchWriter("test", new BatchWriterConfig().setMaxMemory(10000L)
- .setMaxLatency(1000L, TimeUnit.MILLISECONDS).setMaxWriteThreads(4));
-
- try {
- bw.addMutation(null);
- Assert.fail("addMutation should throw IAE for null mutation");
- } catch (IllegalArgumentException iae) {}
- try {
- bw.addMutations(null);
- Assert.fail("addMutations should throw IAE for null iterable");
- } catch (IllegalArgumentException iae) {}
-
- bw.addMutations(Collections.emptyList());
-
- Mutation bad = new Mutation("bad");
- try {
- bw.addMutation(bad);
- Assert.fail("addMutation should throw IAE for empty mutation");
- } catch (IllegalArgumentException iae) {}
-
- Mutation good = new Mutation("good");
- good.put(asText(random.nextInt()), asText(random.nextInt()), new Value("good".getBytes()));
- List<Mutation> mutations = new ArrayList<>();
- mutations.add(good);
- mutations.add(bad);
- try {
- bw.addMutations(mutations);
- Assert.fail("addMutations should throw IAE if it contains empty mutation");
- } catch (IllegalArgumentException iae) {}
-
- bw.close();
- }
-
- @Test
- public void testAggregation() throws Exception {
- MockInstance mockInstance = new MockInstance();
- Connector c = mockInstance.getConnector("root", new PasswordToken(""));
- String table = "perDayCounts";
- c.tableOperations().create(table);
- IteratorSetting is = new IteratorSetting(10, "String Summation", SummingCombiner.class);
- Combiner.setColumns(is, Collections.singletonList(new IteratorSetting.Column("day")));
- SummingCombiner.setEncodingType(is, SummingCombiner.Type.STRING);
- c.tableOperations().attachIterator(table, is);
- String keys[][] = {{"foo", "day", "20080101"}, {"foo", "day", "20080101"},
- {"foo", "day", "20080103"}, {"bar", "day", "20080101"}, {"bar", "day", "20080101"},};
- BatchWriter bw = c.createBatchWriter("perDayCounts", new BatchWriterConfig());
- for (String elt[] : keys) {
- Mutation m = new Mutation(new Text(elt[0]));
- m.put(new Text(elt[1]), new Text(elt[2]), new Value("1".getBytes()));
- bw.addMutation(m);
- }
- bw.close();
-
- Scanner s = c.createScanner("perDayCounts", Authorizations.EMPTY);
- Iterator<Entry<Key,Value>> iterator = s.iterator();
- assertTrue(iterator.hasNext());
- checkEntry(iterator.next(), "bar", "day", "20080101", "2");
- assertTrue(iterator.hasNext());
- checkEntry(iterator.next(), "foo", "day", "20080101", "2");
- assertTrue(iterator.hasNext());
- checkEntry(iterator.next(), "foo", "day", "20080103", "1");
- assertFalse(iterator.hasNext());
- }
-
- @Test
- public void testDelete() throws Exception {
- Connector c = new MockConnector("root", new MockInstance());
- c.tableOperations().create("test");
- BatchWriter bw = c.createBatchWriter("test", new BatchWriterConfig());
-
- Mutation m1 = new Mutation("r1");
-
- m1.put("cf1", "cq1", 1, "v1");
-
- bw.addMutation(m1);
- bw.flush();
-
- Mutation m2 = new Mutation("r1");
-
- m2.putDelete("cf1", "cq1", 2);
-
- bw.addMutation(m2);
- bw.flush();
-
- Scanner scanner = c.createScanner("test", Authorizations.EMPTY);
-
- int count = Iterators.size(scanner.iterator());
-
- assertEquals(0, count);
-
- try {
- c.tableOperations().create("test_this_$tableName");
- fail();
-
- } catch (IllegalArgumentException iae) {
-
- }
- }
-
- @Test
- public void testDeletewithBatchDeleter() throws Exception {
- Connector c = new MockConnector("root", new MockInstance());
-
- // make sure we are using a clean table
- if (c.tableOperations().exists("test"))
- c.tableOperations().delete("test");
- c.tableOperations().create("test");
-
- BatchDeleter deleter = c.createBatchDeleter("test", Authorizations.EMPTY, 2,
- new BatchWriterConfig());
- // first make sure it deletes fine when its empty
- deleter.setRanges(Collections.singletonList(new Range(("r1"))));
- deleter.delete();
- this.checkRemaining(c, "test", 0);
-
- // test deleting just one row
- BatchWriter writer = c.createBatchWriter("test", new BatchWriterConfig());
- Mutation m = new Mutation("r1");
- m.put("fam", "qual", "value");
- writer.addMutation(m);
-
- // make sure the write goes through
- writer.flush();
- writer.close();
-
- deleter.setRanges(Collections.singletonList(new Range(("r1"))));
- deleter.delete();
- this.checkRemaining(c, "test", 0);
-
- // test multi row deletes
- writer = c.createBatchWriter("test", new BatchWriterConfig());
- m = new Mutation("r1");
- m.put("fam", "qual", "value");
- writer.addMutation(m);
- Mutation m2 = new Mutation("r2");
- m2.put("fam", "qual", "value");
- writer.addMutation(m2);
-
- // make sure the write goes through
- writer.flush();
- writer.close();
-
- deleter.setRanges(Collections.singletonList(new Range(("r1"))));
- deleter.delete();
- checkRemaining(c, "test", 1);
- }
-
- /**
- * Test to make sure that a certain number of rows remain
- *
- * @param c
- * connector to the {@link MockInstance}
- * @param tableName
- * Table to check
- * @param count
- * number of entries to expect in the table
- */
- private void checkRemaining(Connector c, String tableName, int count) throws Exception {
- Scanner scanner = c.createScanner(tableName, Authorizations.EMPTY);
-
- int total = Iterators.size(scanner.iterator());
- assertEquals(count, total);
- }
-
- @Test
- public void testCMod() throws Exception {
- // test writing to a table that the is being scanned
- Connector c = new MockConnector("root", new MockInstance());
- c.tableOperations().create("test");
- BatchWriter bw = c.createBatchWriter("test", new BatchWriterConfig());
-
- for (int i = 0; i < 10; i++) {
- Mutation m1 = new Mutation("r" + i);
- m1.put("cf1", "cq1", 1, "v" + i);
- bw.addMutation(m1);
- }
-
- bw.flush();
-
- int count = 10;
-
- Scanner scanner = c.createScanner("test", Authorizations.EMPTY);
- for (Entry<Key,Value> entry : scanner) {
- Key key = entry.getKey();
- Mutation m = new Mutation(key.getRow());
- m.put(key.getColumnFamily().toString(), key.getColumnQualifier().toString(),
- key.getTimestamp() + 1, "v" + (count));
- count++;
- bw.addMutation(m);
- }
-
- bw.flush();
-
- count = 10;
-
- for (Entry<Key,Value> entry : scanner) {
- assertEquals(entry.getValue().toString(), "v" + (count++));
- }
-
- assertEquals(count, 20);
-
- try {
- c.tableOperations().create("test_this_$tableName");
- fail();
-
- } catch (IllegalArgumentException iae) {
-
- }
- }
-
- private void checkEntry(Entry<Key,Value> next, String row, String cf, String cq, String value) {
- assertEquals(row, next.getKey().getRow().toString());
- assertEquals(cf, next.getKey().getColumnFamily().toString());
- assertEquals(cq, next.getKey().getColumnQualifier().toString());
- assertEquals(value, next.getValue().toString());
- }
-
- @Test
- public void testMockMultiTableBatchWriter() throws Exception {
- Connector c = new MockConnector("root", new MockInstance());
- c.tableOperations().create("a");
- c.tableOperations().create("b");
- MultiTableBatchWriter bw = c.createMultiTableBatchWriter(new BatchWriterConfig());
- Mutation m1 = new Mutation("r1");
- m1.put("cf1", "cq1", 1, "v1");
- BatchWriter b = bw.getBatchWriter("a");
- b.addMutation(m1);
- b.flush();
- b = bw.getBatchWriter("b");
- b.addMutation(m1);
- b.flush();
-
- Scanner scanner = c.createScanner("a", Authorizations.EMPTY);
- int count = Iterators.size(scanner.iterator());
- assertEquals(1, count);
- scanner = c.createScanner("b", Authorizations.EMPTY);
- count = Iterators.size(scanner.iterator());
- assertEquals(1, count);
-
- }
-
- @Test
- public void testUpdate() throws Exception {
- Connector c = new MockConnector("root", new MockInstance());
- c.tableOperations().create("test");
- BatchWriter bw = c.createBatchWriter("test", new BatchWriterConfig());
-
- for (int i = 0; i < 10; i++) {
- Mutation m = new Mutation("r1");
- m.put("cf1", "cq1", "" + i);
- bw.addMutation(m);
- }
-
- bw.close();
-
- Scanner scanner = c.createScanner("test", Authorizations.EMPTY);
-
- Entry<Key,Value> entry = scanner.iterator().next();
-
- assertEquals("9", entry.getValue().toString());
-
- }
-
- @Test
- public void testMockConnectorReturnsCorrectInstance()
- throws AccumuloException, AccumuloSecurityException {
- String name = "an-interesting-instance-name";
- Instance mockInstance = new MockInstance(name);
- assertEquals(mockInstance,
- mockInstance.getConnector("foo", new PasswordToken("bar")).getInstance());
- assertEquals(name,
- mockInstance.getConnector("foo", new PasswordToken("bar")).info().getInstanceName());
- }
-
-}
diff --git a/core/src/test/java/org/apache/accumulo/core/client/mock/MockNamespacesTest.java b/core/src/test/java/org/apache/accumulo/core/client/mock/MockNamespacesTest.java
deleted file mode 100644
index 9343260..0000000
--- a/core/src/test/java/org/apache/accumulo/core/client/mock/MockNamespacesTest.java
+++ /dev/null
@@ -1,300 +0,0 @@
-/*
- * 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.core.client.mock;
-
-import static java.nio.charset.StandardCharsets.UTF_8;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-
-import java.util.EnumSet;
-import java.util.HashSet;
-import java.util.Map.Entry;
-
-import org.apache.accumulo.core.client.AccumuloException;
-import org.apache.accumulo.core.client.AccumuloSecurityException;
-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.Instance;
-import org.apache.accumulo.core.client.IteratorSetting;
-import org.apache.accumulo.core.client.NamespaceNotEmptyException;
-import org.apache.accumulo.core.client.NamespaceNotFoundException;
-import org.apache.accumulo.core.client.Scanner;
-import org.apache.accumulo.core.client.TableNotFoundException;
-import org.apache.accumulo.core.client.admin.NamespaceOperations;
-import org.apache.accumulo.core.client.impl.Namespace;
-import org.apache.accumulo.core.client.security.tokens.PasswordToken;
-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.iterators.Filter;
-import org.apache.accumulo.core.iterators.IteratorUtil.IteratorScope;
-import org.apache.accumulo.core.security.Authorizations;
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.TestName;
-
-@Deprecated
-public class MockNamespacesTest {
-
- @Rule
- public TestName test = new TestName();
-
- private Connector conn;
-
- @Before
- public void setupInstance() throws Exception {
- Instance inst = new MockInstance(test.getMethodName());
- conn = inst.getConnector("user", new PasswordToken("pass"));
- }
-
- /**
- * This test creates a table without specifying a namespace. In this case, it puts the table into
- * the default namespace.
- */
- @Test
- public void testDefaultNamespace() throws Exception {
- String tableName = "test";
-
- assertTrue(conn.namespaceOperations().exists(Namespace.DEFAULT));
- conn.tableOperations().create(tableName);
- assertTrue(conn.tableOperations().exists(tableName));
- }
-
- /**
- * This test creates a new namespace "testing" and a table "testing.table1" which puts "table1"
- * into the "testing" namespace. Then we create "testing.table2" which creates "table2" and puts
- * it into "testing" as well. Then we make sure that you can't delete a namespace with tables in
- * it, and then we delete the tables and delete the namespace.
- */
- @Test
- public void testCreateAndDeleteNamespace() throws Exception {
- String namespace = "testing";
- String tableName1 = namespace + ".table1";
- String tableName2 = namespace + ".table2";
-
- conn.namespaceOperations().create(namespace);
- assertTrue(conn.namespaceOperations().exists(namespace));
-
- conn.tableOperations().create(tableName1);
- assertTrue(conn.tableOperations().exists(tableName1));
-
- conn.tableOperations().create(tableName2);
- assertTrue(conn.tableOperations().exists(tableName2));
-
- // deleting
- try {
- // can't delete a namespace with tables in it
- conn.namespaceOperations().delete(namespace);
- fail();
- } catch (NamespaceNotEmptyException e) {
- // ignore, supposed to happen
- }
- assertTrue(conn.namespaceOperations().exists(namespace));
- assertTrue(conn.tableOperations().exists(tableName1));
- assertTrue(conn.tableOperations().exists(tableName2));
-
- conn.tableOperations().delete(tableName2);
- assertTrue(!conn.tableOperations().exists(tableName2));
- assertTrue(conn.namespaceOperations().exists(namespace));
-
- conn.tableOperations().delete(tableName1);
- assertTrue(!conn.tableOperations().exists(tableName1));
- conn.namespaceOperations().delete(namespace);
- assertTrue(!conn.namespaceOperations().exists(namespace));
- }
-
- /**
- * This test creates a namespace, modifies it's properties, and checks to make sure that those
- * properties are applied to its tables. To do something on a namespace-wide level, use
- * {@link NamespaceOperations}.
- *
- * Checks to make sure namespace-level properties are overridden by table-level properties.
- *
- * Checks to see if the default namespace's properties work as well.
- */
-
- @Test
- public void testNamespaceProperties() throws Exception {
- String namespace = "propchange";
- String tableName1 = namespace + ".table1";
- String tableName2 = namespace + ".table2";
-
- String propKey = Property.TABLE_SCAN_MAXMEM.getKey();
- String propVal = "42K";
-
- conn.namespaceOperations().create(namespace);
- conn.tableOperations().create(tableName1);
- conn.namespaceOperations().setProperty(namespace, propKey, propVal);
-
- // check the namespace has the property
- assertTrue(checkNamespaceHasProp(conn, namespace, propKey, propVal));
-
- // check that the table gets it from the namespace
- assertTrue(checkTableHasProp(conn, tableName1, propKey, propVal));
-
- // test a second table to be sure the first wasn't magical
- // (also, changed the order, the namespace has the property already)
- conn.tableOperations().create(tableName2);
- assertTrue(checkTableHasProp(conn, tableName2, propKey, propVal));
-
- // test that table properties override namespace properties
- String propKey2 = Property.TABLE_FILE_MAX.getKey();
- String propVal2 = "42";
- String tablePropVal = "13";
-
- conn.tableOperations().setProperty(tableName2, propKey2, tablePropVal);
- conn.namespaceOperations().setProperty("propchange", propKey2, propVal2);
-
- assertTrue(checkTableHasProp(conn, tableName2, propKey2, tablePropVal));
-
- // now check that you can change the default namespace's properties
- propVal = "13K";
- String tableName = "some_table";
- conn.tableOperations().create(tableName);
- conn.namespaceOperations().setProperty(Namespace.DEFAULT, propKey, propVal);
-
- assertTrue(checkTableHasProp(conn, tableName, propKey, propVal));
-
- // test the properties server-side by configuring an iterator.
- // should not show anything with column-family = 'a'
- String tableName3 = namespace + ".table3";
- conn.tableOperations().create(tableName3);
-
- IteratorSetting setting = new IteratorSetting(250, "thing", SimpleFilter.class.getName());
- conn.namespaceOperations().attachIterator(namespace, setting);
-
- BatchWriter bw = conn.createBatchWriter(tableName3, new BatchWriterConfig());
- Mutation m = new Mutation("r");
- m.put("a", "b", new Value("abcde".getBytes()));
- bw.addMutation(m);
- bw.flush();
- bw.close();
-
- // Scanner s = c.createScanner(tableName3, Authorizations.EMPTY);
- // do scanners work correctly in mock?
- // assertTrue(!s.iterator().hasNext());
- }
-
- /**
- * This test renames and clones two separate table into different namespaces. different namespace.
- */
- @Test
- public void testRenameAndCloneTableToNewNamespace() throws Exception {
- String namespace1 = "renamed";
- String namespace2 = "cloned";
- String tableName = "table";
- String tableName1 = "renamed.table1";
- // String tableName2 = "cloned.table2";
-
- conn.tableOperations().create(tableName);
- conn.namespaceOperations().create(namespace1);
- conn.namespaceOperations().create(namespace2);
-
- conn.tableOperations().rename(tableName, tableName1);
-
- assertTrue(conn.tableOperations().exists(tableName1));
- assertTrue(!conn.tableOperations().exists(tableName));
-
- // TODO implement clone in mock
- // c.tableOperations().clone(tableName1, tableName2, false, null, null);
- // assertTrue(c.tableOperations().exists(tableName1));
- // assertTrue(c.tableOperations().exists(tableName2));
- }
-
- /**
- * This test renames a namespace and ensures that its tables are still correct
- */
- @Test
- public void testNamespaceRename() throws Exception {
- String namespace1 = "n1";
- String namespace2 = "n2";
- String table = "t";
-
- conn.namespaceOperations().create(namespace1);
- conn.tableOperations().create(namespace1 + "." + table);
-
- conn.namespaceOperations().rename(namespace1, namespace2);
-
- assertTrue(!conn.namespaceOperations().exists(namespace1));
- assertTrue(conn.namespaceOperations().exists(namespace2));
- assertTrue(!conn.tableOperations().exists(namespace1 + "." + table));
- assertTrue(conn.tableOperations().exists(namespace2 + "." + table));
- }
-
- /**
- * This tests adding iterators to a namespace, listing them, and removing them
- */
- @Test
- public void testNamespaceIterators() throws Exception {
- String namespace = "iterator";
- String tableName = namespace + ".table";
- String iter = "thing";
-
- conn.namespaceOperations().create(namespace);
- conn.tableOperations().create(tableName);
-
- IteratorSetting setting = new IteratorSetting(250, iter, SimpleFilter.class.getName());
- HashSet<IteratorScope> scope = new HashSet<>();
- scope.add(IteratorScope.scan);
- conn.namespaceOperations().attachIterator(namespace, setting, EnumSet.copyOf(scope));
-
- BatchWriter bw = conn.createBatchWriter(tableName, new BatchWriterConfig());
- Mutation m = new Mutation("r");
- m.put("a", "b", new Value("abcde".getBytes(UTF_8)));
- bw.addMutation(m);
- bw.flush();
-
- Scanner s = conn.createScanner(tableName, Authorizations.EMPTY);
- System.out.println(s.iterator().next());
- // do scanners work correctly in mock?
- // assertTrue(!s.iterator().hasNext());
-
- assertTrue(conn.namespaceOperations().listIterators(namespace).containsKey(iter));
- conn.namespaceOperations().removeIterator(namespace, iter, EnumSet.copyOf(scope));
- }
-
- private boolean checkTableHasProp(Connector c, String t, String propKey, String propVal)
- throws AccumuloException, TableNotFoundException {
- for (Entry<String,String> e : c.tableOperations().getProperties(t)) {
- if (e.getKey().equals(propKey) && e.getValue().equals(propVal)) {
- return true;
- }
- }
- return false;
- }
-
- private boolean checkNamespaceHasProp(Connector c, String n, String propKey, String propVal)
- throws AccumuloException, NamespaceNotFoundException, AccumuloSecurityException {
- for (Entry<String,String> e : c.namespaceOperations().getProperties(n)) {
- if (e.getKey().equals(propKey) && e.getValue().equals(propVal)) {
- return true;
- }
- }
- return false;
- }
-
- public static class SimpleFilter extends Filter {
- @Override
- public boolean accept(Key k, Value v) {
- return !k.getColumnFamily().toString().equals("a");
- }
- }
-}
diff --git a/core/src/test/java/org/apache/accumulo/core/client/mock/MockScannerTest.java b/core/src/test/java/org/apache/accumulo/core/client/mock/MockScannerTest.java
deleted file mode 100644
index 3cbe233..0000000
--- a/core/src/test/java/org/apache/accumulo/core/client/mock/MockScannerTest.java
+++ /dev/null
@@ -1,105 +0,0 @@
-/*
- * 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.core.client.mock;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.fail;
-
-import java.io.IOException;
-import java.util.Collections;
-import java.util.Map;
-import java.util.Map.Entry;
-
-import org.apache.accumulo.core.client.BatchScanner;
-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.IteratorSetting;
-import org.apache.accumulo.core.client.SampleNotPresentException;
-import org.apache.accumulo.core.client.security.tokens.PasswordToken;
-import org.apache.accumulo.core.data.Key;
-import org.apache.accumulo.core.data.Mutation;
-import org.apache.accumulo.core.data.Range;
-import org.apache.accumulo.core.data.Value;
-import org.apache.accumulo.core.iterators.IteratorEnvironment;
-import org.apache.accumulo.core.iterators.SortedKeyValueIterator;
-import org.apache.accumulo.core.iterators.WrappingIterator;
-import org.apache.accumulo.core.security.Authorizations;
-import org.junit.Test;
-
-@Deprecated
-public class MockScannerTest {
-
- public static final String ROOT = "root";
- public static final String TEST = "test";
- public static final String SEP = ",";
- public static final String A_B_C_D = 'A' + SEP + 'B' + SEP + 'C' + SEP + 'D';
- public static final String CF = "cf";
- public static final String CQ = "cq";
-
- public static class DeepCopyIterator extends WrappingIterator {
-
- @Override
- public void init(SortedKeyValueIterator<Key,Value> source, Map<String,String> options,
- IteratorEnvironment env) throws IOException {
- super.init(source.deepCopy(env), options, env);
- }
- }
-
- @Test
- public void testDeepCopy() throws Exception {
- MockInstance inst = new MockInstance();
- Connector conn = inst.getConnector(ROOT, new PasswordToken(""));
- conn.tableOperations().create(TEST);
- BatchWriter bw = conn.createBatchWriter(TEST, new BatchWriterConfig());
- for (String row : A_B_C_D.split(SEP)) {
- Mutation m = new Mutation(row);
- m.put(CF, CQ, "");
- bw.addMutation(m);
- }
- bw.flush();
- BatchScanner bs = conn.createBatchScanner(TEST, Authorizations.EMPTY, 1);
- IteratorSetting cfg = new IteratorSetting(100, DeepCopyIterator.class);
- bs.addScanIterator(cfg);
- bs.setRanges(Collections.singletonList(new Range("A", "Z")));
- StringBuilder sb = new StringBuilder();
- String comma = "";
- for (Entry<Key,Value> entry : bs) {
- sb.append(comma);
- sb.append(entry.getKey().getRow());
- comma = SEP;
- }
- assertEquals(A_B_C_D, sb.toString());
- }
-
- @Test
- public void testEnvironment() throws Exception {
- MockScannerBase.MockIteratorEnvironment env = new MockScannerBase.MockIteratorEnvironment(
- Authorizations.EMPTY);
- assertFalse(env.isSamplingEnabled());
- assertNull(env.getSamplerConfiguration());
- try {
- env.cloneWithSamplingEnabled();
- fail("cloneWithSamplingEnabled should have thrown SampleNotPresentException");
- } catch (SampleNotPresentException se) {
- // expected
- }
- }
-
-}
diff --git a/core/src/test/java/org/apache/accumulo/core/client/mock/MockTableOperationsTest.java b/core/src/test/java/org/apache/accumulo/core/client/mock/MockTableOperationsTest.java
deleted file mode 100644
index 10a3f80..0000000
--- a/core/src/test/java/org/apache/accumulo/core/client/mock/MockTableOperationsTest.java
+++ /dev/null
@@ -1,357 +0,0 @@
-/*
- * 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.core.client.mock;
-
-import java.io.IOException;
-import java.net.URI;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.EnumSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Map.Entry;
-
-import org.apache.accumulo.core.client.AccumuloException;
-import org.apache.accumulo.core.client.AccumuloSecurityException;
-import org.apache.accumulo.core.client.BatchScanner;
-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.Instance;
-import org.apache.accumulo.core.client.IteratorSetting;
-import org.apache.accumulo.core.client.MutationsRejectedException;
-import org.apache.accumulo.core.client.Scanner;
-import org.apache.accumulo.core.client.TableExistsException;
-import org.apache.accumulo.core.client.TableNotFoundException;
-import org.apache.accumulo.core.client.admin.NewTableConfiguration;
-import org.apache.accumulo.core.client.admin.TableOperations;
-import org.apache.accumulo.core.client.admin.TimeType;
-import org.apache.accumulo.core.client.security.tokens.PasswordToken;
-import org.apache.accumulo.core.conf.DefaultConfiguration;
-import org.apache.accumulo.core.data.Key;
-import org.apache.accumulo.core.data.Mutation;
-import org.apache.accumulo.core.data.Range;
-import org.apache.accumulo.core.data.Value;
-import org.apache.accumulo.core.file.FileOperations;
-import org.apache.accumulo.core.file.FileSKVWriter;
-import org.apache.accumulo.core.iterators.IteratorUtil.IteratorScope;
-import org.apache.accumulo.core.iterators.user.VersioningIterator;
-import org.apache.accumulo.core.security.Authorizations;
-import org.apache.accumulo.core.security.ColumnVisibility;
-import org.apache.accumulo.core.util.Pair;
-import org.apache.hadoop.conf.Configuration;
-import org.apache.hadoop.fs.FileSystem;
-import org.apache.hadoop.fs.Path;
-import org.apache.hadoop.io.Text;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.TestName;
-
-import com.google.common.collect.Iterators;
-
-@Deprecated
-public class MockTableOperationsTest {
-
- @Rule
- public TestName test = new TestName();
-
- private Connector conn;
-
- @Before
- public void setupInstance() throws Exception {
- Instance inst = new MockInstance(test.getMethodName());
- conn = inst.getConnector("user", new PasswordToken("pass"));
- }
-
- @Test
- public void testCreateUseVersions() throws AccumuloException, AccumuloSecurityException,
- TableExistsException, TableNotFoundException {
- String t = "tableName1";
-
- {
- conn.tableOperations().create(t,
- new NewTableConfiguration().withoutDefaultIterators().setTimeType(TimeType.LOGICAL));
-
- writeVersionable(conn, t, 3);
- assertVersionable(conn, t, 3);
-
- IteratorSetting settings = new IteratorSetting(20, VersioningIterator.class);
- conn.tableOperations().attachIterator(t, settings);
-
- assertVersionable(conn, t, 1);
-
- conn.tableOperations().delete(t);
- }
-
- {
- conn.tableOperations().create(t, new NewTableConfiguration().setTimeType(TimeType.MILLIS));
-
- try {
- IteratorSetting settings = new IteratorSetting(20, VersioningIterator.class);
- conn.tableOperations().attachIterator(t, settings);
- Assert.fail();
- } catch (AccumuloException ex) {}
-
- writeVersionable(conn, t, 3);
- assertVersionable(conn, t, 1);
-
- conn.tableOperations().delete(t);
- }
- }
-
- protected void writeVersionable(Connector c, String tableName, int size)
- throws TableNotFoundException, MutationsRejectedException {
- for (int i = 0; i < size; i++) {
- BatchWriter w = c.createBatchWriter(tableName, new BatchWriterConfig());
- Mutation m = new Mutation("row1");
- m.put("cf", "cq", String.valueOf(i));
- w.addMutation(m);
- w.close();
- }
- }
-
- protected void assertVersionable(Connector c, String tableName, int size)
- throws TableNotFoundException {
- BatchScanner s = c.createBatchScanner(tableName, Authorizations.EMPTY, 1);
- s.setRanges(Collections.singleton(Range.exact("row1", "cf", "cq")));
- int count = 0;
- for (Map.Entry<Key,Value> e : s) {
- Assert.assertEquals("row1", e.getKey().getRow().toString());
- Assert.assertEquals("cf", e.getKey().getColumnFamily().toString());
- Assert.assertEquals("cq", e.getKey().getColumnQualifier().toString());
- count++;
-
- }
- Assert.assertEquals(size, count);
- s.close();
- }
-
- @Test
- public void testTableNotFound() throws AccumuloException, AccumuloSecurityException,
- TableExistsException, TableNotFoundException {
- IteratorSetting setting = new IteratorSetting(100, "myvers", VersioningIterator.class);
- String t = "tableName";
- try {
- conn.tableOperations().attachIterator(t, setting);
- Assert.fail();
- } catch (TableNotFoundException e) {}
- try {
- conn.tableOperations().checkIteratorConflicts(t, setting, EnumSet.allOf(IteratorScope.class));
- Assert.fail();
- } catch (TableNotFoundException e) {}
- try {
- conn.tableOperations().delete(t);
- Assert.fail();
- } catch (TableNotFoundException e) {}
- try {
- conn.tableOperations().getIteratorSetting(t, "myvers", IteratorScope.scan);
- Assert.fail();
- } catch (TableNotFoundException e) {}
- try {
- conn.tableOperations().getProperties(t);
- Assert.fail();
- } catch (TableNotFoundException e) {}
- try {
- conn.tableOperations().listSplits(t);
- Assert.fail();
- } catch (TableNotFoundException e) {}
- try {
- conn.tableOperations().listIterators(t);
- Assert.fail();
- } catch (TableNotFoundException e) {}
- try {
- conn.tableOperations().removeIterator(t, null, EnumSet.noneOf(IteratorScope.class));
- Assert.fail();
- } catch (TableNotFoundException e) {}
- try {
- conn.tableOperations().rename(t, t);
- Assert.fail();
- } catch (TableNotFoundException e) {}
- conn.tableOperations().create(t);
- try {
- conn.tableOperations().create(t);
- Assert.fail();
- } catch (TableExistsException e) {}
- try {
- conn.tableOperations().rename(t, t);
- Assert.fail();
- } catch (TableExistsException e) {}
- }
-
- private static class ImportTestFilesAndData {
- Path importPath;
- Path failurePath;
- List<Pair<Key,Value>> keyVals;
- }
-
- @Test
- public void testImport() throws Throwable {
- ImportTestFilesAndData dataAndFiles = prepareTestFiles();
- TableOperations tableOperations = conn.tableOperations();
- tableOperations.create("a_table");
- tableOperations.importDirectory("a_table", dataAndFiles.importPath.toString(),
- dataAndFiles.failurePath.toString(), false);
- Scanner scanner = conn.createScanner("a_table", new Authorizations());
- Iterator<Entry<Key,Value>> iterator = scanner.iterator();
- for (int i = 0; i < 5; i++) {
- Assert.assertTrue(iterator.hasNext());
- Entry<Key,Value> kv = iterator.next();
- Pair<Key,Value> expected = dataAndFiles.keyVals.get(i);
- Assert.assertEquals(expected.getFirst(), kv.getKey());
- Assert.assertEquals(expected.getSecond(), kv.getValue());
- }
- Assert.assertFalse(iterator.hasNext());
- }
-
- private ImportTestFilesAndData prepareTestFiles() throws Throwable {
- Configuration defaultConf = new Configuration();
- Path tempFile = new Path("target/accumulo-test/import/sample.rf");
- Path failures = new Path("target/accumulo-test/failures/");
- FileSystem fs = FileSystem.get(new URI("file:///"), defaultConf);
- fs.deleteOnExit(tempFile);
- fs.deleteOnExit(failures);
- fs.delete(failures, true);
- fs.delete(tempFile, true);
- fs.mkdirs(failures);
- fs.mkdirs(tempFile.getParent());
- FileSKVWriter writer = FileOperations.getInstance().newWriterBuilder()
- .forFile(tempFile.toString(), fs, defaultConf)
- .withTableConfiguration(DefaultConfiguration.getInstance()).build();
- writer.startDefaultLocalityGroup();
- List<Pair<Key,Value>> keyVals = new ArrayList<>();
- for (int i = 0; i < 5; i++) {
- keyVals
- .add(new Pair<>(new Key("a" + i, "b" + i, "c" + i, new ColumnVisibility(""), 1000L + i),
- new Value(Integer.toString(i).getBytes())));
- }
- for (Pair<Key,Value> keyVal : keyVals) {
- writer.append(keyVal.getFirst(), keyVal.getSecond());
- }
- writer.close();
- ImportTestFilesAndData files = new ImportTestFilesAndData();
- files.failurePath = failures;
- files.importPath = tempFile.getParent();
- files.keyVals = keyVals;
- return files;
- }
-
- @Test(expected = TableNotFoundException.class)
- public void testFailsWithNoTable() throws Throwable {
- TableOperations tableOperations = conn.tableOperations();
- ImportTestFilesAndData testFiles = prepareTestFiles();
- tableOperations.importDirectory("doesnt_exist_table", testFiles.importPath.toString(),
- testFiles.failurePath.toString(), false);
- }
-
- @Test(expected = IOException.class)
- public void testFailsWithNonEmptyFailureDirectory() throws Throwable {
- TableOperations tableOperations = conn.tableOperations();
- ImportTestFilesAndData testFiles = prepareTestFiles();
- FileSystem fs = testFiles.failurePath.getFileSystem(new Configuration());
- fs.open(testFiles.failurePath.suffix("/something")).close();
- tableOperations.importDirectory("doesnt_exist_table", testFiles.importPath.toString(),
- testFiles.failurePath.toString(), false);
- }
-
- @Test
- public void testDeleteRows() throws Exception {
- TableOperations to = conn.tableOperations();
- to.create("test");
- BatchWriter bw = conn.createBatchWriter("test", new BatchWriterConfig());
- for (int r = 0; r < 20; r++) {
- Mutation m = new Mutation("" + r);
- for (int c = 0; c < 5; c++) {
- m.put(new Text("cf"), new Text("" + c), new Value(("" + c).getBytes()));
- }
- bw.addMutation(m);
- }
- bw.flush();
- to.deleteRows("test", new Text("1"), new Text("2"));
- Scanner s = conn.createScanner("test", Authorizations.EMPTY);
- int oneCnt = 0;
- for (Entry<Key,Value> entry : s) {
- char rowStart = entry.getKey().getRow().toString().charAt(0);
- Assert.assertTrue(rowStart != '2');
- oneCnt += rowStart == '1' ? 1 : 0;
- }
- Assert.assertEquals(5, oneCnt);
- }
-
- @Test
- public void testDeleteRowsWithNullKeys() throws Exception {
- TableOperations to = conn.tableOperations();
- to.create("test2");
- BatchWriter bw = conn.createBatchWriter("test2", new BatchWriterConfig());
- for (int r = 0; r < 30; r++) {
- Mutation m = new Mutation(Integer.toString(r));
- for (int c = 0; c < 5; c++) {
- m.put(new Text("cf"), new Text(Integer.toString(c)),
- new Value(Integer.toString(c).getBytes()));
- }
- bw.addMutation(m);
- }
- bw.flush();
-
- // test null end
- // will remove rows 4 through 9 (6 * 5 = 30 entries)
- to.deleteRows("test2", new Text("30"), null);
- Scanner s = conn.createScanner("test2", Authorizations.EMPTY);
- int rowCnt = 0;
- for (Entry<Key,Value> entry : s) {
- String rowId = entry.getKey().getRow().toString();
- Assert.assertFalse(rowId.startsWith("30"));
- rowCnt++;
- }
- s.close();
- Assert.assertEquals(120, rowCnt);
-
- // test null start
- // will remove 0-1, 10-19, 2
- to.deleteRows("test2", null, new Text("2"));
- s = conn.createScanner("test2", Authorizations.EMPTY);
- rowCnt = 0;
- for (Entry<Key,Value> entry : s) {
- char rowStart = entry.getKey().getRow().toString().charAt(0);
- Assert.assertTrue(rowStart >= '2');
- rowCnt++;
- }
- s.close();
- Assert.assertEquals(55, rowCnt);
-
- // test null start and end
- // deletes everything still left
- to.deleteRows("test2", null, null);
- s = conn.createScanner("test2", Authorizations.EMPTY);
- rowCnt = Iterators.size(s.iterator());
- s.close();
- to.delete("test2");
- Assert.assertEquals(0, rowCnt);
-
- }
-
- @Test
- public void testTableIdMap() throws Exception {
- TableOperations tops = conn.tableOperations();
- tops.create("foo");
-
- // Should get a table ID, not the table name
- Assert.assertNotEquals("foo", tops.tableIdMap().get("foo"));
- }
-}
diff --git a/core/src/test/java/org/apache/accumulo/core/client/mock/TestBatchScanner821.java b/core/src/test/java/org/apache/accumulo/core/client/mock/TestBatchScanner821.java
deleted file mode 100644
index a2fd64f..0000000
--- a/core/src/test/java/org/apache/accumulo/core/client/mock/TestBatchScanner821.java
+++ /dev/null
@@ -1,78 +0,0 @@
-/*
- * 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.core.client.mock;
-
-import static org.junit.Assert.assertEquals;
-
-import java.util.Collections;
-import java.util.Map.Entry;
-
-import org.apache.accumulo.core.client.BatchScanner;
-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.IteratorSetting;
-import org.apache.accumulo.core.client.security.tokens.PasswordToken;
-import org.apache.accumulo.core.data.Key;
-import org.apache.accumulo.core.data.Mutation;
-import org.apache.accumulo.core.data.Range;
-import org.apache.accumulo.core.data.Value;
-import org.apache.accumulo.core.iterators.WrappingIterator;
-import org.apache.accumulo.core.security.Authorizations;
-import org.apache.hadoop.io.Text;
-import org.junit.Test;
-
-@Deprecated
-public class TestBatchScanner821 {
-
- public static class TransformIterator extends WrappingIterator {
-
- @Override
- public Key getTopKey() {
- Key k = getSource().getTopKey();
- return new Key(new Text(k.getRow().toString().toLowerCase()), k.getColumnFamily(),
- k.getColumnQualifier(), k.getColumnVisibility(), k.getTimestamp());
- }
- }
-
- @Test
- public void test() throws Exception {
- MockInstance inst = new MockInstance();
- Connector conn = inst.getConnector("root", new PasswordToken(""));
- conn.tableOperations().create("test");
- BatchWriter bw = conn.createBatchWriter("test", new BatchWriterConfig());
- for (String row : "A,B,C,D".split(",")) {
- Mutation m = new Mutation(row);
- m.put("cf", "cq", "");
- bw.addMutation(m);
- }
- bw.flush();
- BatchScanner bs = conn.createBatchScanner("test", Authorizations.EMPTY, 1);
- IteratorSetting cfg = new IteratorSetting(100, TransformIterator.class);
- bs.addScanIterator(cfg);
- bs.setRanges(Collections.singletonList(new Range("A", "Z")));
- StringBuilder sb = new StringBuilder();
- String comma = "";
- for (Entry<Key,Value> entry : bs) {
- sb.append(comma);
- sb.append(entry.getKey().getRow());
- comma = ",";
- }
- assertEquals("a,b,c,d", sb.toString());
- }
-
-}
diff --git a/core/src/test/java/org/apache/accumulo/core/security/CredentialsTest.java b/core/src/test/java/org/apache/accumulo/core/security/CredentialsTest.java
index 38173b4..6709651 100644
--- a/core/src/test/java/org/apache/accumulo/core/security/CredentialsTest.java
+++ b/core/src/test/java/org/apache/accumulo/core/security/CredentialsTest.java
@@ -19,7 +19,6 @@ package org.apache.accumulo.core.security;
import static java.nio.charset.StandardCharsets.UTF_8;
import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotEquals;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
@@ -27,9 +26,7 @@ import static org.junit.Assert.fail;
import javax.security.auth.DestroyFailedException;
-import org.apache.accumulo.core.client.AccumuloException;
import org.apache.accumulo.core.client.AccumuloSecurityException;
-import org.apache.accumulo.core.client.Connector;
import org.apache.accumulo.core.client.Instance;
import org.apache.accumulo.core.client.impl.Credentials;
import org.apache.accumulo.core.client.security.SecurityErrorCode;
@@ -37,7 +34,6 @@ import org.apache.accumulo.core.client.security.tokens.AuthenticationToken.Authe
import org.apache.accumulo.core.client.security.tokens.NullToken;
import org.apache.accumulo.core.client.security.tokens.PasswordToken;
import org.apache.accumulo.core.security.thrift.TCredentials;
-import org.apache.accumulo.core.util.DeprecationUtil;
import org.easymock.EasyMock;
import org.junit.Before;
import org.junit.Rule;
@@ -90,25 +86,6 @@ public class CredentialsTest {
}
@Test
- public void testMockConnector()
- throws AccumuloException, DestroyFailedException, AccumuloSecurityException {
- Instance inst = DeprecationUtil.makeMockInstance(test.getMethodName());
- Connector rootConnector = inst.getConnector("root", new PasswordToken());
- PasswordToken testToken = new PasswordToken("testPass");
- rootConnector.securityOperations().createLocalUser("testUser", testToken);
-
- assertFalse(testToken.isDestroyed());
- testToken.destroy();
- assertTrue(testToken.isDestroyed());
- try {
- inst.getConnector("testUser", testToken);
- fail();
- } catch (AccumuloSecurityException e) {
- assertEquals(e.getSecurityErrorCode(), SecurityErrorCode.TOKEN_EXPIRED);
- }
- }
-
- @Test
public void testEqualsAndHashCode() {
Credentials nullNullCreds = new Credentials(null, null);
Credentials abcNullCreds = new Credentials("abc", new NullToken());
diff --git a/proxy/proxy.properties b/proxy/proxy.properties
index ad5b77e..3bb3b28 100644
--- a/proxy/proxy.properties
+++ b/proxy/proxy.properties
@@ -15,8 +15,6 @@
# Port to run proxy on
port=42424
-# Set to true if you wish to an in-memory Mock instance
-useMockInstance=false
# Set to true if you wish to use an Mini Accumulo Cluster
useMiniAccumulo=false
protocolFactory=org.apache.thrift.protocol.TCompactProtocol$Factory
diff --git a/proxy/src/main/java/org/apache/accumulo/proxy/Proxy.java b/proxy/src/main/java/org/apache/accumulo/proxy/Proxy.java
index a00d635..0dea95d 100644
--- a/proxy/src/main/java/org/apache/accumulo/proxy/Proxy.java
+++ b/proxy/src/main/java/org/apache/accumulo/proxy/Proxy.java
@@ -62,8 +62,6 @@ public class Proxy implements KeywordExecutable {
public static final String USE_MINI_ACCUMULO_KEY = "useMiniAccumulo";
public static final String USE_MINI_ACCUMULO_DEFAULT = "false";
- public static final String USE_MOCK_INSTANCE_KEY = "useMockInstance";
- public static final String USE_MOCK_INSTANCE_DEFAULT = "false";
public static final String THRIFT_THREAD_POOL_SIZE_KEY = "numThreads";
// Default number of threads from THsHaServer.Args
public static final String THRIFT_THREAD_POOL_SIZE_DEFAULT = "5";
@@ -131,12 +129,10 @@ public class Proxy implements KeywordExecutable {
boolean useMini = Boolean
.parseBoolean(proxyProps.getProperty(USE_MINI_ACCUMULO_KEY, USE_MINI_ACCUMULO_DEFAULT));
- boolean useMock = Boolean
- .parseBoolean(proxyProps.getProperty(USE_MOCK_INSTANCE_KEY, USE_MOCK_INSTANCE_DEFAULT));
- if (!useMini && !useMock && clientProps == null) {
+ if (!useMini && clientProps == null) {
System.err.println("The '-c' option must be set with an accumulo-client.properties file or"
- + " proxy.properties must contain either useMiniAccumulo=true or useMockInstance=true");
+ + " proxy.properties must contain either useMiniAccumulo=true");
System.exit(1);
}
diff --git a/proxy/src/main/java/org/apache/accumulo/proxy/ProxyServer.java b/proxy/src/main/java/org/apache/accumulo/proxy/ProxyServer.java
index d9fc9d7..93c9d49 100644
--- a/proxy/src/main/java/org/apache/accumulo/proxy/ProxyServer.java
+++ b/proxy/src/main/java/org/apache/accumulo/proxy/ProxyServer.java
@@ -86,7 +86,6 @@ import org.apache.accumulo.core.security.NamespacePermission;
import org.apache.accumulo.core.security.SystemPermission;
import org.apache.accumulo.core.security.TablePermission;
import org.apache.accumulo.core.util.ByteBufferUtil;
-import org.apache.accumulo.core.util.DeprecationUtil;
import org.apache.accumulo.core.util.TextUtil;
import org.apache.accumulo.proxy.thrift.AccumuloProxy;
import org.apache.accumulo.proxy.thrift.BatchScanOptions;
@@ -191,14 +190,9 @@ public class ProxyServer implements AccumuloProxy.Iface {
public ProxyServer(Properties props) {
- String useMock = props.getProperty("useMockInstance");
- if (useMock != null && Boolean.parseBoolean(useMock))
- instance = DeprecationUtil.makeMockInstance(this.getClass().getName());
- else {
- @SuppressWarnings("deprecation")
- Instance i = new ZooKeeperInstance(ClientConfConverter.toClientConf(props));
- instance = i;
- }
+ @SuppressWarnings("deprecation")
+ Instance i = new ZooKeeperInstance(ClientConfConverter.toClientConf(props));
+ instance = i;
try {
String tokenProp = props.getProperty("tokenClass", PasswordToken.class.getName());
diff --git a/server/base/src/main/java/org/apache/accumulo/server/AccumuloServerContext.java b/server/base/src/main/java/org/apache/accumulo/server/AccumuloServerContext.java
index 1640cbd..3d37852 100644
--- a/server/base/src/main/java/org/apache/accumulo/server/AccumuloServerContext.java
+++ b/server/base/src/main/java/org/apache/accumulo/server/AccumuloServerContext.java
@@ -28,11 +28,9 @@ import org.apache.accumulo.core.client.ZooKeeperInstance;
import org.apache.accumulo.core.client.impl.ClientContext;
import org.apache.accumulo.core.client.impl.ConnectorImpl;
import org.apache.accumulo.core.client.impl.Credentials;
-import org.apache.accumulo.core.client.security.tokens.PasswordToken;
import org.apache.accumulo.core.conf.AccumuloConfiguration;
import org.apache.accumulo.core.conf.Property;
import org.apache.accumulo.core.rpc.SslConnectionParams;
-import org.apache.accumulo.core.util.DeprecationUtil;
import org.apache.accumulo.server.client.HdfsZooInstance;
import org.apache.accumulo.server.conf.ServerConfigurationFactory;
import org.apache.accumulo.server.rpc.SaslServerConnectionParams;
@@ -63,7 +61,7 @@ public class AccumuloServerContext extends ClientContext {
*/
private AccumuloServerContext(Instance instance, ServerConfigurationFactory confFactory,
AuthenticationTokenSecretManager secretManager) {
- super(instance, getCredentials(instance), confFactory.getSystemConfiguration());
+ super(instance, SystemCredentials.get(instance), confFactory.getSystemConfiguration());
this.confFactory = confFactory;
this.secretManager = secretManager;
if (null != getSaslParams()) {
@@ -97,17 +95,6 @@ public class AccumuloServerContext extends ClientContext {
}
/**
- * Get the credentials to use for this instance so it can be passed to the superclass during
- * construction.
- */
- private static Credentials getCredentials(Instance instance) {
- if (DeprecationUtil.isMockInstance(instance)) {
- return new Credentials("mockSystemUser", new PasswordToken("mockSystemPassword"));
- }
- return SystemCredentials.get(instance);
- }
-
- /**
* Retrieve the configuration factory used to construct this context
*/
public ServerConfigurationFactory getServerConfigurationFactory() {
diff --git a/shell/src/main/java/org/apache/accumulo/shell/Shell.java b/shell/src/main/java/org/apache/accumulo/shell/Shell.java
index 6baae6d..98cd953 100644
--- a/shell/src/main/java/org/apache/accumulo/shell/Shell.java
+++ b/shell/src/main/java/org/apache/accumulo/shell/Shell.java
@@ -62,7 +62,6 @@ import org.apache.accumulo.core.data.thrift.TConstraintViolationSummary;
import org.apache.accumulo.core.tabletserver.thrift.ConstraintViolationException;
import org.apache.accumulo.core.trace.DistributedTrace;
import org.apache.accumulo.core.util.BadArgumentException;
-import org.apache.accumulo.core.util.DeprecationUtil;
import org.apache.accumulo.core.util.format.DefaultFormatter;
import org.apache.accumulo.core.util.format.Formatter;
import org.apache.accumulo.core.util.format.FormatterConfig;
@@ -337,9 +336,7 @@ public class Shell extends ShellOptions implements KeywordExecutable {
}
try {
- if (!options.isFake()) {
- DistributedTrace.enable(InetAddress.getLocalHost().getHostName(), "shell", properties);
- }
+ DistributedTrace.enable(InetAddress.getLocalHost().getHostName(), "shell", properties);
this.setTableName("");
connector = instance.getConnector(user, token);
@@ -428,21 +425,17 @@ public class Shell extends ShellOptions implements KeywordExecutable {
protected void setInstance(ShellOptionsJC options) {
// should only be one set of instance options set
instance = null;
- if (options.isFake()) {
- instance = DeprecationUtil.makeMockInstance("fake");
+ String instanceName, hosts;
+ if (options.getZooKeeperInstance().size() > 0) {
+ List<String> zkOpts = options.getZooKeeperInstance();
+ instanceName = zkOpts.get(0);
+ hosts = zkOpts.get(1);
} else {
- String instanceName, hosts;
- if (options.getZooKeeperInstance().size() > 0) {
- List<String> zkOpts = options.getZooKeeperInstance();
- instanceName = zkOpts.get(0);
- hosts = zkOpts.get(1);
- } else {
- instanceName = options.getZooKeeperInstanceName();
- hosts = options.getZooKeeperHosts();
- }
- final Properties properties = options.getClientProperties();
- instance = getZooInstance(instanceName, hosts, properties);
+ instanceName = options.getZooKeeperInstanceName();
+ hosts = options.getZooKeeperHosts();
}
+ final Properties properties = options.getClientProperties();
+ instance = getZooInstance(instanceName, hosts, properties);
}
/**
diff --git a/shell/src/main/java/org/apache/accumulo/shell/ShellOptionsJC.java b/shell/src/main/java/org/apache/accumulo/shell/ShellOptionsJC.java
index 86032f0..25aec13 100644
--- a/shell/src/main/java/org/apache/accumulo/shell/ShellOptionsJC.java
+++ b/shell/src/main/java/org/apache/accumulo/shell/ShellOptionsJC.java
@@ -132,9 +132,6 @@ public class ShellOptionsJC {
@Parameter(names = "--debug", description = "enables client debugging")
private boolean debugEnabled;
- @Parameter(names = "--fake", description = "fake a connection to accumulo")
- private boolean fake;
-
@Parameter(names = {"-?", "--help"}, help = true, description = "display this help")
private boolean helpEnabled;
@@ -226,10 +223,6 @@ public class ShellOptionsJC {
return debugEnabled;
}
- public boolean isFake() {
- return fake;
- }
-
public boolean isHelpEnabled() {
return helpEnabled;
}
diff --git a/shell/src/main/java/org/apache/accumulo/shell/mock/MockShell.java b/shell/src/main/java/org/apache/accumulo/shell/mock/MockShell.java
deleted file mode 100644
index 5790241..0000000
--- a/shell/src/main/java/org/apache/accumulo/shell/mock/MockShell.java
+++ /dev/null
@@ -1,158 +0,0 @@
-/*
- * 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.mock;
-
-import static java.nio.charset.StandardCharsets.UTF_8;
-
-import java.io.ByteArrayInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-
-import org.apache.accumulo.core.client.AccumuloException;
-import org.apache.accumulo.core.client.AccumuloSecurityException;
-import org.apache.accumulo.core.client.TableNotFoundException;
-import org.apache.accumulo.shell.Shell;
-import org.apache.accumulo.shell.ShellOptionsJC;
-import org.apache.commons.cli.CommandLine;
-import org.apache.commons.vfs2.FileSystemException;
-
-import jline.console.ConsoleReader;
-
-/**
- * An Accumulo Shell implementation that allows a developer to attach an InputStream and Writer to
- * the Shell for testing purposes.
- *
- * @deprecated since 1.8.0; use MiniAccumuloCluster or a standard mock framework instead.
- */
-@Deprecated
-public class MockShell extends Shell {
- private static final String NEWLINE = "\n";
-
- protected InputStream in;
- protected OutputStream out;
-
- public MockShell(InputStream in, OutputStream out) throws IOException {
- super();
- this.in = in;
- this.out = out;
- }
-
- @Override
- public boolean config(String... args) throws IOException {
- // If configuring the shell failed, fail quickly
- if (!super.config(args)) {
- return false;
- }
-
- // Update the ConsoleReader with the input and output "redirected"
- try {
- this.reader = new ConsoleReader(in, out);
- } catch (Exception e) {
- printException(e);
- return false;
- }
-
- // Don't need this for testing purposes
- this.reader.setHistoryEnabled(false);
- this.reader.setPaginationEnabled(false);
-
- // Make the parsing from the client easier;
- this.verbose = false;
- return true;
- }
-
- @Override
- protected void setInstance(ShellOptionsJC options) {
- // We always want a MockInstance for this test
- instance = new org.apache.accumulo.core.client.mock.MockInstance();
- }
-
- @Override
- public int start() throws IOException {
- String input;
- if (isVerbose())
- printInfo();
-
- if (execFile != null) {
- try (java.util.Scanner scanner = new java.util.Scanner(execFile, UTF_8.name())) {
- while (scanner.hasNextLine() && !hasExited()) {
- execCommand(scanner.nextLine(), true, isVerbose());
- }
- }
- } else if (execCommand != null) {
- for (String command : execCommand.split("\n")) {
- execCommand(command, true, isVerbose());
- }
- return exitCode;
- }
-
- while (true) {
- if (hasExited())
- return exitCode;
-
- reader.setPrompt(getDefaultPrompt());
- input = reader.readLine();
- if (input == null) {
- reader.println();
- return exitCode;
- } // user canceled
-
- execCommand(input, false, false);
- }
- }
-
- /**
- * @param in
- * the in to set
- */
- public void setConsoleInputStream(InputStream in) {
- this.in = in;
- }
-
- /**
- * @param out
- * the output stream to set
- */
- public void setConsoleWriter(OutputStream out) {
- this.out = out;
- }
-
- @Override
- public ClassLoader getClassLoader(final CommandLine cl, final Shell shellState)
- throws AccumuloException, TableNotFoundException, AccumuloSecurityException, IOException,
- FileSystemException {
- return MockShell.class.getClassLoader();
- }
-
- /**
- * Convenience method to create the byte-array to hand to the console
- *
- * @param commands
- * An array of commands to run
- * @return A byte[] input stream which can be handed to the console.
- */
- public static ByteArrayInputStream makeCommands(String... commands) {
- StringBuilder sb = new StringBuilder(commands.length * 8);
-
- for (String command : commands) {
- sb.append(command).append(NEWLINE);
- }
-
- return new ByteArrayInputStream(sb.toString().getBytes(UTF_8));
- }
-}
diff --git a/shell/src/test/java/org/apache/accumulo/shell/ShellConfigTest.java b/shell/src/test/java/org/apache/accumulo/shell/ShellConfigTest.java
index 9782f30..cc29383 100644
--- a/shell/src/test/java/org/apache/accumulo/shell/ShellConfigTest.java
+++ b/shell/src/test/java/org/apache/accumulo/shell/ShellConfigTest.java
@@ -24,12 +24,12 @@ import java.io.File;
import java.io.FileDescriptor;
import java.io.FileInputStream;
import java.io.IOException;
+import java.io.OutputStream;
import java.io.PrintStream;
import java.nio.file.Files;
import java.util.Properties;
import org.apache.accumulo.core.conf.ClientProperty;
-import org.apache.accumulo.shell.ShellTest.TestOutputStream;
import org.apache.log4j.Level;
import org.junit.After;
import org.junit.Before;
@@ -40,6 +40,24 @@ import org.slf4j.LoggerFactory;
import jline.console.ConsoleReader;
public class ShellConfigTest {
+
+ public static class TestOutputStream extends OutputStream {
+ StringBuilder sb = new StringBuilder();
+
+ @Override
+ public void write(int b) throws IOException {
+ sb.append((char) (0xff & b));
+ }
+
+ public String get() {
+ return sb.toString();
+ }
+
+ public void clear() {
+ sb.setLength(0);
+ }
+ }
+
TestOutputStream output;
Shell shell;
PrintStream out;
diff --git a/shell/src/test/java/org/apache/accumulo/shell/ShellSetInstanceTest.java b/shell/src/test/java/org/apache/accumulo/shell/ShellSetInstanceTest.java
index ebb1e12..b0e48db 100644
--- a/shell/src/test/java/org/apache/accumulo/shell/ShellSetInstanceTest.java
+++ b/shell/src/test/java/org/apache/accumulo/shell/ShellSetInstanceTest.java
@@ -40,7 +40,6 @@ import org.apache.accumulo.core.zookeeper.ZooUtil;
import org.apache.log4j.Level;
import org.junit.After;
import org.junit.AfterClass;
-import org.junit.Assert;
import org.junit.Assume;
import org.junit.Before;
import org.junit.BeforeClass;
@@ -115,18 +114,6 @@ public class ShellSetInstanceTest {
SiteConfiguration.clearInstance();
}
- @Deprecated
- @Test
- public void testSetInstance_Fake() throws Exception {
- ShellOptionsJC opts = createMock(ShellOptionsJC.class);
- expect(opts.isFake()).andReturn(true);
- replay(opts);
-
- shell.setInstance(opts);
- Assert.assertTrue(
- shell.getInstance() instanceof org.apache.accumulo.core.client.mock.MockInstance);
- }
-
@Test
public void testSetInstance_ZKInstance_DashZ() throws Exception {
testSetInstance_ZKInstance(true);
@@ -140,7 +127,6 @@ public class ShellSetInstanceTest {
private void testSetInstance_ZKInstance(boolean dashZ) throws Exception {
Properties props = createMock(Properties.class);
ShellOptionsJC opts = createMock(ShellOptionsJC.class);
- expect(opts.isFake()).andReturn(false);
expect(opts.getClientProperties()).andReturn(new Properties());
expect(props.getProperty(Property.GENERAL_SECURITY_CREDENTIAL_PROVIDER_PATHS.getKey()))
.andReturn(null);
diff --git a/shell/src/test/java/org/apache/accumulo/shell/ShellTest.java b/test/src/main/java/org/apache/accumulo/test/ShellIT.java
similarity index 92%
rename from shell/src/test/java/org/apache/accumulo/shell/ShellTest.java
rename to test/src/main/java/org/apache/accumulo/test/ShellIT.java
index 7095114..a837a51 100644
--- a/shell/src/test/java/org/apache/accumulo/shell/ShellTest.java
+++ b/test/src/main/java/org/apache/accumulo/test/ShellIT.java
@@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.accumulo.shell;
+package org.apache.accumulo.test;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
@@ -31,17 +31,41 @@ import java.util.Date;
import java.util.List;
import java.util.TimeZone;
+import org.apache.accumulo.harness.SharedMiniClusterBase;
+import org.apache.accumulo.shell.Shell;
+import org.apache.accumulo.test.categories.MiniClusterOnlyTests;
+import org.apache.accumulo.test.categories.SunnyDayTests;
import org.apache.log4j.Level;
import org.junit.After;
+import org.junit.AfterClass;
import org.junit.Before;
+import org.junit.BeforeClass;
import org.junit.Test;
+import org.junit.experimental.categories.Category;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import jline.console.ConsoleReader;
-public class ShellTest {
- private static final Logger log = LoggerFactory.getLogger(ShellTest.class);
+@Category({MiniClusterOnlyTests.class, SunnyDayTests.class})
+public class ShellIT extends SharedMiniClusterBase {
+
+ @Override
+ protected int defaultTimeoutSeconds() {
+ return 30;
+ }
+
+ @BeforeClass
+ public static void setup() throws Exception {
+ SharedMiniClusterBase.startMiniCluster();
+ }
+
+ @AfterClass
+ public static void teardown() throws Exception {
+ SharedMiniClusterBase.stopMiniCluster();
+ }
+
+ private static final Logger log = LoggerFactory.getLogger(ShellIT.class);
public static class TestOutputStream extends OutputStream {
StringBuilder sb = new StringBuilder();
@@ -125,7 +149,7 @@ public class ShellTest {
}
@Before
- public void setup() throws IOException {
+ public void setupShell() throws IOException {
TimeZone.setDefault(TimeZone.getTimeZone("UTC"));
Shell.log.setLevel(Level.OFF);
output = new TestOutputStream();
@@ -133,11 +157,12 @@ public class ShellTest {
config = Files.createTempFile(null, null).toFile();
shell = new Shell(new ConsoleReader(input, output));
shell.setLogErrorsToConsole();
- shell.config("--config-file", config.toString(), "--fake", "-u", "test", "-p", "secret");
+ shell.config("--config-file", config.toString(), "-u", "root", "-p", getRootPassword(), "-zi",
+ getCluster().getInstanceName(), "-zh", getCluster().getZooKeepers());
}
@After
- public void teardown() {
+ public void teardownShell() {
if (config.exists()) {
if (!config.delete()) {
log.error("Unable to delete {}", config);
@@ -370,8 +395,9 @@ public class ShellTest {
@Test
public void execFileTest() throws IOException {
Shell.log.debug("Starting exec file test --------------------------");
- shell.config("--config-file", config.toString(), "--fake", "-u", "test", "-p", "secret", "-f",
- "src/test/resources/shelltest.txt");
+ shell.config("--config-file", config.toString(), "-u", "root", "-p", getRootPassword(), "-zi",
+ getCluster().getInstanceName(), "-zh", getCluster().getZooKeepers(), "-f",
+ "src/main/resources/shellit.txt");
assertEquals(0, shell.start());
assertGoodExit("Unknown command", false);
}
diff --git a/test/src/main/java/org/apache/accumulo/test/functional/KerberosProxyIT.java b/test/src/main/java/org/apache/accumulo/test/functional/KerberosProxyIT.java
index d7ee459..7fa12b8 100644
--- a/test/src/main/java/org/apache/accumulo/test/functional/KerberosProxyIT.java
+++ b/test/src/main/java/org/apache/accumulo/test/functional/KerberosProxyIT.java
@@ -255,7 +255,6 @@ public class KerberosProxyIT extends AccumuloITBase {
assertTrue("Failed to delete proxy.properties file", proxyPropertiesFile.delete());
}
Properties proxyProperties = new Properties();
- proxyProperties.setProperty("useMockInstance", "false");
proxyProperties.setProperty("useMiniAccumulo", "false");
proxyProperties.setProperty("protocolFactory", TCompactProtocol.Factory.class.getName());
proxyProperties.setProperty("tokenClass", KerberosToken.class.getName());
diff --git a/test/src/main/java/org/apache/accumulo/test/proxy/TestProxyInstanceOperations.java b/test/src/main/java/org/apache/accumulo/test/proxy/TestProxyInstanceOperations.java
index 2b8c189..e4aca9b 100644
--- a/test/src/main/java/org/apache/accumulo/test/proxy/TestProxyInstanceOperations.java
+++ b/test/src/main/java/org/apache/accumulo/test/proxy/TestProxyInstanceOperations.java
@@ -47,7 +47,6 @@ public class TestProxyInstanceOperations {
@BeforeClass
public static void setup() throws Exception {
Properties proxyProps = new Properties();
- proxyProps.setProperty("useMockInstance", "true");
proxyProps.put("tokenClass", PasswordToken.class.getName());
proxy = Proxy.createProxyServer(HostAndPort.fromParts("localhost", port),
diff --git a/test/src/main/java/org/apache/accumulo/test/proxy/TestProxyNamespaceOperations.java b/test/src/main/java/org/apache/accumulo/test/proxy/TestProxyNamespaceOperations.java
index c050bb4..526fe49 100644
--- a/test/src/main/java/org/apache/accumulo/test/proxy/TestProxyNamespaceOperations.java
+++ b/test/src/main/java/org/apache/accumulo/test/proxy/TestProxyNamespaceOperations.java
@@ -56,7 +56,6 @@ public class TestProxyNamespaceOperations {
@BeforeClass
public static void setup() throws Exception {
Properties prop = new Properties();
- prop.setProperty("useMockInstance", "true");
prop.put("tokenClass", PasswordToken.class.getName());
proxy = Proxy.createProxyServer(HostAndPort.fromParts("localhost", port),
diff --git a/test/src/main/java/org/apache/accumulo/test/proxy/TestProxyReadWrite.java b/test/src/main/java/org/apache/accumulo/test/proxy/TestProxyReadWrite.java
index 3867ba4..685c435 100644
--- a/test/src/main/java/org/apache/accumulo/test/proxy/TestProxyReadWrite.java
+++ b/test/src/main/java/org/apache/accumulo/test/proxy/TestProxyReadWrite.java
@@ -60,7 +60,6 @@ public class TestProxyReadWrite {
@BeforeClass
public static void setup() throws Exception {
Properties prop = new Properties();
- prop.setProperty("useMockInstance", "true");
prop.put("tokenClass", PasswordToken.class.getName());
proxy = Proxy.createProxyServer(HostAndPort.fromParts("localhost", port),
diff --git a/test/src/main/java/org/apache/accumulo/test/proxy/TestProxySecurityOperations.java b/test/src/main/java/org/apache/accumulo/test/proxy/TestProxySecurityOperations.java
index 35b0ad5..d1f905f 100644
--- a/test/src/main/java/org/apache/accumulo/test/proxy/TestProxySecurityOperations.java
+++ b/test/src/main/java/org/apache/accumulo/test/proxy/TestProxySecurityOperations.java
@@ -58,7 +58,6 @@ public class TestProxySecurityOperations {
@BeforeClass
public static void setup() throws Exception {
Properties prop = new Properties();
- prop.setProperty("useMockInstance", "true");
prop.put("tokenClass", PasswordToken.class.getName());
proxy = Proxy.createProxyServer(HostAndPort.fromParts("localhost", port),
diff --git a/test/src/main/java/org/apache/accumulo/test/proxy/TestProxyTableOperations.java b/test/src/main/java/org/apache/accumulo/test/proxy/TestProxyTableOperations.java
index fbd07c7..b8e14e2 100644
--- a/test/src/main/java/org/apache/accumulo/test/proxy/TestProxyTableOperations.java
+++ b/test/src/main/java/org/apache/accumulo/test/proxy/TestProxyTableOperations.java
@@ -55,7 +55,6 @@ public class TestProxyTableOperations {
@BeforeClass
public static void setup() throws Exception {
Properties prop = new Properties();
- prop.setProperty("useMockInstance", "true");
prop.put("tokenClass", PasswordToken.class.getName());
proxy = Proxy.createProxyServer(HostAndPort.fromParts("localhost", port),
diff --git a/shell/src/test/resources/shelltest.txt b/test/src/main/resources/shellit.txt
similarity index 100%
rename from shell/src/test/resources/shelltest.txt
rename to test/src/main/resources/shellit.txt
diff --git a/test/src/test/java/org/apache/accumulo/test/security/KerberosTokenEmbeddedKDCTest.java b/test/src/test/java/org/apache/accumulo/test/security/KerberosTokenEmbeddedKDCTest.java
index ae101d0..dbda155 100644
--- a/test/src/test/java/org/apache/accumulo/test/security/KerberosTokenEmbeddedKDCTest.java
+++ b/test/src/test/java/org/apache/accumulo/test/security/KerberosTokenEmbeddedKDCTest.java
@@ -43,7 +43,7 @@ public class KerberosTokenEmbeddedKDCTest {
@Rule
public TestName testName = new TestName();
- private static TestingKdc kdc;
+ private volatile static TestingKdc kdc;
@BeforeClass
public static void startKdc() throws Exception {