You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@accumulo.apache.org by mw...@apache.org on 2018/08/21 14:38:59 UTC
[accumulo] branch master updated: Reduced use of
SiteConfiguration.getInstance() (#602)
This is an automated email from the ASF dual-hosted git repository.
mwalch pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/accumulo.git
The following commit(s) were added to refs/heads/master by this push:
new e227e8c Reduced use of SiteConfiguration.getInstance() (#602)
e227e8c is described below
commit e227e8c948161c3547af2442904774b0eb413e3e
Author: Mike Walch <mw...@apache.org>
AuthorDate: Tue Aug 21 10:38:54 2018 -0400
Reduced use of SiteConfiguration.getInstance() (#602)
* Reduced calls to SiteConfiguration.getInstance() by passing
ServerContext and using it to retrieve SiteConfiguration
* Created SiteConfiguration.create() methods to properly
load accumulo-site.xml when it is not on classpath (i.e.
integration tests).
* Removed CliConfiguration. Instead, pass map of overrides.
---
.../accumulo/core/conf/CliConfiguration.java | 64 -----------
.../accumulo/core/conf/SiteConfiguration.java | 123 ++++++++++++++++-----
.../apache/accumulo/core/file/rfile/PrintInfo.java | 5 +-
.../accumulo/core/file/rfile/bcfile/PrintInfo.java | 13 +--
.../accumulo/core/conf/CliConfigurationTest.java | 50 ---------
.../accumulo/core/conf/SiteConfigurationTest.java | 12 +-
.../apache/accumulo/core/file/rfile/RFileTest.java | 8 +-
.../accumulo/core/security/crypto/CryptoTest.java | 12 +-
core/src/test/resources/accumulo-site.xml | 24 ++++
.../standalone/StandaloneAccumuloCluster.java | 28 ++---
.../minicluster/impl/MiniAccumuloClusterImpl.java | 12 +-
.../minicluster/impl/MiniAccumuloConfigImpl.java | 4 +
.../org/apache/accumulo/server/ServerContext.java | 24 ++--
.../org/apache/accumulo/server/ServerInfo.java | 27 +++--
.../org/apache/accumulo/server/ServerOpts.java | 25 ++++-
.../accumulo/server/cli/ClientOnDefaultTable.java | 15 ++-
.../accumulo/server/cli/ClientOnRequiredTable.java | 15 ++-
.../org/apache/accumulo/server/cli/ClientOpts.java | 15 ++-
.../accumulo/server/conf/ConfigSanityCheck.java | 3 +-
.../accumulo/server/conf/NamespaceConfWatcher.java | 7 +-
.../server/conf/ServerConfigurationFactory.java | 10 +-
.../accumulo/server/conf/TableConfiguration.java | 3 +-
.../apache/accumulo/server/init/Initialize.java | 99 ++++++++---------
.../accumulo/server/problems/ProblemReports.java | 3 +-
.../server/security/AuditedSecurityOperation.java | 4 +-
.../server/security/SecurityOperation.java | 28 ++---
.../server/security/SystemCredentials.java | 15 ++-
.../server/security/handler/Authenticator.java | 3 +-
.../security/handler/InsecureAuthenticator.java | 3 +-
.../security/handler/KerberosAuthenticator.java | 23 ++--
.../server/security/handler/ZKAuthenticator.java | 7 +-
.../org/apache/accumulo/server/util/Admin.java | 10 +-
.../accumulo/server/util/CleanZookeeper.java | 3 +-
.../java/org/apache/accumulo/server/util/Info.java | 3 +-
.../apache/accumulo/server/util/ListInstances.java | 3 +-
.../accumulo/server/util/ListVolumesUsed.java | 3 +-
.../accumulo/server/util/LoginProperties.java | 3 +-
.../accumulo/server/util/TabletServerLocks.java | 3 +-
.../apache/accumulo/server/util/ZooKeeperMain.java | 3 +-
.../org/apache/accumulo/server/util/ZooZap.java | 3 +-
.../org/apache/accumulo/server/ServerOptsTest.java | 9 +-
.../conf/ServerConfigurationFactoryTest.java | 3 +-
.../accumulo/server/init/InitializeTest.java | 34 +++---
.../BaseHostRegexTableLoadBalancerTest.java | 5 +-
.../master/balancer/TableLoadBalancerTest.java | 4 +-
.../server/security/SystemCredentialsTest.java | 9 +-
.../accumulo/server/util/TServerUtilsTest.java | 13 ++-
.../apache/accumulo/gc/SimpleGarbageCollector.java | 2 +-
.../accumulo/gc/SimpleGarbageCollectorTest.java | 4 +-
server/gc/src/test/resources/accumulo-site.xml | 24 ++++
.../java/org/apache/accumulo/master/Master.java | 2 +-
.../apache/accumulo/master/state/SetGoalState.java | 4 +-
.../org/apache/accumulo/master/util/FateAdmin.java | 3 +-
.../MasterReplicationCoordinatorTest.java | 8 +-
server/master/src/test/resources/accumulo-site.xml | 24 ++++
.../java/org/apache/accumulo/monitor/Monitor.java | 4 +-
.../apache/accumulo/monitor/ZooKeeperStatus.java | 10 +-
.../monitor/util/AccumuloMonitorAppender.java | 3 +-
.../org/apache/accumulo/tracer/TraceServer.java | 5 +-
.../org/apache/accumulo/tserver/TabletServer.java | 5 +-
.../apache/accumulo/tserver/logger/LogReader.java | 3 +-
.../tserver/LargestFirstMemoryManagerTest.java | 4 +-
.../tserver/log/TestUpgradePathForWALogs.java | 8 +-
.../tserver/src/test/resources/accumulo-site.xml | 24 ++++
shell/pom.xml | 4 -
.../accumulo/shell/commands/FateCommand.java | 11 +-
.../accumulo/shell/commands/ListBulkCommand.java | 4 +-
.../accumulo/harness/AccumuloClusterHarness.java | 4 +-
.../org/apache/accumulo/test/GetMasterStats.java | 3 +-
.../accumulo/test/functional/SplitRecoveryIT.java | 3 +-
.../accumulo/test/functional/ZombieTServer.java | 3 +-
.../accumulo/test/performance/NullTserver.java | 4 +-
.../test/server/security/SystemCredentialsIT.java | 8 +-
.../org/apache/accumulo/test/util/CertUtils.java | 57 ++--------
74 files changed, 559 insertions(+), 474 deletions(-)
diff --git a/core/src/main/java/org/apache/accumulo/core/conf/CliConfiguration.java b/core/src/main/java/org/apache/accumulo/core/conf/CliConfiguration.java
deleted file mode 100644
index 792d57b..0000000
--- a/core/src/main/java/org/apache/accumulo/core/conf/CliConfiguration.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.accumulo.core.conf;
-
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Objects;
-import java.util.function.Predicate;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class CliConfiguration {
-
- private static final Logger log = LoggerFactory.getLogger(CliConfiguration.class);
- private static volatile Map<String,String> config = new HashMap<>();
-
- /**
- * Sets CliConfiguration with map of configuration. Additional calls will overwrite existing
- * properties and values.
- *
- * @param conf
- * Map of configuration
- */
- public static void set(Map<String,String> conf) {
- Objects.requireNonNull(conf);
- config = conf;
- }
-
- public static void print() {
- log.info("The following configuration was set on the command line:");
- for (Map.Entry<String,String> entry : config.entrySet()) {
- String key = entry.getKey();
- log.info(key + " = " + (Property.isSensitive(key) ? "<hidden>" : entry.getValue()));
- }
- }
-
- public static String get(Property property) {
- return config.get(property.getKey());
- }
-
- public static void getProperties(Map<String,String> props, Predicate<String> filter) {
- for (Map.Entry<String,String> entry : config.entrySet()) {
- if (filter.test(entry.getKey())) {
- props.put(entry.getKey(), entry.getValue());
- }
- }
- }
-}
diff --git a/core/src/main/java/org/apache/accumulo/core/conf/SiteConfiguration.java b/core/src/main/java/org/apache/accumulo/core/conf/SiteConfiguration.java
index cf0fe25..c66ac17 100644
--- a/core/src/main/java/org/apache/accumulo/core/conf/SiteConfiguration.java
+++ b/core/src/main/java/org/apache/accumulo/core/conf/SiteConfiguration.java
@@ -55,15 +55,26 @@ public class SiteConfiguration extends AccumuloConfiguration {
private static final AccumuloConfiguration parent = DefaultConfiguration.getInstance();
private static SiteConfiguration instance = null;
+ private final Map<String,String> overrides;
private static Configuration xmlConfig;
private final Map<String,String> staticConfigs;
private SiteConfiguration() {
+ this(getAccumuloSiteLocation(), Collections.emptyMap());
+ }
+
+ private SiteConfiguration(URL accumuloSiteLocation, Map<String,String> overrides) {
+ this.overrides = overrides;
/*
* Make a read-only copy of static configs so we can avoid lock contention on the Hadoop
* Configuration object
*/
- final Configuration conf = getXmlConfig();
+ xmlConfig = new Configuration(false);
+ if (accumuloSiteLocation != null) {
+ xmlConfig.addResource(accumuloSiteLocation);
+ }
+
+ final Configuration conf = xmlConfig;
Map<String,String> temp = new HashMap<>((int) (Math.ceil(conf.size() / 0.75f)), 0.75f);
for (Entry<String,String> entry : conf) {
temp.put(entry.getKey(), entry.getValue());
@@ -80,11 +91,52 @@ public class SiteConfiguration extends AccumuloConfiguration {
staticConfigs = Collections.unmodifiableMap(temp);
}
+ private static URL toURL(File f) {
+ try {
+ return f.toURI().toURL();
+ } catch (MalformedURLException e) {
+ throw new IllegalArgumentException(e);
+ }
+ }
+
+ synchronized public static SiteConfiguration create() {
+ if (instance == null) {
+ instance = new SiteConfiguration();
+ ConfigSanityCheck.validate(instance);
+ } else {
+ log.warn("SiteConfiguration was previously created! Returning previous instance.");
+ }
+ return instance;
+ }
+
+ synchronized public static SiteConfiguration create(URL accumuloSiteUrl,
+ Map<String,String> overrides) {
+ if (instance == null) {
+ instance = new SiteConfiguration(accumuloSiteUrl, overrides);
+ ConfigSanityCheck.validate(instance);
+ } else {
+ log.warn("SiteConfiguration was previously created! Returning previous instance.");
+ }
+ return instance;
+ }
+
+ public static SiteConfiguration create(URL accumuloSiteUrl) {
+ return create(accumuloSiteUrl, Collections.emptyMap());
+ }
+
+ public static SiteConfiguration create(File accumuloSiteFile, Map<String,String> overrides) {
+ return create(toURL(accumuloSiteFile), overrides);
+ }
+
+ public static SiteConfiguration create(File accumuloSiteFile) {
+ return create(toURL(accumuloSiteFile), Collections.emptyMap());
+ }
+
/**
* Gets an instance of this class. A new instance is only created on the first call.
*
- * @throws RuntimeException
- * if the configuration is invalid
+ * @throws IllegalArgumentException
+ * if the configuration is invalid or accumulo-site.xml is not on classpath.
*/
synchronized public static SiteConfiguration getInstance() {
if (instance == null) {
@@ -94,40 +146,45 @@ public class SiteConfiguration extends AccumuloConfiguration {
return instance;
}
- synchronized private static Configuration getXmlConfig() {
- if (xmlConfig == null) {
- xmlConfig = new Configuration(false);
- String configFile = System.getProperty("accumulo.configuration", "accumulo-site.xml");
- if (configFile.startsWith("file://")) {
- try {
- File f = new File(new URI(configFile));
- if (f.exists() && !f.isDirectory()) {
- xmlConfig.addResource(f.toURI().toURL());
- log.info("Loaded configuration from filesystem at {}", configFile);
- } else {
- log.warn("Failed to load Accumulo configuration from " + configFile, new Throwable());
- }
- } catch (MalformedURLException | URISyntaxException e) {
- log.warn("Failed to load Accumulo configuration from " + configFile, e);
- }
- } else {
- URL accumuloConfigUrl = SiteConfiguration.class.getClassLoader().getResource(configFile);
- if (accumuloConfigUrl == null) {
- log.warn("Accumulo configuration '" + configFile + "' is not on classpath",
- new Throwable());
+ public static URL getAccumuloSiteLocation() {
+ String configFile = System.getProperty("accumulo.configuration", "accumulo-site.xml");
+ if (configFile.startsWith("file://")) {
+ try {
+ File f = new File(new URI(configFile));
+ if (f.exists() && !f.isDirectory()) {
+ log.info("Found Accumulo configuration at {}", configFile);
+ return f.toURI().toURL();
} else {
- xmlConfig.addResource(accumuloConfigUrl);
- log.info("Loaded configuration from classpath at {}", accumuloConfigUrl.getFile());
+ throw new IllegalArgumentException(
+ "Failed to load Accumulo configuration at " + configFile);
}
+ } catch (MalformedURLException | URISyntaxException e) {
+ throw new IllegalArgumentException(
+ "Failed to load Accumulo configuration from " + configFile, e);
+ }
+ } else {
+ URL accumuloConfigUrl = SiteConfiguration.class.getClassLoader().getResource(configFile);
+ if (accumuloConfigUrl == null) {
+ throw new IllegalArgumentException(
+ "Failed to load Accumulo configuration '" + configFile + "' from classpath");
+ } else {
+ log.info("Found Accumulo configuration on classpath at {}", accumuloConfigUrl.getFile());
+ return accumuloConfigUrl;
}
}
+ }
+
+ private Configuration getXmlConfig() {
+ if (xmlConfig == null) {
+ return new Configuration(false);
+ }
return xmlConfig;
}
@Override
public String get(Property property) {
- if (CliConfiguration.get(property) != null) {
- return CliConfiguration.get(property);
+ if (overrides.containsKey(property.getKey())) {
+ return overrides.get(property.getKey());
}
String key = property.getKey();
@@ -170,7 +227,7 @@ public class SiteConfiguration extends AccumuloConfiguration {
public boolean isPropertySet(Property prop) {
Preconditions.checkArgument(!prop.isSensitive(),
"This method not implemented for sensitive props");
- return CliConfiguration.get(prop) != null || staticConfigs.containsKey(prop.getKey())
+ return overrides.containsKey(prop.getKey()) || staticConfigs.containsKey(prop.getKey())
|| getXmlConfig().get(prop.getKey()) != null || parent.isPropertySet(prop);
}
@@ -211,7 +268,13 @@ public class SiteConfiguration extends AccumuloConfiguration {
+ " CredentialProvider, falling back to accumulo-site.xml", e);
}
}
- CliConfiguration.getProperties(props, filter);
+ if (overrides != null) {
+ for (Map.Entry<String,String> entry : overrides.entrySet()) {
+ if (filter.test(entry.getKey())) {
+ props.put(entry.getKey(), entry.getValue());
+ }
+ }
+ }
}
protected Configuration getHadoopConfiguration() {
diff --git a/core/src/main/java/org/apache/accumulo/core/file/rfile/PrintInfo.java b/core/src/main/java/org/apache/accumulo/core/file/rfile/PrintInfo.java
index 2dccd7a..51df3ee 100644
--- a/core/src/main/java/org/apache/accumulo/core/file/rfile/PrintInfo.java
+++ b/core/src/main/java/org/apache/accumulo/core/file/rfile/PrintInfo.java
@@ -23,7 +23,6 @@ import java.util.List;
import java.util.Map;
import org.apache.accumulo.core.cli.Help;
-import org.apache.accumulo.core.conf.AccumuloConfiguration;
import org.apache.accumulo.core.conf.SiteConfiguration;
import org.apache.accumulo.core.data.ByteSequence;
import org.apache.accumulo.core.data.Key;
@@ -143,6 +142,7 @@ public class PrintInfo implements KeywordExecutable {
System.err.println("No files were given");
System.exit(-1);
}
+ SiteConfiguration siteConfig = SiteConfiguration.create();
Configuration conf = new Configuration();
for (String confFile : opts.configFiles) {
@@ -173,9 +173,8 @@ public class PrintInfo implements KeywordExecutable {
printCryptoParams(path, fs);
- AccumuloConfiguration aconf = SiteConfiguration.getInstance();
CachableBlockFile.Reader _rdr = new CachableBlockFile.Reader(fs, path, conf, null, null,
- aconf, CryptoServiceFactory.getConfigured(aconf));
+ siteConfig, CryptoServiceFactory.getConfigured(siteConfig));
Reader iter = new RFile.Reader(_rdr);
MetricsGatherer<Map<String,ArrayList<VisibilityMetric>>> vmg = new VisMetricsGatherer();
diff --git a/core/src/main/java/org/apache/accumulo/core/file/rfile/bcfile/PrintInfo.java b/core/src/main/java/org/apache/accumulo/core/file/rfile/bcfile/PrintInfo.java
index 7547ba2..d854841 100644
--- a/core/src/main/java/org/apache/accumulo/core/file/rfile/bcfile/PrintInfo.java
+++ b/core/src/main/java/org/apache/accumulo/core/file/rfile/bcfile/PrintInfo.java
@@ -21,7 +21,6 @@ import java.io.PrintStream;
import java.util.Map.Entry;
import java.util.Set;
-import org.apache.accumulo.core.conf.AccumuloConfiguration;
import org.apache.accumulo.core.conf.SiteConfiguration;
import org.apache.accumulo.core.file.rfile.bcfile.BCFile.MetaIndexEntry;
import org.apache.accumulo.core.security.crypto.CryptoServiceFactory;
@@ -31,14 +30,13 @@ import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
public class PrintInfo {
- public static void printMetaBlockInfo(Configuration conf, FileSystem fs, Path path)
- throws IOException {
+ public static void printMetaBlockInfo(SiteConfiguration siteConfig, Configuration conf,
+ FileSystem fs, Path path) throws IOException {
FSDataInputStream fsin = fs.open(path);
- AccumuloConfiguration aconf = SiteConfiguration.getInstance();
BCFile.Reader bcfr = null;
try {
- bcfr = new BCFile.Reader(fsin, fs.getFileStatus(path).getLen(), conf, aconf,
- CryptoServiceFactory.getConfigured(aconf));
+ bcfr = new BCFile.Reader(fsin, fs.getFileStatus(path).getLen(), conf, siteConfig,
+ CryptoServiceFactory.getConfigured(siteConfig));
Set<Entry<String,MetaIndexEntry>> es = bcfr.metaIndex.index.entrySet();
@@ -61,6 +59,7 @@ public class PrintInfo {
}
public static void main(String[] args) throws Exception {
+ SiteConfiguration siteConfig = SiteConfiguration.create();
Configuration conf = new Configuration();
FileSystem hadoopFs = FileSystem.get(conf);
FileSystem localFs = FileSystem.getLocal(conf);
@@ -70,6 +69,6 @@ public class PrintInfo {
fs = path.getFileSystem(conf);
else
fs = hadoopFs.exists(path) ? hadoopFs : localFs; // fall back to local
- printMetaBlockInfo(conf, fs, path);
+ printMetaBlockInfo(siteConfig, conf, fs, path);
}
}
diff --git a/core/src/test/java/org/apache/accumulo/core/conf/CliConfigurationTest.java b/core/src/test/java/org/apache/accumulo/core/conf/CliConfigurationTest.java
deleted file mode 100644
index e7f76dc..0000000
--- a/core/src/test/java/org/apache/accumulo/core/conf/CliConfigurationTest.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.accumulo.core.conf;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import org.junit.Assert;
-import org.junit.Test;
-
-import com.google.common.collect.ImmutableMap;
-
-public class CliConfigurationTest {
-
- @Test
- public void testBasic() {
- try {
- CliConfiguration.set(null);
- Assert.fail();
- } catch (NullPointerException e) {
- // expected
- }
- CliConfiguration.set(new HashMap<>());
-
- Map<String,String> expected = new HashMap<>();
- expected.put(Property.TRACE_USER.getKey(), "test");
- expected.put(Property.TSERV_CLIENTPORT.getKey(), "123");
- CliConfiguration.set(expected);
-
- Assert.assertEquals("test", CliConfiguration.get(Property.TRACE_USER));
-
- Map<String,String> results = new HashMap<>();
- CliConfiguration.getProperties(results, p -> p.startsWith("trace"));
- Assert.assertEquals(ImmutableMap.of(Property.TRACE_USER.getKey(), "test"), results);
- }
-}
diff --git a/core/src/test/java/org/apache/accumulo/core/conf/SiteConfigurationTest.java b/core/src/test/java/org/apache/accumulo/core/conf/SiteConfigurationTest.java
index e868eeb..d2449ba 100644
--- a/core/src/test/java/org/apache/accumulo/core/conf/SiteConfigurationTest.java
+++ b/core/src/test/java/org/apache/accumulo/core/conf/SiteConfigurationTest.java
@@ -80,11 +80,17 @@ public class SiteConfigurationTest {
}
@Test
- public void testCliConfig() {
- SiteConfiguration conf = SiteConfiguration.getInstance();
+ public void testConfigOverrides() {
+ SiteConfiguration conf = SiteConfiguration.create();
Assert.assertEquals("localhost:2181", conf.get(Property.INSTANCE_ZK_HOST));
- CliConfiguration.set(ImmutableMap.of(Property.INSTANCE_ZK_HOST.getKey(), "myhost:2181"));
+ SiteConfiguration.clearInstance();
+ conf = SiteConfiguration.create((URL) null,
+ ImmutableMap.of(Property.INSTANCE_ZK_HOST.getKey(), "myhost:2181"));
Assert.assertEquals("myhost:2181", conf.get(Property.INSTANCE_ZK_HOST));
+
+ Map<String,String> results = new HashMap<>();
+ conf.getProperties(results, p -> p.startsWith("instance"));
+ Assert.assertEquals("myhost:2181", results.get(Property.INSTANCE_ZK_HOST.getKey()));
}
}
diff --git a/core/src/test/java/org/apache/accumulo/core/file/rfile/RFileTest.java b/core/src/test/java/org/apache/accumulo/core/file/rfile/RFileTest.java
index 51b3bdf..6055522 100644
--- a/core/src/test/java/org/apache/accumulo/core/file/rfile/RFileTest.java
+++ b/core/src/test/java/org/apache/accumulo/core/file/rfile/RFileTest.java
@@ -1803,10 +1803,10 @@ public class RFileTest {
public void turnCryptoOnInSiteConfig() {
SiteConfiguration.clearInstance();
- SiteConfiguration.getInstance().set(Property.INSTANCE_CRYPTO_SERVICE,
- AESCryptoService.class.getName());
- SiteConfiguration.getInstance().set("instance.crypto.opts.kekId", "file:///tmp/testAESFile");
- SiteConfiguration.getInstance().set("instance.crypto.opts.keyManager", "uri");
+ SiteConfiguration siteConfig = SiteConfiguration.create();
+ siteConfig.set(Property.INSTANCE_CRYPTO_SERVICE, AESCryptoService.class.getName());
+ siteConfig.set("instance.crypto.opts.kekId", "file:///tmp/testAESFile");
+ siteConfig.set("instance.crypto.opts.keyManager", "uri");
CryptoServiceFactory.resetInstance();
}
diff --git a/core/src/test/java/org/apache/accumulo/core/security/crypto/CryptoTest.java b/core/src/test/java/org/apache/accumulo/core/security/crypto/CryptoTest.java
index b99144a..7092a9c 100644
--- a/core/src/test/java/org/apache/accumulo/core/security/crypto/CryptoTest.java
+++ b/core/src/test/java/org/apache/accumulo/core/security/crypto/CryptoTest.java
@@ -106,16 +106,16 @@ public class CryptoTest {
@Before
public void turnCryptoOnInSiteConfig() {
- SiteConfiguration.getInstance().set(Property.INSTANCE_CRYPTO_SERVICE,
- AESCryptoService.class.getName());
- SiteConfiguration.getInstance().set("instance.crypto.opts.kekId", "file:///tmp/testAESFile");
- SiteConfiguration.getInstance().set("instance.crypto.opts.keyManager", "uri");
+ SiteConfiguration siteConfig = SiteConfiguration.getInstance();
+ siteConfig.set(Property.INSTANCE_CRYPTO_SERVICE, AESCryptoService.class.getName());
+ siteConfig.set("instance.crypto.opts.kekId", "file:///tmp/testAESFile");
+ siteConfig.set("instance.crypto.opts.keyManager", "uri");
CryptoServiceFactory.resetInstance();
}
public static void turnCryptoOffInSiteConfig() {
- SiteConfiguration.getInstance().set(Property.INSTANCE_CRYPTO_SERVICE,
- NoCryptoService.class.getName());
+ SiteConfiguration siteConfig = SiteConfiguration.getInstance();
+ siteConfig.set(Property.INSTANCE_CRYPTO_SERVICE, NoCryptoService.class.getName());
CryptoServiceFactory.resetInstance();
}
diff --git a/core/src/test/resources/accumulo-site.xml b/core/src/test/resources/accumulo-site.xml
new file mode 100644
index 0000000..9618efb
--- /dev/null
+++ b/core/src/test/resources/accumulo-site.xml
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<configuration>
+
+ <!-- This file needs to exists for unit tests -->
+
+</configuration>
diff --git a/minicluster/src/main/java/org/apache/accumulo/cluster/standalone/StandaloneAccumuloCluster.java b/minicluster/src/main/java/org/apache/accumulo/cluster/standalone/StandaloneAccumuloCluster.java
index 786f0be..281aa48 100644
--- a/minicluster/src/main/java/org/apache/accumulo/cluster/standalone/StandaloneAccumuloCluster.java
+++ b/minicluster/src/main/java/org/apache/accumulo/cluster/standalone/StandaloneAccumuloCluster.java
@@ -18,6 +18,7 @@ package org.apache.accumulo.cluster.standalone;
import static com.google.common.base.Preconditions.checkArgument;
+import java.io.File;
import java.io.IOException;
import java.util.Arrays;
import java.util.Collections;
@@ -33,7 +34,7 @@ import org.apache.accumulo.core.client.impl.ClientConfConverter;
import org.apache.accumulo.core.client.security.tokens.AuthenticationToken;
import org.apache.accumulo.core.conf.AccumuloConfiguration;
import org.apache.accumulo.core.conf.ConfigurationCopy;
-import org.apache.accumulo.core.conf.DefaultConfiguration;
+import org.apache.accumulo.core.conf.SiteConfiguration;
import org.apache.accumulo.core.master.thrift.MasterGoalState;
import org.apache.accumulo.core.util.CachedConfiguration;
import org.apache.accumulo.minicluster.ServerType;
@@ -44,8 +45,6 @@ import org.apache.hadoop.fs.Path;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import com.google.common.collect.Iterables;
-
/**
* AccumuloCluster implementation to connect to an existing deployment of Accumulo
*/
@@ -63,11 +62,16 @@ public class StandaloneAccumuloCluster implements AccumuloCluster {
private List<ClusterUser> users;
private String clientCmdPrefix;
private String serverCmdPrefix;
+ private SiteConfiguration siteConfig;
+ private ServerContext context;
- public StandaloneAccumuloCluster(ClientInfo info, Path tmp, List<ClusterUser> users) {
+ public StandaloneAccumuloCluster(ClientInfo info, Path tmp, List<ClusterUser> users,
+ String serverAccumuloConfDir) {
this.info = info;
this.tmp = tmp;
this.users = users;
+ this.serverAccumuloConfDir = serverAccumuloConfDir;
+ siteConfig = SiteConfiguration.create(new File(serverAccumuloConfDir, "accumulo-site.xml"));
}
public String getAccumuloHome() {
@@ -90,10 +94,6 @@ public class StandaloneAccumuloCluster implements AccumuloCluster {
return serverAccumuloConfDir;
}
- public void setServerAccumuloConfDir(String accumuloConfDir) {
- this.serverAccumuloConfDir = accumuloConfDir;
- }
-
public void setServerCmdPrefix(String serverCmdPrefix) {
this.serverCmdPrefix = serverCmdPrefix;
}
@@ -127,8 +127,11 @@ public class StandaloneAccumuloCluster implements AccumuloCluster {
}
@Override
- public ServerContext getServerContext() {
- return new ServerContext(getClientInfo());
+ public synchronized ServerContext getServerContext() {
+ if (context == null) {
+ context = new ServerContext(siteConfig, getClientInfo());
+ }
+ return context;
}
@Override
@@ -210,9 +213,6 @@ public class StandaloneAccumuloCluster implements AccumuloCluster {
@Override
public AccumuloConfiguration getSiteConfiguration() {
- Configuration conf = new Configuration(false);
- Path accumuloSite = new Path(serverAccumuloConfDir, "accumulo-site.xml");
- conf.addResource(accumuloSite);
- return new ConfigurationCopy(Iterables.concat(DefaultConfiguration.getInstance(), conf));
+ return new ConfigurationCopy(siteConfig);
}
}
diff --git a/minicluster/src/main/java/org/apache/accumulo/minicluster/impl/MiniAccumuloClusterImpl.java b/minicluster/src/main/java/org/apache/accumulo/minicluster/impl/MiniAccumuloClusterImpl.java
index e9d8864..c0a1069 100644
--- a/minicluster/src/main/java/org/apache/accumulo/minicluster/impl/MiniAccumuloClusterImpl.java
+++ b/minicluster/src/main/java/org/apache/accumulo/minicluster/impl/MiniAccumuloClusterImpl.java
@@ -68,6 +68,7 @@ import org.apache.accumulo.core.conf.ClientProperty;
import org.apache.accumulo.core.conf.ConfigurationCopy;
import org.apache.accumulo.core.conf.DefaultConfiguration;
import org.apache.accumulo.core.conf.Property;
+import org.apache.accumulo.core.conf.SiteConfiguration;
import org.apache.accumulo.core.master.thrift.MasterClientService;
import org.apache.accumulo.core.master.thrift.MasterGoalState;
import org.apache.accumulo.core.master.thrift.MasterMonitorInfo;
@@ -172,6 +173,8 @@ public class MiniAccumuloClusterImpl implements AccumuloCluster {
private File zooCfgFile;
private String dfsUri;
+ private SiteConfiguration siteConfig;
+ private ServerContext context;
private ClientInfo clientInfo;
public List<LogWriter> getLogWriters() {
@@ -460,6 +463,8 @@ public class MiniAccumuloClusterImpl implements AccumuloCluster {
File siteFile = new File(config.getConfDir(), "accumulo-site.xml");
writeConfig(siteFile, config.getSiteConfig().entrySet());
+ SiteConfiguration.clearInstance();
+ siteConfig = SiteConfiguration.create(siteFile);
if (!config.useExistingInstance() && !config.useExistingZooKeepers()) {
zooCfgFile = new File(config.getConfDir(), "zoo.cfg");
@@ -714,8 +719,11 @@ public class MiniAccumuloClusterImpl implements AccumuloCluster {
}
@Override
- public ServerContext getServerContext() {
- return new ServerContext(getClientInfo());
+ public synchronized ServerContext getServerContext() {
+ if (context == null) {
+ context = new ServerContext(siteConfig);
+ }
+ return context;
}
/**
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 2c4524d..bad5a4e 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
@@ -573,6 +573,10 @@ public class MiniAccumuloConfigImpl {
return new File(getConfDir(), "client.conf");
}
+ public File getAccumuloSiteFile() {
+ return new File(getConfDir(), "accumulo-site.xml");
+ }
+
/**
* @return location of accumulo-client.properties file for connecting to this mini cluster
*/
diff --git a/server/base/src/main/java/org/apache/accumulo/server/ServerContext.java b/server/base/src/main/java/org/apache/accumulo/server/ServerContext.java
index 0d1dca3..4ae6b3e 100644
--- a/server/base/src/main/java/org/apache/accumulo/server/ServerContext.java
+++ b/server/base/src/main/java/org/apache/accumulo/server/ServerContext.java
@@ -64,28 +64,30 @@ public class ServerContext extends ClientContext {
private String hostname = null;
private AuthenticationTokenSecretManager secretManager;
- public ServerContext() {
- this(new ServerInfo());
+ public ServerContext(SiteConfiguration siteConfig) {
+ this(new ServerInfo(siteConfig));
}
- private ServerContext(ServerInfo info) {
- super(info, SiteConfiguration.getInstance());
- this.info = info;
+ public ServerContext(SiteConfiguration siteConfig, String instanceName, String zooKeepers,
+ int zooKeepersSessionTimeOut) {
+ this(new ServerInfo(siteConfig, instanceName, zooKeepers, zooKeepersSessionTimeOut));
}
- public ServerContext(String instanceName, String zooKeepers, int zooKeepersSessionTimeOut) {
- this(new ServerInfo(instanceName, zooKeepers, zooKeepersSessionTimeOut));
+ public ServerContext(SiteConfiguration siteConfig, ClientInfo info) {
+ this(new ServerInfo(siteConfig, info.getInstanceName(), info.getZooKeepers(),
+ info.getZooKeepersSessionTimeOut()));
}
- public ServerContext(ClientInfo info) {
- this(new ServerInfo(info));
+ private ServerContext(ServerInfo info) {
+ super(info, info.getSiteConfiguration());
+ this.info = info;
}
public void setupServer(String appName, String appClassName, String hostname) {
applicationName = appName;
applicationClassName = appClassName;
this.hostname = hostname;
- SecurityUtil.serverLogin(SiteConfiguration.getInstance());
+ SecurityUtil.serverLogin(info.getSiteConfiguration());
log.info("Version " + Constants.VERSION);
log.info("Instance " + info.getInstanceID());
try {
@@ -123,7 +125,7 @@ public class ServerContext extends ClientContext {
public synchronized ServerConfigurationFactory getServerConfFactory() {
if (serverConfFactory == null) {
- serverConfFactory = new ServerConfigurationFactory(this);
+ serverConfFactory = new ServerConfigurationFactory(this, info.getSiteConfiguration());
}
return serverConfFactory;
}
diff --git a/server/base/src/main/java/org/apache/accumulo/server/ServerInfo.java b/server/base/src/main/java/org/apache/accumulo/server/ServerInfo.java
index 4f3f096..77e73b0 100644
--- a/server/base/src/main/java/org/apache/accumulo/server/ServerInfo.java
+++ b/server/base/src/main/java/org/apache/accumulo/server/ServerInfo.java
@@ -28,7 +28,6 @@ import org.apache.accumulo.core.client.impl.ClientConfConverter;
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.conf.AccumuloConfiguration;
import org.apache.accumulo.core.conf.ClientProperty;
import org.apache.accumulo.core.conf.Property;
import org.apache.accumulo.core.conf.SiteConfiguration;
@@ -42,6 +41,7 @@ import org.apache.hadoop.fs.Path;
public class ServerInfo implements ClientInfo {
+ private SiteConfiguration siteConfig;
private String instanceID;
private String instanceName;
private String zooKeepers;
@@ -50,11 +50,9 @@ public class ServerInfo implements ClientInfo {
private VolumeManager volumeManager;
private ZooCache zooCache;
- public ServerInfo(ClientInfo info) {
- this(info.getInstanceName(), info.getZooKeepers(), info.getZooKeepersSessionTimeOut());
- }
-
- public ServerInfo(String instanceName, String zooKeepers, int zooKeepersSessionTimeOut) {
+ ServerInfo(SiteConfiguration siteConfig, String instanceName, String zooKeepers,
+ int zooKeepersSessionTimeOut) {
+ this.siteConfig = siteConfig;
this.instanceName = instanceName;
this.zooKeepers = zooKeepers;
this.zooKeepersSessionTimeOut = zooKeepersSessionTimeOut;
@@ -76,11 +74,8 @@ public class ServerInfo implements ClientInfo {
zooKeeperRoot = ZooUtil.getRoot(instanceID);
}
- public ServerInfo() {
- this(SiteConfiguration.getInstance());
- }
-
- public ServerInfo(AccumuloConfiguration config) {
+ ServerInfo(SiteConfiguration config) {
+ siteConfig = config;
try {
volumeManager = VolumeManagerImpl.get();
} catch (IOException e) {
@@ -95,6 +90,10 @@ public class ServerInfo implements ClientInfo {
instanceName = InstanceOperationsImpl.lookupInstanceName(zooCache, UUID.fromString(instanceID));
}
+ public SiteConfiguration getSiteConfiguration() {
+ return siteConfig;
+ }
+
public VolumeManager getVolumeManager() {
return volumeManager;
}
@@ -127,12 +126,12 @@ public class ServerInfo implements ClientInfo {
@Override
public boolean saslEnabled() {
- return SiteConfiguration.getInstance().getBoolean(Property.INSTANCE_RPC_SASL_ENABLED);
+ return getSiteConfiguration().getBoolean(Property.INSTANCE_RPC_SASL_ENABLED);
}
@Override
public Properties getProperties() {
- Properties properties = ClientConfConverter.toProperties(SiteConfiguration.getInstance());
+ Properties properties = ClientConfConverter.toProperties(getSiteConfiguration());
properties.setProperty(ClientProperty.INSTANCE_ZOOKEEPERS.getKey(), getZooKeepers());
properties.setProperty(ClientProperty.INSTANCE_ZOOKEEPERS_TIMEOUT.getKey(),
Integer.toString(getZooKeepersSessionTimeOut()));
@@ -147,6 +146,6 @@ public class ServerInfo implements ClientInfo {
}
public Credentials getCredentials() {
- return SystemCredentials.get(getInstanceID());
+ return SystemCredentials.get(getInstanceID(), getSiteConfiguration());
}
}
diff --git a/server/base/src/main/java/org/apache/accumulo/server/ServerOpts.java b/server/base/src/main/java/org/apache/accumulo/server/ServerOpts.java
index c49f6a1..355e412 100644
--- a/server/base/src/main/java/org/apache/accumulo/server/ServerOpts.java
+++ b/server/base/src/main/java/org/apache/accumulo/server/ServerOpts.java
@@ -23,12 +23,18 @@ import java.util.List;
import java.util.Map;
import org.apache.accumulo.core.cli.Help;
-import org.apache.accumulo.core.conf.CliConfiguration;
+import org.apache.accumulo.core.conf.Property;
+import org.apache.accumulo.core.conf.SiteConfiguration;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import com.beust.jcommander.Parameter;
import com.beust.jcommander.converters.IParameterSplitter;
public class ServerOpts extends Help {
+
+ private static final Logger log = LoggerFactory.getLogger(ServerOpts.class);
+
@Parameter(names = {"-a", "--address"}, description = "address to bind to")
private String address = null;
@@ -54,6 +60,16 @@ public class ServerOpts extends Help {
return properties;
}
+ private SiteConfiguration siteConfig = null;
+
+ public synchronized SiteConfiguration getSiteConfiguration() {
+ if (siteConfig == null) {
+ siteConfig = SiteConfiguration.create(SiteConfiguration.getAccumuloSiteLocation(),
+ getConfig());
+ }
+ return siteConfig;
+ }
+
public Map<String,String> getConfig() {
Map<String,String> config = new HashMap<>();
for (String prop : getProperties()) {
@@ -76,9 +92,12 @@ public class ServerOpts extends Help {
@Override
public void parseArgs(String programName, String[] args, Object... others) {
super.parseArgs(programName, args, others);
- CliConfiguration.set(getConfig());
if (getConfig().size() > 0) {
- CliConfiguration.print();
+ log.info("The following configuration was set on the command line:");
+ for (Map.Entry<String,String> entry : getConfig().entrySet()) {
+ String key = entry.getKey();
+ log.info(key + " = " + (Property.isSensitive(key) ? "<hidden>" : entry.getValue()));
+ }
}
}
}
diff --git a/server/base/src/main/java/org/apache/accumulo/server/cli/ClientOnDefaultTable.java b/server/base/src/main/java/org/apache/accumulo/server/cli/ClientOnDefaultTable.java
index 1192814..b0f4f96 100644
--- a/server/base/src/main/java/org/apache/accumulo/server/cli/ClientOnDefaultTable.java
+++ b/server/base/src/main/java/org/apache/accumulo/server/cli/ClientOnDefaultTable.java
@@ -16,6 +16,7 @@
*/
package org.apache.accumulo.server.cli;
+import org.apache.accumulo.core.conf.SiteConfiguration;
import org.apache.accumulo.server.ServerContext;
public class ClientOnDefaultTable extends org.apache.accumulo.core.cli.ClientOnDefaultTable {
@@ -23,11 +24,17 @@ public class ClientOnDefaultTable extends org.apache.accumulo.core.cli.ClientOnD
setPrincipal("root");
}
- public ServerContext getServerContext() {
- if (instance == null) {
- return new ServerContext();
+ private ServerContext context;
+
+ public synchronized ServerContext getServerContext() {
+ if (context == null) {
+ if (instance == null) {
+ context = new ServerContext(SiteConfiguration.create());
+ } else {
+ context = new ServerContext(SiteConfiguration.create(), getClientInfo());
+ }
}
- return new ServerContext(getClientInfo());
+ return context;
}
public ClientOnDefaultTable(String table) {
diff --git a/server/base/src/main/java/org/apache/accumulo/server/cli/ClientOnRequiredTable.java b/server/base/src/main/java/org/apache/accumulo/server/cli/ClientOnRequiredTable.java
index 1036320..bacd769 100644
--- a/server/base/src/main/java/org/apache/accumulo/server/cli/ClientOnRequiredTable.java
+++ b/server/base/src/main/java/org/apache/accumulo/server/cli/ClientOnRequiredTable.java
@@ -16,6 +16,7 @@
*/
package org.apache.accumulo.server.cli;
+import org.apache.accumulo.core.conf.SiteConfiguration;
import org.apache.accumulo.server.ServerContext;
public class ClientOnRequiredTable extends org.apache.accumulo.core.cli.ClientOnRequiredTable {
@@ -23,10 +24,16 @@ public class ClientOnRequiredTable extends org.apache.accumulo.core.cli.ClientOn
setPrincipal("root");
}
- public ServerContext getServerContext() {
- if (instance == null) {
- return new ServerContext();
+ private ServerContext context;
+
+ public synchronized ServerContext getServerContext() {
+ if (context == null) {
+ if (instance == null) {
+ context = new ServerContext(SiteConfiguration.create());
+ } else {
+ context = new ServerContext(SiteConfiguration.create(), getClientInfo());
+ }
}
- return new ServerContext(getClientInfo());
+ return context;
}
}
diff --git a/server/base/src/main/java/org/apache/accumulo/server/cli/ClientOpts.java b/server/base/src/main/java/org/apache/accumulo/server/cli/ClientOpts.java
index dab53e2..ba4caa7 100644
--- a/server/base/src/main/java/org/apache/accumulo/server/cli/ClientOpts.java
+++ b/server/base/src/main/java/org/apache/accumulo/server/cli/ClientOpts.java
@@ -17,6 +17,7 @@
package org.apache.accumulo.server.cli;
import org.apache.accumulo.core.client.impl.ClientContext;
+import org.apache.accumulo.core.conf.SiteConfiguration;
import org.apache.accumulo.server.ServerContext;
public class ClientOpts extends org.apache.accumulo.core.cli.ClientOpts {
@@ -28,10 +29,16 @@ public class ClientOpts extends org.apache.accumulo.core.cli.ClientOpts {
return new ClientContext(getClientInfo());
}
- public ServerContext getServerContext() {
- if (instance == null) {
- return new ServerContext();
+ private ServerContext context;
+
+ public synchronized ServerContext getServerContext() {
+ if (context == null) {
+ if (instance == null) {
+ context = new ServerContext(SiteConfiguration.create());
+ } else {
+ context = new ServerContext(SiteConfiguration.create(), getClientInfo());
+ }
}
- return new ServerContext(getClientInfo());
+ return context;
}
}
diff --git a/server/base/src/main/java/org/apache/accumulo/server/conf/ConfigSanityCheck.java b/server/base/src/main/java/org/apache/accumulo/server/conf/ConfigSanityCheck.java
index be67117..9c50a10 100644
--- a/server/base/src/main/java/org/apache/accumulo/server/conf/ConfigSanityCheck.java
+++ b/server/base/src/main/java/org/apache/accumulo/server/conf/ConfigSanityCheck.java
@@ -16,6 +16,7 @@
*/
package org.apache.accumulo.server.conf;
+import org.apache.accumulo.core.conf.SiteConfiguration;
import org.apache.accumulo.server.ServerContext;
import org.apache.accumulo.start.spi.KeywordExecutable;
@@ -25,7 +26,7 @@ import com.google.auto.service.AutoService;
public class ConfigSanityCheck implements KeywordExecutable {
public static void main(String[] args) {
- ServerContext context = new ServerContext();
+ ServerContext context = new ServerContext(SiteConfiguration.create());
context.getServerConfFactory().getSystemConfiguration();
}
diff --git a/server/base/src/main/java/org/apache/accumulo/server/conf/NamespaceConfWatcher.java b/server/base/src/main/java/org/apache/accumulo/server/conf/NamespaceConfWatcher.java
index 46481e5..ea085c5 100644
--- a/server/base/src/main/java/org/apache/accumulo/server/conf/NamespaceConfWatcher.java
+++ b/server/base/src/main/java/org/apache/accumulo/server/conf/NamespaceConfWatcher.java
@@ -34,13 +34,11 @@ class NamespaceConfWatcher implements Watcher {
private final ServerContext context;
private final String namespacesPrefix;
private final int namespacesPrefixLength;
- private ServerConfigurationFactory scf;
NamespaceConfWatcher(ServerContext context) {
this.context = context;
namespacesPrefix = context.getZooKeeperRoot() + Constants.ZNAMESPACES + "/";
namespacesPrefixLength = namespacesPrefix.length();
- scf = new ServerConfigurationFactory(context);
}
static String toString(WatchedEvent event) {
@@ -81,10 +79,11 @@ class NamespaceConfWatcher implements Watcher {
if (log.isTraceEnabled())
log.trace("EventNodeDataChanged " + event.getPath());
if (key != null)
- scf.getNamespaceConfiguration(namespaceId).propertyChanged(key);
+ context.getServerConfFactory().getNamespaceConfiguration(namespaceId)
+ .propertyChanged(key);
break;
case NodeChildrenChanged:
- scf.getNamespaceConfiguration(namespaceId).propertiesChanged();
+ context.getServerConfFactory().getNamespaceConfiguration(namespaceId).propertiesChanged();
break;
case NodeDeleted:
if (key == null) {
diff --git a/server/base/src/main/java/org/apache/accumulo/server/conf/ServerConfigurationFactory.java b/server/base/src/main/java/org/apache/accumulo/server/conf/ServerConfigurationFactory.java
index 108cf08..d6ab92d 100644
--- a/server/base/src/main/java/org/apache/accumulo/server/conf/ServerConfigurationFactory.java
+++ b/server/base/src/main/java/org/apache/accumulo/server/conf/ServerConfigurationFactory.java
@@ -88,11 +88,13 @@ public class ServerConfigurationFactory extends ServerConfiguration {
}
private final ServerContext context;
+ private final SiteConfiguration siteConfig;
private final String instanceID;
private ZooCacheFactory zcf = new ZooCacheFactory();
- public ServerConfigurationFactory(ServerContext context) {
+ public ServerConfigurationFactory(ServerContext context, SiteConfiguration siteConfig) {
this.context = context;
+ this.siteConfig = siteConfig;
instanceID = context.getInstanceID();
addInstanceToCaches(instanceID);
}
@@ -105,14 +107,10 @@ public class ServerConfigurationFactory extends ServerConfiguration {
this.zcf = zcf;
}
- private SiteConfiguration siteConfig = null;
private DefaultConfiguration defaultConfig = null;
private AccumuloConfiguration systemConfig = null;
- public synchronized SiteConfiguration getSiteConfiguration() {
- if (siteConfig == null) {
- siteConfig = SiteConfiguration.getInstance();
- }
+ public SiteConfiguration getSiteConfiguration() {
return siteConfig;
}
diff --git a/server/base/src/main/java/org/apache/accumulo/server/conf/TableConfiguration.java b/server/base/src/main/java/org/apache/accumulo/server/conf/TableConfiguration.java
index 7741cae..3bc99cc 100644
--- a/server/base/src/main/java/org/apache/accumulo/server/conf/TableConfiguration.java
+++ b/server/base/src/main/java/org/apache/accumulo/server/conf/TableConfiguration.java
@@ -136,8 +136,7 @@ public class TableConfiguration extends ObservableConfiguration {
* returns the actual NamespaceConfiguration that corresponds to the current parent namespace.
*/
public NamespaceConfiguration getNamespaceConfiguration() {
- return new ServerConfigurationFactory(parent.context)
- .getNamespaceConfiguration(parent.namespaceId);
+ return context.getServerConfFactory().getNamespaceConfiguration(parent.namespaceId);
}
/**
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 26e6bfa..ec7aad5 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
@@ -246,8 +246,7 @@ public class Initialize implements KeywordExecutable {
if (fsUri.equals(""))
fsUri = FileSystem.getDefaultUri(conf).toString();
log.info("Hadoop Filesystem is {}", fsUri);
- log.info("Accumulo data dirs are {}",
- Arrays.asList(VolumeConfiguration.getVolumeUris(SiteConfiguration.getInstance())));
+ log.info("Accumulo data dirs are {}", Arrays.asList(VolumeConfiguration.getVolumeUris(sconf)));
log.info("Zookeeper server is {}", sconf.get(Property.INSTANCE_ZK_HOST));
log.info("Checking if Zookeeper is available. If this hangs, then you need"
+ " to make sure zookeeper is running");
@@ -272,7 +271,7 @@ public class Initialize implements KeywordExecutable {
+ " accumulo-site.xml. Without this accumulo will not operate" + " correctly");
}
try {
- if (isInitialized(fs)) {
+ if (isInitialized(fs, sconf)) {
printInitializeFailureMessages(sconf);
return false;
}
@@ -291,8 +290,7 @@ public class Initialize implements KeywordExecutable {
String instanceDfsDir = sconf.get(INSTANCE_DFS_DIR);
// ACCUMULO-3651 Changed level to error and added FATAL to message for slf4j compatibility
log.error("FATAL It appears the directories {}",
- Arrays.asList(VolumeConfiguration.getVolumeUris(SiteConfiguration.getInstance()))
- + " were previously initialized.");
+ Arrays.asList(VolumeConfiguration.getVolumeUris(sconf)) + " were previously initialized.");
String instanceVolumes = sconf.get(Property.INSTANCE_VOLUMES);
String instanceDfsUri = sconf.get(INSTANCE_DFS_URI);
@@ -313,8 +311,9 @@ public class Initialize implements KeywordExecutable {
log.error("FATAL: The current value of {} is |{}|", Property.INSTANCE_VOLUMES, instanceVolumes);
}
- public boolean doInit(Opts opts, Configuration conf, VolumeManager fs) throws IOException {
- if (!checkInit(conf, fs, SiteConfiguration.getInstance())) {
+ public boolean doInit(SiteConfiguration siteConfig, Opts opts, Configuration conf,
+ VolumeManager fs) throws IOException {
+ if (!checkInit(conf, fs, siteConfig)) {
return false;
}
@@ -330,29 +329,28 @@ public class Initialize implements KeywordExecutable {
String rootUser;
try {
- rootUser = getRootUserName(opts);
+ rootUser = getRootUserName(siteConfig, opts);
} catch (Exception e) {
log.error("FATAL: Failed to obtain user for administrative privileges");
return false;
}
// Don't prompt for a password when we're running SASL(Kerberos)
- final AccumuloConfiguration siteConf = SiteConfiguration.getInstance();
- if (siteConf.getBoolean(Property.INSTANCE_RPC_SASL_ENABLED)) {
+ if (siteConfig.getBoolean(Property.INSTANCE_RPC_SASL_ENABLED)) {
opts.rootpass = UUID.randomUUID().toString().getBytes(UTF_8);
} else {
- opts.rootpass = getRootPassword(opts, rootUser);
+ opts.rootpass = getRootPassword(siteConfig, opts, rootUser);
}
- return initialize(opts, instanceNamePath, fs, rootUser);
+ return initialize(siteConfig, opts, instanceNamePath, fs, rootUser);
}
- private boolean initialize(Opts opts, String instanceNamePath, VolumeManager fs,
- String rootUser) {
+ private boolean initialize(SiteConfiguration siteConfig, Opts opts, String instanceNamePath,
+ VolumeManager fs, String rootUser) {
UUID uuid = UUID.randomUUID();
// the actual disk locations of the root table and tablets
- String[] configuredVolumes = VolumeConfiguration.getVolumeUris(SiteConfiguration.getInstance());
+ String[] configuredVolumes = VolumeConfiguration.getVolumeUris(siteConfig);
VolumeChooserEnvironment chooserEnv = new VolumeChooserEnvironment(ChooserScope.INIT);
final String rootTabletDir = new Path(
fs.choose(chooserEnv, configuredVolumes) + Path.SEPARATOR + ServerConstants.TABLE_DIR
@@ -366,11 +364,11 @@ public class Initialize implements KeywordExecutable {
}
try {
- initFileSystem(opts, fs, uuid, rootTabletDir);
+ initFileSystem(siteConfig, fs, uuid, rootTabletDir);
} catch (Exception e) {
log.error("FATAL Failed to initialize filesystem", e);
- if (SiteConfiguration.getInstance().get(Property.INSTANCE_VOLUMES).trim().equals("")) {
+ if (siteConfig.get(Property.INSTANCE_VOLUMES).trim().equals("")) {
Configuration fsConf = CachedConfiguration.getInstance();
final String defaultFsUri = "file:///";
@@ -391,7 +389,7 @@ public class Initialize implements KeywordExecutable {
return false;
}
- final ServerContext context = new ServerContext();
+ final ServerContext context = new ServerContext(siteConfig);
// When we're using Kerberos authentication, we need valid credentials to perform
// initialization. If the user provided some, use them.
@@ -437,7 +435,7 @@ public class Initialize implements KeywordExecutable {
log.info("Uploading properties in accumulo-site.xml to Zookeeper."
+ " Properties that cannot be set in Zookeeper will be skipped:");
Map<String,String> entries = new TreeMap<>();
- SiteConfiguration.getInstance().getProperties(entries, x -> true, false);
+ siteConfig.getProperties(entries, x -> true, false);
for (Map.Entry<String,String> entry : entries.entrySet()) {
String key = entry.getKey();
String value = entry.getValue();
@@ -480,10 +478,9 @@ public class Initialize implements KeywordExecutable {
}
}
- private void initFileSystem(Opts opts, VolumeManager fs, UUID uuid, String rootTabletDir)
- throws IOException {
- AccumuloConfiguration siteConf = SiteConfiguration.getInstance();
- initDirs(fs, uuid, VolumeConfiguration.getVolumeUris(siteConf), false);
+ private void initFileSystem(SiteConfiguration siteConfig, VolumeManager fs, UUID uuid,
+ String rootTabletDir) throws IOException {
+ initDirs(fs, uuid, VolumeConfiguration.getVolumeUris(siteConfig), false);
// initialize initial system tables config in zookeeper
initSystemTablesConfig(Constants.ZROOT + "/" + uuid);
@@ -509,7 +506,7 @@ public class Initialize implements KeywordExecutable {
String metadataFileName = tableMetadataTabletDir + Path.SEPARATOR + "0_1." + ext;
Tablet replicationTablet = new Tablet(ReplicationTable.ID, replicationTableDefaultTabletDir,
null, null);
- createMetadataFile(fs, metadataFileName, siteConf, replicationTablet);
+ createMetadataFile(fs, metadataFileName, siteConfig, replicationTablet);
// populate the root tablet with info about the metadata table's two initial tablets
String rootTabletFileName = rootTabletDir + Path.SEPARATOR + "00000_00000." + ext;
@@ -517,7 +514,7 @@ public class Initialize implements KeywordExecutable {
Tablet tablesTablet = new Tablet(MetadataTable.ID, tableMetadataTabletDir, null, splitPoint,
metadataFileName);
Tablet defaultTablet = new Tablet(MetadataTable.ID, defaultMetadataTabletDir, splitPoint, null);
- createMetadataFile(fs, rootTabletFileName, siteConf, tablesTablet, defaultTablet);
+ createMetadataFile(fs, rootTabletFileName, siteConfig, tablesTablet, defaultTablet);
}
private static class Tablet {
@@ -703,11 +700,10 @@ public class Initialize implements KeywordExecutable {
return instanceNamePath;
}
- private String getRootUserName(Opts opts) throws IOException {
- AccumuloConfiguration conf = SiteConfiguration.getInstance();
- final String keytab = conf.get(Property.GENERAL_KERBEROS_KEYTAB);
+ private String getRootUserName(SiteConfiguration siteConfig, Opts opts) throws IOException {
+ final String keytab = siteConfig.get(Property.GENERAL_KERBEROS_KEYTAB);
if (keytab.equals(Property.GENERAL_KERBEROS_KEYTAB.getDefaultValue())
- || !conf.getBoolean(Property.INSTANCE_RPC_SASL_ENABLED)) {
+ || !siteConfig.getBoolean(Property.INSTANCE_RPC_SASL_ENABLED)) {
return DEFAULT_ROOT_USER;
}
@@ -730,15 +726,16 @@ public class Initialize implements KeywordExecutable {
} while (true);
}
- private byte[] getRootPassword(Opts opts, String rootUser) throws IOException {
+ private byte[] getRootPassword(SiteConfiguration siteConfig, Opts opts, String rootUser)
+ throws IOException {
if (opts.cliPassword != null) {
return opts.cliPassword.getBytes(UTF_8);
}
String rootpass;
String confirmpass;
do {
- rootpass = getConsoleReader()
- .readLine("Enter initial password for " + rootUser + getInitialPasswordWarning(), '*');
+ rootpass = getConsoleReader().readLine(
+ "Enter initial password for " + rootUser + getInitialPasswordWarning(siteConfig), '*');
if (rootpass == null)
System.exit(0);
confirmpass = getConsoleReader().readLine("Confirm initial password for " + rootUser + ": ",
@@ -761,11 +758,10 @@ public class Initialize implements KeywordExecutable {
*
* @return String containing warning portion of console message.
*/
- private String getInitialPasswordWarning() {
+ private String getInitialPasswordWarning(SiteConfiguration siteConfig) {
String optionalWarning;
Property authenticatorProperty = Property.INSTANCE_SECURITY_AUTHENTICATOR;
- if (SiteConfiguration.getInstance().get(authenticatorProperty)
- .equals(authenticatorProperty.getDefaultValue()))
+ if (siteConfig.get(authenticatorProperty).equals(authenticatorProperty.getDefaultValue()))
optionalWarning = ": ";
else
optionalWarning = " (this may not be applicable for your security setup): ";
@@ -829,8 +825,9 @@ public class Initialize implements KeywordExecutable {
initialMetadataConf.put(Property.TABLE_FILE_REPLICATION.getKey(), rep);
}
- public static boolean isInitialized(VolumeManager fs) throws IOException {
- for (String baseDir : VolumeConfiguration.getVolumeUris(SiteConfiguration.getInstance())) {
+ public static boolean isInitialized(VolumeManager fs, SiteConfiguration siteConfig)
+ throws IOException {
+ for (String baseDir : VolumeConfiguration.getVolumeUris(siteConfig)) {
if (fs.exists(new Path(baseDir, ServerConstants.INSTANCE_ID_DIR))
|| fs.exists(new Path(baseDir, ServerConstants.VERSION_DIR)))
return true;
@@ -839,9 +836,10 @@ public class Initialize implements KeywordExecutable {
return false;
}
- private static void addVolumes(VolumeManager fs) throws IOException {
+ private static void addVolumes(VolumeManager fs, SiteConfiguration siteConfig)
+ throws IOException {
- String[] volumeURIs = VolumeConfiguration.getVolumeUris(SiteConfiguration.getInstance());
+ String[] volumeURIs = VolumeConfiguration.getVolumeUris(siteConfig);
HashSet<String> initializedDirs = new HashSet<>();
initializedDirs.addAll(Arrays.asList(ServerConstants.checkBaseUris(volumeURIs, true)));
@@ -854,8 +852,7 @@ public class Initialize implements KeywordExecutable {
Path iidPath = new Path(aBasePath, ServerConstants.INSTANCE_ID_DIR);
Path versionPath = new Path(aBasePath, ServerConstants.VERSION_DIR);
- UUID uuid = UUID
- .fromString(ZooUtil.getInstanceIDFromHdfs(iidPath, SiteConfiguration.getInstance()));
+ UUID uuid = UUID.fromString(ZooUtil.getInstanceIDFromHdfs(iidPath, siteConfig));
for (Pair<Path,Path> replacementVolume : ServerConstants.getVolumeReplacements()) {
if (aBasePath.equals(replacementVolume.getFirst()))
log.error(
@@ -921,19 +918,19 @@ public class Initialize implements KeywordExecutable {
public void execute(final String[] args) {
Opts opts = new Opts();
opts.parseArgs("accumulo init", args);
+ SiteConfiguration siteConfig = SiteConfiguration.create();
try {
zoo = ZooReaderWriter.getInstance();
- AccumuloConfiguration acuConf = SiteConfiguration.getInstance();
- SecurityUtil.serverLogin(acuConf);
- Configuration conf = CachedConfiguration.getInstance();
+ SecurityUtil.serverLogin(siteConfig);
+ Configuration hadoopConfig = CachedConfiguration.getInstance();
- VolumeManager fs = VolumeManagerImpl.get(acuConf);
+ VolumeManager fs = VolumeManagerImpl.get(siteConfig);
if (opts.resetSecurity) {
log.info("Resetting security on accumulo.");
- ServerContext context = new ServerContext();
- if (isInitialized(fs)) {
+ ServerContext context = new ServerContext(siteConfig);
+ if (isInitialized(fs, siteConfig)) {
if (!opts.forceResetSecurity) {
ConsoleReader c = getConsoleReader();
String userEnteredName = c.readLine("WARNING: This will remove all"
@@ -944,8 +941,8 @@ public class Initialize implements KeywordExecutable {
}
}
- final String rootUser = getRootUserName(opts);
- opts.rootpass = getRootPassword(opts, rootUser);
+ final String rootUser = getRootUserName(siteConfig, opts);
+ opts.rootpass = getRootPassword(siteConfig, opts, rootUser);
initSecurity(context, opts, context.getInstanceID(), rootUser);
} else {
log.error("FATAL: Attempted to reset security on accumulo before it was initialized");
@@ -953,11 +950,11 @@ public class Initialize implements KeywordExecutable {
}
if (opts.addVolumes) {
- addVolumes(fs);
+ addVolumes(fs, siteConfig);
}
if (!opts.resetSecurity && !opts.addVolumes)
- if (!doInit(opts, conf, fs))
+ if (!doInit(siteConfig, opts, hadoopConfig, fs))
System.exit(-1);
} catch (Exception e) {
log.error("Fatal exception", e);
diff --git a/server/base/src/main/java/org/apache/accumulo/server/problems/ProblemReports.java b/server/base/src/main/java/org/apache/accumulo/server/problems/ProblemReports.java
index 8217a67..4901994 100644
--- a/server/base/src/main/java/org/apache/accumulo/server/problems/ProblemReports.java
+++ b/server/base/src/main/java/org/apache/accumulo/server/problems/ProblemReports.java
@@ -35,6 +35,7 @@ import org.apache.accumulo.core.client.Connector;
import org.apache.accumulo.core.client.IteratorSetting;
import org.apache.accumulo.core.client.Scanner;
import org.apache.accumulo.core.client.impl.Table;
+import org.apache.accumulo.core.conf.SiteConfiguration;
import org.apache.accumulo.core.data.Key;
import org.apache.accumulo.core.data.Mutation;
import org.apache.accumulo.core.data.Range;
@@ -300,7 +301,7 @@ public class ProblemReports implements Iterable<ProblemReport> {
}
public static void main(String args[]) throws Exception {
- ServerContext context = new ServerContext();
+ ServerContext context = new ServerContext(SiteConfiguration.create());
getInstance(context).printProblems();
}
diff --git a/server/base/src/main/java/org/apache/accumulo/server/security/AuditedSecurityOperation.java b/server/base/src/main/java/org/apache/accumulo/server/security/AuditedSecurityOperation.java
index f4d0bfb..b63aa48 100644
--- a/server/base/src/main/java/org/apache/accumulo/server/security/AuditedSecurityOperation.java
+++ b/server/base/src/main/java/org/apache/accumulo/server/security/AuditedSecurityOperation.java
@@ -72,8 +72,8 @@ public class AuditedSecurityOperation extends SecurityOperation {
boolean initialize) {
if (instance == null) {
String instanceId = context.getInstanceID();
- instance = new AuditedSecurityOperation(context, getAuthorizor(instanceId, initialize),
- getAuthenticator(instanceId, initialize), getPermHandler(instanceId, initialize));
+ instance = new AuditedSecurityOperation(context, getAuthorizor(context, initialize),
+ getAuthenticator(context, initialize), getPermHandler(context, initialize));
}
return instance;
}
diff --git a/server/base/src/main/java/org/apache/accumulo/server/security/SecurityOperation.java b/server/base/src/main/java/org/apache/accumulo/server/security/SecurityOperation.java
index 7679457..5fa3248 100644
--- a/server/base/src/main/java/org/apache/accumulo/server/security/SecurityOperation.java
+++ b/server/base/src/main/java/org/apache/accumulo/server/security/SecurityOperation.java
@@ -33,9 +33,7 @@ import org.apache.accumulo.core.client.impl.Table;
import org.apache.accumulo.core.client.impl.thrift.SecurityErrorCode;
import org.apache.accumulo.core.client.impl.thrift.ThriftSecurityException;
import org.apache.accumulo.core.client.security.tokens.AuthenticationToken;
-import org.apache.accumulo.core.conf.AccumuloConfiguration;
import org.apache.accumulo.core.conf.Property;
-import org.apache.accumulo.core.conf.SiteConfiguration;
import org.apache.accumulo.core.data.thrift.IterInfo;
import org.apache.accumulo.core.data.thrift.TColumn;
import org.apache.accumulo.core.data.thrift.TKeyExtent;
@@ -83,36 +81,32 @@ public class SecurityOperation {
public static synchronized SecurityOperation getInstance(ServerContext context,
boolean initialize) {
if (instance == null) {
- String instanceId = context.getInstanceID();
- instance = new SecurityOperation(context, getAuthorizor(instanceId, initialize),
- getAuthenticator(instanceId, initialize), getPermHandler(instanceId, initialize));
+ instance = new SecurityOperation(context, getAuthorizor(context, initialize),
+ getAuthenticator(context, initialize), getPermHandler(context, initialize));
}
return instance;
}
- protected static Authorizor getAuthorizor(String instanceId, boolean initialize) {
- AccumuloConfiguration conf = SiteConfiguration.getInstance();
- Authorizor toRet = Property.createInstanceFromPropertyName(conf,
+ protected static Authorizor getAuthorizor(ServerContext context, boolean initialize) {
+ Authorizor toRet = Property.createInstanceFromPropertyName(context.getConfiguration(),
Property.INSTANCE_SECURITY_AUTHORIZOR, Authorizor.class, ZKAuthorizor.getInstance());
- toRet.initialize(instanceId, initialize);
+ toRet.initialize(context.getInstanceID(), initialize);
return toRet;
}
- protected static Authenticator getAuthenticator(String instanceId, boolean initialize) {
- AccumuloConfiguration conf = SiteConfiguration.getInstance();
- Authenticator toRet = Property.createInstanceFromPropertyName(conf,
+ protected static Authenticator getAuthenticator(ServerContext context, boolean initialize) {
+ Authenticator toRet = Property.createInstanceFromPropertyName(context.getConfiguration(),
Property.INSTANCE_SECURITY_AUTHENTICATOR, Authenticator.class,
ZKAuthenticator.getInstance());
- toRet.initialize(instanceId, initialize);
+ toRet.initialize(context, initialize);
return toRet;
}
- protected static PermissionHandler getPermHandler(String instanceId, boolean initialize) {
- AccumuloConfiguration conf = SiteConfiguration.getInstance();
- PermissionHandler toRet = Property.createInstanceFromPropertyName(conf,
+ protected static PermissionHandler getPermHandler(ServerContext context, boolean initialize) {
+ PermissionHandler toRet = Property.createInstanceFromPropertyName(context.getConfiguration(),
Property.INSTANCE_SECURITY_PERMISSION_HANDLER, PermissionHandler.class,
ZKPermHandler.getInstance());
- toRet.initialize(instanceId, initialize);
+ toRet.initialize(context.getInstanceID(), initialize);
return toRet;
}
diff --git a/server/base/src/main/java/org/apache/accumulo/server/security/SystemCredentials.java b/server/base/src/main/java/org/apache/accumulo/server/security/SystemCredentials.java
index 31a4bad..8d8e01e 100644
--- a/server/base/src/main/java/org/apache/accumulo/server/security/SystemCredentials.java
+++ b/server/base/src/main/java/org/apache/accumulo/server/security/SystemCredentials.java
@@ -30,7 +30,6 @@ import org.apache.accumulo.core.Constants;
import org.apache.accumulo.core.client.impl.Credentials;
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.Property;
import org.apache.accumulo.core.conf.SiteConfiguration;
import org.apache.accumulo.core.security.thrift.TCredentials;
@@ -53,19 +52,19 @@ public final class SystemCredentials extends Credentials {
AS_THRIFT = super.toThrift(instanceID);
}
- public static SystemCredentials get(String instanceID) {
+ public static SystemCredentials get(String instanceID, SiteConfiguration siteConfig) {
String principal = SYSTEM_PRINCIPAL;
- AccumuloConfiguration conf = SiteConfiguration.getInstance();
- if (conf.getBoolean(Property.INSTANCE_RPC_SASL_ENABLED)) {
+ if (siteConfig.getBoolean(Property.INSTANCE_RPC_SASL_ENABLED)) {
// Use the server's kerberos principal as the Accumulo principal. We could also unwrap the
// principal server-side, but the principal for SystemCredentials
// isnt' actually used anywhere, so it really doesn't matter. We can't include the kerberos
// principal in the SystemToken as it would break equality when
// different Accumulo servers are using different kerberos principals are their accumulo
// principal
- principal = SecurityUtil.getServerPrincipal(conf.get(Property.GENERAL_KERBEROS_PRINCIPAL));
+ principal = SecurityUtil
+ .getServerPrincipal(siteConfig.get(Property.GENERAL_KERBEROS_PRINCIPAL));
}
- return new SystemCredentials(instanceID, principal, SystemToken.get(instanceID));
+ return new SystemCredentials(instanceID, principal, SystemToken.get(instanceID, siteConfig));
}
@Override
@@ -92,7 +91,7 @@ public final class SystemCredentials extends Credentials {
super(systemPassword);
}
- private static SystemToken get(String instanceID) {
+ private static SystemToken get(String instanceID, SiteConfiguration siteConfig) {
byte[] instanceIdBytes = instanceID.getBytes(UTF_8);
byte[] confChecksum;
MessageDigest md;
@@ -106,7 +105,7 @@ public final class SystemCredentials extends Credentials {
md.update(ServerConstants.WIRE_VERSION.toString().getBytes(UTF_8));
md.update(instanceIdBytes);
- for (Entry<String,String> entry : SiteConfiguration.getInstance()) {
+ for (Entry<String,String> entry : siteConfig) {
// only include instance properties
if (entry.getKey().startsWith(Property.INSTANCE_PREFIX.toString())) {
md.update(entry.getKey().getBytes(UTF_8));
diff --git a/server/base/src/main/java/org/apache/accumulo/server/security/handler/Authenticator.java b/server/base/src/main/java/org/apache/accumulo/server/security/handler/Authenticator.java
index 0150111..14a03f0 100644
--- a/server/base/src/main/java/org/apache/accumulo/server/security/handler/Authenticator.java
+++ b/server/base/src/main/java/org/apache/accumulo/server/security/handler/Authenticator.java
@@ -22,6 +22,7 @@ import org.apache.accumulo.core.client.AccumuloSecurityException;
import org.apache.accumulo.core.client.impl.thrift.ThriftSecurityException;
import org.apache.accumulo.core.client.security.tokens.AuthenticationToken;
import org.apache.accumulo.core.security.thrift.TCredentials;
+import org.apache.accumulo.server.ServerContext;
/**
* This interface is used for the system which will be used for authenticating a user. If the
@@ -30,7 +31,7 @@ import org.apache.accumulo.core.security.thrift.TCredentials;
*/
public interface Authenticator {
- void initialize(String instanceId, boolean initialize);
+ void initialize(ServerContext context, boolean initialize);
boolean validSecurityHandlers(Authorizor auth, PermissionHandler pm);
diff --git a/server/base/src/main/java/org/apache/accumulo/server/security/handler/InsecureAuthenticator.java b/server/base/src/main/java/org/apache/accumulo/server/security/handler/InsecureAuthenticator.java
index ad777f2..246d9bb 100644
--- a/server/base/src/main/java/org/apache/accumulo/server/security/handler/InsecureAuthenticator.java
+++ b/server/base/src/main/java/org/apache/accumulo/server/security/handler/InsecureAuthenticator.java
@@ -24,6 +24,7 @@ import org.apache.accumulo.core.client.AccumuloSecurityException;
import org.apache.accumulo.core.client.security.tokens.AuthenticationToken;
import org.apache.accumulo.core.client.security.tokens.NullToken;
import org.apache.accumulo.core.security.thrift.TCredentials;
+import org.apache.accumulo.server.ServerContext;
/**
* This is an Authenticator implementation that doesn't actually do any security. Any principal will
@@ -33,7 +34,7 @@ import org.apache.accumulo.core.security.thrift.TCredentials;
public class InsecureAuthenticator implements Authenticator {
@Override
- public void initialize(String instanceId, boolean initialize) {}
+ public void initialize(ServerContext context, boolean initialize) {}
@Override
public boolean validSecurityHandlers(Authorizor auth, PermissionHandler pm) {
diff --git a/server/base/src/main/java/org/apache/accumulo/server/security/handler/KerberosAuthenticator.java b/server/base/src/main/java/org/apache/accumulo/server/security/handler/KerberosAuthenticator.java
index 75a694a..1b6e512 100644
--- a/server/base/src/main/java/org/apache/accumulo/server/security/handler/KerberosAuthenticator.java
+++ b/server/base/src/main/java/org/apache/accumulo/server/security/handler/KerberosAuthenticator.java
@@ -30,12 +30,11 @@ import org.apache.accumulo.core.client.impl.thrift.SecurityErrorCode;
import org.apache.accumulo.core.client.impl.thrift.ThriftSecurityException;
import org.apache.accumulo.core.client.security.tokens.AuthenticationToken;
import org.apache.accumulo.core.client.security.tokens.KerberosToken;
-import org.apache.accumulo.core.conf.AccumuloConfiguration;
-import org.apache.accumulo.core.conf.SiteConfiguration;
import org.apache.accumulo.core.security.thrift.TCredentials;
import org.apache.accumulo.fate.zookeeper.IZooReaderWriter;
import org.apache.accumulo.fate.zookeeper.ZooUtil.NodeExistsPolicy;
import org.apache.accumulo.fate.zookeeper.ZooUtil.NodeMissingPolicy;
+import org.apache.accumulo.server.ServerContext;
import org.apache.accumulo.server.rpc.UGIAssumingProcessor;
import org.apache.accumulo.server.security.SystemCredentials.SystemToken;
import org.apache.accumulo.server.security.UserImpersonation;
@@ -57,23 +56,21 @@ public class KerberosAuthenticator implements Authenticator {
.newHashSet(KerberosToken.class.getName(), SystemToken.class.getName());
private final ZKAuthenticator zkAuthenticator = new ZKAuthenticator();
- private String zkUserPath;
private final ZooCache zooCache;
- private final UserImpersonation impersonation;
+ private ServerContext context;
+ private String zkUserPath;
+ private UserImpersonation impersonation;
public KerberosAuthenticator() {
- this(new ZooCache(), SiteConfiguration.getInstance());
- }
-
- public KerberosAuthenticator(ZooCache cache, AccumuloConfiguration conf) {
- this.zooCache = cache;
- this.impersonation = new UserImpersonation(conf);
+ zooCache = new ZooCache();
}
@Override
- public void initialize(String instanceId, boolean initialize) {
- zkAuthenticator.initialize(instanceId, initialize);
- zkUserPath = Constants.ZROOT + "/" + instanceId + "/users";
+ public void initialize(ServerContext context, boolean initialize) {
+ this.context = context;
+ impersonation = new UserImpersonation(context.getConfiguration());
+ zkAuthenticator.initialize(context, initialize);
+ zkUserPath = Constants.ZROOT + "/" + context.getInstanceID() + "/users";
}
@Override
diff --git a/server/base/src/main/java/org/apache/accumulo/server/security/handler/ZKAuthenticator.java b/server/base/src/main/java/org/apache/accumulo/server/security/handler/ZKAuthenticator.java
index 5e34cf2..491c2cf 100644
--- a/server/base/src/main/java/org/apache/accumulo/server/security/handler/ZKAuthenticator.java
+++ b/server/base/src/main/java/org/apache/accumulo/server/security/handler/ZKAuthenticator.java
@@ -32,6 +32,7 @@ import org.apache.accumulo.core.security.thrift.TCredentials;
import org.apache.accumulo.fate.zookeeper.IZooReaderWriter;
import org.apache.accumulo.fate.zookeeper.ZooUtil.NodeExistsPolicy;
import org.apache.accumulo.fate.zookeeper.ZooUtil.NodeMissingPolicy;
+import org.apache.accumulo.server.ServerContext;
import org.apache.accumulo.server.zookeeper.ZooCache;
import org.apache.accumulo.server.zookeeper.ZooReaderWriter;
import org.apache.zookeeper.KeeperException;
@@ -43,6 +44,7 @@ public final class ZKAuthenticator implements Authenticator {
private static final Logger log = LoggerFactory.getLogger(ZKAuthenticator.class);
private static Authenticator zkAuthenticatorInstance = null;
+ private ServerContext context;
private String ZKUserPath;
private final ZooCache zooCache;
@@ -57,8 +59,9 @@ public final class ZKAuthenticator implements Authenticator {
}
@Override
- public void initialize(String instanceId, boolean initialize) {
- ZKUserPath = Constants.ZROOT + "/" + instanceId + "/users";
+ public void initialize(ServerContext context, boolean initialize) {
+ this.context = context;
+ ZKUserPath = Constants.ZROOT + "/" + context.getInstanceID() + "/users";
}
@Override
diff --git a/server/base/src/main/java/org/apache/accumulo/server/util/Admin.java b/server/base/src/main/java/org/apache/accumulo/server/util/Admin.java
index 48bc90a..24cf730 100644
--- a/server/base/src/main/java/org/apache/accumulo/server/util/Admin.java
+++ b/server/base/src/main/java/org/apache/accumulo/server/util/Admin.java
@@ -45,7 +45,6 @@ import org.apache.accumulo.core.client.impl.MasterClient;
import org.apache.accumulo.core.conf.AccumuloConfiguration;
import org.apache.accumulo.core.conf.DefaultConfiguration;
import org.apache.accumulo.core.conf.Property;
-import org.apache.accumulo.core.conf.SiteConfiguration;
import org.apache.accumulo.core.metadata.MetadataTable;
import org.apache.accumulo.core.security.Authorizations;
import org.apache.accumulo.core.security.NamespacePermission;
@@ -207,14 +206,15 @@ public class Admin implements KeywordExecutable {
return;
}
- AccumuloConfiguration siteConf = SiteConfiguration.getInstance();
+ ServerContext context = opts.getServerContext();
+
+ AccumuloConfiguration conf = context.getConfiguration();
// Login as the server on secure HDFS
- if (siteConf.getBoolean(Property.INSTANCE_RPC_SASL_ENABLED)) {
- SecurityUtil.serverLogin(siteConf);
+ if (conf.getBoolean(Property.INSTANCE_RPC_SASL_ENABLED)) {
+ SecurityUtil.serverLogin(conf);
}
try {
- ServerContext context = opts.getServerContext();
int rc = 0;
diff --git a/server/base/src/main/java/org/apache/accumulo/server/util/CleanZookeeper.java b/server/base/src/main/java/org/apache/accumulo/server/util/CleanZookeeper.java
index d241d57..6ecaf15 100644
--- a/server/base/src/main/java/org/apache/accumulo/server/util/CleanZookeeper.java
+++ b/server/base/src/main/java/org/apache/accumulo/server/util/CleanZookeeper.java
@@ -20,6 +20,7 @@ import static java.nio.charset.StandardCharsets.UTF_8;
import org.apache.accumulo.core.Constants;
import org.apache.accumulo.core.cli.Help;
+import org.apache.accumulo.core.conf.SiteConfiguration;
import org.apache.accumulo.fate.zookeeper.IZooReaderWriter;
import org.apache.accumulo.fate.zookeeper.ZooUtil.NodeMissingPolicy;
import org.apache.accumulo.server.ServerContext;
@@ -56,7 +57,7 @@ public class CleanZookeeper {
zk.getZooKeeper().addAuthInfo("digest", ("accumulo:" + opts.auth).getBytes(UTF_8));
}
- ServerContext context = new ServerContext();
+ ServerContext context = new ServerContext(SiteConfiguration.create());
try {
for (String child : zk.getChildren(root)) {
diff --git a/server/base/src/main/java/org/apache/accumulo/server/util/Info.java b/server/base/src/main/java/org/apache/accumulo/server/util/Info.java
index 4bc8f85..acbcd17 100644
--- a/server/base/src/main/java/org/apache/accumulo/server/util/Info.java
+++ b/server/base/src/main/java/org/apache/accumulo/server/util/Info.java
@@ -16,6 +16,7 @@
*/
package org.apache.accumulo.server.util;
+import org.apache.accumulo.core.conf.SiteConfiguration;
import org.apache.accumulo.core.util.MonitorUtil;
import org.apache.accumulo.server.ServerContext;
import org.apache.accumulo.start.spi.KeywordExecutable;
@@ -43,7 +44,7 @@ public class Info implements KeywordExecutable {
@Override
public void execute(final String[] args) throws KeeperException, InterruptedException {
- ServerContext context = new ServerContext();
+ ServerContext context = new ServerContext(SiteConfiguration.create());
System.out.println("monitor: " + MonitorUtil.getLocation(context));
System.out.println("masters: " + context.getMasterLocations());
System.out.println("zookeepers: " + context.getZooKeepers());
diff --git a/server/base/src/main/java/org/apache/accumulo/server/util/ListInstances.java b/server/base/src/main/java/org/apache/accumulo/server/util/ListInstances.java
index cefc7da..bd0036e 100644
--- a/server/base/src/main/java/org/apache/accumulo/server/util/ListInstances.java
+++ b/server/base/src/main/java/org/apache/accumulo/server/util/ListInstances.java
@@ -65,7 +65,8 @@ public class ListInstances {
opts.parseArgs(ListInstances.class.getName(), args);
if (opts.keepers == null) {
- opts.keepers = SiteConfiguration.getInstance().get(Property.INSTANCE_ZK_HOST);
+ SiteConfiguration siteConfig = SiteConfiguration.create();
+ opts.keepers = siteConfig.get(Property.INSTANCE_ZK_HOST);
}
String keepers = opts.keepers;
diff --git a/server/base/src/main/java/org/apache/accumulo/server/util/ListVolumesUsed.java b/server/base/src/main/java/org/apache/accumulo/server/util/ListVolumesUsed.java
index 219ddd4..d96273d 100644
--- a/server/base/src/main/java/org/apache/accumulo/server/util/ListVolumesUsed.java
+++ b/server/base/src/main/java/org/apache/accumulo/server/util/ListVolumesUsed.java
@@ -21,6 +21,7 @@ import java.util.Map.Entry;
import java.util.TreeSet;
import org.apache.accumulo.core.client.Scanner;
+import org.apache.accumulo.core.conf.SiteConfiguration;
import org.apache.accumulo.core.data.Key;
import org.apache.accumulo.core.data.Value;
import org.apache.accumulo.core.metadata.MetadataTable;
@@ -37,7 +38,7 @@ import org.apache.hadoop.fs.Path;
public class ListVolumesUsed {
public static void main(String[] args) throws Exception {
- listVolumes(new ServerContext());
+ listVolumes(new ServerContext(SiteConfiguration.create()));
}
private static String getTableURI(String rootTabletDir) {
diff --git a/server/base/src/main/java/org/apache/accumulo/server/util/LoginProperties.java b/server/base/src/main/java/org/apache/accumulo/server/util/LoginProperties.java
index ed415e3..608e8c1 100644
--- a/server/base/src/main/java/org/apache/accumulo/server/util/LoginProperties.java
+++ b/server/base/src/main/java/org/apache/accumulo/server/util/LoginProperties.java
@@ -24,6 +24,7 @@ import org.apache.accumulo.core.client.security.tokens.AuthenticationToken;
import org.apache.accumulo.core.client.security.tokens.AuthenticationToken.TokenProperty;
import org.apache.accumulo.core.conf.AccumuloConfiguration;
import org.apache.accumulo.core.conf.Property;
+import org.apache.accumulo.core.conf.SiteConfiguration;
import org.apache.accumulo.server.ServerContext;
import org.apache.accumulo.server.security.handler.Authenticator;
import org.apache.accumulo.start.classloader.vfs.AccumuloVFSClassLoader;
@@ -46,7 +47,7 @@ public class LoginProperties implements KeywordExecutable {
@Override
public void execute(String[] args) throws Exception {
- ServerContext context = new ServerContext();
+ ServerContext context = new ServerContext(SiteConfiguration.create());
AccumuloConfiguration config = context.getServerConfFactory().getSystemConfiguration();
Authenticator authenticator = AccumuloVFSClassLoader.getClassLoader()
.loadClass(config.get(Property.INSTANCE_SECURITY_AUTHENTICATOR))
diff --git a/server/base/src/main/java/org/apache/accumulo/server/util/TabletServerLocks.java b/server/base/src/main/java/org/apache/accumulo/server/util/TabletServerLocks.java
index 3228abf..d471ce7 100644
--- a/server/base/src/main/java/org/apache/accumulo/server/util/TabletServerLocks.java
+++ b/server/base/src/main/java/org/apache/accumulo/server/util/TabletServerLocks.java
@@ -22,6 +22,7 @@ import java.util.List;
import org.apache.accumulo.core.Constants;
import org.apache.accumulo.core.cli.Help;
+import org.apache.accumulo.core.conf.SiteConfiguration;
import org.apache.accumulo.fate.zookeeper.IZooReaderWriter;
import org.apache.accumulo.fate.zookeeper.ZooCache;
import org.apache.accumulo.server.ServerContext;
@@ -41,7 +42,7 @@ public class TabletServerLocks {
public static void main(String[] args) throws Exception {
- ServerContext context = new ServerContext();
+ ServerContext context = new ServerContext(SiteConfiguration.create());
String tserverPath = context.getZooKeeperRoot() + Constants.ZTSERVERS;
Opts opts = new Opts();
opts.parseArgs(TabletServerLocks.class.getName(), args);
diff --git a/server/base/src/main/java/org/apache/accumulo/server/util/ZooKeeperMain.java b/server/base/src/main/java/org/apache/accumulo/server/util/ZooKeeperMain.java
index 6ac817f..e0ed7b4 100644
--- a/server/base/src/main/java/org/apache/accumulo/server/util/ZooKeeperMain.java
+++ b/server/base/src/main/java/org/apache/accumulo/server/util/ZooKeeperMain.java
@@ -17,6 +17,7 @@
package org.apache.accumulo.server.util;
import org.apache.accumulo.core.cli.Help;
+import org.apache.accumulo.core.conf.SiteConfiguration;
import org.apache.accumulo.server.ServerConstants;
import org.apache.accumulo.server.ServerContext;
import org.apache.accumulo.server.fs.VolumeManagerImpl;
@@ -68,7 +69,7 @@ public class ZooKeeperMain implements KeywordExecutable {
String baseDir = ServerConstants.getBaseUris()[0];
System.out.println("Using " + fs.makeQualified(new Path(baseDir + "/instance_id"))
+ " to lookup accumulo instance");
- ServerContext context = new ServerContext();
+ ServerContext context = new ServerContext(SiteConfiguration.create());
if (opts.servers == null) {
opts.servers = context.getZooKeepers();
}
diff --git a/server/base/src/main/java/org/apache/accumulo/server/util/ZooZap.java b/server/base/src/main/java/org/apache/accumulo/server/util/ZooZap.java
index f1a6bce..7ba2a5d 100644
--- a/server/base/src/main/java/org/apache/accumulo/server/util/ZooZap.java
+++ b/server/base/src/main/java/org/apache/accumulo/server/util/ZooZap.java
@@ -20,7 +20,6 @@ import java.util.List;
import org.apache.accumulo.core.Constants;
import org.apache.accumulo.core.cli.Help;
-import org.apache.accumulo.core.conf.AccumuloConfiguration;
import org.apache.accumulo.core.conf.Property;
import org.apache.accumulo.core.conf.SiteConfiguration;
import org.apache.accumulo.core.volume.VolumeConfiguration;
@@ -66,7 +65,7 @@ public class ZooZap {
return;
}
- AccumuloConfiguration siteConf = SiteConfiguration.getInstance();
+ SiteConfiguration siteConf = SiteConfiguration.create();
// Login as the server on secure HDFS
if (siteConf.getBoolean(Property.INSTANCE_RPC_SASL_ENABLED)) {
SecurityUtil.serverLogin(siteConf);
diff --git a/server/base/src/test/java/org/apache/accumulo/server/ServerOptsTest.java b/server/base/src/test/java/org/apache/accumulo/server/ServerOptsTest.java
index 049c409..b1818a4 100644
--- a/server/base/src/test/java/org/apache/accumulo/server/ServerOptsTest.java
+++ b/server/base/src/test/java/org/apache/accumulo/server/ServerOptsTest.java
@@ -18,8 +18,9 @@ package org.apache.accumulo.server;
import static org.junit.Assert.assertEquals;
+import org.apache.accumulo.core.conf.AccumuloConfiguration;
+import org.apache.accumulo.core.conf.DefaultConfiguration;
import org.apache.accumulo.core.conf.Property;
-import org.apache.accumulo.core.conf.SiteConfiguration;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
@@ -46,10 +47,10 @@ public class ServerOptsTest {
@Test
public void testOverrideConfig() {
- SiteConfiguration siteConf = SiteConfiguration.getInstance();
- Assert.assertEquals("localhost:2181", siteConf.get(Property.INSTANCE_ZK_HOST));
+ AccumuloConfiguration defaults = DefaultConfiguration.getInstance();
+ Assert.assertEquals("localhost:2181", defaults.get(Property.INSTANCE_ZK_HOST));
opts.parseArgs(ServerOptsTest.class.getName(),
new String[] {"-o", "instance.zookeeper.host=test:123"});
- Assert.assertEquals("test:123", siteConf.get(Property.INSTANCE_ZK_HOST));
+ Assert.assertEquals("test:123", opts.getSiteConfiguration().get(Property.INSTANCE_ZK_HOST));
}
}
diff --git a/server/base/src/test/java/org/apache/accumulo/server/conf/ServerConfigurationFactoryTest.java b/server/base/src/test/java/org/apache/accumulo/server/conf/ServerConfigurationFactoryTest.java
index 0d198c4..f73d95b 100644
--- a/server/base/src/test/java/org/apache/accumulo/server/conf/ServerConfigurationFactoryTest.java
+++ b/server/base/src/test/java/org/apache/accumulo/server/conf/ServerConfigurationFactoryTest.java
@@ -50,6 +50,7 @@ public class ServerConfigurationFactoryTest {
// use the same mock ZooCacheFactory and ZooCache for all tests
private static ZooCacheFactory zcf;
private static ZooCache zc;
+ private static SiteConfiguration siteConfig = SiteConfiguration.create();
@BeforeClass
public static void setUpClass() throws Exception {
@@ -92,7 +93,7 @@ public class ServerConfigurationFactoryTest {
private void ready() {
replay(context);
- scf = new ServerConfigurationFactory(context);
+ scf = new ServerConfigurationFactory(context, siteConfig);
scf.setZooCacheFactory(zcf);
}
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 ca75cf6..d8ee0b1 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
@@ -47,11 +47,15 @@ public class InitializeTest {
private IZooReaderWriter zooOrig;
private IZooReaderWriter zoo;
+ @SuppressWarnings("deprecation")
@Before
public void setUp() throws Exception {
conf = createMock(Configuration.class);
fs = createMock(VolumeManager.class);
sconf = createMock(SiteConfiguration.class);
+ expect(sconf.get(Property.INSTANCE_VOLUMES)).andReturn("").anyTimes();
+ expect(sconf.get(Property.INSTANCE_DFS_DIR)).andReturn("/bar").anyTimes();
+ expect(sconf.get(Property.INSTANCE_ZK_HOST)).andReturn("zk1").anyTimes();
zoo = createMock(IZooReaderWriter.class);
zooOrig = Initialize.getZooReaderWriter();
Initialize.setZooReaderWriter(zoo);
@@ -62,19 +66,23 @@ public class InitializeTest {
Initialize.setZooReaderWriter(zooOrig);
}
+ @SuppressWarnings("deprecation")
@Test
public void testIsInitialized_HasInstanceId() throws Exception {
+ expect(sconf.get(Property.INSTANCE_DFS_URI)).andReturn("hdfs://foo");
expect(fs.exists(anyObject(Path.class))).andReturn(true);
- replay(fs);
- assertTrue(Initialize.isInitialized(fs));
+ replay(fs, sconf);
+ assertTrue(Initialize.isInitialized(fs, sconf));
}
+ @SuppressWarnings("deprecation")
@Test
public void testIsInitialized_HasDataVersion() throws Exception {
+ expect(sconf.get(Property.INSTANCE_DFS_URI)).andReturn("hdfs://foo");
expect(fs.exists(anyObject(Path.class))).andReturn(false);
expect(fs.exists(anyObject(Path.class))).andReturn(true);
- replay(fs);
- assertTrue(Initialize.isInitialized(fs));
+ replay(fs, sconf);
+ assertTrue(Initialize.isInitialized(fs, sconf));
}
@SuppressWarnings("deprecation")
@@ -82,7 +90,6 @@ public class InitializeTest {
public void testCheckInit_NoZK() throws Exception {
expect(sconf.get(Property.INSTANCE_DFS_URI)).andReturn("hdfs://foo");
expectLastCall().anyTimes();
- expect(sconf.get(Property.INSTANCE_ZK_HOST)).andReturn("zk1");
replay(sconf);
expect(zoo.exists("/")).andReturn(false);
replay(zoo);
@@ -93,11 +100,7 @@ public class InitializeTest {
@SuppressWarnings("deprecation")
@Test
public void testCheckInit_AlreadyInit() throws Exception {
- expect(sconf.get(Property.INSTANCE_DFS_URI)).andReturn("hdfs://foo");
- expectLastCall().anyTimes();
- expect(sconf.get(Property.INSTANCE_DFS_DIR)).andReturn("/bar");
- expect(sconf.get(Property.INSTANCE_VOLUMES)).andReturn("");
- expect(sconf.get(Property.INSTANCE_ZK_HOST)).andReturn("zk1");
+ expect(sconf.get(Property.INSTANCE_DFS_URI)).andReturn("hdfs://foo").anyTimes();
expect(sconf.get(Property.INSTANCE_SECRET))
.andReturn(Property.INSTANCE_SECRET.getDefaultValue());
replay(sconf);
@@ -114,10 +117,8 @@ public class InitializeTest {
@Ignore
@Test
public void testCheckInit_AlreadyInit_DefaultUri() throws Exception {
- expect(sconf.get(Property.INSTANCE_DFS_URI)).andReturn("");
- expectLastCall().anyTimes();
+ expect(sconf.get(Property.INSTANCE_DFS_URI)).andReturn("").anyTimes();
expect(sconf.get(Property.INSTANCE_DFS_DIR)).andReturn("/bar");
- expect(sconf.get(Property.INSTANCE_ZK_HOST)).andReturn("zk1");
expect(sconf.get(Property.INSTANCE_SECRET))
.andReturn(Property.INSTANCE_SECRET.getDefaultValue());
replay(sconf);
@@ -135,7 +136,6 @@ public class InitializeTest {
public void testCheckInit_FSException() throws Exception {
expect(sconf.get(Property.INSTANCE_DFS_URI)).andReturn("hdfs://foo");
expectLastCall().anyTimes();
- expect(sconf.get(Property.INSTANCE_ZK_HOST)).andReturn("zk1");
expect(sconf.get(Property.INSTANCE_SECRET))
.andReturn(Property.INSTANCE_SECRET.getDefaultValue());
replay(sconf);
@@ -150,11 +150,9 @@ public class InitializeTest {
@SuppressWarnings("deprecation")
@Test
public void testCheckInit_OK() throws Exception {
- expect(sconf.get(Property.INSTANCE_DFS_URI)).andReturn("hdfs://foo");
- expectLastCall().anyTimes();
- expect(sconf.get(Property.INSTANCE_ZK_HOST)).andReturn("zk1");
+ expect(sconf.get(Property.INSTANCE_DFS_URI)).andReturn("hdfs://foo").anyTimes();
expect(sconf.get(Property.INSTANCE_SECRET))
- .andReturn(Property.INSTANCE_SECRET.getDefaultValue());
+ .andReturn(Property.INSTANCE_SECRET.getDefaultValue()).anyTimes();
replay(sconf);
expect(zoo.exists("/")).andReturn(true);
replay(zoo);
diff --git a/server/base/src/test/java/org/apache/accumulo/server/master/balancer/BaseHostRegexTableLoadBalancerTest.java b/server/base/src/test/java/org/apache/accumulo/server/master/balancer/BaseHostRegexTableLoadBalancerTest.java
index aef9964..7c4bdfd 100644
--- a/server/base/src/test/java/org/apache/accumulo/server/master/balancer/BaseHostRegexTableLoadBalancerTest.java
+++ b/server/base/src/test/java/org/apache/accumulo/server/master/balancer/BaseHostRegexTableLoadBalancerTest.java
@@ -42,6 +42,7 @@ import org.apache.accumulo.core.conf.AccumuloConfiguration;
import org.apache.accumulo.core.conf.ConfigurationCopy;
import org.apache.accumulo.core.conf.DefaultConfiguration;
import org.apache.accumulo.core.conf.Property;
+import org.apache.accumulo.core.conf.SiteConfiguration;
import org.apache.accumulo.core.data.impl.KeyExtent;
import org.apache.accumulo.core.master.thrift.TableInfo;
import org.apache.accumulo.core.master.thrift.TabletServerStatus;
@@ -90,12 +91,14 @@ public abstract class BaseHostRegexTableLoadBalancerTest extends HostRegexTableL
TestDefaultBalancer.class.getName());
}
+ private static SiteConfiguration siteConfg = SiteConfiguration.create();
+
protected static class TestServerConfigurationFactory extends ServerConfigurationFactory {
final ServerContext context;
public TestServerConfigurationFactory(ServerContext context) {
- super(context);
+ super(context, siteConfg);
this.context = context;
}
diff --git a/server/base/src/test/java/org/apache/accumulo/server/master/balancer/TableLoadBalancerTest.java b/server/base/src/test/java/org/apache/accumulo/server/master/balancer/TableLoadBalancerTest.java
index 0ffb552..fb46537 100644
--- a/server/base/src/test/java/org/apache/accumulo/server/master/balancer/TableLoadBalancerTest.java
+++ b/server/base/src/test/java/org/apache/accumulo/server/master/balancer/TableLoadBalancerTest.java
@@ -34,6 +34,7 @@ import org.apache.accumulo.core.client.impl.Table;
import org.apache.accumulo.core.client.impl.thrift.ThriftSecurityException;
import org.apache.accumulo.core.conf.DefaultConfiguration;
import org.apache.accumulo.core.conf.Property;
+import org.apache.accumulo.core.conf.SiteConfiguration;
import org.apache.accumulo.core.data.impl.KeyExtent;
import org.apache.accumulo.core.master.thrift.TableInfo;
import org.apache.accumulo.core.master.thrift.TabletServerStatus;
@@ -153,7 +154,8 @@ public class TableLoadBalancerTest {
public void test() throws Exception {
final ServerContext context = createMockContext();
replay(context);
- ServerConfigurationFactory confFactory = new ServerConfigurationFactory(context) {
+ ServerConfigurationFactory confFactory = new ServerConfigurationFactory(context,
+ SiteConfiguration.create()) {
@Override
public TableConfiguration getTableConfiguration(Table.ID tableId) {
// create a dummy namespaceConfiguration to satisfy requireNonNull in TableConfiguration
diff --git a/server/base/src/test/java/org/apache/accumulo/server/security/SystemCredentialsTest.java b/server/base/src/test/java/org/apache/accumulo/server/security/SystemCredentialsTest.java
index c1e7434..503af65 100644
--- a/server/base/src/test/java/org/apache/accumulo/server/security/SystemCredentialsTest.java
+++ b/server/base/src/test/java/org/apache/accumulo/server/security/SystemCredentialsTest.java
@@ -25,6 +25,7 @@ import java.util.UUID;
import org.apache.accumulo.core.client.impl.ConnectorImpl;
import org.apache.accumulo.core.client.impl.Credentials;
+import org.apache.accumulo.core.conf.SiteConfiguration;
import org.apache.accumulo.server.ServerConstants;
import org.apache.accumulo.server.security.SystemCredentials.SystemToken;
import org.junit.BeforeClass;
@@ -37,6 +38,7 @@ public class SystemCredentialsTest {
@Rule
public TestName test = new TestName();
+ private static SiteConfiguration siteConfig = SiteConfiguration.create();
private String instanceId = UUID.nameUUIDFromBytes(new byte[] {1, 2, 3, 4, 5, 6, 7, 8, 9, 0})
.toString();
@@ -71,13 +73,14 @@ public class SystemCredentialsTest {
public void testSystemToken() {
assertEquals("org.apache.accumulo.server.security.SystemCredentials$SystemToken",
SystemToken.class.getName());
- assertEquals(SystemCredentials.get(instanceId).getToken().getClass(), SystemToken.class);
+ assertEquals(SystemCredentials.get(instanceId, siteConfig).getToken().getClass(),
+ SystemToken.class);
}
@Test
public void testSystemCredentials() {
- Credentials a = SystemCredentials.get(instanceId);
- Credentials b = SystemCredentials.get(instanceId);
+ Credentials a = SystemCredentials.get(instanceId, siteConfig);
+ Credentials b = SystemCredentials.get(instanceId, siteConfig);
assertEquals(a, b);
}
}
diff --git a/server/base/src/test/java/org/apache/accumulo/server/util/TServerUtilsTest.java b/server/base/src/test/java/org/apache/accumulo/server/util/TServerUtilsTest.java
index 4806602..2516b37 100644
--- a/server/base/src/test/java/org/apache/accumulo/server/util/TServerUtilsTest.java
+++ b/server/base/src/test/java/org/apache/accumulo/server/util/TServerUtilsTest.java
@@ -38,6 +38,7 @@ import org.apache.accumulo.core.conf.AccumuloConfiguration;
import org.apache.accumulo.core.conf.ConfigurationCopy;
import org.apache.accumulo.core.conf.DefaultConfiguration;
import org.apache.accumulo.core.conf.Property;
+import org.apache.accumulo.core.conf.SiteConfiguration;
import org.apache.accumulo.core.trace.wrappers.TraceWrap;
import org.apache.accumulo.server.ServerContext;
import org.apache.accumulo.server.client.ClientServiceHandler;
@@ -58,7 +59,7 @@ public class TServerUtilsTest {
private ConfigurationCopy conf = null;
public TestServerConfigurationFactory(ServerContext context) {
- super(context);
+ super(context, SiteConfiguration.create());
conf = new ConfigurationCopy(DefaultConfiguration.getInstance());
}
@@ -120,6 +121,9 @@ public class TServerUtilsTest {
// not dying is enough
}
+ private static AccumuloConfiguration config = new ConfigurationCopy(
+ DefaultConfiguration.getInstance());
+
private static ServerContext createMockContext() {
ServerContext context = EasyMock.createMock(ServerContext.class);
expect(context.getProperties()).andReturn(new Properties()).anyTimes();
@@ -127,6 +131,7 @@ public class TServerUtilsTest {
expect(context.getInstanceName()).andReturn("instance").anyTimes();
expect(context.getZooKeepersSessionTimeOut()).andReturn(1).anyTimes();
expect(context.getInstanceID()).andReturn("11111").anyTimes();
+ expect(context.getConfiguration()).andReturn(config).anyTimes();
return context;
}
@@ -289,16 +294,14 @@ public class TServerUtilsTest {
}
private ServerAddress startServer() throws Exception {
- ServerContext context = createMockContext();
- expect(context.getServerConfFactory()).andReturn(factory).anyTimes();
ServerContext ctx = createMock(ServerContext.class);
expect(ctx.getInstanceID()).andReturn("instance").anyTimes();
- expect(ctx.getConfiguration()).andReturn(factory.getSystemConfiguration());
+ expect(ctx.getConfiguration()).andReturn(factory.getSystemConfiguration()).anyTimes();
expect(ctx.getThriftServerType()).andReturn(ThriftServerType.THREADPOOL);
expect(ctx.getServerSslParams()).andReturn(null).anyTimes();
expect(ctx.getSaslParams()).andReturn(null).anyTimes();
expect(ctx.getClientTimeoutInMillis()).andReturn((long) 1000).anyTimes();
- replay(ctx, context);
+ replay(ctx);
ClientServiceHandler clientHandler = new ClientServiceHandler(ctx, null, null);
Iface rpcProxy = TraceWrap.service(clientHandler);
Processor<Iface> processor = new Processor<>(rpcProxy);
diff --git a/server/gc/src/main/java/org/apache/accumulo/gc/SimpleGarbageCollector.java b/server/gc/src/main/java/org/apache/accumulo/gc/SimpleGarbageCollector.java
index c897de4..9908fe9 100644
--- a/server/gc/src/main/java/org/apache/accumulo/gc/SimpleGarbageCollector.java
+++ b/server/gc/src/main/java/org/apache/accumulo/gc/SimpleGarbageCollector.java
@@ -141,7 +141,7 @@ public class SimpleGarbageCollector implements Iface {
final String app = "gc";
Opts opts = new Opts();
opts.parseArgs(app, args);
- ServerContext context = new ServerContext();
+ ServerContext context = new ServerContext(opts.getSiteConfiguration());
context.setupServer(app, SimpleGarbageCollector.class.getName(), opts.getAddress());
try {
SimpleGarbageCollector gc = new SimpleGarbageCollector(opts, context);
diff --git a/server/gc/src/test/java/org/apache/accumulo/gc/SimpleGarbageCollectorTest.java b/server/gc/src/test/java/org/apache/accumulo/gc/SimpleGarbageCollectorTest.java
index 15c8c9d..663333c 100644
--- a/server/gc/src/test/java/org/apache/accumulo/gc/SimpleGarbageCollectorTest.java
+++ b/server/gc/src/test/java/org/apache/accumulo/gc/SimpleGarbageCollectorTest.java
@@ -35,6 +35,7 @@ import java.util.Map;
import org.apache.accumulo.core.client.impl.Credentials;
import org.apache.accumulo.core.conf.ConfigurationCopy;
import org.apache.accumulo.core.conf.Property;
+import org.apache.accumulo.core.conf.SiteConfiguration;
import org.apache.accumulo.core.security.thrift.TCredentials;
import org.apache.accumulo.core.trace.thrift.TInfo;
import org.apache.accumulo.gc.SimpleGarbageCollector.Opts;
@@ -52,6 +53,7 @@ public class SimpleGarbageCollectorTest {
private Opts opts;
private SimpleGarbageCollector gc;
private ConfigurationCopy systemConfig;
+ private static SiteConfiguration siteConfig = SiteConfiguration.create();
@Before
public void setUp() {
@@ -66,7 +68,7 @@ public class SimpleGarbageCollectorTest {
expect(context.getConfiguration()).andReturn(systemConfig).anyTimes();
expect(context.getVolumeManager()).andReturn(volMgr).anyTimes();
- credentials = SystemCredentials.get("mock");
+ credentials = SystemCredentials.get("mock", siteConfig);
expect(context.getPrincipal()).andReturn(credentials.getPrincipal()).anyTimes();
expect(context.getAuthenticationToken()).andReturn(credentials.getToken()).anyTimes();
expect(context.getCredentials()).andReturn(credentials).anyTimes();
diff --git a/server/gc/src/test/resources/accumulo-site.xml b/server/gc/src/test/resources/accumulo-site.xml
new file mode 100644
index 0000000..9618efb
--- /dev/null
+++ b/server/gc/src/test/resources/accumulo-site.xml
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<configuration>
+
+ <!-- This file needs to exists for unit tests -->
+
+</configuration>
diff --git a/server/master/src/main/java/org/apache/accumulo/master/Master.java b/server/master/src/main/java/org/apache/accumulo/master/Master.java
index 6a2a6f8..e382e3f 100644
--- a/server/master/src/main/java/org/apache/accumulo/master/Master.java
+++ b/server/master/src/main/java/org/apache/accumulo/master/Master.java
@@ -1552,7 +1552,7 @@ public class Master
final String app = "master";
ServerOpts opts = new ServerOpts();
opts.parseArgs(app, args);
- ServerContext context = new ServerContext();
+ ServerContext context = new ServerContext(opts.getSiteConfiguration());
context.setupServer(app, Master.class.getName(), opts.getAddress());
try {
Master master = new Master(context);
diff --git a/server/master/src/main/java/org/apache/accumulo/master/state/SetGoalState.java b/server/master/src/main/java/org/apache/accumulo/master/state/SetGoalState.java
index 57a235a..6d3227b 100644
--- a/server/master/src/main/java/org/apache/accumulo/master/state/SetGoalState.java
+++ b/server/master/src/main/java/org/apache/accumulo/master/state/SetGoalState.java
@@ -38,9 +38,9 @@ public class SetGoalState {
"Usage: accumulo " + SetGoalState.class.getName() + " [NORMAL|SAFE_MODE|CLEAN_STOP]");
System.exit(-1);
}
- SecurityUtil.serverLogin(SiteConfiguration.getInstance());
- ServerContext context = new ServerContext();
+ ServerContext context = new ServerContext(SiteConfiguration.create());
+ SecurityUtil.serverLogin(context.getConfiguration());
Accumulo.waitForZookeeperAndHdfs(context.getVolumeManager());
ZooReaderWriter.getInstance().putPersistentData(
context.getZooKeeperRoot() + Constants.ZMASTER_GOAL_STATE, args[0].getBytes(UTF_8),
diff --git a/server/master/src/main/java/org/apache/accumulo/master/util/FateAdmin.java b/server/master/src/main/java/org/apache/accumulo/master/util/FateAdmin.java
index bc21f8b..ebb46ed 100644
--- a/server/master/src/main/java/org/apache/accumulo/master/util/FateAdmin.java
+++ b/server/master/src/main/java/org/apache/accumulo/master/util/FateAdmin.java
@@ -23,6 +23,7 @@ import java.util.Map.Entry;
import org.apache.accumulo.core.Constants;
import org.apache.accumulo.core.cli.Help;
+import org.apache.accumulo.core.conf.SiteConfiguration;
import org.apache.accumulo.fate.AdminUtil;
import org.apache.accumulo.fate.ReadOnlyStore;
import org.apache.accumulo.fate.ZooStore;
@@ -77,7 +78,7 @@ public class FateAdmin {
AdminUtil<Master> admin = new AdminUtil<>();
- ServerContext context = new ServerContext();
+ ServerContext context = new ServerContext(SiteConfiguration.create());
final String zkRoot = context.getZooKeeperRoot();
String path = zkRoot + Constants.ZFATE;
String masterPath = zkRoot + Constants.ZMASTER_LOCK;
diff --git a/server/master/src/test/java/org/apache/accumulo/master/replication/MasterReplicationCoordinatorTest.java b/server/master/src/test/java/org/apache/accumulo/master/replication/MasterReplicationCoordinatorTest.java
index 24d527a..6516ec1 100644
--- a/server/master/src/test/java/org/apache/accumulo/master/replication/MasterReplicationCoordinatorTest.java
+++ b/server/master/src/test/java/org/apache/accumulo/master/replication/MasterReplicationCoordinatorTest.java
@@ -19,6 +19,8 @@ package org.apache.accumulo.master.replication;
import java.util.Collections;
import java.util.TreeSet;
+import org.apache.accumulo.core.conf.AccumuloConfiguration;
+import org.apache.accumulo.core.conf.DefaultConfiguration;
import org.apache.accumulo.core.util.HostAndPort;
import org.apache.accumulo.fate.zookeeper.ZooReader;
import org.apache.accumulo.master.Master;
@@ -30,11 +32,14 @@ import org.junit.Test;
public class MasterReplicationCoordinatorTest {
+ static AccumuloConfiguration config = DefaultConfiguration.getInstance();
+
@Test
public void randomServer() {
Master master = EasyMock.createMock(Master.class);
ZooReader reader = EasyMock.createMock(ZooReader.class);
ServerContext context = EasyMock.createMock(ServerContext.class);
+ EasyMock.expect(context.getConfiguration()).andReturn(config).anyTimes();
EasyMock.expect(master.getContext()).andReturn(context);
EasyMock.expect(master.getInstanceID()).andReturn("1234");
EasyMock.replay(master, reader);
@@ -49,6 +54,7 @@ public class MasterReplicationCoordinatorTest {
public void invalidOffset() {
Master master = EasyMock.createMock(Master.class);
ServerContext context = EasyMock.createMock(ServerContext.class);
+ EasyMock.expect(context.getConfiguration()).andReturn(config).anyTimes();
ZooReader reader = EasyMock.createMock(ZooReader.class);
EasyMock.expect(master.getContext()).andReturn(context);
EasyMock.expect(master.getInstanceID()).andReturn("1234");
@@ -65,7 +71,7 @@ public class MasterReplicationCoordinatorTest {
Master master = EasyMock.createMock(Master.class);
ZooReader reader = EasyMock.createMock(ZooReader.class);
ServerContext context = EasyMock.createMock(ServerContext.class);
-
+ EasyMock.expect(context.getConfiguration()).andReturn(config).anyTimes();
EasyMock.expect(context.getInstanceID()).andReturn("1234").anyTimes();
EasyMock.expect(master.getInstanceID()).andReturn("1234").anyTimes();
EasyMock.expect(master.getContext()).andReturn(context).anyTimes();
diff --git a/server/master/src/test/resources/accumulo-site.xml b/server/master/src/test/resources/accumulo-site.xml
new file mode 100644
index 0000000..9618efb
--- /dev/null
+++ b/server/master/src/test/resources/accumulo-site.xml
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<configuration>
+
+ <!-- This file needs to exists for unit tests -->
+
+</configuration>
diff --git a/server/monitor/src/main/java/org/apache/accumulo/monitor/Monitor.java b/server/monitor/src/main/java/org/apache/accumulo/monitor/Monitor.java
index 624a2d3..fcd819a 100644
--- a/server/monitor/src/main/java/org/apache/accumulo/monitor/Monitor.java
+++ b/server/monitor/src/main/java/org/apache/accumulo/monitor/Monitor.java
@@ -434,7 +434,7 @@ public class Monitor implements HighlyAvailableService {
final String app = "monitor";
ServerOpts opts = new ServerOpts();
opts.parseArgs(app, args);
- Monitor.context = new ServerContext();
+ Monitor.context = new ServerContext(opts.getSiteConfiguration());
context.setupServer(app, Monitor.class.getName(), opts.getAddress());
try {
config = context.getServerConfFactory();
@@ -505,7 +505,7 @@ public class Monitor implements HighlyAvailableService {
log.warn("Not starting log4j listener as we could not determine address to use");
}
- new Daemon(new LoggingRunnable(log, new ZooKeeperStatus()), "ZooKeeperStatus").start();
+ new Daemon(new LoggingRunnable(log, new ZooKeeperStatus(context)), "ZooKeeperStatus").start();
// need to regularly fetch data so plot data is updated
new Daemon(new LoggingRunnable(log, new Runnable() {
diff --git a/server/monitor/src/main/java/org/apache/accumulo/monitor/ZooKeeperStatus.java b/server/monitor/src/main/java/org/apache/accumulo/monitor/ZooKeeperStatus.java
index 1f5f0eb..25ae353 100644
--- a/server/monitor/src/main/java/org/apache/accumulo/monitor/ZooKeeperStatus.java
+++ b/server/monitor/src/main/java/org/apache/accumulo/monitor/ZooKeeperStatus.java
@@ -26,9 +26,9 @@ import java.util.TreeSet;
import java.util.concurrent.TimeUnit;
import org.apache.accumulo.core.conf.Property;
-import org.apache.accumulo.core.conf.SiteConfiguration;
import org.apache.accumulo.core.rpc.TTimeoutTransport;
import org.apache.accumulo.core.util.HostAndPort;
+import org.apache.accumulo.server.ServerContext;
import org.apache.thrift.transport.TTransport;
import org.apache.thrift.transport.TTransportException;
import org.slf4j.Logger;
@@ -38,8 +38,13 @@ public class ZooKeeperStatus implements Runnable {
private static final Logger log = LoggerFactory.getLogger(ZooKeeperStatus.class);
+ private ServerContext context;
private volatile boolean stop = false;
+ public ZooKeeperStatus(ServerContext context) {
+ this.context = context;
+ }
+
public static class ZooKeeperState implements Comparable<ZooKeeperState> {
public final String keeper;
public final String mode;
@@ -95,8 +100,7 @@ public class ZooKeeperStatus implements Runnable {
TreeSet<ZooKeeperState> update = new TreeSet<>();
- String zookeepers[] = SiteConfiguration.getInstance().get(Property.INSTANCE_ZK_HOST)
- .split(",");
+ String zookeepers[] = context.getConfiguration().get(Property.INSTANCE_ZK_HOST).split(",");
for (String keeper : zookeepers) {
int clients = 0;
String mode = "unknown";
diff --git a/server/monitor/src/main/java/org/apache/accumulo/monitor/util/AccumuloMonitorAppender.java b/server/monitor/src/main/java/org/apache/accumulo/monitor/util/AccumuloMonitorAppender.java
index 88432e5..d97d081 100644
--- a/server/monitor/src/main/java/org/apache/accumulo/monitor/util/AccumuloMonitorAppender.java
+++ b/server/monitor/src/main/java/org/apache/accumulo/monitor/util/AccumuloMonitorAppender.java
@@ -28,6 +28,7 @@ import java.util.function.Supplier;
import org.apache.accumulo.core.Constants;
import org.apache.accumulo.core.conf.Property;
+import org.apache.accumulo.core.conf.SiteConfiguration;
import org.apache.accumulo.core.util.HostAndPort;
import org.apache.accumulo.fate.zookeeper.ZooCache;
import org.apache.accumulo.fate.zookeeper.ZooCache.ZcStat;
@@ -144,7 +145,7 @@ public class AccumuloMonitorAppender extends AsyncAppender implements AutoClosea
public MonitorLocation get() {
// lazily set up path and zooCache (see comment in constructor)
if (this.context == null) {
- this.context = new ServerContext();
+ this.context = new ServerContext(SiteConfiguration.create());
this.path = context.getZooKeeperRoot() + Constants.ZMONITOR_LOG4J_ADDR;
this.zooCache = context.getZooCache();
}
diff --git a/server/tracer/src/main/java/org/apache/accumulo/tracer/TraceServer.java b/server/tracer/src/main/java/org/apache/accumulo/tracer/TraceServer.java
index 43a5e67..8e71408 100644
--- a/server/tracer/src/main/java/org/apache/accumulo/tracer/TraceServer.java
+++ b/server/tracer/src/main/java/org/apache/accumulo/tracer/TraceServer.java
@@ -45,7 +45,6 @@ import org.apache.accumulo.core.client.security.tokens.KerberosToken;
import org.apache.accumulo.core.client.security.tokens.PasswordToken;
import org.apache.accumulo.core.conf.AccumuloConfiguration;
import org.apache.accumulo.core.conf.Property;
-import org.apache.accumulo.core.conf.SiteConfiguration;
import org.apache.accumulo.core.data.Mutation;
import org.apache.accumulo.core.data.Value;
import org.apache.accumulo.core.iterators.user.AgeOffFilter;
@@ -402,8 +401,8 @@ public class TraceServer implements Watcher {
final String app = "tracer";
ServerOpts opts = new ServerOpts();
opts.parseArgs(app, args);
- loginTracer(SiteConfiguration.getInstance());
- ServerContext context = new ServerContext();
+ ServerContext context = new ServerContext(opts.getSiteConfiguration());
+ loginTracer(context.getConfiguration());
MetricsSystemHelper.configure(TraceServer.class.getSimpleName());
Accumulo.init(context.getVolumeManager(), context.getInstanceID(),
context.getServerConfFactory(), app);
diff --git a/server/tserver/src/main/java/org/apache/accumulo/tserver/TabletServer.java b/server/tserver/src/main/java/org/apache/accumulo/tserver/TabletServer.java
index 831d9a3..f211a6e 100644
--- a/server/tserver/src/main/java/org/apache/accumulo/tserver/TabletServer.java
+++ b/server/tserver/src/main/java/org/apache/accumulo/tserver/TabletServer.java
@@ -85,7 +85,6 @@ import org.apache.accumulo.core.client.impl.thrift.ThriftSecurityException;
import org.apache.accumulo.core.client.impl.thrift.ThriftTableOperationException;
import org.apache.accumulo.core.conf.AccumuloConfiguration;
import org.apache.accumulo.core.conf.Property;
-import org.apache.accumulo.core.conf.SiteConfiguration;
import org.apache.accumulo.core.data.Column;
import org.apache.accumulo.core.data.ConstraintViolationSummary;
import org.apache.accumulo.core.data.Key;
@@ -2783,7 +2782,7 @@ public class TabletServer implements Runnable {
// main loop listens for client requests
@Override
public void run() {
- SecurityUtil.serverLogin(SiteConfiguration.getInstance());
+ SecurityUtil.serverLogin(context.getConfiguration());
// To make things easier on users/devs, and to avoid creating an upgrade path to 1.7
// We can just make the zookeeper paths before we try to use.
@@ -3338,7 +3337,7 @@ public class TabletServer implements Runnable {
final String app = "tserver";
ServerOpts opts = new ServerOpts();
opts.parseArgs(app, args);
- ServerContext context = new ServerContext();
+ ServerContext context = new ServerContext(opts.getSiteConfiguration());
context.setupServer(app, TabletServer.class.getSimpleName(), opts.getAddress());
try {
final TabletServer server = new TabletServer(context);
diff --git a/server/tserver/src/main/java/org/apache/accumulo/tserver/logger/LogReader.java b/server/tserver/src/main/java/org/apache/accumulo/tserver/logger/LogReader.java
index e17c45d..6bb2ea9 100644
--- a/server/tserver/src/main/java/org/apache/accumulo/tserver/logger/LogReader.java
+++ b/server/tserver/src/main/java/org/apache/accumulo/tserver/logger/LogReader.java
@@ -75,6 +75,7 @@ public class LogReader {
public static void main(String[] args) throws IOException {
Opts opts = new Opts();
opts.parseArgs(LogReader.class.getName(), args);
+ SiteConfiguration siteConfig = SiteConfiguration.create();
VolumeManager fs = VolumeManagerImpl.get();
Matcher rowMatcher = null;
@@ -108,7 +109,7 @@ public class LogReader {
// read log entries from a simple hdfs file
DFSLoggerInputStreams streams;
try {
- streams = DfsLogger.readHeaderAndReturnStream(fsinput, SiteConfiguration.getInstance());
+ streams = DfsLogger.readHeaderAndReturnStream(fsinput, siteConfig);
} catch (LogHeaderIncompleteException e) {
log.warn("Could not read header for {} . Ignoring...", path);
continue;
diff --git a/server/tserver/src/test/java/org/apache/accumulo/tserver/LargestFirstMemoryManagerTest.java b/server/tserver/src/test/java/org/apache/accumulo/tserver/LargestFirstMemoryManagerTest.java
index dab49c4..2fc0777 100644
--- a/server/tserver/src/test/java/org/apache/accumulo/tserver/LargestFirstMemoryManagerTest.java
+++ b/server/tserver/src/test/java/org/apache/accumulo/tserver/LargestFirstMemoryManagerTest.java
@@ -25,9 +25,9 @@ import java.util.function.Function;
import org.apache.accumulo.core.client.impl.Namespace;
import org.apache.accumulo.core.client.impl.Table;
import org.apache.accumulo.core.conf.AccumuloConfiguration;
+import org.apache.accumulo.core.conf.ConfigurationCopy;
import org.apache.accumulo.core.conf.DefaultConfiguration;
import org.apache.accumulo.core.conf.Property;
-import org.apache.accumulo.core.conf.SiteConfiguration;
import org.apache.accumulo.core.data.impl.KeyExtent;
import org.apache.accumulo.server.ServerContext;
import org.apache.accumulo.server.conf.NamespaceConfiguration;
@@ -66,7 +66,7 @@ public class LargestFirstMemoryManagerTest {
@Override
public AccumuloConfiguration getSystemConfiguration() {
- SiteConfiguration conf = SiteConfiguration.getInstance();
+ ConfigurationCopy conf = new ConfigurationCopy(DefaultConfiguration.getInstance());
conf.set(Property.TSERV_MAXMEM, "1g");
return conf;
}
diff --git a/server/tserver/src/test/java/org/apache/accumulo/tserver/log/TestUpgradePathForWALogs.java b/server/tserver/src/test/java/org/apache/accumulo/tserver/log/TestUpgradePathForWALogs.java
index 5687b88..b516f93 100644
--- a/server/tserver/src/test/java/org/apache/accumulo/tserver/log/TestUpgradePathForWALogs.java
+++ b/server/tserver/src/test/java/org/apache/accumulo/tserver/log/TestUpgradePathForWALogs.java
@@ -25,7 +25,8 @@ import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
-import org.apache.accumulo.core.conf.SiteConfiguration;
+import org.apache.accumulo.core.conf.AccumuloConfiguration;
+import org.apache.accumulo.core.conf.DefaultConfiguration;
import org.apache.accumulo.server.fs.VolumeManager;
import org.apache.accumulo.server.fs.VolumeManagerImpl;
import org.apache.accumulo.server.log.SortedLogState;
@@ -46,6 +47,7 @@ public class TestUpgradePathForWALogs {
private static final String WALOG_FROM_16 = "/walog-from-16.walog";
private static File testDir;
+ AccumuloConfiguration config = DefaultConfiguration.getInstance();
VolumeManager fs;
@BeforeClass
@@ -88,7 +90,7 @@ public class TestUpgradePathForWALogs {
walogInHDFStream.close();
walogInHDFStream = null;
- LogSorter logSorter = new LogSorter(null, fs, SiteConfiguration.getInstance());
+ LogSorter logSorter = new LogSorter(null, fs, config);
LogSorter.LogProcessor logProcessor = logSorter.new LogProcessor();
logProcessor.sort(WALOG_FROM_15,
@@ -124,7 +126,7 @@ public class TestUpgradePathForWALogs {
walogInHDFStream.close();
walogInHDFStream = null;
- LogSorter logSorter = new LogSorter(null, fs, SiteConfiguration.getInstance());
+ LogSorter logSorter = new LogSorter(null, fs, config);
LogSorter.LogProcessor logProcessor = logSorter.new LogProcessor();
logProcessor.sort(walogToTest,
diff --git a/server/tserver/src/test/resources/accumulo-site.xml b/server/tserver/src/test/resources/accumulo-site.xml
new file mode 100644
index 0000000..9618efb
--- /dev/null
+++ b/server/tserver/src/test/resources/accumulo-site.xml
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<configuration>
+
+ <!-- This file needs to exists for unit tests -->
+
+</configuration>
diff --git a/shell/pom.xml b/shell/pom.xml
index c0e9ba1..bc4590f 100644
--- a/shell/pom.xml
+++ b/shell/pom.xml
@@ -73,10 +73,6 @@
</dependency>
<dependency>
<groupId>org.apache.accumulo</groupId>
- <artifactId>accumulo-server-base</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.accumulo</groupId>
<artifactId>accumulo-start</artifactId>
</dependency>
<dependency>
diff --git a/shell/src/main/java/org/apache/accumulo/shell/commands/FateCommand.java b/shell/src/main/java/org/apache/accumulo/shell/commands/FateCommand.java
index 276ea71..e401026 100644
--- a/shell/src/main/java/org/apache/accumulo/shell/commands/FateCommand.java
+++ b/shell/src/main/java/org/apache/accumulo/shell/commands/FateCommand.java
@@ -31,7 +31,6 @@ import java.util.Set;
import org.apache.accumulo.core.Constants;
import org.apache.accumulo.core.client.impl.ClientContext;
-import org.apache.accumulo.core.conf.AccumuloConfiguration;
import org.apache.accumulo.core.conf.Property;
import org.apache.accumulo.core.conf.SiteConfiguration;
import org.apache.accumulo.fate.AdminUtil;
@@ -114,6 +113,7 @@ public class FateCommand extends Command {
public int execute(final String fullCommand, final CommandLine cl, final Shell shellState)
throws ParseException, KeeperException, InterruptedException, IOException {
ClientContext context = shellState.getContext();
+ SiteConfiguration siteConfig = SiteConfiguration.getInstance();
String[] args = cl.getArgs();
if (args.length <= 0) {
throw new ParseException("Must provide a command to execute");
@@ -125,7 +125,8 @@ public class FateCommand extends Command {
String path = context.getZooKeeperRoot() + Constants.ZFATE;
String masterPath = context.getZooKeeperRoot() + Constants.ZMASTER_LOCK;
- IZooReaderWriter zk = getZooReaderWriter(context, cl.getOptionValue(secretOption.getOpt()));
+ IZooReaderWriter zk = getZooReaderWriter(context, siteConfig,
+ cl.getOptionValue(secretOption.getOpt()));
ZooStore<FateCommand> zs = new ZooStore<>(path, zk);
if ("fail".equals(cmd)) {
@@ -222,11 +223,11 @@ public class FateCommand extends Command {
return failedCommand ? 1 : 0;
}
- protected synchronized IZooReaderWriter getZooReaderWriter(ClientContext context, String secret) {
+ protected synchronized IZooReaderWriter getZooReaderWriter(ClientContext context,
+ SiteConfiguration siteConfig, String secret) {
if (secret == null) {
- AccumuloConfiguration conf = SiteConfiguration.getInstance();
- secret = conf.get(Property.INSTANCE_SECRET);
+ secret = siteConfig.get(Property.INSTANCE_SECRET);
}
return new ZooReaderWriter(context.getZooKeepers(), context.getZooKeepersSessionTimeOut(),
diff --git a/shell/src/main/java/org/apache/accumulo/shell/commands/ListBulkCommand.java b/shell/src/main/java/org/apache/accumulo/shell/commands/ListBulkCommand.java
index 2c38aa6..bb432e3 100644
--- a/shell/src/main/java/org/apache/accumulo/shell/commands/ListBulkCommand.java
+++ b/shell/src/main/java/org/apache/accumulo/shell/commands/ListBulkCommand.java
@@ -23,12 +23,12 @@ import java.util.Collections;
import java.util.List;
import java.util.concurrent.TimeUnit;
+import org.apache.accumulo.core.client.impl.ClientContext;
import org.apache.accumulo.core.client.impl.MasterClient;
import org.apache.accumulo.core.client.impl.thrift.ThriftNotActiveServiceException;
import org.apache.accumulo.core.master.thrift.MasterClientService;
import org.apache.accumulo.core.master.thrift.MasterMonitorInfo;
import org.apache.accumulo.core.trace.Tracer;
-import org.apache.accumulo.server.ServerContext;
import org.apache.accumulo.shell.Shell;
import org.apache.accumulo.shell.Shell.Command;
import org.apache.commons.cli.CommandLine;
@@ -52,7 +52,7 @@ public class ListBulkCommand extends Command {
MasterMonitorInfo stats;
MasterClientService.Iface client = null;
- ServerContext context = new ServerContext(shellState.getContext().getClientInfo());
+ ClientContext context = shellState.getContext();
while (true) {
try {
client = MasterClient.getConnectionWithRetry(context);
diff --git a/test/src/main/java/org/apache/accumulo/harness/AccumuloClusterHarness.java b/test/src/main/java/org/apache/accumulo/harness/AccumuloClusterHarness.java
index d44b372..2fc5b84 100644
--- a/test/src/main/java/org/apache/accumulo/harness/AccumuloClusterHarness.java
+++ b/test/src/main/java/org/apache/accumulo/harness/AccumuloClusterHarness.java
@@ -136,11 +136,11 @@ public abstract class AccumuloClusterHarness extends AccumuloITBase
(StandaloneAccumuloClusterConfiguration) clusterConf;
// @formatter:on
StandaloneAccumuloCluster standaloneCluster = new StandaloneAccumuloCluster(
- cluster.getClientInfo(), conf.getTmpDirectory(), conf.getUsers());
+ cluster.getClientInfo(), conf.getTmpDirectory(), conf.getUsers(),
+ conf.getServerAccumuloConfDir());
// If these are provided in the configuration, pass them into the cluster
standaloneCluster.setAccumuloHome(conf.getAccumuloHome());
standaloneCluster.setClientAccumuloConfDir(conf.getClientAccumuloConfDir());
- standaloneCluster.setServerAccumuloConfDir(conf.getServerAccumuloConfDir());
standaloneCluster.setHadoopConfDir(conf.getHadoopConfDir());
standaloneCluster.setServerCmdPrefix(conf.getServerCmdPrefix());
standaloneCluster.setClientCmdPrefix(conf.getClientCmdPrefix());
diff --git a/test/src/main/java/org/apache/accumulo/test/GetMasterStats.java b/test/src/main/java/org/apache/accumulo/test/GetMasterStats.java
index 65ec980..b0c7b72 100644
--- a/test/src/main/java/org/apache/accumulo/test/GetMasterStats.java
+++ b/test/src/main/java/org/apache/accumulo/test/GetMasterStats.java
@@ -25,6 +25,7 @@ import java.util.concurrent.TimeUnit;
import org.apache.accumulo.core.client.impl.MasterClient;
import org.apache.accumulo.core.client.impl.thrift.ThriftNotActiveServiceException;
+import org.apache.accumulo.core.conf.SiteConfiguration;
import org.apache.accumulo.core.master.thrift.BulkImportStatus;
import org.apache.accumulo.core.master.thrift.DeadServer;
import org.apache.accumulo.core.master.thrift.MasterClientService;
@@ -40,7 +41,7 @@ public class GetMasterStats {
public static void main(String[] args) throws Exception {
MasterClientService.Iface client = null;
MasterMonitorInfo stats = null;
- ServerContext context = new ServerContext();
+ ServerContext context = new ServerContext(SiteConfiguration.create());
while (true) {
try {
client = MasterClient.getConnectionWithRetry(context);
diff --git a/test/src/main/java/org/apache/accumulo/test/functional/SplitRecoveryIT.java b/test/src/main/java/org/apache/accumulo/test/functional/SplitRecoveryIT.java
index 74684fb..79309ae 100644
--- a/test/src/main/java/org/apache/accumulo/test/functional/SplitRecoveryIT.java
+++ b/test/src/main/java/org/apache/accumulo/test/functional/SplitRecoveryIT.java
@@ -35,6 +35,7 @@ import org.apache.accumulo.core.client.Scanner;
import org.apache.accumulo.core.client.impl.ScannerImpl;
import org.apache.accumulo.core.client.impl.Table;
import org.apache.accumulo.core.client.impl.Writer;
+import org.apache.accumulo.core.conf.SiteConfiguration;
import org.apache.accumulo.core.data.Key;
import org.apache.accumulo.core.data.Mutation;
import org.apache.accumulo.core.data.Value;
@@ -285,7 +286,7 @@ public class SplitRecoveryIT extends ConfigurableMacBase {
}
public static void main(String[] args) throws Exception {
- new SplitRecoveryIT().run(new ServerContext());
+ new SplitRecoveryIT().run(new ServerContext(SiteConfiguration.create()));
}
@Test
diff --git a/test/src/main/java/org/apache/accumulo/test/functional/ZombieTServer.java b/test/src/main/java/org/apache/accumulo/test/functional/ZombieTServer.java
index d8547da..bd15e46 100644
--- a/test/src/main/java/org/apache/accumulo/test/functional/ZombieTServer.java
+++ b/test/src/main/java/org/apache/accumulo/test/functional/ZombieTServer.java
@@ -25,6 +25,7 @@ import java.util.concurrent.TimeUnit;
import org.apache.accumulo.core.Constants;
import org.apache.accumulo.core.client.impl.thrift.ThriftSecurityException;
+import org.apache.accumulo.core.conf.SiteConfiguration;
import org.apache.accumulo.core.master.thrift.TabletServerStatus;
import org.apache.accumulo.core.security.thrift.TCredentials;
import org.apache.accumulo.core.tabletserver.thrift.TabletClientService.Iface;
@@ -99,7 +100,7 @@ public class ZombieTServer {
public static void main(String[] args) throws Exception {
Random random = new Random(System.currentTimeMillis() % 1000);
int port = random.nextInt(30000) + 2000;
- ServerContext context = new ServerContext();
+ ServerContext context = new ServerContext(SiteConfiguration.create());
TransactionWatcher watcher = new TransactionWatcher(context);
final ThriftClientHandler tch = new ThriftClientHandler(context, watcher);
Processor<Iface> processor = new Processor<>(tch);
diff --git a/test/src/main/java/org/apache/accumulo/test/performance/NullTserver.java b/test/src/main/java/org/apache/accumulo/test/performance/NullTserver.java
index 549f335..3cb65e9 100644
--- a/test/src/main/java/org/apache/accumulo/test/performance/NullTserver.java
+++ b/test/src/main/java/org/apache/accumulo/test/performance/NullTserver.java
@@ -33,6 +33,7 @@ import org.apache.accumulo.core.client.impl.thrift.ThriftSecurityException;
import org.apache.accumulo.core.client.impl.thrift.ThriftTableOperationException;
import org.apache.accumulo.core.conf.DefaultConfiguration;
import org.apache.accumulo.core.conf.Property;
+import org.apache.accumulo.core.conf.SiteConfiguration;
import org.apache.accumulo.core.data.Range;
import org.apache.accumulo.core.data.impl.KeyExtent;
import org.apache.accumulo.core.data.thrift.InitialMultiScan;
@@ -309,7 +310,8 @@ public class NullTserver {
// modify metadata
int zkTimeOut = (int) DefaultConfiguration.getInstance()
.getTimeInMillis(Property.INSTANCE_ZK_TIMEOUT);
- ServerContext context = new ServerContext(opts.iname, opts.keepers, zkTimeOut);
+ SiteConfiguration siteConfig = SiteConfiguration.create();
+ ServerContext context = new ServerContext(siteConfig, opts.iname, opts.keepers, zkTimeOut);
TransactionWatcher watcher = new TransactionWatcher(context);
ThriftClientHandler tch = new ThriftClientHandler(context, watcher);
Processor<Iface> processor = new Processor<>(tch);
diff --git a/test/src/main/java/org/apache/accumulo/test/server/security/SystemCredentialsIT.java b/test/src/main/java/org/apache/accumulo/test/server/security/SystemCredentialsIT.java
index 39b33e6..05d7e30 100644
--- a/test/src/main/java/org/apache/accumulo/test/server/security/SystemCredentialsIT.java
+++ b/test/src/main/java/org/apache/accumulo/test/server/security/SystemCredentialsIT.java
@@ -28,6 +28,7 @@ import org.apache.accumulo.core.client.TableNotFoundException;
import org.apache.accumulo.core.client.impl.Credentials;
import org.apache.accumulo.core.client.security.SecurityErrorCode;
import org.apache.accumulo.core.client.security.tokens.PasswordToken;
+import org.apache.accumulo.core.conf.SiteConfiguration;
import org.apache.accumulo.core.data.Key;
import org.apache.accumulo.core.data.Value;
import org.apache.accumulo.core.metadata.RootTable;
@@ -58,15 +59,16 @@ public class SystemCredentialsIT extends ConfigurableMacBase {
public static void main(final String[] args)
throws AccumuloException, TableNotFoundException, AccumuloSecurityException {
- ServerContext context = new ServerContext();
+ SiteConfiguration siteConfig = SiteConfiguration.create();
+ ServerContext context = new ServerContext(siteConfig);
Credentials creds = null;
String badInstanceID = SystemCredentials.class.getName();
if (args.length < 2)
throw new RuntimeException("Incorrect usage; expected to be run by test only");
if (args[0].equals("bad")) {
- creds = SystemCredentials.get(badInstanceID);
+ creds = SystemCredentials.get(badInstanceID, siteConfig);
} else if (args[0].equals("good")) {
- creds = SystemCredentials.get(context.getInstanceID());
+ creds = SystemCredentials.get(context.getInstanceID(), siteConfig);
} else if (args[0].equals("bad_password")) {
creds = new SystemCredentials(badInstanceID, "!SYSTEM", new PasswordToken("fake"));
} else {
diff --git a/test/src/main/java/org/apache/accumulo/test/util/CertUtils.java b/test/src/main/java/org/apache/accumulo/test/util/CertUtils.java
index 37ce50e..483a5e2 100644
--- a/test/src/main/java/org/apache/accumulo/test/util/CertUtils.java
+++ b/test/src/main/java/org/apache/accumulo/test/util/CertUtils.java
@@ -36,22 +36,13 @@ import java.security.cert.Certificate;
import java.security.cert.CertificateException;
import java.util.Calendar;
import java.util.Enumeration;
-import java.util.Iterator;
import java.util.List;
-import java.util.Map;
-import java.util.Map.Entry;
-import java.util.TreeMap;
-import java.util.function.Predicate;
import org.apache.accumulo.core.cli.Help;
import org.apache.accumulo.core.client.AccumuloSecurityException;
-import org.apache.accumulo.core.conf.AccumuloConfiguration;
-import org.apache.accumulo.core.conf.DefaultConfiguration;
import org.apache.accumulo.core.conf.Property;
import org.apache.accumulo.core.conf.SiteConfiguration;
import org.apache.commons.io.FileExistsException;
-import org.apache.hadoop.conf.Configuration;
-import org.apache.hadoop.fs.Path;
import org.bouncycastle.asn1.x500.X500Name;
import org.bouncycastle.asn1.x500.style.IETFUtils;
import org.bouncycastle.asn1.x500.style.RFC4519Style;
@@ -131,41 +122,11 @@ public class CertUtils {
@Parameter(names = "--keysize", description = "Key size used by encryption algorithm")
public int keysize = 2048;
- public AccumuloConfiguration getConfiguration() {
+ public SiteConfiguration getSiteConfiguration() {
if (siteFile == null) {
- return SiteConfiguration.getInstance();
+ return SiteConfiguration.create();
} else {
- return new AccumuloConfiguration() {
- Configuration xml = new Configuration();
- {
- xml.addResource(new Path(siteFile));
- }
-
- @Override
- public Iterator<Entry<String,String>> iterator() {
- TreeMap<String,String> map = new TreeMap<>();
- for (Entry<String,String> props : DefaultConfiguration.getInstance())
- map.put(props.getKey(), props.getValue());
- for (Entry<String,String> props : xml)
- map.put(props.getKey(), props.getValue());
- return map.entrySet().iterator();
- }
-
- @Override
- public String get(Property property) {
- String value = xml.get(property.getKey());
- if (value != null)
- return value;
- return DefaultConfiguration.getInstance().get(property);
- }
-
- @Override
- public void getProperties(Map<String,String> props, Predicate<String> filter) {
- for (Entry<String,String> entry : this)
- if (filter.test(entry.getKey()))
- props.put(entry.getKey(), entry.getValue());
- }
- };
+ return SiteConfiguration.create(new File(siteFile));
}
}
}
@@ -173,12 +134,12 @@ public class CertUtils {
public static void main(String[] args) throws Exception {
Opts opts = new Opts();
opts.parseArgs(CertUtils.class.getName(), args);
- String operation = opts.operation.get(0);
+ String operation = opts.operation.get(0);
String keyPassword = opts.keystorePassword;
- if (keyPassword == null)
- keyPassword = getDefaultKeyPassword();
-
+ if (keyPassword == null) {
+ keyPassword = opts.getSiteConfiguration().get(Property.INSTANCE_SECRET);
+ }
String rootKeyPassword = opts.rootKeystorePassword;
if (rootKeyPassword == null) {
rootKeyPassword = keyPassword;
@@ -206,10 +167,6 @@ public class CertUtils {
}
}
- private static String getDefaultKeyPassword() {
- return SiteConfiguration.getInstance().get(Property.INSTANCE_SECRET);
- }
-
private String issuerDirString;
private String keystoreType;
private String encryptionAlgorithm;