Repository: accumulo Updated Branches: refs/heads/1.6.0-SNAPSHOT d9fe31577 -> be688faa6 refs/heads/master afbf5f160 -> 5d0d6aa05
ACCUMULO-2527 Compiler warning cleanup. For internal use of deprecations, where applicable, new tickets with TODOs were placed in the comments to mark the necessity to fix the code. To ease deprecation suppression, some code was lifted into a single method to reduce impact. Project: http://git-wip-us.apache.org/repos/asf/accumulo/repo Commit: http://git-wip-us.apache.org/repos/asf/accumulo/commit/be688faa Tree: http://git-wip-us.apache.org/repos/asf/accumulo/tree/be688faa Diff: http://git-wip-us.apache.org/repos/asf/accumulo/diff/be688faa Branch: refs/heads/1.6.0-SNAPSHOT Commit: be688faa68d35579a9782a93816790f7a870d7ca Parents: d9fe315 Author: Josh Elser <els...@apache.org> Authored: Fri Mar 21 17:04:44 2014 -0400 Committer: Josh Elser <els...@apache.org> Committed: Fri Mar 21 17:04:44 2014 -0400 ---------------------------------------------------------------------- .../apache/accumulo/core/cli/ClientOpts.java | 3 ++ .../core/client/impl/OfflineScanner.java | 3 ++ .../CachingHDFSSecretKeyEncryptionStrategy.java | 1 + .../NonCachingSecretKeyEncryptionStrategy.java | 9 ++-- .../apache/accumulo/core/volume/VolumeImpl.java | 2 - .../core/util/shell/ShellSetInstanceTest.java | 1 + .../impl/MiniAccumuloConfigImpl.java | 11 ++++- .../impl/MiniAccumuloConfigImplTest.java | 1 + .../apache/accumulo/proxy/SimpleProxyIT.java | 1 - .../org/apache/accumulo/server/Accumulo.java | 1 - .../apache/accumulo/server/init/Initialize.java | 46 +++++++++++--------- .../apache/accumulo/server/util/FileUtil.java | 4 ++ .../accumulo/server/init/InitializeTest.java | 5 +++ .../apache/accumulo/tserver/RootFilesTest.java | 1 + .../accumulo/test/BulkImportVolumeIT.java | 1 - 15 files changed, 59 insertions(+), 31 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/accumulo/blob/be688faa/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 7573f69..efb910a 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 @@ -257,6 +257,9 @@ public class ClientOpts extends Help { } }; this.zookeepers = config.get(Property.INSTANCE_ZK_HOST); + //TODO ACCUMULO-2531 Need something that is capable of using instance.volumes or + // instance.dfs.{uri,dir} to find the instanceID + @SuppressWarnings("deprecation") Path instanceDir = new Path(config.get(Property.INSTANCE_DFS_DIR), "instance_id"); String instanceIDFromFile = ZooUtil.getInstanceIDFromHdfs(instanceDir, config); if (config.getBoolean(Property.INSTANCE_RPC_SSL_ENABLED)) http://git-wip-us.apache.org/repos/asf/accumulo/blob/be688faa/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 20228d2..522125f 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 @@ -229,6 +229,9 @@ class OfflineIterator implements Iterator<Entry<Key,Value>> { if (currentExtent != null && !extent.isPreviousExtent(currentExtent)) throw new AccumuloException(" " + currentExtent + " is not previous extent " + extent); + // Old property is only used to resolve relative paths into absolute paths. For systems upgraded + // with relative paths, it's assumed that correct instance.dfs.{uri,dir} is still correct in the configuration + @SuppressWarnings("deprecation") String tablesDir = config.get(Property.INSTANCE_DFS_DIR) + Constants.HDFS_TABLES_DIR; List<String> absFiles = new ArrayList<String>(); http://git-wip-us.apache.org/repos/asf/accumulo/blob/be688faa/core/src/main/java/org/apache/accumulo/core/security/crypto/CachingHDFSSecretKeyEncryptionStrategy.java ---------------------------------------------------------------------- diff --git a/core/src/main/java/org/apache/accumulo/core/security/crypto/CachingHDFSSecretKeyEncryptionStrategy.java b/core/src/main/java/org/apache/accumulo/core/security/crypto/CachingHDFSSecretKeyEncryptionStrategy.java index 5b0b361..d25d08c 100644 --- a/core/src/main/java/org/apache/accumulo/core/security/crypto/CachingHDFSSecretKeyEncryptionStrategy.java +++ b/core/src/main/java/org/apache/accumulo/core/security/crypto/CachingHDFSSecretKeyEncryptionStrategy.java @@ -174,6 +174,7 @@ public class CachingHDFSSecretKeyEncryptionStrategy implements SecretKeyEncrypti } + @SuppressWarnings("deprecation") private String getFullPathToKey(CryptoModuleParameters params) { String pathToKeyName = params.getAllOptions().get(Property.CRYPTO_DEFAULT_KEY_STRATEGY_KEY_LOCATION.getKey()); String instanceDirectory = params.getAllOptions().get(Property.INSTANCE_DFS_DIR.getKey()); http://git-wip-us.apache.org/repos/asf/accumulo/blob/be688faa/core/src/main/java/org/apache/accumulo/core/security/crypto/NonCachingSecretKeyEncryptionStrategy.java ---------------------------------------------------------------------- diff --git a/core/src/main/java/org/apache/accumulo/core/security/crypto/NonCachingSecretKeyEncryptionStrategy.java b/core/src/main/java/org/apache/accumulo/core/security/crypto/NonCachingSecretKeyEncryptionStrategy.java index e72fd06..efcec01 100644 --- a/core/src/main/java/org/apache/accumulo/core/security/crypto/NonCachingSecretKeyEncryptionStrategy.java +++ b/core/src/main/java/org/apache/accumulo/core/security/crypto/NonCachingSecretKeyEncryptionStrategy.java @@ -35,6 +35,7 @@ import org.apache.hadoop.fs.FileSystem; import org.apache.hadoop.fs.Path; import org.apache.log4j.Logger; +//TODO ACCUMULO-2530 Update properties to use a URI instead of a relative path to secret key public class NonCachingSecretKeyEncryptionStrategy implements SecretKeyEncryptionStrategy { private static final Logger log = Logger.getLogger(NonCachingSecretKeyEncryptionStrategy.class); @@ -118,7 +119,7 @@ public class NonCachingSecretKeyEncryptionStrategy implements SecretKeyEncryptio } } - + @SuppressWarnings("deprecation") private String getFullPathToKey(CryptoModuleParameters params) { String pathToKeyName = params.getAllOptions().get(Property.CRYPTO_DEFAULT_KEY_STRATEGY_KEY_LOCATION.getKey()); String instanceDirectory = params.getAllOptions().get(Property.INSTANCE_DFS_DIR.getKey()); @@ -139,7 +140,8 @@ public class NonCachingSecretKeyEncryptionStrategy implements SecretKeyEncryptio String fullPath = instanceDirectory + pathToKeyName; return fullPath; } - + + @SuppressWarnings("deprecation") @Override public CryptoModuleParameters encryptSecretKey(CryptoModuleParameters params) { String hdfsURI = params.getAllOptions().get(Property.INSTANCE_DFS_URI.getKey()); @@ -161,7 +163,8 @@ public class NonCachingSecretKeyEncryptionStrategy implements SecretKeyEncryptio return params; } - + + @SuppressWarnings("deprecation") @Override public CryptoModuleParameters decryptSecretKey(CryptoModuleParameters params) { String hdfsURI = params.getAllOptions().get(Property.INSTANCE_DFS_URI.getKey()); http://git-wip-us.apache.org/repos/asf/accumulo/blob/be688faa/core/src/main/java/org/apache/accumulo/core/volume/VolumeImpl.java ---------------------------------------------------------------------- diff --git a/core/src/main/java/org/apache/accumulo/core/volume/VolumeImpl.java b/core/src/main/java/org/apache/accumulo/core/volume/VolumeImpl.java index 43ab96b..2394063 100644 --- a/core/src/main/java/org/apache/accumulo/core/volume/VolumeImpl.java +++ b/core/src/main/java/org/apache/accumulo/core/volume/VolumeImpl.java @@ -20,8 +20,6 @@ import static com.google.common.base.Preconditions.checkNotNull; import java.io.IOException; -import jline.internal.Log; - import org.apache.accumulo.core.util.CachedConfiguration; import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.fs.FileSystem; http://git-wip-us.apache.org/repos/asf/accumulo/blob/be688faa/core/src/test/java/org/apache/accumulo/core/util/shell/ShellSetInstanceTest.java ---------------------------------------------------------------------- diff --git a/core/src/test/java/org/apache/accumulo/core/util/shell/ShellSetInstanceTest.java b/core/src/test/java/org/apache/accumulo/core/util/shell/ShellSetInstanceTest.java index ad24e6d..d4c0aea 100644 --- a/core/src/test/java/org/apache/accumulo/core/util/shell/ShellSetInstanceTest.java +++ b/core/src/test/java/org/apache/accumulo/core/util/shell/ShellSetInstanceTest.java @@ -133,6 +133,7 @@ public class ShellSetInstanceTest { testSetInstance_HdfsZooInstance(false, false, false); } + @SuppressWarnings("deprecation") private void testSetInstance_HdfsZooInstance(boolean explicitHdfs, boolean onlyInstance, boolean onlyHosts) throws Exception { ClientConfiguration clientConf = createMock(ClientConfiguration.class); http://git-wip-us.apache.org/repos/asf/accumulo/blob/be688faa/minicluster/src/main/java/org/apache/accumulo/minicluster/impl/MiniAccumuloConfigImpl.java ---------------------------------------------------------------------- diff --git a/minicluster/src/main/java/org/apache/accumulo/minicluster/impl/MiniAccumuloConfigImpl.java b/minicluster/src/main/java/org/apache/accumulo/minicluster/impl/MiniAccumuloConfigImpl.java index 2962861..b2de7db 100644 --- a/minicluster/src/main/java/org/apache/accumulo/minicluster/impl/MiniAccumuloConfigImpl.java +++ b/minicluster/src/main/java/org/apache/accumulo/minicluster/impl/MiniAccumuloConfigImpl.java @@ -99,8 +99,9 @@ public class MiniAccumuloConfigImpl { logDir = new File(dir, "logs"); walogDir = new File(dir, "walogs"); - mergeProp(Property.INSTANCE_DFS_URI.getKey(), "file:///"); - mergeProp(Property.INSTANCE_DFS_DIR.getKey(), accumuloDir.getAbsolutePath()); + // TODO ACCUMULO-XXXX replace usage of instance.dfs.{dir,uri} with instance.volumes + setInstanceLocation(); + mergeProp(Property.INSTANCE_SECRET.getKey(), DEFAULT_INSTANCE_SECRET); mergeProp(Property.TSERV_PORTSEARCH.getKey(), "true"); mergeProp(Property.LOGGER_DIR.getKey(), walogDir.getAbsolutePath()); @@ -131,6 +132,12 @@ public class MiniAccumuloConfigImpl { return this; } + @SuppressWarnings("deprecation") + private void setInstanceLocation() { + mergeProp(Property.INSTANCE_DFS_URI.getKey(), "file:///"); + mergeProp(Property.INSTANCE_DFS_DIR.getKey(), accumuloDir.getAbsolutePath()); + } + /** * Set a given key/value on the site config if it doesn't already exist */ http://git-wip-us.apache.org/repos/asf/accumulo/blob/be688faa/minicluster/src/test/java/org/apache/accumulo/minicluster/impl/MiniAccumuloConfigImplTest.java ---------------------------------------------------------------------- diff --git a/minicluster/src/test/java/org/apache/accumulo/minicluster/impl/MiniAccumuloConfigImplTest.java b/minicluster/src/test/java/org/apache/accumulo/minicluster/impl/MiniAccumuloConfigImplTest.java index c0f7053..ff25420 100644 --- a/minicluster/src/test/java/org/apache/accumulo/minicluster/impl/MiniAccumuloConfigImplTest.java +++ b/minicluster/src/test/java/org/apache/accumulo/minicluster/impl/MiniAccumuloConfigImplTest.java @@ -53,6 +53,7 @@ public class MiniAccumuloConfigImplTest { assertTrue(config.getZooKeeperPort() > 0); } + @SuppressWarnings("deprecation") @Test public void testSiteConfig() { http://git-wip-us.apache.org/repos/asf/accumulo/blob/be688faa/proxy/src/test/java/org/apache/accumulo/proxy/SimpleProxyIT.java ---------------------------------------------------------------------- diff --git a/proxy/src/test/java/org/apache/accumulo/proxy/SimpleProxyIT.java b/proxy/src/test/java/org/apache/accumulo/proxy/SimpleProxyIT.java index 5ad977d..62e5b64 100644 --- a/proxy/src/test/java/org/apache/accumulo/proxy/SimpleProxyIT.java +++ b/proxy/src/test/java/org/apache/accumulo/proxy/SimpleProxyIT.java @@ -42,7 +42,6 @@ import java.util.TreeMap; import java.util.UUID; import java.util.concurrent.atomic.AtomicInteger; -import org.apache.accumulo.core.Constants; import org.apache.accumulo.core.client.Connector; import org.apache.accumulo.core.client.ZooKeeperInstance; import org.apache.accumulo.core.client.security.tokens.PasswordToken; http://git-wip-us.apache.org/repos/asf/accumulo/blob/be688faa/server/base/src/main/java/org/apache/accumulo/server/Accumulo.java ---------------------------------------------------------------------- diff --git a/server/base/src/main/java/org/apache/accumulo/server/Accumulo.java b/server/base/src/main/java/org/apache/accumulo/server/Accumulo.java index 925c0d0..a9e4b5f 100644 --- a/server/base/src/main/java/org/apache/accumulo/server/Accumulo.java +++ b/server/base/src/main/java/org/apache/accumulo/server/Accumulo.java @@ -32,7 +32,6 @@ import org.apache.accumulo.core.util.AddressUtil; import org.apache.accumulo.core.util.UtilWaitThread; import org.apache.accumulo.core.util.Version; import org.apache.accumulo.core.volume.Volume; -import org.apache.accumulo.core.zookeeper.ZooUtil; import org.apache.accumulo.server.client.HdfsZooInstance; import org.apache.accumulo.server.conf.ServerConfiguration; import org.apache.accumulo.server.fs.VolumeManager; http://git-wip-us.apache.org/repos/asf/accumulo/blob/be688faa/server/base/src/main/java/org/apache/accumulo/server/init/Initialize.java ---------------------------------------------------------------------- diff --git a/server/base/src/main/java/org/apache/accumulo/server/init/Initialize.java b/server/base/src/main/java/org/apache/accumulo/server/init/Initialize.java index 206a721..5cbffc3 100644 --- a/server/base/src/main/java/org/apache/accumulo/server/init/Initialize.java +++ b/server/base/src/main/java/org/apache/accumulo/server/init/Initialize.java @@ -145,10 +145,9 @@ public class Initialize { } static boolean checkInit(Configuration conf, VolumeManager fs, SiteConfiguration sconf) throws IOException { - String fsUri; - if (!sconf.get(Property.INSTANCE_DFS_URI).equals("")) - fsUri = sconf.get(Property.INSTANCE_DFS_URI); - else + @SuppressWarnings("deprecation") + String fsUri = sconf.get(Property.INSTANCE_DFS_URI); + if (fsUri.equals("")) fsUri = FileSystem.getDefaultUri(conf).toString(); log.info("Hadoop Filesystem is " + fsUri); log.info("Accumulo data dirs are " + Arrays.asList(VolumeConfiguration.getVolumeUris(ServerConfiguration.getSiteConfiguration()))); @@ -172,23 +171,7 @@ public class Initialize { } try { if (isInitialized(fs)) { - String instanceDfsDir = sconf.get(Property.INSTANCE_DFS_DIR); - log.fatal("It appears the directories " + Arrays.asList(VolumeConfiguration.getVolumeUris(ServerConfiguration.getSiteConfiguration())) - + " were previously initialized."); - String instanceVolumes = sconf.get(Property.INSTANCE_VOLUMES); - String instanceDfsUri = sconf.get(Property.INSTANCE_DFS_URI); - - if (!instanceVolumes.isEmpty()) { - log.fatal("Change the property " + Property.INSTANCE_VOLUMES + " to use different filesystems,"); - } else if (!instanceDfsDir.isEmpty()) { - log.fatal("Change the property " + Property.INSTANCE_DFS_URI + " to use a different filesystem,"); - } else { - log.fatal("You are using the default URI for the filesystem. Set the property " + Property.INSTANCE_VOLUMES + " to use a different filesystem,"); - } - log.fatal("or change the property " + Property.INSTANCE_DFS_DIR + " to use a different directory."); - log.fatal("The current value of " + Property.INSTANCE_DFS_URI + " is |" + instanceDfsUri + "|"); - log.fatal("The current value of " + Property.INSTANCE_DFS_DIR + " is |" + instanceDfsDir + "|"); - log.fatal("The current value of " + Property.INSTANCE_VOLUMES + " is |" + instanceVolumes + "|"); + printInitializeFailureMessages(sconf); return false; } } catch (IOException e) { @@ -198,6 +181,27 @@ public class Initialize { return true; } + @SuppressWarnings("deprecation") + static void printInitializeFailureMessages(SiteConfiguration sconf) { + String instanceDfsDir = sconf.get(Property.INSTANCE_DFS_DIR); + log.fatal("It appears the directories " + Arrays.asList(VolumeConfiguration.getVolumeUris(ServerConfiguration.getSiteConfiguration())) + + " were previously initialized."); + String instanceVolumes = sconf.get(Property.INSTANCE_VOLUMES); + String instanceDfsUri = sconf.get(Property.INSTANCE_DFS_URI); + + if (!instanceVolumes.isEmpty()) { + log.fatal("Change the property " + Property.INSTANCE_VOLUMES + " to use different filesystems,"); + } else if (!instanceDfsDir.isEmpty()) { + log.fatal("Change the property " + Property.INSTANCE_DFS_URI + " to use a different filesystem,"); + } else { + log.fatal("You are using the default URI for the filesystem. Set the property " + Property.INSTANCE_VOLUMES + " to use a different filesystem,"); + } + log.fatal("or change the property " + Property.INSTANCE_DFS_DIR + " to use a different directory."); + log.fatal("The current value of " + Property.INSTANCE_DFS_URI + " is |" + instanceDfsUri + "|"); + log.fatal("The current value of " + Property.INSTANCE_DFS_DIR + " is |" + instanceDfsDir + "|"); + log.fatal("The current value of " + Property.INSTANCE_VOLUMES + " is |" + instanceVolumes + "|"); + } + public static boolean doInit(Opts opts, Configuration conf, VolumeManager fs) throws IOException { if (!checkInit(conf, fs, ServerConfiguration.getSiteConfiguration())) { return false; http://git-wip-us.apache.org/repos/asf/accumulo/blob/be688faa/server/base/src/main/java/org/apache/accumulo/server/util/FileUtil.java ---------------------------------------------------------------------- diff --git a/server/base/src/main/java/org/apache/accumulo/server/util/FileUtil.java b/server/base/src/main/java/org/apache/accumulo/server/util/FileUtil.java index 277a0c2..b1e39f0 100644 --- a/server/base/src/main/java/org/apache/accumulo/server/util/FileUtil.java +++ b/server/base/src/main/java/org/apache/accumulo/server/util/FileUtil.java @@ -373,6 +373,10 @@ public class FileUtil { } if (tmpDir != null) { + // TODO ACCUMULO-2532 instance.dfs.dir is not required to be a part of + // the path for tmpDir. Could result in tmpDir not being removed when it should + // Needs unit tests + @SuppressWarnings("deprecation") String tmpPrefix = acuConf.get(Property.INSTANCE_DFS_DIR) + "/tmp"; if (tmpDir.toUri().getPath().startsWith(tmpPrefix)) fs.deleteRecursively(tmpDir); http://git-wip-us.apache.org/repos/asf/accumulo/blob/be688faa/server/base/src/test/java/org/apache/accumulo/server/init/InitializeTest.java ---------------------------------------------------------------------- diff --git a/server/base/src/test/java/org/apache/accumulo/server/init/InitializeTest.java b/server/base/src/test/java/org/apache/accumulo/server/init/InitializeTest.java index 251d859..cb34fb9 100644 --- a/server/base/src/test/java/org/apache/accumulo/server/init/InitializeTest.java +++ b/server/base/src/test/java/org/apache/accumulo/server/init/InitializeTest.java @@ -77,6 +77,7 @@ public class InitializeTest { assertTrue(Initialize.isInitialized(fs)); } + @SuppressWarnings("deprecation") @Test public void testCheckInit_NoZK() throws Exception { expect(sconf.get(Property.INSTANCE_DFS_URI)).andReturn("hdfs://foo"); @@ -89,6 +90,7 @@ public class InitializeTest { assertFalse(Initialize.checkInit(conf, fs, sconf)); } + @SuppressWarnings("deprecation") @Test public void testCheckInit_AlreadyInit() throws Exception { expect(sconf.get(Property.INSTANCE_DFS_URI)).andReturn("hdfs://foo"); @@ -107,6 +109,7 @@ public class InitializeTest { } // Cannot test, need to mock static FileSystem.getDefaultUri() + @SuppressWarnings("deprecation") @Ignore @Test public void testCheckInit_AlreadyInit_DefaultUri() throws Exception { @@ -125,6 +128,7 @@ public class InitializeTest { assertFalse(Initialize.checkInit(conf, fs, sconf)); } + @SuppressWarnings("deprecation") @Test(expected = IOException.class) public void testCheckInit_FSException() throws Exception { expect(sconf.get(Property.INSTANCE_DFS_URI)).andReturn("hdfs://foo"); @@ -140,6 +144,7 @@ public class InitializeTest { Initialize.checkInit(conf, fs, sconf); } + @SuppressWarnings("deprecation") @Test public void testCheckInit_OK() throws Exception { expect(sconf.get(Property.INSTANCE_DFS_URI)).andReturn("hdfs://foo"); http://git-wip-us.apache.org/repos/asf/accumulo/blob/be688faa/server/tserver/src/test/java/org/apache/accumulo/tserver/RootFilesTest.java ---------------------------------------------------------------------- diff --git a/server/tserver/src/test/java/org/apache/accumulo/tserver/RootFilesTest.java b/server/tserver/src/test/java/org/apache/accumulo/tserver/RootFilesTest.java index 7a1c84b..f216e93 100644 --- a/server/tserver/src/test/java/org/apache/accumulo/tserver/RootFilesTest.java +++ b/server/tserver/src/test/java/org/apache/accumulo/tserver/RootFilesTest.java @@ -111,6 +111,7 @@ public class RootFilesTest { } } + @SuppressWarnings("deprecation") @Test public void testFileReplacement() throws IOException { http://git-wip-us.apache.org/repos/asf/accumulo/blob/be688faa/test/src/test/java/org/apache/accumulo/test/BulkImportVolumeIT.java ---------------------------------------------------------------------- diff --git a/test/src/test/java/org/apache/accumulo/test/BulkImportVolumeIT.java b/test/src/test/java/org/apache/accumulo/test/BulkImportVolumeIT.java index 45a6655..25d5784 100644 --- a/test/src/test/java/org/apache/accumulo/test/BulkImportVolumeIT.java +++ b/test/src/test/java/org/apache/accumulo/test/BulkImportVolumeIT.java @@ -20,7 +20,6 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; import java.io.File; -import java.net.URI; import org.apache.accumulo.core.client.admin.TableOperations; import org.apache.accumulo.core.conf.Property;