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 2016/06/30 20:41:49 UTC
[6/8] accumulo git commit: ACCUMULO-2589 Drop deprecated code from 1.x
http://git-wip-us.apache.org/repos/asf/accumulo/blob/b69291a3/core/src/main/java/org/apache/accumulo/core/client/mapreduce/lib/util/OutputConfigurator.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/client/mapreduce/lib/util/OutputConfigurator.java b/core/src/main/java/org/apache/accumulo/core/client/mapreduce/lib/util/OutputConfigurator.java
deleted file mode 100644
index 39163a6..0000000
--- a/core/src/main/java/org/apache/accumulo/core/client/mapreduce/lib/util/OutputConfigurator.java
+++ /dev/null
@@ -1,196 +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.mapreduce.lib.util;
-
-import org.apache.accumulo.core.client.BatchWriter;
-import org.apache.accumulo.core.client.BatchWriterConfig;
-import org.apache.hadoop.conf.Configuration;
-
-/**
- * @deprecated since 1.6.0; Configure your job with the appropriate InputFormat or OutputFormat.
- * @since 1.5.0
- */
-@Deprecated
-public class OutputConfigurator extends ConfiguratorBase {
-
- /**
- * Configuration keys for {@link BatchWriter}.
- *
- * @deprecated since 1.6.0; Configure your job with the appropriate InputFormat or OutputFormat.
- * @since 1.5.0
- */
- @Deprecated
- public static enum WriteOpts {
- DEFAULT_TABLE_NAME, BATCH_WRITER_CONFIG
- }
-
- /**
- * Configuration keys for various features.
- *
- * @deprecated since 1.6.0; Configure your job with the appropriate InputFormat or OutputFormat.
- * @since 1.5.0
- */
- @Deprecated
- public static enum Features {
- CAN_CREATE_TABLES, SIMULATION_MODE
- }
-
- /**
- * Sets the default table name to use if one emits a null in place of a table name for a given mutation. Table names can only be alpha-numeric and
- * underscores.
- *
- * @param implementingClass
- * the class whose name will be used as a prefix for the property configuration key
- * @param conf
- * the Hadoop configuration object to configure
- * @param tableName
- * the table to use when the tablename is null in the write call
- * @deprecated since 1.6.0; Configure your job with the appropriate InputFormat or OutputFormat.
- * @since 1.5.0
- */
- @Deprecated
- public static void setDefaultTableName(Class<?> implementingClass, Configuration conf, String tableName) {
- org.apache.accumulo.core.client.mapreduce.lib.impl.OutputConfigurator.setDefaultTableName(implementingClass, conf, tableName);
- }
-
- /**
- * Gets the default table name from the configuration.
- *
- * @param implementingClass
- * the class whose name will be used as a prefix for the property configuration key
- * @param conf
- * the Hadoop configuration object to configure
- * @return the default table name
- * @deprecated since 1.6.0; Configure your job with the appropriate InputFormat or OutputFormat.
- * @since 1.5.0
- * @see #setDefaultTableName(Class, Configuration, String)
- */
- @Deprecated
- public static String getDefaultTableName(Class<?> implementingClass, Configuration conf) {
- return org.apache.accumulo.core.client.mapreduce.lib.impl.OutputConfigurator.getDefaultTableName(implementingClass, conf);
- }
-
- /**
- * Sets the configuration for for the job's {@link BatchWriter} instances. If not set, a new {@link BatchWriterConfig}, with sensible built-in defaults is
- * used. Setting the configuration multiple times overwrites any previous configuration.
- *
- * @param implementingClass
- * the class whose name will be used as a prefix for the property configuration key
- * @param conf
- * the Hadoop configuration object to configure
- * @param bwConfig
- * the configuration for the {@link BatchWriter}
- * @deprecated since 1.6.0; Configure your job with the appropriate InputFormat or OutputFormat.
- * @since 1.5.0
- */
- @Deprecated
- public static void setBatchWriterOptions(Class<?> implementingClass, Configuration conf, BatchWriterConfig bwConfig) {
- org.apache.accumulo.core.client.mapreduce.lib.impl.OutputConfigurator.setBatchWriterOptions(implementingClass, conf, bwConfig);
- }
-
- /**
- * Gets the {@link BatchWriterConfig} settings.
- *
- * @param implementingClass
- * the class whose name will be used as a prefix for the property configuration key
- * @param conf
- * the Hadoop configuration object to configure
- * @return the configuration object
- * @deprecated since 1.6.0; Configure your job with the appropriate InputFormat or OutputFormat.
- * @since 1.5.0
- * @see #setBatchWriterOptions(Class, Configuration, BatchWriterConfig)
- */
- @Deprecated
- public static BatchWriterConfig getBatchWriterOptions(Class<?> implementingClass, Configuration conf) {
- return org.apache.accumulo.core.client.mapreduce.lib.impl.OutputConfigurator.getBatchWriterOptions(implementingClass, conf);
- }
-
- /**
- * Sets the directive to create new tables, as necessary. Table names can only be alpha-numeric and underscores.
- *
- * <p>
- * By default, this feature is <b>disabled</b>.
- *
- * @param implementingClass
- * the class whose name will be used as a prefix for the property configuration key
- * @param conf
- * the Hadoop configuration object to configure
- * @param enableFeature
- * the feature is enabled if true, disabled otherwise
- * @deprecated since 1.6.0; Configure your job with the appropriate InputFormat or OutputFormat.
- * @since 1.5.0
- */
- @Deprecated
- public static void setCreateTables(Class<?> implementingClass, Configuration conf, boolean enableFeature) {
- org.apache.accumulo.core.client.mapreduce.lib.impl.OutputConfigurator.setCreateTables(implementingClass, conf, enableFeature);
- }
-
- /**
- * Determines whether tables are permitted to be created as needed.
- *
- * @param implementingClass
- * the class whose name will be used as a prefix for the property configuration key
- * @param conf
- * the Hadoop configuration object to configure
- * @return true if the feature is disabled, false otherwise
- * @deprecated since 1.6.0; Configure your job with the appropriate InputFormat or OutputFormat.
- * @since 1.5.0
- * @see #setCreateTables(Class, Configuration, boolean)
- */
- @Deprecated
- public static Boolean canCreateTables(Class<?> implementingClass, Configuration conf) {
- return org.apache.accumulo.core.client.mapreduce.lib.impl.OutputConfigurator.canCreateTables(implementingClass, conf);
- }
-
- /**
- * Sets the directive to use simulation mode for this job. In simulation mode, no output is produced. This is useful for testing.
- *
- * <p>
- * By default, this feature is <b>disabled</b>.
- *
- * @param implementingClass
- * the class whose name will be used as a prefix for the property configuration key
- * @param conf
- * the Hadoop configuration object to configure
- * @param enableFeature
- * the feature is enabled if true, disabled otherwise
- * @deprecated since 1.6.0; Configure your job with the appropriate InputFormat or OutputFormat.
- * @since 1.5.0
- */
- @Deprecated
- public static void setSimulationMode(Class<?> implementingClass, Configuration conf, boolean enableFeature) {
- org.apache.accumulo.core.client.mapreduce.lib.impl.OutputConfigurator.setSimulationMode(implementingClass, conf, enableFeature);
- }
-
- /**
- * Determines whether this feature is enabled.
- *
- * @param implementingClass
- * the class whose name will be used as a prefix for the property configuration key
- * @param conf
- * the Hadoop configuration object to configure
- * @return true if the feature is enabled, false otherwise
- * @deprecated since 1.6.0; Configure your job with the appropriate InputFormat or OutputFormat.
- * @since 1.5.0
- * @see #setSimulationMode(Class, Configuration, boolean)
- */
- @Deprecated
- public static Boolean getSimulationMode(Class<?> implementingClass, Configuration conf) {
- return org.apache.accumulo.core.client.mapreduce.lib.impl.OutputConfigurator.getSimulationMode(implementingClass, conf);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/accumulo/blob/b69291a3/core/src/main/java/org/apache/accumulo/core/client/mapreduce/lib/util/package-info.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/client/mapreduce/lib/util/package-info.java b/core/src/main/java/org/apache/accumulo/core/client/mapreduce/lib/util/package-info.java
deleted file mode 100644
index 269ffea..0000000
--- a/core/src/main/java/org/apache/accumulo/core/client/mapreduce/lib/util/package-info.java
+++ /dev/null
@@ -1,22 +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.
- */
-/**
- * @deprecated since 1.6.0; This package was moved out of the public API.
- * @since 1.5.0
- */
-package org.apache.accumulo.core.client.mapreduce.lib.util;
-
http://git-wip-us.apache.org/repos/asf/accumulo/blob/b69291a3/core/src/main/java/org/apache/accumulo/core/client/mock/IteratorAdapter.java
----------------------------------------------------------------------
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);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/accumulo/blob/b69291a3/core/src/main/java/org/apache/accumulo/core/client/mock/MockAccumulo.java
----------------------------------------------------------------------
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 18dac55..0000000
--- a/core/src/main/java/org/apache/accumulo/core/client/mock/MockAccumulo.java
+++ /dev/null
@@ -1,148 +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.Namespaces;
-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<String,MockTable>();
- final Map<String,MockNamespace> namespaces = new HashMap<String,MockNamespace>();
- final Map<String,String> systemProperties = new HashMap<String,String>();
- Map<String,MockUser> users = new HashMap<String,MockUser>();
- 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(Namespaces.DEFAULT_NAMESPACE, new MockNamespace());
- namespaces.put(Namespaces.ACCUMULO_NAMESPACE, 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);
- }
-}
http://git-wip-us.apache.org/repos/asf/accumulo/blob/b69291a3/core/src/main/java/org/apache/accumulo/core/client/mock/MockBatchDeleter.java
----------------------------------------------------------------------
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 bacd844..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 {
-
- BatchWriter writer = new MockBatchWriter(acc, tableName);
- try {
- 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);
- }
- } finally {
- writer.close();
- }
- }
-
-}
http://git-wip-us.apache.org/repos/asf/accumulo/blob/b69291a3/core/src/main/java/org/apache/accumulo/core/client/mock/MockBatchScanner.java
----------------------------------------------------------------------
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 0622f33..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<Range>(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() {}
-}
http://git-wip-us.apache.org/repos/asf/accumulo/blob/b69291a3/core/src/main/java/org/apache/accumulo/core/client/mock/MockBatchWriter.java
----------------------------------------------------------------------
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 {}
-
-}
http://git-wip-us.apache.org/repos/asf/accumulo/blob/b69291a3/core/src/main/java/org/apache/accumulo/core/client/mock/MockConfiguration.java
----------------------------------------------------------------------
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());
- }
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/accumulo/blob/b69291a3/core/src/main/java/org/apache/accumulo/core/client/mock/MockConnector.java
----------------------------------------------------------------------
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 9b5601b..0000000
--- a/core/src/main/java/org/apache/accumulo/core/client/mock/MockConnector.java
+++ /dev/null
@@ -1,162 +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.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.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.Credentials;
-import org.apache.accumulo.core.client.impl.thrift.SecurityErrorCode;
-import org.apache.accumulo.core.client.security.tokens.NullToken;
-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());
- }
-
- @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());
- }
-
- @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 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 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();
- }
-
-}
http://git-wip-us.apache.org/repos/asf/accumulo/blob/b69291a3/core/src/main/java/org/apache/accumulo/core/client/mock/MockInstance.java
----------------------------------------------------------------------
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 a37706a..0000000
--- a/core/src/main/java/org/apache/accumulo/core/client/mock/MockInstance.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.nio.ByteBuffer;
-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.conf.AccumuloConfiguration;
-import org.apache.accumulo.core.conf.DefaultConfiguration;
-import org.apache.accumulo.core.util.ByteBufferUtil;
-import org.apache.accumulo.core.util.CachedConfiguration;
-import org.apache.accumulo.core.util.TextUtil;
-import org.apache.hadoop.conf.Configuration;
-import org.apache.hadoop.fs.FileSystem;
-import org.apache.hadoop.io.Text;
-
-/**
- * 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<String,MockAccumulo>();
- 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
- @Deprecated
- public Connector getConnector(String user, byte[] pass) throws AccumuloException, AccumuloSecurityException {
- return getConnector(user, new PasswordToken(pass));
- }
-
- @Override
- @Deprecated
- public Connector getConnector(String user, ByteBuffer pass) throws AccumuloException, AccumuloSecurityException {
- return getConnector(user, ByteBufferUtil.toBytes(pass));
- }
-
- @Override
- @Deprecated
- public Connector getConnector(String user, CharSequence pass) throws AccumuloException, AccumuloSecurityException {
- return getConnector(user, TextUtil.getBytes(new Text(pass.toString())));
- }
-
- AccumuloConfiguration conf = null;
-
- @Deprecated
- @Override
- public AccumuloConfiguration getConfiguration() {
- return conf == null ? DefaultConfiguration.getInstance() : conf;
- }
-
- @Override
- @Deprecated
- public void setConfiguration(AccumuloConfiguration conf) {
- this.conf = conf;
- }
-
- @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;
- }
-}
http://git-wip-us.apache.org/repos/asf/accumulo/blob/b69291a3/core/src/main/java/org/apache/accumulo/core/client/mock/MockInstanceOperations.java
----------------------------------------------------------------------
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 b7e8e68..0000000
--- a/core/src/main/java/org/apache/accumulo/core/client/mock/MockInstanceOperations.java
+++ /dev/null
@@ -1,97 +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<String>();
- }
-
- @Override
- public List<ActiveScan> getActiveScans(String tserver) throws AccumuloException, AccumuloSecurityException {
- return new ArrayList<ActiveScan>();
- }
-
- @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<ActiveCompaction>();
- }
-
- @Override
- public void ping(String tserver) throws AccumuloException {
-
- }
-
- @Override
- public void waitForBalance() throws AccumuloException {}
-}
http://git-wip-us.apache.org/repos/asf/accumulo/blob/b69291a3/core/src/main/java/org/apache/accumulo/core/client/mock/MockMultiTableBatchWriter.java
----------------------------------------------------------------------
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 cfacccb..0000000
--- a/core/src/main/java/org/apache/accumulo/core/client/mock/MockMultiTableBatchWriter.java
+++ /dev/null
@@ -1,60 +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<String,MockBatchWriter>();
- }
-
- @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();
- }
-}
http://git-wip-us.apache.org/repos/asf/accumulo/blob/b69291a3/core/src/main/java/org/apache/accumulo/core/client/mock/MockNamespace.java
----------------------------------------------------------------------
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 da118c3..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.AccumuloConfiguration;
-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<String,EnumSet<NamespacePermission>>();
-
- public MockNamespace() {
- settings = new HashMap<String,String>();
- for (Entry<String,String> entry : AccumuloConfiguration.getDefaultConfiguration()) {
- 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<String>();
- for (String t : acu.tables.keySet()) {
- if (acu.tables.get(t).getNamespace().equals(this)) {
- l.add(t);
- }
- }
- return l;
- }
-}
http://git-wip-us.apache.org/repos/asf/accumulo/blob/b69291a3/core/src/main/java/org/apache/accumulo/core/client/mock/MockNamespaceOperations.java
----------------------------------------------------------------------
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 0c657a9..0000000
--- a/core/src/main/java/org/apache/accumulo/core/client/mock/MockNamespaceOperations.java
+++ /dev/null
@@ -1,138 +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<String>(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<String,String>();
- 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;
- }
-}
http://git-wip-us.apache.org/repos/asf/accumulo/blob/b69291a3/core/src/main/java/org/apache/accumulo/core/client/mock/MockScanner.java
----------------------------------------------------------------------
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) {
-
- }
-
-}
http://git-wip-us.apache.org/repos/asf/accumulo/blob/b69291a3/core/src/main/java/org/apache/accumulo/core/client/mock/MockScannerBase.java
----------------------------------------------------------------------
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 a79255c..0000000
--- a/core/src/main/java/org/apache/accumulo/core/client/mock/MockScannerBase.java
+++ /dev/null
@@ -1,159 +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.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.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<ByteSequence>();
- 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 AccumuloConfiguration.getDefaultConfiguration();
- }
-
- @Override
- public IteratorScope getIteratorScope() {
- return IteratorScope.scan;
- }
-
- @Override
- public boolean isFullMajorCompaction() {
- return false;
- }
-
- private ArrayList<SortedKeyValueIterator<Key,Value>> topLevelIterators = new ArrayList<SortedKeyValueIterator<Key,Value>>();
-
- @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<SortedKeyValueIterator<Key,Value>>(topLevelIterators);
- allIters.add(iter);
- return new MultiIterator(allIters, false);
- }
-
- @Override
- public boolean isSamplingEnabled() {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public SamplerConfiguration getSamplerConfiguration() {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public IteratorEnvironment cloneWithSamplingEnabled() {
- throw new UnsupportedOperationException();
- }
- }
-
- public SortedKeyValueIterator<Key,Value> createFilter(SortedKeyValueIterator<Key,Value> inner) throws IOException {
- byte[] defaultLabels = {};
- inner = new ColumnFamilySkippingIterator(new DeletingIterator(inner, false));
- ColumnQualifierFilter cqf = new ColumnQualifierFilter(inner, new HashSet<Column>(fetchedColumns));
- VisibilityFilter vf = new VisibilityFilter(cqf, auths, defaultLabels);
- AccumuloConfiguration conf = new MockConfiguration(table.settings);
- MockIteratorEnvironment iterEnv = new MockIteratorEnvironment(auths);
- SortedKeyValueIterator<Key,Value> result = iterEnv.getTopLevelIterator(IteratorUtil.loadIterators(IteratorScope.scan, vf, null, conf,
- serverSideIteratorList, serverSideIteratorOptions, iterEnv, false));
- return result;
- }
-
- @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();
- }
-}
http://git-wip-us.apache.org/repos/asf/accumulo/blob/b69291a3/core/src/main/java/org/apache/accumulo/core/client/mock/MockSecurityOperations.java
----------------------------------------------------------------------
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 bf4b46e..0000000
--- a/core/src/main/java/org/apache/accumulo/core/client/mock/MockSecurityOperations.java
+++ /dev/null
@@ -1,236 +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;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/accumulo/blob/b69291a3/core/src/main/java/org/apache/accumulo/core/client/mock/MockTable.java
----------------------------------------------------------------------
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 fa0fbcd..0000000
--- a/core/src/main/java/org/apache/accumulo/core/client/mock/MockTable.java
+++ /dev/null
@@ -1,212 +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.AccumuloConfiguration;
-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<Key,Value>();
- int mutationCount = 0;
- final Map<String,String> settings;
- Map<String,EnumSet<TablePermission>> userPermissions = new HashMap<String,EnumSet<TablePermission>>();
- private TimeType timeType;
- SortedSet<Text> splits = new ConcurrentSkipListSet<Text>();
- Map<String,Set<Text>> localityGroups = new TreeMap<String,Set<Text>>();
- 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 : AccumuloConfiguration.getDefaultConfiguration()) {
- 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 : AccumuloConfiguration.getDefaultConfiguration()) {
- 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;
- }
-}