Revert "ACCUMULO-2589 Drop deprecated code from 1.x" Restore all of the aggressively removed deprecated code, except the trace module, which is no longer needed.
This reverts commit b69291a3453fd0e6091586cf37fb1636a356caa9. Conflicts: minicluster/src/test/java/org/apache/accumulo/minicluster/impl/MiniAccumuloConfigImplTest.java server/base/src/test/java/org/apache/accumulo/server/util/FileUtilTest.java shell/src/main/java/org/apache/accumulo/shell/Shell.java Project: http://git-wip-us.apache.org/repos/asf/accumulo/repo Commit: http://git-wip-us.apache.org/repos/asf/accumulo/commit/4f2e6472 Tree: http://git-wip-us.apache.org/repos/asf/accumulo/tree/4f2e6472 Diff: http://git-wip-us.apache.org/repos/asf/accumulo/diff/4f2e6472 Branch: refs/heads/master Commit: 4f2e64728292af22d07b1907b6ec2d432f8564e2 Parents: 5ead817 Author: Christopher Tubbs <ctubb...@apache.org> Authored: Mon Aug 22 18:04:34 2016 -0400 Committer: Christopher Tubbs <ctubb...@apache.org> Committed: Mon Aug 22 18:04:34 2016 -0400 ---------------------------------------------------------------------- .../org/apache/accumulo/core/Constants.java | 8 + .../apache/accumulo/core/cli/ClientOpts.java | 6 + .../core/client/ClientConfiguration.java | 17 +- .../core/client/ClientSideIteratorScanner.java | 33 ++ .../apache/accumulo/core/client/Connector.java | 67 +++ .../apache/accumulo/core/client/Instance.java | 75 +++ .../accumulo/core/client/IsolatedScanner.java | 18 + .../core/client/MutationsRejectedException.java | 77 +++ .../apache/accumulo/core/client/Scanner.java | 19 + .../accumulo/core/client/ZooKeeperInstance.java | 91 ++++ .../core/client/admin/ActiveCompaction.java | 7 + .../accumulo/core/client/admin/ActiveScan.java | 7 + .../core/client/admin/SecurityOperations.java | 79 +++ .../core/client/admin/TableOperations.java | 71 +++ .../core/client/impl/ActiveCompactionImpl.java | 9 + .../core/client/impl/ActiveScanImpl.java | 7 + .../core/client/impl/ConnectorImpl.java | 27 + .../core/client/impl/OfflineScanner.java | 13 + .../accumulo/core/client/impl/ScannerImpl.java | 20 +- .../core/client/impl/ScannerIterator.java | 6 +- .../client/impl/SecurityOperationsImpl.java | 31 ++ .../core/client/impl/TableOperationsImpl.java | 51 ++ .../core/client/impl/ThriftScanner.java | 2 +- .../core/client/mapred/AbstractInputFormat.java | 95 +++- .../client/mapred/AccumuloFileOutputFormat.java | 15 + .../client/mapred/AccumuloOutputFormat.java | 56 ++ .../core/client/mapred/InputFormatBase.java | 69 +++ .../client/mapreduce/AbstractInputFormat.java | 119 ++++- .../mapreduce/AccumuloFileOutputFormat.java | 16 + .../client/mapreduce/AccumuloOutputFormat.java | 54 ++ .../core/client/mapreduce/InputFormatBase.java | 66 +++ .../core/client/mapreduce/RangeInputSplit.java | 62 ++- .../core/client/mapreduce/impl/SplitUtils.java | 2 + .../mapreduce/lib/impl/ConfiguratorBase.java | 28 +- .../mapreduce/lib/impl/InputConfigurator.java | 69 +++ .../mapreduce/lib/util/ConfiguratorBase.java | 275 ++++++++++ .../lib/util/FileOutputConfigurator.java | 170 +++++++ .../mapreduce/lib/util/InputConfigurator.java | 461 +++++++++++++++++ .../mapreduce/lib/util/OutputConfigurator.java | 196 +++++++ .../client/mapreduce/lib/util/package-info.java | 22 + .../core/client/mock/IteratorAdapter.java | 33 ++ .../accumulo/core/client/mock/MockAccumulo.java | 148 ++++++ .../core/client/mock/MockBatchDeleter.java | 76 +++ .../core/client/mock/MockBatchScanner.java | 79 +++ .../core/client/mock/MockBatchWriter.java | 59 +++ .../core/client/mock/MockConfiguration.java | 54 ++ .../core/client/mock/MockConnector.java | 162 ++++++ .../accumulo/core/client/mock/MockInstance.java | 163 ++++++ .../client/mock/MockInstanceOperations.java | 97 ++++ .../client/mock/MockMultiTableBatchWriter.java | 60 +++ .../core/client/mock/MockNamespace.java | 58 +++ .../client/mock/MockNamespaceOperations.java | 138 +++++ .../accumulo/core/client/mock/MockScanner.java | 127 +++++ .../core/client/mock/MockScannerBase.java | 159 ++++++ .../client/mock/MockSecurityOperations.java | 236 +++++++++ .../accumulo/core/client/mock/MockTable.java | 212 ++++++++ .../core/client/mock/MockTableOperations.java | 505 +++++++++++++++++++ .../accumulo/core/client/mock/MockUser.java | 41 ++ .../client/mock/impl/MockTabletLocator.java | 75 +++ .../accumulo/core/client/mock/package-info.java | 25 + .../core/client/rfile/RFileScanner.java | 19 + .../client/security/tokens/KerberosToken.java | 25 +- .../org/apache/accumulo/core/conf/Property.java | 13 + .../accumulo/core/constraints/Constraint.java | 10 + .../accumulo/core/data/ComparableBytes.java | 58 +++ .../apache/accumulo/core/data/KeyExtent.java | 259 ++++++++++ .../apache/accumulo/core/data/PartialKey.java | 18 + .../org/apache/accumulo/core/data/Value.java | 36 +- .../accumulo/core/data/impl/KeyExtent.java | 73 +++ .../accumulo/core/data/impl/TabletIdImpl.java | 31 ++ .../core/iterators/AggregatingIterator.java | 215 ++++++++ .../iterators/FamilyIntersectingIterator.java | 29 ++ .../accumulo/core/iterators/GrepIterator.java | 27 + .../core/iterators/IntersectingIterator.java | 27 + .../accumulo/core/iterators/IteratorUtil.java | 11 + .../accumulo/core/iterators/LargeRowFilter.java | 27 + .../core/iterators/RowDeletingIterator.java | 27 + .../core/iterators/VersioningIterator.java | 36 ++ .../core/iterators/WholeRowIterator.java | 27 + .../core/iterators/aggregation/Aggregator.java | 31 ++ .../iterators/aggregation/LongSummation.java | 76 +++ .../aggregation/NumArraySummation.java | 96 ++++ .../iterators/aggregation/NumSummation.java | 91 ++++ .../core/iterators/aggregation/StringMax.java | 48 ++ .../core/iterators/aggregation/StringMin.java | 48 ++ .../iterators/aggregation/StringSummation.java | 45 ++ .../conf/AggregatorConfiguration.java | 34 ++ .../aggregation/conf/AggregatorSet.java | 41 ++ .../iterators/conf/PerColumnIteratorConfig.java | 81 +++ .../iterators/user/IntersectingIterator.java | 24 + .../core/replication/ReplicationTable.java | 3 +- .../core/security/VisibilityConstraint.java | 29 ++ .../CachingHDFSSecretKeyEncryptionStrategy.java | 7 +- .../NonCachingSecretKeyEncryptionStrategy.java | 19 +- .../accumulo/core/trace/DistributedTrace.java | 11 + .../org/apache/accumulo/core/trace/Trace.java | 18 + .../accumulo/core/util/DeprecationUtil.java | 61 +++ .../core/util/format/BinaryFormatter.java | 66 +++ .../core/util/format/DateStringFormatter.java | 75 +++ .../core/volume/VolumeConfiguration.java | 27 +- .../accumulo/core/cli/TestClientOpts.java | 10 +- .../client/impl/TableOperationsHelperTest.java | 27 + .../core/client/impl/TabletLocatorImplTest.java | 34 +- .../core/client/mapred/RangeInputSplitTest.java | 3 + .../client/mapreduce/RangeInputSplitTest.java | 3 + .../mapreduce/impl/BatchInputSplitTest.java | 3 + .../lib/impl/ConfiguratorBaseTest.java | 14 + .../core/client/mock/MockConnectorTest.java | 375 ++++++++++++++ .../core/client/mock/MockNamespacesTest.java | 297 +++++++++++ .../client/mock/MockTableOperationsTest.java | 345 +++++++++++++ .../core/client/mock/TestBatchScanner821.java | 77 +++ .../accumulo/core/data/KeyExtentTest.java | 58 +++ .../apache/accumulo/core/data/ValueTest.java | 26 + .../core/iterators/AggregatingIteratorTest.java | 471 +++++++++++++++++ .../iterators/aggregation/NumSummationTest.java | 149 ++++++ .../conf/AggregatorConfigurationTest.java | 72 +++ .../core/iterators/user/FilterTest.java | 4 +- .../accumulo/core/security/CredentialsTest.java | 21 + .../util/format/DateStringFormatterTest.java | 80 +++ .../standalone/StandaloneAccumuloCluster.java | 4 + .../impl/MiniAccumuloClusterImpl.java | 10 +- pom.xml | 48 -- .../org/apache/accumulo/proxy/ProxyServer.java | 26 +- .../accumulo/server/AccumuloServerContext.java | 5 + .../server/cli/ClientOnDefaultTable.java | 3 + .../server/cli/ClientOnRequiredTable.java | 3 + .../apache/accumulo/server/cli/ClientOpts.java | 3 + .../accumulo/server/client/HdfsZooInstance.java | 41 +- .../server/security/UserImpersonation.java | 68 ++- .../accumulo/server/init/InitializeTest.java | 24 +- .../BaseHostRegexTableLoadBalancerTest.java | 29 ++ ...redentialsUpdatingInvocationHandlerTest.java | 81 +++ .../server/security/UserImpersonationTest.java | 227 +++++++++ .../accumulo/server/util/TServerUtilsTest.java | 29 ++ .../java/org/apache/accumulo/master/Master.java | 6 +- .../apache/accumulo/master/util/FateAdmin.java | 104 ++++ .../accumulo/monitor/servlets/ShellServlet.java | 13 +- .../monitor/servlets/trace/NullScanner.java | 10 + .../org/apache/accumulo/tracer/TracerTest.java | 3 +- .../accumulo/tserver/TservConstraintEnv.java | 14 + .../accumulo/tserver/log/LocalWALRecovery.java | 5 +- .../tserver/log/SortedLogRecoveryTest.java | 3 +- .../accumulo/tserver/tablet/RootFilesTest.java | 9 +- .../java/org/apache/accumulo/shell/Shell.java | 47 +- .../apache/accumulo/shell/ShellOptionsJC.java | 4 + .../shell/commands/DeleteScanIterCommand.java | 103 ++++ .../accumulo/shell/commands/SetIterCommand.java | 27 +- .../shell/commands/SetScanIterCommand.java | 113 +++++ .../apache/accumulo/shell/mock/MockShell.java | 159 ++++++ .../apache/accumulo/shell/ShellConfigTest.java | 28 +- .../accumulo/shell/ShellSetInstanceTest.java | 35 +- .../org/apache/accumulo/shell/ShellTest.java | 394 +++++++++++++++ shell/src/test/resources/shelltest.txt | 16 + .../accumulo/test/BulkImportDirectory.java | 25 +- .../test/CreateTableWithNewTableConfigIT.java | 49 +- .../org/apache/accumulo/test/ShellServerIT.java | 244 +-------- .../java/org/apache/accumulo/test/VolumeIT.java | 10 +- .../accumulo/test/functional/WALSunnyDayIT.java | 2 +- .../server/security/SystemCredentialsIT.java | 62 +++ test/src/test/resources/shelltest.txt | 16 - 160 files changed, 10619 insertions(+), 474 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/accumulo/blob/4f2e6472/core/src/main/java/org/apache/accumulo/core/Constants.java ---------------------------------------------------------------------- diff --git a/core/src/main/java/org/apache/accumulo/core/Constants.java b/core/src/main/java/org/apache/accumulo/core/Constants.java index 7098d7c..eebd81d 100644 --- a/core/src/main/java/org/apache/accumulo/core/Constants.java +++ b/core/src/main/java/org/apache/accumulo/core/Constants.java @@ -22,6 +22,8 @@ import java.util.Arrays; import java.util.Collection; import java.util.Collections; +import org.apache.accumulo.core.security.Authorizations; + public class Constants { public static final String VERSION = FilteredConstants.VERSION; @@ -107,6 +109,12 @@ public class Constants { // Security configuration public static final String PW_HASH_ALGORITHM = "SHA-256"; + /** + * @deprecated since 1.6.0; Use {@link Authorizations#EMPTY} instead + */ + @Deprecated + public static final Authorizations NO_AUTHS = Authorizations.EMPTY; + public static final int MAX_DATA_TO_PRINT = 64; public static final String CORE_PACKAGE_NAME = "org.apache.accumulo.core"; public static final String MAPFILE_EXTENSION = "map"; http://git-wip-us.apache.org/repos/asf/accumulo/blob/4f2e6472/core/src/main/java/org/apache/accumulo/core/cli/ClientOpts.java ---------------------------------------------------------------------- diff --git a/core/src/main/java/org/apache/accumulo/core/cli/ClientOpts.java b/core/src/main/java/org/apache/accumulo/core/cli/ClientOpts.java index d78c1b5..a73da7b 100644 --- a/core/src/main/java/org/apache/accumulo/core/cli/ClientOpts.java +++ b/core/src/main/java/org/apache/accumulo/core/cli/ClientOpts.java @@ -45,6 +45,7 @@ import org.apache.accumulo.core.conf.Property; import org.apache.accumulo.core.security.Authorizations; import org.apache.accumulo.core.security.ColumnVisibility; import org.apache.accumulo.core.trace.Trace; +import org.apache.accumulo.core.util.DeprecationUtil; import org.apache.accumulo.core.volume.VolumeConfiguration; import org.apache.accumulo.core.zookeeper.ZooUtil; import org.apache.hadoop.conf.Configuration; @@ -162,6 +163,9 @@ public class ClientOpts extends Help { @Parameter(names = "--debug", description = "turn on TRACE-level log messages") public boolean debug = false; + @Parameter(names = {"-fake", "--mock"}, description = "Use a mock Instance") + public boolean mock = false; + @Parameter(names = "--site-file", description = "Read the given accumulo site file to find the accumulo instance") public String siteFile = null; @@ -255,6 +259,8 @@ public class ClientOpts extends Help { synchronized public Instance getInstance() { if (cachedInstance != null) return cachedInstance; + if (mock) + return cachedInstance = DeprecationUtil.makeMockInstance(instance); return cachedInstance = new ZooKeeperInstance(this.getClientConfiguration()); } http://git-wip-us.apache.org/repos/asf/accumulo/blob/4f2e6472/core/src/main/java/org/apache/accumulo/core/client/ClientConfiguration.java ---------------------------------------------------------------------- diff --git a/core/src/main/java/org/apache/accumulo/core/client/ClientConfiguration.java b/core/src/main/java/org/apache/accumulo/core/client/ClientConfiguration.java index 09d6b42..1b9b380 100644 --- a/core/src/main/java/org/apache/accumulo/core/client/ClientConfiguration.java +++ b/core/src/main/java/org/apache/accumulo/core/client/ClientConfiguration.java @@ -97,8 +97,11 @@ public class ClientConfiguration extends CompositeConfiguration { private PropertyType type; private String description; + private Property accumuloProperty = null; + private ClientProperty(Property prop) { this(prop.getKey(), prop.getDefaultValue(), prop.getType(), prop.getDescription()); + accumuloProperty = prop; } private ClientProperty(String key, String defaultValue, PropertyType type, String description) { @@ -116,7 +119,11 @@ public class ClientConfiguration extends CompositeConfiguration { return defaultValue; } - private PropertyType getType() { + /** + * @deprecated since 1.7.0 This method returns a type that is not part of the public API and not guaranteed to be stable. + */ + @Deprecated + public PropertyType getType() { return type; } @@ -124,6 +131,14 @@ public class ClientConfiguration extends CompositeConfiguration { return description; } + /** + * @deprecated since 1.7.0 This method returns a type that is not part of the public API and not guaranteed to be stable. + */ + @Deprecated + public Property getAccumuloProperty() { + return accumuloProperty; + } + public static ClientProperty getPropertyByKey(String key) { for (ClientProperty prop : ClientProperty.values()) if (prop.getKey().equals(key)) http://git-wip-us.apache.org/repos/asf/accumulo/blob/4f2e6472/core/src/main/java/org/apache/accumulo/core/client/ClientSideIteratorScanner.java ---------------------------------------------------------------------- diff --git a/core/src/main/java/org/apache/accumulo/core/client/ClientSideIteratorScanner.java b/core/src/main/java/org/apache/accumulo/core/client/ClientSideIteratorScanner.java index 978d85a..d4622c6 100644 --- a/core/src/main/java/org/apache/accumulo/core/client/ClientSideIteratorScanner.java +++ b/core/src/main/java/org/apache/accumulo/core/client/ClientSideIteratorScanner.java @@ -65,6 +65,21 @@ public class ClientSideIteratorScanner extends ScannerOptions implements Scanner private long readaheadThreshold = Constants.SCANNER_DEFAULT_READAHEAD_THRESHOLD; private SamplerConfiguration iteratorSamplerConfig; + /** + * @deprecated since 1.7.0 was never intended for public use. However this could have been used by anything extending this class. + */ + @Deprecated + public class ScannerTranslator extends ScannerTranslatorImpl { + public ScannerTranslator(Scanner scanner) { + super(scanner, scanner.getSamplerConfiguration()); + } + + @Override + public SortedKeyValueIterator<Key,Value> deepCopy(final IteratorEnvironment env) { + return new ScannerTranslator(scanner); + } + } + private class ClientSideIteratorEnvironment implements IteratorEnvironment { private SamplerConfiguration samplerConfig; @@ -269,6 +284,24 @@ public class ClientSideIteratorScanner extends ScannerOptions implements Scanner return smi.scanner.getAuthorizations(); } + @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(final Range range) { this.range = range; http://git-wip-us.apache.org/repos/asf/accumulo/blob/4f2e6472/core/src/main/java/org/apache/accumulo/core/client/Connector.java ---------------------------------------------------------------------- diff --git a/core/src/main/java/org/apache/accumulo/core/client/Connector.java b/core/src/main/java/org/apache/accumulo/core/client/Connector.java index 95cfd10..e36cc82 100644 --- a/core/src/main/java/org/apache/accumulo/core/client/Connector.java +++ b/core/src/main/java/org/apache/accumulo/core/client/Connector.java @@ -50,6 +50,33 @@ public abstract class Connector { public abstract BatchScanner createBatchScanner(String tableName, Authorizations authorizations, int numQueryThreads) throws TableNotFoundException; /** + * Factory method to create a BatchDeleter connected to Accumulo. + * + * @param tableName + * the name of the table to query and delete from + * @param authorizations + * A set of authorization labels that will be checked against the column visibility of each key in order to filter data. The authorizations passed in + * must be a subset of the accumulo user's set of authorizations. If the accumulo user has authorizations (A1, A2) and authorizations (A2, A3) are + * passed, then an exception will be thrown. + * @param numQueryThreads + * the number of concurrent threads to spawn for querying + * @param maxMemory + * size in bytes of the maximum memory to batch before writing + * @param maxLatency + * size in milliseconds; set to 0 or Long.MAX_VALUE to allow the maximum time to hold a batch before writing + * @param maxWriteThreads + * the maximum number of threads to use for writing data to the tablet servers + * + * @return BatchDeleter object for configuring and deleting + * @throws TableNotFoundException + * when the specified table doesn't exist + * @deprecated since 1.5.0; Use {@link #createBatchDeleter(String, Authorizations, int, BatchWriterConfig)} instead. + */ + @Deprecated + public abstract BatchDeleter createBatchDeleter(String tableName, Authorizations authorizations, int numQueryThreads, long maxMemory, long maxLatency, + int maxWriteThreads) throws TableNotFoundException; + + /** * * @param tableName * the name of the table to query and delete from @@ -64,6 +91,7 @@ public abstract class Connector { * @return BatchDeleter object for configuring and deleting * @since 1.5.0 */ + public abstract BatchDeleter createBatchDeleter(String tableName, Authorizations authorizations, int numQueryThreads, BatchWriterConfig config) throws TableNotFoundException; @@ -72,14 +100,52 @@ public abstract class Connector { * * @param tableName * the name of the table to insert data into + * @param maxMemory + * size in bytes of the maximum memory to batch before writing + * @param maxLatency + * time in milliseconds; set to 0 or Long.MAX_VALUE to allow the maximum time to hold a batch before writing + * @param maxWriteThreads + * the maximum number of threads to use for writing data to the tablet servers + * + * @return BatchWriter object for configuring and writing data to + * @throws TableNotFoundException + * when the specified table doesn't exist + * @deprecated since 1.5.0; Use {@link #createBatchWriter(String, BatchWriterConfig)} instead. + */ + @Deprecated + public abstract BatchWriter createBatchWriter(String tableName, long maxMemory, long maxLatency, int maxWriteThreads) throws TableNotFoundException; + + /** + * Factory method to create a BatchWriter connected to Accumulo. + * + * @param tableName + * the name of the table to insert data into * @param config * configuration used to create batch writer * @return BatchWriter object for configuring and writing data to * @since 1.5.0 */ + public abstract BatchWriter createBatchWriter(String tableName, BatchWriterConfig config) throws TableNotFoundException; /** + * Factory method to create a Multi-Table BatchWriter connected to Accumulo. Multi-table batch writers can queue data for multiple tables, which is good for + * ingesting data into multiple tables from the same source + * + * @param maxMemory + * size in bytes of the maximum memory to batch before writing + * @param maxLatency + * size in milliseconds; set to 0 or Long.MAX_VALUE to allow the maximum time to hold a batch before writing + * @param maxWriteThreads + * the maximum number of threads to use for writing data to the tablet servers + * + * @return MultiTableBatchWriter object for configuring and writing data to + * @deprecated since 1.5.0; Use {@link #createMultiTableBatchWriter(BatchWriterConfig)} instead. + */ + @Deprecated + public abstract MultiTableBatchWriter createMultiTableBatchWriter(long maxMemory, long maxLatency, int maxWriteThreads); + + /** * Factory method to create a Multi-Table BatchWriter connected to Accumulo. Multi-table batch writers can queue data for multiple tables. Also data for * multiple tables can be sent to a server in a single batch. Its an efficient way to ingest data into multiple tables from a single process. * @@ -88,6 +154,7 @@ public abstract class Connector { * @return MultiTableBatchWriter object for configuring and writing data to * @since 1.5.0 */ + public abstract MultiTableBatchWriter createMultiTableBatchWriter(BatchWriterConfig config); /** http://git-wip-us.apache.org/repos/asf/accumulo/blob/4f2e6472/core/src/main/java/org/apache/accumulo/core/client/Instance.java ---------------------------------------------------------------------- diff --git a/core/src/main/java/org/apache/accumulo/core/client/Instance.java b/core/src/main/java/org/apache/accumulo/core/client/Instance.java index 3cb8973..8a70d4c 100644 --- a/core/src/main/java/org/apache/accumulo/core/client/Instance.java +++ b/core/src/main/java/org/apache/accumulo/core/client/Instance.java @@ -16,10 +16,13 @@ */ package org.apache.accumulo.core.client; +import java.nio.ByteBuffer; import java.util.List; +import org.apache.accumulo.core.client.admin.InstanceOperations; 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; /** * This class represents the information a client needs to know to connect to an instance of accumulo. @@ -69,6 +72,78 @@ public interface Instance { int getZooKeepersSessionTimeOut(); /** + * Returns a connection to accumulo. + * + * @param user + * a valid accumulo user + * @param pass + * A UTF-8 encoded password. The password may be cleared after making this call. + * @return the accumulo Connector + * @throws AccumuloException + * when a generic exception occurs + * @throws AccumuloSecurityException + * when a user's credentials are invalid + * @deprecated since 1.5, use {@link #getConnector(String, AuthenticationToken)} with {@link PasswordToken} + */ + @Deprecated + Connector getConnector(String user, byte[] pass) throws AccumuloException, AccumuloSecurityException; + + /** + * Returns a connection to accumulo. + * + * @param user + * a valid accumulo user + * @param pass + * A UTF-8 encoded password. The password may be cleared after making this call. + * @return the accumulo Connector + * @throws AccumuloException + * when a generic exception occurs + * @throws AccumuloSecurityException + * when a user's credentials are invalid + * @deprecated since 1.5, use {@link #getConnector(String, AuthenticationToken)} with {@link PasswordToken} + */ + @Deprecated + Connector getConnector(String user, ByteBuffer pass) throws AccumuloException, AccumuloSecurityException; + + /** + * Returns a connection to this instance of accumulo. + * + * @param user + * a valid accumulo user + * @param pass + * If a mutable CharSequence is passed in, it may be cleared after this call. + * @return the accumulo Connector + * @throws AccumuloException + * when a generic exception occurs + * @throws AccumuloSecurityException + * when a user's credentials are invalid + * @deprecated since 1.5, use {@link #getConnector(String, AuthenticationToken)} with {@link PasswordToken} + */ + @Deprecated + Connector getConnector(String user, CharSequence pass) throws AccumuloException, AccumuloSecurityException; + + /** + * Returns the AccumuloConfiguration to use when interacting with this instance. + * + * @return the AccumuloConfiguration that specifies properties related to interacting with this instance + * @deprecated since 1.6.0. This method makes very little sense in the context of the client API and never should have been exposed. + * @see InstanceOperations#getSystemConfiguration() for client-side reading of the server-side configuration. + */ + @Deprecated + AccumuloConfiguration getConfiguration(); + + /** + * Set the AccumuloConfiguration to use when interacting with this instance. + * + * @param conf + * accumulo configuration + * @deprecated since 1.6.0. This method makes very little sense in the context of the client API and never should have been exposed. + * @see InstanceOperations#setProperty(String, String) + */ + @Deprecated + void setConfiguration(AccumuloConfiguration conf); + + /** * Returns a connection to this instance of accumulo. * * @param principal http://git-wip-us.apache.org/repos/asf/accumulo/blob/4f2e6472/core/src/main/java/org/apache/accumulo/core/client/IsolatedScanner.java ---------------------------------------------------------------------- diff --git a/core/src/main/java/org/apache/accumulo/core/client/IsolatedScanner.java b/core/src/main/java/org/apache/accumulo/core/client/IsolatedScanner.java index 164cb1c..90e8637 100644 --- a/core/src/main/java/org/apache/accumulo/core/client/IsolatedScanner.java +++ b/core/src/main/java/org/apache/accumulo/core/client/IsolatedScanner.java @@ -238,6 +238,24 @@ public class IsolatedScanner extends ScannerOptions implements Scanner { return new RowBufferingIterator(scanner, this, range, timeOut, batchSize, readaheadThreshold, bufferFactory); } + @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; http://git-wip-us.apache.org/repos/asf/accumulo/blob/4f2e6472/core/src/main/java/org/apache/accumulo/core/client/MutationsRejectedException.java ---------------------------------------------------------------------- diff --git a/core/src/main/java/org/apache/accumulo/core/client/MutationsRejectedException.java b/core/src/main/java/org/apache/accumulo/core/client/MutationsRejectedException.java index 8f8720a..b67a3a0 100644 --- a/core/src/main/java/org/apache/accumulo/core/client/MutationsRejectedException.java +++ b/core/src/main/java/org/apache/accumulo/core/client/MutationsRejectedException.java @@ -23,11 +23,14 @@ import java.util.List; import java.util.Map; import java.util.Map.Entry; import java.util.Set; +import java.util.function.Function; +import java.util.stream.Collectors; import org.apache.accumulo.core.client.impl.Tables; import org.apache.accumulo.core.client.security.SecurityErrorCode; import org.apache.accumulo.core.data.ConstraintViolationSummary; import org.apache.accumulo.core.data.TabletId; +import org.apache.accumulo.core.data.impl.TabletIdImpl; /** * Communicate the failed mutations of a BatchWriter back to the client. @@ -41,6 +44,61 @@ public class MutationsRejectedException extends AccumuloException { private Collection<String> es; private int unknownErrors; + private static <K,V,L> Map<L,V> transformKeys(Map<K,V> map, Function<K,L> keyFunction) { + HashMap<L,V> ret = new HashMap<>(); + for (Entry<K,V> entry : map.entrySet()) { + ret.put(keyFunction.apply(entry.getKey()), entry.getValue()); + } + + return ret; + } + + /** + * @param cvsList + * list of constraint violations + * @param hashMap + * authorization failures + * @param serverSideErrors + * server side errors + * @param unknownErrors + * number of unknown errors + * + * @deprecated since 1.6.0, see {@link #MutationsRejectedException(Instance, List, Map, Collection, int, Throwable)} + */ + @Deprecated + public MutationsRejectedException(List<ConstraintViolationSummary> cvsList, HashMap<org.apache.accumulo.core.data.KeyExtent,Set<SecurityErrorCode>> hashMap, + Collection<String> serverSideErrors, int unknownErrors, Throwable cause) { + super("# constraint violations : " + cvsList.size() + " security codes: " + hashMap.values() + " # server errors " + serverSideErrors.size() + + " # exceptions " + unknownErrors, cause); + this.cvsl = cvsList; + this.af = transformKeys(hashMap, TabletIdImpl.KE_2_TID_OLD); + this.es = serverSideErrors; + this.unknownErrors = unknownErrors; + } + + /** + * @param cvsList + * list of constraint violations + * @param hashMap + * authorization failures + * @param serverSideErrors + * server side errors + * @param unknownErrors + * number of unknown errors + * + * @deprecated since 1.7.0 see {@link #MutationsRejectedException(Instance, List, Map, Collection, int, Throwable)} + */ + @Deprecated + public MutationsRejectedException(Instance instance, List<ConstraintViolationSummary> cvsList, + HashMap<org.apache.accumulo.core.data.KeyExtent,Set<SecurityErrorCode>> hashMap, Collection<String> serverSideErrors, int unknownErrors, Throwable cause) { + super("# constraint violations : " + cvsList.size() + " security codes: " + format(transformKeys(hashMap, TabletIdImpl.KE_2_TID_OLD), instance) + + " # server errors " + serverSideErrors.size() + " # exceptions " + unknownErrors, cause); + this.cvsl = cvsList; + this.af = transformKeys(hashMap, TabletIdImpl.KE_2_TID_OLD); + this.es = serverSideErrors; + this.unknownErrors = unknownErrors; + } + /** * * @param cvsList @@ -88,6 +146,25 @@ public class MutationsRejectedException extends AccumuloException { } /** + * @return the internal list of authorization failures + * @deprecated since 1.5, see {@link #getAuthorizationFailuresMap()} + */ + @Deprecated + public List<org.apache.accumulo.core.data.KeyExtent> getAuthorizationFailures() { + return af.keySet().stream().map(TabletIdImpl.TID_2_KE_OLD).collect(Collectors.toList()); + } + + /** + * @return the internal mapping of keyextent mappings to SecurityErrorCode + * @since 1.5.0 + * @deprecated since 1.7.0 see {@link #getSecurityErrorCodes()} + */ + @Deprecated + public Map<org.apache.accumulo.core.data.KeyExtent,Set<SecurityErrorCode>> getAuthorizationFailuresMap() { + return transformKeys(af, TabletIdImpl.TID_2_KE_OLD); + } + + /** * @return the internal mapping of TabletID to SecurityErrorCodes */ public Map<TabletId,Set<SecurityErrorCode>> getSecurityErrorCodes() { http://git-wip-us.apache.org/repos/asf/accumulo/blob/4f2e6472/core/src/main/java/org/apache/accumulo/core/client/Scanner.java ---------------------------------------------------------------------- diff --git a/core/src/main/java/org/apache/accumulo/core/client/Scanner.java b/core/src/main/java/org/apache/accumulo/core/client/Scanner.java index 547c89c..372ee42 100644 --- a/core/src/main/java/org/apache/accumulo/core/client/Scanner.java +++ b/core/src/main/java/org/apache/accumulo/core/client/Scanner.java @@ -28,6 +28,25 @@ import org.apache.accumulo.core.data.Range; public interface Scanner extends ScannerBase { /** + * This setting determines how long a scanner will automatically retry when a failure occurs. By default a scanner will retry forever. + * + * @param timeOut + * in seconds + * @deprecated Since 1.5. See {@link ScannerBase#setTimeout(long, java.util.concurrent.TimeUnit)} + */ + @Deprecated + void setTimeOut(int timeOut); + + /** + * Returns the setting for how long a scanner will automatically retry when a failure occurs. + * + * @return the timeout configured for this scanner + * @deprecated Since 1.5. See {@link ScannerBase#getTimeout(java.util.concurrent.TimeUnit)} + */ + @Deprecated + int getTimeOut(); + + /** * Sets the range of keys to scan over. * * @param range http://git-wip-us.apache.org/repos/asf/accumulo/blob/4f2e6472/core/src/main/java/org/apache/accumulo/core/client/ZooKeeperInstance.java ---------------------------------------------------------------------- diff --git a/core/src/main/java/org/apache/accumulo/core/client/ZooKeeperInstance.java b/core/src/main/java/org/apache/accumulo/core/client/ZooKeeperInstance.java index a545c72..4a4dd5f 100644 --- a/core/src/main/java/org/apache/accumulo/core/client/ZooKeeperInstance.java +++ b/core/src/main/java/org/apache/accumulo/core/client/ZooKeeperInstance.java @@ -19,6 +19,7 @@ package org.apache.accumulo.core.client; import static com.google.common.base.Preconditions.checkArgument; import static java.nio.charset.StandardCharsets.UTF_8; +import java.nio.ByteBuffer; import java.util.Collections; import java.util.List; import java.util.UUID; @@ -31,13 +32,18 @@ import org.apache.accumulo.core.client.impl.ConnectorImpl; import org.apache.accumulo.core.client.impl.Credentials; import org.apache.accumulo.core.client.impl.InstanceOperationsImpl; 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.metadata.RootTable; +import org.apache.accumulo.core.util.ByteBufferUtil; import org.apache.accumulo.core.util.OpTimer; +import org.apache.accumulo.core.util.TextUtil; import org.apache.accumulo.core.zookeeper.ZooUtil; import org.apache.accumulo.fate.zookeeper.ZooCache; import org.apache.accumulo.fate.zookeeper.ZooCacheFactory; import org.apache.commons.configuration.Configuration; +import org.apache.hadoop.io.Text; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -67,6 +73,7 @@ public class ZooKeeperInstance implements Instance { private final int zooKeepersSessionTimeOut; + private AccumuloConfiguration conf; private ClientConfiguration clientConf; /** @@ -81,6 +88,49 @@ public class ZooKeeperInstance implements Instance { } /** + * + * @param instanceName + * The name of specific accumulo instance. This is set at initialization time. + * @param zooKeepers + * A comma separated list of zoo keeper server locations. Each location can contain an optional port, of the format host:port. + * @param sessionTimeout + * zoo keeper session time out in milliseconds. + * @deprecated since 1.6.0; Use {@link #ZooKeeperInstance(Configuration)} instead. + */ + @Deprecated + public ZooKeeperInstance(String instanceName, String zooKeepers, int sessionTimeout) { + this(ClientConfiguration.loadDefault().withInstance(instanceName).withZkHosts(zooKeepers).withZkTimeout(sessionTimeout)); + } + + /** + * + * @param instanceId + * The UUID that identifies the accumulo instance you want to connect to. + * @param zooKeepers + * A comma separated list of zoo keeper server locations. Each location can contain an optional port, of the format host:port. + * @deprecated since 1.6.0; Use {@link #ZooKeeperInstance(Configuration)} instead. + */ + @Deprecated + public ZooKeeperInstance(UUID instanceId, String zooKeepers) { + this(ClientConfiguration.loadDefault().withInstance(instanceId).withZkHosts(zooKeepers)); + } + + /** + * + * @param instanceId + * The UUID that identifies the accumulo instance you want to connect to. + * @param zooKeepers + * A comma separated list of zoo keeper server locations. Each location can contain an optional port, of the format host:port. + * @param sessionTimeout + * zoo keeper session time out in milliseconds. + * @deprecated since 1.6.0; Use {@link #ZooKeeperInstance(Configuration)} instead. + */ + @Deprecated + public ZooKeeperInstance(UUID instanceId, String zooKeepers, int sessionTimeout) { + this(ClientConfiguration.loadDefault().withInstance(instanceId).withZkHosts(zooKeepers).withZkTimeout(sessionTimeout)); + } + + /** * @param config * Client configuration for specifying connection options. See {@link ClientConfiguration} which extends Configuration with convenience methods * specific to Accumulo. @@ -204,11 +254,52 @@ public class ZooKeeperInstance implements Instance { } @Override + @Deprecated + public Connector getConnector(String user, CharSequence pass) throws AccumuloException, AccumuloSecurityException { + return getConnector(user, TextUtil.getBytes(new Text(pass.toString()))); + } + + @Override + @Deprecated + public Connector getConnector(String user, ByteBuffer pass) throws AccumuloException, AccumuloSecurityException { + return getConnector(user, ByteBufferUtil.toBytes(pass)); + } + + @Override public Connector getConnector(String principal, AuthenticationToken token) throws AccumuloException, AccumuloSecurityException { return new ConnectorImpl(new ClientContext(this, new Credentials(principal, token), clientConf)); } @Override + @Deprecated + public Connector getConnector(String principal, byte[] pass) throws AccumuloException, AccumuloSecurityException { + return getConnector(principal, new PasswordToken(pass)); + } + + @Override + @Deprecated + public AccumuloConfiguration getConfiguration() { + return conf = conf == null ? DefaultConfiguration.getInstance() : ClientContext.convertClientConfig(clientConf); + } + + @Override + @Deprecated + public void setConfiguration(AccumuloConfiguration conf) { + this.conf = conf; + } + + /** + * Given a zooCache and instanceId, look up the instance name. + * + * @deprecated since 1.7.0 {@link ZooCache} is not part of the public API, but its a parameter to this method. Therefore code that uses this method is not + * guaranteed to be stable. This method was deprecated to discourage its use. + */ + @Deprecated + public static String lookupInstanceName(ZooCache zooCache, UUID instanceId) { + return InstanceOperationsImpl.lookupInstanceName(zooCache, instanceId); + } + + @Override public String toString() { StringBuilder sb = new StringBuilder(64); sb.append("ZooKeeperInstance: ").append(getInstanceName()).append(" ").append(getZooKeepers()); http://git-wip-us.apache.org/repos/asf/accumulo/blob/4f2e6472/core/src/main/java/org/apache/accumulo/core/client/admin/ActiveCompaction.java ---------------------------------------------------------------------- diff --git a/core/src/main/java/org/apache/accumulo/core/client/admin/ActiveCompaction.java b/core/src/main/java/org/apache/accumulo/core/client/admin/ActiveCompaction.java index ddb7fa9..5228391 100644 --- a/core/src/main/java/org/apache/accumulo/core/client/admin/ActiveCompaction.java +++ b/core/src/main/java/org/apache/accumulo/core/client/admin/ActiveCompaction.java @@ -78,6 +78,13 @@ public abstract class ActiveCompaction { /** * @return tablet thats is compacting + * @deprecated since 1.7.0 use {@link #getTablet()} + */ + @Deprecated + public abstract org.apache.accumulo.core.data.KeyExtent getExtent(); + + /** + * @return tablet thats is compacting * @since 1.7.0 */ public abstract TabletId getTablet(); http://git-wip-us.apache.org/repos/asf/accumulo/blob/4f2e6472/core/src/main/java/org/apache/accumulo/core/client/admin/ActiveScan.java ---------------------------------------------------------------------- diff --git a/core/src/main/java/org/apache/accumulo/core/client/admin/ActiveScan.java b/core/src/main/java/org/apache/accumulo/core/client/admin/ActiveScan.java index 9510895..81bb1cc 100644 --- a/core/src/main/java/org/apache/accumulo/core/client/admin/ActiveScan.java +++ b/core/src/main/java/org/apache/accumulo/core/client/admin/ActiveScan.java @@ -65,6 +65,13 @@ public abstract class ActiveScan { /** * @return tablet the scan is running against, if a batch scan may be one of many or null + * @deprecated since 1.7.0 use {@link #getTablet()} + */ + @Deprecated + public abstract org.apache.accumulo.core.data.KeyExtent getExtent(); + + /** + * @return tablet the scan is running against, if a batch scan may be one of many or null * @since 1.7.0 */ public abstract TabletId getTablet(); http://git-wip-us.apache.org/repos/asf/accumulo/blob/4f2e6472/core/src/main/java/org/apache/accumulo/core/client/admin/SecurityOperations.java ---------------------------------------------------------------------- diff --git a/core/src/main/java/org/apache/accumulo/core/client/admin/SecurityOperations.java b/core/src/main/java/org/apache/accumulo/core/client/admin/SecurityOperations.java index 21d507b..cb916ef 100644 --- a/core/src/main/java/org/apache/accumulo/core/client/admin/SecurityOperations.java +++ b/core/src/main/java/org/apache/accumulo/core/client/admin/SecurityOperations.java @@ -36,6 +36,24 @@ public interface SecurityOperations { /** * Create a user * + * @param user + * the name of the user to create + * @param password + * the plaintext password for the user + * @param authorizations + * the authorizations that the user has for scanning + * @throws AccumuloException + * if a general error occurs + * @throws AccumuloSecurityException + * if the user does not have permission to create a user + * @deprecated since 1.5.0; use {@link #createLocalUser(String, PasswordToken)} or the user management functions of your configured authenticator instead. + */ + @Deprecated + void createUser(String user, byte[] password, Authorizations authorizations) throws AccumuloException, AccumuloSecurityException; + + /** + * Create a user + * * @param principal * the name of the user to create * @param password @@ -51,6 +69,20 @@ public interface SecurityOperations { /** * Delete a user * + * @param user + * the user name to delete + * @throws AccumuloException + * if a general error occurs + * @throws AccumuloSecurityException + * if the user does not have permission to delete a user + * @deprecated since 1.5.0; use {@link #dropUser(String)} or the user management functions of your configured authenticator instead. + */ + @Deprecated + void dropUser(String user) throws AccumuloException, AccumuloSecurityException; + + /** + * Delete a user + * * @param principal * the user name to delete * @throws AccumuloException @@ -64,6 +96,23 @@ public interface SecurityOperations { /** * Verify a username/password combination is valid * + * @param user + * the name of the user to authenticate + * @param password + * the plaintext password for the user + * @return true if the user asking is allowed to know and the specified user/password is valid, false otherwise + * @throws AccumuloException + * if a general error occurs + * @throws AccumuloSecurityException + * if the user does not have permission to ask + * @deprecated since 1.5.0; use {@link #authenticateUser(String, AuthenticationToken)} instead. + */ + @Deprecated + boolean authenticateUser(String user, byte[] password) throws AccumuloException, AccumuloSecurityException; + + /** + * Verify a username/password combination is valid + * * @param principal * the name of the user to authenticate * @param token @@ -80,6 +129,23 @@ public interface SecurityOperations { /** * Set the user's password * + * @param user + * the name of the user to modify + * @param password + * the plaintext password for the user + * @throws AccumuloException + * if a general error occurs + * @throws AccumuloSecurityException + * if the user does not have permission to modify a user + * @deprecated since 1.5.0; use {@link #changeLocalUserPassword(String, PasswordToken)} or the user management functions of your configured authenticator + * instead. + */ + @Deprecated + void changeUserPassword(String user, byte[] password) throws AccumuloException, AccumuloSecurityException; + + /** + * Set the user's password + * * @param principal * the name of the user to modify * @param token @@ -268,6 +334,19 @@ public interface SecurityOperations { * if a general error occurs * @throws AccumuloSecurityException * if the user does not have permission to query users + * @deprecated since 1.5.0; use {@link #listLocalUsers()} or the user management functions of your configured authenticator instead. + */ + @Deprecated + Set<String> listUsers() throws AccumuloException, AccumuloSecurityException; + + /** + * Return a list of users in accumulo + * + * @return a set of user names + * @throws AccumuloException + * if a general error occurs + * @throws AccumuloSecurityException + * if the user does not have permission to query users * @since 1.5.0 */ Set<String> listLocalUsers() throws AccumuloException, AccumuloSecurityException; http://git-wip-us.apache.org/repos/asf/accumulo/blob/4f2e6472/core/src/main/java/org/apache/accumulo/core/client/admin/TableOperations.java ---------------------------------------------------------------------- diff --git a/core/src/main/java/org/apache/accumulo/core/client/admin/TableOperations.java b/core/src/main/java/org/apache/accumulo/core/client/admin/TableOperations.java index a6046c6..3e56736 100644 --- a/core/src/main/java/org/apache/accumulo/core/client/admin/TableOperations.java +++ b/core/src/main/java/org/apache/accumulo/core/client/admin/TableOperations.java @@ -79,6 +79,40 @@ public interface TableOperations { /** * @param tableName * the name of the table + * @param limitVersion + * Enables/disables the versioning iterator, which will limit the number of Key versions kept. + * @throws AccumuloException + * if a general error occurs + * @throws AccumuloSecurityException + * if the user does not have permission + * @throws TableExistsException + * if the table already exists + * @deprecated since 1.7.0; use {@link #create(String, NewTableConfiguration)} instead. + */ + @Deprecated + void create(String tableName, boolean limitVersion) throws AccumuloException, AccumuloSecurityException, TableExistsException; + + /** + * @param tableName + * the name of the table + * @param versioningIter + * Enables/disables the versioning iterator, which will limit the number of Key versions kept. + * @param timeType + * specifies logical or real-time based time recording for entries in the table + * @throws AccumuloException + * if a general error occurs + * @throws AccumuloSecurityException + * if the user does not have permission + * @throws TableExistsException + * if the table already exists + * @deprecated since 1.7.0; use {@link #create(String, NewTableConfiguration)} instead. + */ + @Deprecated + void create(String tableName, boolean versioningIter, TimeType timeType) throws AccumuloException, AccumuloSecurityException, TableExistsException; + + /** + * @param tableName + * the name of the table * @param ntc * specifies the new table's configuration variable, which are: 1. enable/disable the versioning iterator, which will limit the number of Key * versions kept; 2. specifies logical or real-time based time recording for entries in the table; 3. user defined properties to be merged into the @@ -156,6 +190,17 @@ public interface TableOperations { * @return the split points (end-row names) for the table's current split profile * @throws TableNotFoundException * if the table does not exist + * @deprecated since 1.5.0; use {@link #listSplits(String)} instead. + */ + @Deprecated + Collection<Text> getSplits(String tableName) throws TableNotFoundException; + + /** + * @param tableName + * the name of the table + * @return the split points (end-row names) for the table's current split profile + * @throws TableNotFoundException + * if the table does not exist * @throws AccumuloException * if a general error occurs * @throws AccumuloSecurityException @@ -169,6 +214,17 @@ public interface TableOperations { * the name of the table * @param maxSplits * specifies the maximum number of splits to return + * @return the split points (end-row names) for the table's current split profile, grouped into fewer splits so as not to exceed maxSplits + * @deprecated since 1.5.0; use {@link #listSplits(String, int)} instead. + */ + @Deprecated + Collection<Text> getSplits(String tableName, int maxSplits) throws TableNotFoundException; + + /** + * @param tableName + * the name of the table + * @param maxSplits + * specifies the maximum number of splits to return * @throws AccumuloException * if a general error occurs * @throws AccumuloSecurityException @@ -360,6 +416,21 @@ public interface TableOperations { void rename(String oldTableName, String newTableName) throws AccumuloSecurityException, TableNotFoundException, AccumuloException, TableExistsException; /** + * Initiate a flush of a table's data that is in memory + * + * @param tableName + * the name of the table + * @throws AccumuloException + * if a general error occurs + * @throws AccumuloSecurityException + * if the user does not have permission + * + * @deprecated since 1.4; use {@link #flush(String, Text, Text, boolean)} instead + */ + @Deprecated + void flush(String tableName) throws AccumuloException, AccumuloSecurityException; + + /** * Flush a table's data that is currently in memory. * * @param tableName http://git-wip-us.apache.org/repos/asf/accumulo/blob/4f2e6472/core/src/main/java/org/apache/accumulo/core/client/impl/ActiveCompactionImpl.java ---------------------------------------------------------------------- diff --git a/core/src/main/java/org/apache/accumulo/core/client/impl/ActiveCompactionImpl.java b/core/src/main/java/org/apache/accumulo/core/client/impl/ActiveCompactionImpl.java index a34bcf7..bdd5d51 100644 --- a/core/src/main/java/org/apache/accumulo/core/client/impl/ActiveCompactionImpl.java +++ b/core/src/main/java/org/apache/accumulo/core/client/impl/ActiveCompactionImpl.java @@ -28,6 +28,7 @@ import org.apache.accumulo.core.data.TabletId; import org.apache.accumulo.core.data.impl.KeyExtent; import org.apache.accumulo.core.data.impl.TabletIdImpl; import org.apache.accumulo.core.data.thrift.IterInfo; +import org.apache.hadoop.io.Text; /** * @@ -49,6 +50,14 @@ public class ActiveCompactionImpl extends ActiveCompaction { } @Override + @Deprecated + public org.apache.accumulo.core.data.KeyExtent getExtent() { + KeyExtent ke = new KeyExtent(tac.getExtent()); + org.apache.accumulo.core.data.KeyExtent oke = new org.apache.accumulo.core.data.KeyExtent(new Text(ke.getTableId()), ke.getEndRow(), ke.getPrevEndRow()); + return oke; + } + + @Override public TabletId getTablet() { return new TabletIdImpl(new KeyExtent(tac.getExtent())); } http://git-wip-us.apache.org/repos/asf/accumulo/blob/4f2e6472/core/src/main/java/org/apache/accumulo/core/client/impl/ActiveScanImpl.java ---------------------------------------------------------------------- diff --git a/core/src/main/java/org/apache/accumulo/core/client/impl/ActiveScanImpl.java b/core/src/main/java/org/apache/accumulo/core/client/impl/ActiveScanImpl.java index dd96aa3..9021190 100644 --- a/core/src/main/java/org/apache/accumulo/core/client/impl/ActiveScanImpl.java +++ b/core/src/main/java/org/apache/accumulo/core/client/impl/ActiveScanImpl.java @@ -32,6 +32,7 @@ import org.apache.accumulo.core.data.impl.TabletIdImpl; import org.apache.accumulo.core.data.thrift.IterInfo; import org.apache.accumulo.core.data.thrift.TColumn; import org.apache.accumulo.core.security.Authorizations; +import org.apache.hadoop.io.Text; /** * A class that contains information about an ActiveScan @@ -119,6 +120,12 @@ public class ActiveScanImpl extends ActiveScan { } @Override + @Deprecated + public org.apache.accumulo.core.data.KeyExtent getExtent() { + return new org.apache.accumulo.core.data.KeyExtent(new Text(extent.getTableId()), extent.getEndRow(), extent.getPrevEndRow()); + } + + @Override public TabletId getTablet() { return new TabletIdImpl(extent); } http://git-wip-us.apache.org/repos/asf/accumulo/blob/4f2e6472/core/src/main/java/org/apache/accumulo/core/client/impl/ConnectorImpl.java ---------------------------------------------------------------------- diff --git a/core/src/main/java/org/apache/accumulo/core/client/impl/ConnectorImpl.java b/core/src/main/java/org/apache/accumulo/core/client/impl/ConnectorImpl.java index 324e11a..b2b02b1 100644 --- a/core/src/main/java/org/apache/accumulo/core/client/impl/ConnectorImpl.java +++ b/core/src/main/java/org/apache/accumulo/core/client/impl/ConnectorImpl.java @@ -18,6 +18,8 @@ package org.apache.accumulo.core.client.impl; import static com.google.common.base.Preconditions.checkArgument; +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; @@ -94,6 +96,16 @@ public class ConnectorImpl extends Connector { return new TabletServerBatchReader(context, getTableId(tableName), authorizations, numQueryThreads); } + @Deprecated + @Override + public BatchDeleter createBatchDeleter(String tableName, Authorizations authorizations, int numQueryThreads, long maxMemory, long maxLatency, + int maxWriteThreads) throws TableNotFoundException { + checkArgument(tableName != null, "tableName is null"); + checkArgument(authorizations != null, "authorizations is null"); + return new TabletServerBatchDeleter(context, getTableId(tableName), authorizations, numQueryThreads, new BatchWriterConfig().setMaxMemory(maxMemory) + .setMaxLatency(maxLatency, TimeUnit.MILLISECONDS).setMaxWriteThreads(maxWriteThreads)); + } + @Override public BatchDeleter createBatchDeleter(String tableName, Authorizations authorizations, int numQueryThreads, BatchWriterConfig config) throws TableNotFoundException { @@ -102,12 +114,27 @@ public class ConnectorImpl extends Connector { return new TabletServerBatchDeleter(context, getTableId(tableName), authorizations, numQueryThreads, config); } + @Deprecated + @Override + public BatchWriter createBatchWriter(String tableName, long maxMemory, long maxLatency, int maxWriteThreads) throws TableNotFoundException { + checkArgument(tableName != null, "tableName is null"); + return new BatchWriterImpl(context, getTableId(tableName), new BatchWriterConfig().setMaxMemory(maxMemory).setMaxLatency(maxLatency, TimeUnit.MILLISECONDS) + .setMaxWriteThreads(maxWriteThreads)); + } + @Override public BatchWriter createBatchWriter(String tableName, BatchWriterConfig config) throws TableNotFoundException { checkArgument(tableName != null, "tableName is null"); return new BatchWriterImpl(context, getTableId(tableName), config); } + @Deprecated + @Override + public MultiTableBatchWriter createMultiTableBatchWriter(long maxMemory, long maxLatency, int maxWriteThreads) { + return new MultiTableBatchWriterImpl(context, new BatchWriterConfig().setMaxMemory(maxMemory).setMaxLatency(maxLatency, TimeUnit.MILLISECONDS) + .setMaxWriteThreads(maxWriteThreads)); + } + @Override public MultiTableBatchWriter createMultiTableBatchWriter(BatchWriterConfig config) { return new MultiTableBatchWriterImpl(context, config); http://git-wip-us.apache.org/repos/asf/accumulo/blob/4f2e6472/core/src/main/java/org/apache/accumulo/core/client/impl/OfflineScanner.java ---------------------------------------------------------------------- diff --git a/core/src/main/java/org/apache/accumulo/core/client/impl/OfflineScanner.java b/core/src/main/java/org/apache/accumulo/core/client/impl/OfflineScanner.java index 176096a..427a7cc 100644 --- a/core/src/main/java/org/apache/accumulo/core/client/impl/OfflineScanner.java +++ b/core/src/main/java/org/apache/accumulo/core/client/impl/OfflineScanner.java @@ -33,6 +33,7 @@ import org.apache.hadoop.io.Text; public class OfflineScanner extends ScannerOptions implements Scanner { private int batchSize; + private int timeOut; private Range range; private Instance instance; @@ -56,6 +57,18 @@ public class OfflineScanner extends ScannerOptions implements Scanner { this.timeOut = Integer.MAX_VALUE; } + @Deprecated + @Override + public void setTimeOut(int timeOut) { + this.timeOut = timeOut; + } + + @Deprecated + @Override + public int getTimeOut() { + return timeOut; + } + @Override public void setRange(Range range) { this.range = range; http://git-wip-us.apache.org/repos/asf/accumulo/blob/4f2e6472/core/src/main/java/org/apache/accumulo/core/client/impl/ScannerImpl.java ---------------------------------------------------------------------- diff --git a/core/src/main/java/org/apache/accumulo/core/client/impl/ScannerImpl.java b/core/src/main/java/org/apache/accumulo/core/client/impl/ScannerImpl.java index b0a0fa3..89406f4 100644 --- a/core/src/main/java/org/apache/accumulo/core/client/impl/ScannerImpl.java +++ b/core/src/main/java/org/apache/accumulo/core/client/impl/ScannerImpl.java @@ -92,7 +92,7 @@ public class ScannerImpl extends ScannerOptions implements Scanner { @Override public synchronized Iterator<Entry<Key,Value>> iterator() { - return new ScannerIterator(context, tableId, authorizations, range, size, getTimeout(TimeUnit.SECONDS), this, isolated, readaheadThreshold); + return new ScannerIterator(context, tableId, authorizations, range, size, getTimeOut(), this, isolated, readaheadThreshold); } @Override @@ -110,6 +110,24 @@ public class ScannerImpl extends ScannerOptions implements Scanner { this.isolated = false; } + @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 synchronized void setReadaheadThreshold(long batches) { if (0 > batches) { http://git-wip-us.apache.org/repos/asf/accumulo/blob/4f2e6472/core/src/main/java/org/apache/accumulo/core/client/impl/ScannerIterator.java ---------------------------------------------------------------------- diff --git a/core/src/main/java/org/apache/accumulo/core/client/impl/ScannerIterator.java b/core/src/main/java/org/apache/accumulo/core/client/impl/ScannerIterator.java index 7d01895..ae55cc0 100644 --- a/core/src/main/java/org/apache/accumulo/core/client/impl/ScannerIterator.java +++ b/core/src/main/java/org/apache/accumulo/core/client/impl/ScannerIterator.java @@ -48,7 +48,7 @@ public class ScannerIterator implements Iterator<Entry<Key,Value>> { private static final Logger log = LoggerFactory.getLogger(ScannerIterator.class); // scanner options - private long timeOut; + private int timeOut; // scanner state private Iterator<KeyValue> iter; @@ -104,7 +104,7 @@ public class ScannerIterator implements Iterator<Entry<Key,Value>> { } - ScannerIterator(ClientContext context, String tableId, Authorizations authorizations, Range range, int size, long timeOut, ScannerOptions options, + ScannerIterator(ClientContext context, String tableId, Authorizations authorizations, Range range, int size, int timeOut, ScannerOptions options, boolean isolated, long readaheadThreshold) { this.timeOut = timeOut; this.readaheadThreshold = readaheadThreshold; @@ -133,6 +133,7 @@ public class ScannerIterator implements Iterator<Entry<Key,Value>> { } @Override + @SuppressWarnings("unchecked") public boolean hasNext() { if (finished) return false; @@ -159,7 +160,6 @@ public class ScannerIterator implements Iterator<Entry<Key,Value>> { throw new RuntimeException((Exception) obj); } - @SuppressWarnings("unchecked") List<KeyValue> currentBatch = (List<KeyValue>) obj; if (currentBatch.size() == 0) { http://git-wip-us.apache.org/repos/asf/accumulo/blob/4f2e6472/core/src/main/java/org/apache/accumulo/core/client/impl/SecurityOperationsImpl.java ---------------------------------------------------------------------- diff --git a/core/src/main/java/org/apache/accumulo/core/client/impl/SecurityOperationsImpl.java b/core/src/main/java/org/apache/accumulo/core/client/impl/SecurityOperationsImpl.java index 6e3d714..781a5d4 100644 --- a/core/src/main/java/org/apache/accumulo/core/client/impl/SecurityOperationsImpl.java +++ b/core/src/main/java/org/apache/accumulo/core/client/impl/SecurityOperationsImpl.java @@ -93,6 +93,13 @@ public class SecurityOperationsImpl implements SecurityOperations { this.context = context; } + @Deprecated + @Override + public void createUser(String user, byte[] password, final Authorizations authorizations) throws AccumuloException, AccumuloSecurityException { + createLocalUser(user, new PasswordToken(password)); + changeUserAuthorizations(user, authorizations); + } + @Override public void createLocalUser(final String principal, final PasswordToken password) throws AccumuloException, AccumuloSecurityException { checkArgument(principal != null, "principal is null"); @@ -111,6 +118,12 @@ public class SecurityOperationsImpl implements SecurityOperations { }); } + @Deprecated + @Override + public void dropUser(final String user) throws AccumuloException, AccumuloSecurityException { + dropLocalUser(user); + } + @Override public void dropLocalUser(final String principal) throws AccumuloException, AccumuloSecurityException { checkArgument(principal != null, "principal is null"); @@ -122,6 +135,12 @@ public class SecurityOperationsImpl implements SecurityOperations { }); } + @Deprecated + @Override + public boolean authenticateUser(String user, byte[] password) throws AccumuloException, AccumuloSecurityException { + return authenticateUser(user, new PasswordToken(password)); + } + @Override public boolean authenticateUser(final String principal, final AuthenticationToken token) throws AccumuloException, AccumuloSecurityException { checkArgument(principal != null, "principal is null"); @@ -136,6 +155,12 @@ public class SecurityOperationsImpl implements SecurityOperations { } @Override + @Deprecated + public void changeUserPassword(String user, byte[] password) throws AccumuloException, AccumuloSecurityException { + changeLocalUserPassword(user, new PasswordToken(password)); + } + + @Override public void changeLocalUserPassword(final String principal, final PasswordToken token) throws AccumuloException, AccumuloSecurityException { checkArgument(principal != null, "principal is null"); checkArgument(token != null, "token is null"); @@ -314,6 +339,12 @@ public class SecurityOperationsImpl implements SecurityOperations { }); } + @Deprecated + @Override + public Set<String> listUsers() throws AccumuloException, AccumuloSecurityException { + return listLocalUsers(); + } + @Override public Set<String> listLocalUsers() throws AccumuloException, AccumuloSecurityException { return execute(new ClientExecReturn<Set<String>,ClientService.Client>() { http://git-wip-us.apache.org/repos/asf/accumulo/blob/4f2e6472/core/src/main/java/org/apache/accumulo/core/client/impl/TableOperationsImpl.java ---------------------------------------------------------------------- diff --git a/core/src/main/java/org/apache/accumulo/core/client/impl/TableOperationsImpl.java b/core/src/main/java/org/apache/accumulo/core/client/impl/TableOperationsImpl.java index 931c7f7..3d17a85 100644 --- a/core/src/main/java/org/apache/accumulo/core/client/impl/TableOperationsImpl.java +++ b/core/src/main/java/org/apache/accumulo/core/client/impl/TableOperationsImpl.java @@ -70,6 +70,7 @@ 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.TableOperations; +import org.apache.accumulo.core.client.admin.TimeType; import org.apache.accumulo.core.client.impl.TabletLocator.TabletLocation; import org.apache.accumulo.core.client.impl.thrift.ClientService; import org.apache.accumulo.core.client.impl.thrift.ClientService.Client; @@ -187,6 +188,26 @@ public class TableOperationsImpl extends TableOperationsHelper { } @Override + @Deprecated + public void create(String tableName, boolean limitVersion) throws AccumuloException, AccumuloSecurityException, TableExistsException { + create(tableName, limitVersion, TimeType.MILLIS); + } + + @Override + @Deprecated + public void create(String tableName, boolean limitVersion, TimeType timeType) throws AccumuloException, AccumuloSecurityException, TableExistsException { + checkArgument(tableName != null, "tableName is null"); + checkArgument(timeType != null, "timeType is null"); + + NewTableConfiguration ntc = new NewTableConfiguration().setTimeType(timeType); + + if (limitVersion) + create(tableName, ntc); + else + create(tableName, ntc.withoutDefaultIterators()); + } + + @Override public void create(String tableName, NewTableConfiguration ntc) throws AccumuloException, AccumuloSecurityException, TableExistsException { checkArgument(tableName != null, "tableName is null"); checkArgument(ntc != null, "ntc is null"); @@ -573,6 +594,16 @@ public class TableOperationsImpl extends TableOperationsHelper { return endRows; } + @Deprecated + @Override + public Collection<Text> getSplits(String tableName) throws TableNotFoundException { + try { + return listSplits(tableName); + } catch (AccumuloSecurityException e) { + throw new RuntimeException(e); + } + } + @Override public Collection<Text> listSplits(String tableName, int maxSplits) throws TableNotFoundException, AccumuloSecurityException { Collection<Text> endRows = listSplits(tableName); @@ -598,6 +629,16 @@ public class TableOperationsImpl extends TableOperationsHelper { return subset; } + @Deprecated + @Override + public Collection<Text> getSplits(String tableName, int maxSplits) throws TableNotFoundException { + try { + return listSplits(tableName, maxSplits); + } catch (AccumuloSecurityException e) { + throw new RuntimeException(e); + } + } + @Override public void delete(String tableName) throws AccumuloException, AccumuloSecurityException, TableNotFoundException { checkArgument(tableName != null, "tableName is null"); @@ -657,6 +698,16 @@ public class TableOperationsImpl extends TableOperationsHelper { } @Override + @Deprecated + public void flush(String tableName) throws AccumuloException, AccumuloSecurityException { + try { + flush(tableName, null, null, false); + } catch (TableNotFoundException e) { + throw new AccumuloException(e.getMessage(), e); + } + } + + @Override public void flush(String tableName, Text start, Text end, boolean wait) throws AccumuloException, AccumuloSecurityException, TableNotFoundException { checkArgument(tableName != null, "tableName is null"); http://git-wip-us.apache.org/repos/asf/accumulo/blob/4f2e6472/core/src/main/java/org/apache/accumulo/core/client/impl/ThriftScanner.java ---------------------------------------------------------------------- diff --git a/core/src/main/java/org/apache/accumulo/core/client/impl/ThriftScanner.java b/core/src/main/java/org/apache/accumulo/core/client/impl/ThriftScanner.java index 7f85afc..e69143c 100644 --- a/core/src/main/java/org/apache/accumulo/core/client/impl/ThriftScanner.java +++ b/core/src/main/java/org/apache/accumulo/core/client/impl/ThriftScanner.java @@ -214,7 +214,7 @@ public class ThriftScanner { return (long) (Math.min(millis * 2, maxSleep) * (.9 + Math.random() / 5)); } - public static List<KeyValue> scan(ClientContext context, ScanState scanState, long timeOut) throws ScanTimedOutException, AccumuloException, + public static List<KeyValue> scan(ClientContext context, ScanState scanState, int timeOut) throws ScanTimedOutException, AccumuloException, AccumuloSecurityException, TableNotFoundException { TabletLocation loc = null; Instance instance = context.getInstance(); http://git-wip-us.apache.org/repos/asf/accumulo/blob/4f2e6472/core/src/main/java/org/apache/accumulo/core/client/mapred/AbstractInputFormat.java ---------------------------------------------------------------------- diff --git a/core/src/main/java/org/apache/accumulo/core/client/mapred/AbstractInputFormat.java b/core/src/main/java/org/apache/accumulo/core/client/mapred/AbstractInputFormat.java index 9ca686c..6165346 100644 --- a/core/src/main/java/org/apache/accumulo/core/client/mapred/AbstractInputFormat.java +++ b/core/src/main/java/org/apache/accumulo/core/client/mapred/AbstractInputFormat.java @@ -16,8 +16,6 @@ */ package org.apache.accumulo.core.client.mapred; -import static com.google.common.util.concurrent.Uninterruptibles.sleepUninterruptibly; - import java.io.IOException; import java.net.InetAddress; import java.util.ArrayList; @@ -70,6 +68,7 @@ import org.apache.accumulo.core.data.Value; import org.apache.accumulo.core.data.impl.KeyExtent; import org.apache.accumulo.core.master.state.tables.TableState; import org.apache.accumulo.core.security.Authorizations; +import org.apache.accumulo.core.util.DeprecationUtil; import org.apache.accumulo.core.util.Pair; import org.apache.hadoop.io.Text; import org.apache.hadoop.mapred.InputFormat; @@ -80,6 +79,8 @@ import org.apache.hadoop.security.token.Token; import org.apache.log4j.Level; import org.apache.log4j.Logger; +import static com.google.common.util.concurrent.Uninterruptibles.sleepUninterruptibly; + /** * An abstract input format to provide shared methods common to all other input format classes. At the very least, any classes inheriting from this class will * need to define their own {@link RecordReader}. @@ -221,6 +222,23 @@ public abstract class AbstractInputFormat<K,V> implements InputFormat<K,V> { * * @param job * the Hadoop job instance to be configured + * @param instanceName + * the Accumulo instance name + * @param zooKeepers + * a comma-separated list of zookeeper servers + * @since 1.5.0 + * @deprecated since 1.6.0; Use {@link #setZooKeeperInstance(JobConf, ClientConfiguration)} instead. + */ + @Deprecated + public static void setZooKeeperInstance(JobConf job, String instanceName, String zooKeepers) { + setZooKeeperInstance(job, new ClientConfiguration().withInstance(instanceName).withZkHosts(zooKeepers)); + } + + /** + * Configures a {@link org.apache.accumulo.core.client.ZooKeeperInstance} for this job. + * + * @param job + * the Hadoop job instance to be configured * @param clientConfig * client configuration containing connection options * @since 1.6.0 @@ -230,6 +248,21 @@ public abstract class AbstractInputFormat<K,V> implements InputFormat<K,V> { } /** + * Configures a {@link org.apache.accumulo.core.client.mock.MockInstance} for this job. + * + * @param job + * the Hadoop job instance to be configured + * @param instanceName + * the Accumulo instance name + * @since 1.5.0 + * @deprecated since 1.8.0; use MiniAccumuloCluster or a standard mock framework + */ + @Deprecated + public static void setMockInstance(JobConf job, String instanceName) { + InputConfigurator.setMockInstance(CLASS, job, instanceName); + } + + /** * Initializes an Accumulo {@link org.apache.accumulo.core.client.Instance} based on the configuration. * * @param job @@ -295,6 +328,23 @@ public abstract class AbstractInputFormat<K,V> implements InputFormat<K,V> { } /** + * Initializes an Accumulo {@link org.apache.accumulo.core.client.impl.TabletLocator} based on the configuration. + * + * @param job + * the Hadoop context for the configured job + * @return an Accumulo tablet locator + * @throws org.apache.accumulo.core.client.TableNotFoundException + * if the table name set on the configuration doesn't exist + * @since 1.6.0 + * @deprecated since 1.7.0 This method returns a type that is not part of the public API and is not guaranteed to be stable. The method was deprecated to + * discourage its use. + */ + @Deprecated + protected static TabletLocator getTabletLocator(JobConf job, String tableId) throws TableNotFoundException { + return InputConfigurator.getTabletLocator(CLASS, job, tableId); + } + + /** * Fetch the client configuration from the job. * * @param job @@ -417,6 +467,23 @@ public abstract class AbstractInputFormat<K,V> implements InputFormat<K,V> { } /** + * Configures the iterators on a scanner for the given table name. + * + * @param job + * the Hadoop job configuration + * @param scanner + * the scanner for which to configure the iterators + * @param tableName + * the table name for which the scanner is configured + * @since 1.6.0 + * @deprecated since 1.7.0; Use {@link #jobIterators} instead. + */ + @Deprecated + protected void setupIterators(JobConf job, Scanner scanner, String tableName, RangeInputSplit split) { + setupIterators(job, (ScannerBase) scanner, tableName, split); + } + + /** * Initialize a scanner over the given input split using this task attempt configuration. */ public void initialize(InputSplit inSplit, JobConf job) throws IOException { @@ -494,6 +561,8 @@ public abstract class AbstractInputFormat<K,V> implements InputFormat<K,V> { try { if (isOffline) { scanner = new OfflineScanner(instance, new Credentials(principal, token), baseSplit.getTableId(), authorizations); + } else if (DeprecationUtil.isMockInstance(instance)) { + scanner = instance.getConnector(principal, token).createScanner(baseSplit.getTableName(), authorizations); } else { ClientConfiguration clientConf = getClientConfiguration(job); ClientContext context = new ClientContext(instance, new Credentials(principal, token), clientConf); @@ -602,10 +671,14 @@ public abstract class AbstractInputFormat<K,V> implements InputFormat<K,V> { Instance instance = getInstance(job); String tableId; // resolve table name to id once, and use id from this point forward - try { - tableId = Tables.getTableId(instance, tableName); - } catch (TableNotFoundException e) { - throw new IOException(e); + if (DeprecationUtil.isMockInstance(instance)) { + tableId = ""; + } else { + try { + tableId = Tables.getTableId(instance, tableName); + } catch (TableNotFoundException e) { + throw new IOException(e); + } } Authorizations auths = getScanAuthorizations(job); @@ -647,10 +720,12 @@ public abstract class AbstractInputFormat<K,V> implements InputFormat<K,V> { ClientContext context = new ClientContext(getInstance(job), new Credentials(getPrincipal(job), getAuthenticationToken(job)), getClientConfiguration(job)); while (!tl.binRanges(context, ranges, binnedRanges).isEmpty()) { - if (!Tables.exists(instance, tableId)) - throw new TableDeletedException(tableId); - if (Tables.getTableState(instance, tableId) == TableState.OFFLINE) - throw new TableOfflineException(instance, tableId); + if (!DeprecationUtil.isMockInstance(instance)) { + if (!Tables.exists(instance, tableId)) + throw new TableDeletedException(tableId); + if (Tables.getTableState(instance, tableId) == TableState.OFFLINE) + throw new TableOfflineException(instance, tableId); + } binnedRanges.clear(); log.warn("Unable to locate bins for specified ranges. Retrying."); // sleep randomly between 100 and 200 ms http://git-wip-us.apache.org/repos/asf/accumulo/blob/4f2e6472/core/src/main/java/org/apache/accumulo/core/client/mapred/AccumuloFileOutputFormat.java ---------------------------------------------------------------------- diff --git a/core/src/main/java/org/apache/accumulo/core/client/mapred/AccumuloFileOutputFormat.java b/core/src/main/java/org/apache/accumulo/core/client/mapred/AccumuloFileOutputFormat.java index 640a85d..f2bc4cd 100644 --- a/core/src/main/java/org/apache/accumulo/core/client/mapred/AccumuloFileOutputFormat.java +++ b/core/src/main/java/org/apache/accumulo/core/client/mapred/AccumuloFileOutputFormat.java @@ -53,6 +53,21 @@ public class AccumuloFileOutputFormat extends FileOutputFormat<Key,Value> { protected static final Logger log = Logger.getLogger(CLASS); /** + * This helper method provides an AccumuloConfiguration object constructed from the Accumulo defaults, and overridden with Accumulo properties that have been + * stored in the Job's configuration. + * + * @param job + * the Hadoop context for the configured job + * @since 1.5.0 + * @deprecated since 1.7.0 This method returns a type that is not part of the public API and is not guaranteed to be stable. The method was deprecated to + * discourage its use. + */ + @Deprecated + protected static AccumuloConfiguration getAccumuloConfiguration(JobConf job) { + return FileOutputConfigurator.getAccumuloConfiguration(CLASS, job); + } + + /** * Sets the compression type to use for data blocks. Specifying a compression may require additional libraries to be available to your Job. * * @param job http://git-wip-us.apache.org/repos/asf/accumulo/blob/4f2e6472/core/src/main/java/org/apache/accumulo/core/client/mapred/AccumuloOutputFormat.java ---------------------------------------------------------------------- diff --git a/core/src/main/java/org/apache/accumulo/core/client/mapred/AccumuloOutputFormat.java b/core/src/main/java/org/apache/accumulo/core/client/mapred/AccumuloOutputFormat.java index 9ac459e..5feadb8 100644 --- a/core/src/main/java/org/apache/accumulo/core/client/mapred/AccumuloOutputFormat.java +++ b/core/src/main/java/org/apache/accumulo/core/client/mapred/AccumuloOutputFormat.java @@ -42,6 +42,7 @@ import org.apache.accumulo.core.client.mapreduce.lib.impl.ConfiguratorBase; import org.apache.accumulo.core.client.mapreduce.lib.impl.OutputConfigurator; import org.apache.accumulo.core.client.security.SecurityErrorCode; import org.apache.accumulo.core.client.security.tokens.AuthenticationToken; +import org.apache.accumulo.core.client.security.tokens.AuthenticationToken.AuthenticationTokenSerializer; import org.apache.accumulo.core.client.security.tokens.DelegationToken; import org.apache.accumulo.core.client.security.tokens.KerberosToken; import org.apache.accumulo.core.client.security.tokens.PasswordToken; @@ -168,6 +169,28 @@ public class AccumuloOutputFormat implements OutputFormat<Text,Mutation> { } /** + * Gets the serialized token class from either the configuration or the token file. + * + * @since 1.5.0 + * @deprecated since 1.6.0; Use {@link #getAuthenticationToken(JobConf)} instead. + */ + @Deprecated + protected static String getTokenClass(JobConf job) { + return getAuthenticationToken(job).getClass().getName(); + } + + /** + * Gets the serialized token from either the configuration or the token file. + * + * @since 1.5.0 + * @deprecated since 1.6.0; Use {@link #getAuthenticationToken(JobConf)} instead. + */ + @Deprecated + protected static byte[] getToken(JobConf job) { + return AuthenticationTokenSerializer.serialize(getAuthenticationToken(job)); + } + + /** * Gets the authenticated token from either the specified token file or directly from the configuration, whichever was used when the job was configured. * * @param job @@ -187,6 +210,24 @@ public class AccumuloOutputFormat implements OutputFormat<Text,Mutation> { * * @param job * the Hadoop job instance to be configured + * @param instanceName + * the Accumulo instance name + * @param zooKeepers + * a comma-separated list of zookeeper servers + * @since 1.5.0 + * @deprecated since 1.6.0; Use {@link #setZooKeeperInstance(JobConf, ClientConfiguration)} instead. + */ + + @Deprecated + public static void setZooKeeperInstance(JobConf job, String instanceName, String zooKeepers) { + setZooKeeperInstance(job, new ClientConfiguration().withInstance(instanceName).withZkHosts(zooKeepers)); + } + + /** + * Configures a {@link ZooKeeperInstance} for this job. + * + * @param job + * the Hadoop job instance to be configured * * @param clientConfig * client configuration for specifying connection timeouts, SSL connection options, etc. @@ -197,6 +238,21 @@ public class AccumuloOutputFormat implements OutputFormat<Text,Mutation> { } /** + * Configures a {@link org.apache.accumulo.core.client.mock.MockInstance} for this job. + * + * @param job + * the Hadoop job instance to be configured + * @param instanceName + * the Accumulo instance name + * @since 1.5.0 + * @deprecated since 1.8.0; use MiniAccumuloCluster or a standard mock framework + */ + @Deprecated + public static void setMockInstance(JobConf job, String instanceName) { + OutputConfigurator.setMockInstance(CLASS, job, instanceName); + } + + /** * Initializes an Accumulo {@link Instance} based on the configuration. * * @param job http://git-wip-us.apache.org/repos/asf/accumulo/blob/4f2e6472/core/src/main/java/org/apache/accumulo/core/client/mapred/InputFormatBase.java ---------------------------------------------------------------------- diff --git a/core/src/main/java/org/apache/accumulo/core/client/mapred/InputFormatBase.java b/core/src/main/java/org/apache/accumulo/core/client/mapred/InputFormatBase.java index 2523819..0cf57d2 100644 --- a/core/src/main/java/org/apache/accumulo/core/client/mapred/InputFormatBase.java +++ b/core/src/main/java/org/apache/accumulo/core/client/mapred/InputFormatBase.java @@ -24,7 +24,10 @@ import java.util.Set; import org.apache.accumulo.core.client.ClientSideIteratorScanner; import org.apache.accumulo.core.client.IsolatedScanner; import org.apache.accumulo.core.client.IteratorSetting; +import org.apache.accumulo.core.client.Scanner; import org.apache.accumulo.core.client.ScannerBase; +import org.apache.accumulo.core.client.TableNotFoundException; +import org.apache.accumulo.core.client.impl.TabletLocator; import org.apache.accumulo.core.client.mapreduce.lib.impl.InputConfigurator; import org.apache.accumulo.core.client.sample.SamplerConfiguration; import org.apache.accumulo.core.data.Key; @@ -352,6 +355,22 @@ public abstract class InputFormatBase<K,V> extends AbstractInputFormat<K,V> { InputConfigurator.setSamplerConfiguration(CLASS, job, samplerConfig); } + /** + * Initializes an Accumulo {@link org.apache.accumulo.core.client.impl.TabletLocator} based on the configuration. + * + * @param job + * the Hadoop job for the configured job + * @return an Accumulo tablet locator + * @throws org.apache.accumulo.core.client.TableNotFoundException + * if the table name set on the job doesn't exist + * @since 1.5.0 + * @deprecated since 1.6.0 + */ + @Deprecated + protected static TabletLocator getTabletLocator(JobConf job) throws TableNotFoundException { + return InputConfigurator.getTabletLocator(CLASS, job, InputConfigurator.getInputTableName(CLASS, job)); + } + protected abstract static class RecordReaderBase<K,V> extends AbstractRecordReader<K,V> { @Override @@ -359,6 +378,56 @@ public abstract class InputFormatBase<K,V> extends AbstractInputFormat<K,V> { return getIterators(job); } + /** + * Apply the configured iterators to the scanner. + * + * @param iterators + * the iterators to set + * @param scanner + * the scanner to configure + * @deprecated since 1.7.0; Use {@link #jobIterators} instead. + */ + @Deprecated + protected void setupIterators(List<IteratorSetting> iterators, Scanner scanner) { + for (IteratorSetting iterator : iterators) { + scanner.addScanIterator(iterator); + } + } + + /** + * Apply the configured iterators from the configuration to the scanner. + * + * @param job + * the job configuration + * @param scanner + * the scanner to configure + */ + @Deprecated + protected void setupIterators(JobConf job, Scanner scanner) { + setupIterators(getIterators(job), scanner); + } } + /** + * @deprecated since 1.5.2; Use {@link org.apache.accumulo.core.client.mapred.RangeInputSplit} instead. + * @see org.apache.accumulo.core.client.mapred.RangeInputSplit + */ + @Deprecated + public static class RangeInputSplit extends org.apache.accumulo.core.client.mapred.RangeInputSplit { + public RangeInputSplit() { + super(); + } + + public RangeInputSplit(RangeInputSplit other) throws IOException { + super(other); + } + + public RangeInputSplit(String table, String tableId, Range range, String[] locations) { + super(table, tableId, range, locations); + } + + protected RangeInputSplit(String table, Range range, String[] locations) { + super(table, "", range, locations); + } + } }