You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@accumulo.apache.org by GitBox <gi...@apache.org> on 2018/11/14 20:44:12 UTC
[GitHub] mikewalch closed pull request #752: Fixes #747 - Shorten method
names in AccumuloClient builder
mikewalch closed pull request #752: Fixes #747 - Shorten method names in AccumuloClient builder
URL: https://github.com/apache/accumulo/pull/752
This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:
As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):
diff --git a/core/src/main/java/org/apache/accumulo/core/cli/ClientOpts.java b/core/src/main/java/org/apache/accumulo/core/cli/ClientOpts.java
index 2ac66e1330..82b214be89 100644
--- a/core/src/main/java/org/apache/accumulo/core/cli/ClientOpts.java
+++ b/core/src/main/java/org/apache/accumulo/core/cli/ClientOpts.java
@@ -174,14 +174,14 @@ public void setClientInfo(ClientInfo info) {
public ClientInfo getClientInfo() {
if (cachedInfo == null) {
- cachedInfo = Accumulo.newClient().usingProperties(getClientProperties()).info();
+ cachedInfo = Accumulo.newClient().from(getClientProperties()).info();
}
return cachedInfo;
}
public AccumuloClient getClient() throws AccumuloException, AccumuloSecurityException {
if (cachedAccumuloClient == null) {
- cachedAccumuloClient = Accumulo.newClient().usingClientInfo(getClientInfo()).build();
+ cachedAccumuloClient = Accumulo.newClient().from(getClientInfo()).build();
}
return cachedAccumuloClient;
}
diff --git a/core/src/main/java/org/apache/accumulo/core/client/Accumulo.java b/core/src/main/java/org/apache/accumulo/core/client/Accumulo.java
index b1bd13cd62..3db071d069 100644
--- a/core/src/main/java/org/apache/accumulo/core/client/Accumulo.java
+++ b/core/src/main/java/org/apache/accumulo/core/client/Accumulo.java
@@ -52,8 +52,8 @@ private Accumulo() {}
* <pre>
* <code>
* try (AccumuloClient client = Accumulo.newClient()
- * .forInstance(instanceName, zookeepers)
- * .usingPassword(user, password).build())
+ * .to(instanceName, zookeepers)
+ * .as(user, password).build())
* {
* // use the client
* }
diff --git a/core/src/main/java/org/apache/accumulo/core/client/AccumuloClient.java b/core/src/main/java/org/apache/accumulo/core/client/AccumuloClient.java
index 2955972d65..10885a4d33 100644
--- a/core/src/main/java/org/apache/accumulo/core/client/AccumuloClient.java
+++ b/core/src/main/java/org/apache/accumulo/core/client/AccumuloClient.java
@@ -16,6 +16,7 @@
*/
package org.apache.accumulo.core.client;
+import java.nio.file.Path;
import java.util.Properties;
import org.apache.accumulo.core.client.admin.InstanceOperations;
@@ -40,8 +41,8 @@
* <pre>
* <code>
* try (AccumuloClient client = Accumulo.newClient()
- * .forInstance(instanceName, zookeepers)
- * .usingPassword(user, password).build())
+ * .to(instanceName, zookeepers)
+ * .as(user, password).build())
* {
* // use the client
* }
@@ -330,10 +331,12 @@ AccumuloClient changeUser(String principal, AuthenticationToken token)
* using this client will likely fail after close is called.
*/
@Override
- public void close();
+ void close();
/**
* Builds ClientInfo after all options have been specified
+ *
+ * @since 2.0.0
*/
interface ClientInfoFactory {
@@ -347,6 +350,8 @@ AccumuloClient changeUser(String principal, AuthenticationToken token)
/**
* Builds AccumuloClient
+ *
+ * @since 2.0.0
*/
interface AccumuloClientFactory extends ClientInfoFactory {
@@ -361,16 +366,30 @@ AccumuloClient changeUser(String principal, AuthenticationToken token)
/**
* Builder method for setting Accumulo instance and zookeepers
+ *
+ * @since 2.0.0
*/
interface InstanceArgs {
- AuthenticationArgs forInstance(String instanceName, String zookeepers);
+ AuthenticationArgs to(CharSequence instanceName, CharSequence zookeepers);
}
/**
* Builder methods for creating AccumuloClient using properties
+ *
+ * @since 2.0.0
*/
interface PropertyOptions extends InstanceArgs {
+ /**
+ * Build using properties file. An example properties file can be found at
+ * conf/accumulo-client.properties in the Accumulo tarball distribution.
+ *
+ * @param propertiesFilePath
+ * Path to properties file
+ * @return this builder
+ */
+ AccumuloClientFactory from(String propertiesFilePath);
+
/**
* Build using properties file. An example properties file can be found at
* conf/accumulo-client.properties in the Accumulo tarball distribution.
@@ -379,20 +398,22 @@ AccumuloClient changeUser(String principal, AuthenticationToken token)
* Path to properties file
* @return this builder
*/
- AccumuloClientFactory usingProperties(String propertiesFile);
+ AccumuloClientFactory from(Path propertiesFile);
/**
* Build using Java properties object. A list of available properties can be found in the
- * documentation on the project website (http://accumulo.apache.org) under 'Development' ->
- * 'Client Properties'
+ * documentation at https://accumulo.apache.org/docs/2.x/configuration/client-properties
*
* @param properties
* Properties object
* @return this builder
*/
- AccumuloClientFactory usingProperties(Properties properties);
+ AccumuloClientFactory from(Properties properties);
}
+ /**
+ * @since 2.0.0
+ */
interface ClientInfoOptions extends PropertyOptions {
/**
@@ -402,11 +423,13 @@ AccumuloClient changeUser(String principal, AuthenticationToken token)
* ClientInfo object
* @return this builder
*/
- FromOptions usingClientInfo(ClientInfo clientInfo);
+ FromOptions from(ClientInfo clientInfo);
}
/**
- * Build methods for authentication
+ * Builder methods for authentication
+ *
+ * @since 2.0.0
*/
interface AuthenticationArgs {
@@ -419,7 +442,7 @@ AccumuloClient changeUser(String principal, AuthenticationToken token)
* Password
* @return this builder
*/
- ConnectionOptions usingPassword(String username, CharSequence password);
+ ConnectionOptions as(CharSequence username, CharSequence password);
/**
* Build using Kerberos credentials
@@ -430,7 +453,7 @@ AccumuloClient changeUser(String principal, AuthenticationToken token)
* Path to keytab file
* @return this builder
*/
- ConnectionOptions usingKerberos(String principal, String keyTabFile);
+ ConnectionOptions as(CharSequence principal, Path keyTabFile);
/**
* Build using specified credentials
@@ -441,11 +464,13 @@ AccumuloClient changeUser(String principal, AuthenticationToken token)
* Authentication token
* @return this builder
*/
- ConnectionOptions usingToken(String principal, AuthenticationToken token);
+ ConnectionOptions as(CharSequence principal, AuthenticationToken token);
}
/**
* Build methods for SSL/TLS
+ *
+ * @since 2.0.0
*/
interface SslOptions extends AccumuloClientFactory {
@@ -456,7 +481,7 @@ AccumuloClient changeUser(String principal, AuthenticationToken token)
* Path to trust store
* @return this builder
*/
- SslOptions withTruststore(String path);
+ SslOptions truststore(CharSequence path);
/**
* Build with SSL trust store
@@ -469,7 +494,7 @@ AccumuloClient changeUser(String principal, AuthenticationToken token)
* Trust store type
* @return this builder
*/
- SslOptions withTruststore(String path, String password, String type);
+ SslOptions truststore(CharSequence path, CharSequence password, CharSequence type);
/**
* Build with SSL key store
@@ -478,7 +503,7 @@ AccumuloClient changeUser(String principal, AuthenticationToken token)
* Path to SSL key store
* @return this builder
*/
- SslOptions withKeystore(String path);
+ SslOptions keystore(CharSequence path);
/**
* Build with SSL key store
@@ -491,7 +516,7 @@ AccumuloClient changeUser(String principal, AuthenticationToken token)
* Key store type
* @return this builder
*/
- SslOptions withKeystore(String path, String password, String type);
+ SslOptions keystore(CharSequence path, CharSequence password, CharSequence type);
/**
* Use JSSE system properties to configure SSL
@@ -503,6 +528,8 @@ AccumuloClient changeUser(String principal, AuthenticationToken token)
/**
* Build methods for SASL
+ *
+ * @since 2.0.0
*/
interface SaslOptions extends AccumuloClientFactory {
@@ -513,7 +540,7 @@ AccumuloClient changeUser(String principal, AuthenticationToken token)
* Kerberos server primary
* @return this builder
*/
- SaslOptions withPrimary(String kerberosServerPrimary);
+ SaslOptions primary(CharSequence kerberosServerPrimary);
/**
* Build with SASL quality of protection
@@ -522,11 +549,13 @@ AccumuloClient changeUser(String principal, AuthenticationToken token)
* Quality of protection
* @return this builder
*/
- SaslOptions withQop(String qualityOfProtection);
+ SaslOptions qop(CharSequence qualityOfProtection);
}
/**
* Build methods for connection options
+ *
+ * @since 2.0.0
*/
interface ConnectionOptions extends AccumuloClientFactory {
@@ -537,21 +566,21 @@ AccumuloClient changeUser(String principal, AuthenticationToken token)
* Zookeeper timeout (in milliseconds)
* @return this builder
*/
- ConnectionOptions withZkTimeout(int timeout);
+ ConnectionOptions zkTimeout(int timeout);
/**
* Build with SSL/TLS options
*
* @return this builder
*/
- SslOptions withSsl();
+ SslOptions useSsl();
/**
* Build with SASL options
*
* @return this builder
*/
- SaslOptions withSasl();
+ SaslOptions useSasl();
/**
* Build with BatchWriterConfig defaults for BatchWriter, MultiTableBatchWriter &
@@ -561,19 +590,22 @@ AccumuloClient changeUser(String principal, AuthenticationToken token)
* BatchWriterConfig
* @return this builder
*/
- ConnectionOptions withBatchWriterConfig(BatchWriterConfig batchWriterConfig);
+ ConnectionOptions batchWriterConfig(BatchWriterConfig batchWriterConfig);
/**
* Build with default number of query threads for BatchScanner
*/
- ConnectionOptions withBatchScannerQueryThreads(int numQueryThreads);
+ ConnectionOptions batchScannerQueryThreads(int numQueryThreads);
/**
* Build with default batch size for Scanner
*/
- ConnectionOptions withScannerBatchSize(int batchSize);
+ ConnectionOptions scannerBatchSize(int batchSize);
}
+ /**
+ * @since 2.0.0
+ */
interface FromOptions extends ConnectionOptions, PropertyOptions, AuthenticationArgs {
}
diff --git a/core/src/main/java/org/apache/accumulo/core/client/ClientInfo.java b/core/src/main/java/org/apache/accumulo/core/client/ClientInfo.java
index 6eb8809aef..b55874bd25 100644
--- a/core/src/main/java/org/apache/accumulo/core/client/ClientInfo.java
+++ b/core/src/main/java/org/apache/accumulo/core/client/ClientInfo.java
@@ -16,6 +16,7 @@
*/
package org.apache.accumulo.core.client;
+import java.nio.file.Path;
import java.util.Properties;
import org.apache.accumulo.core.client.impl.ClientInfoImpl;
@@ -80,7 +81,7 @@ static ClientInfo from(Properties properties, AuthenticationToken token) {
/**
* @return ClientInfo given path to client config file
*/
- static ClientInfo from(String configFile) {
- return new ClientInfoImpl(configFile);
+ static ClientInfo from(Path propertiesFile) {
+ return new ClientInfoImpl(propertiesFile);
}
}
diff --git a/core/src/main/java/org/apache/accumulo/core/client/impl/AccumuloClientImpl.java b/core/src/main/java/org/apache/accumulo/core/client/impl/AccumuloClientImpl.java
index 1506f26066..6839014d8f 100644
--- a/core/src/main/java/org/apache/accumulo/core/client/impl/AccumuloClientImpl.java
+++ b/core/src/main/java/org/apache/accumulo/core/client/impl/AccumuloClientImpl.java
@@ -18,6 +18,7 @@
import static com.google.common.base.Preconditions.checkArgument;
+import java.nio.file.Path;
import java.util.Objects;
import java.util.Properties;
import java.util.concurrent.TimeUnit;
@@ -269,7 +270,7 @@ public ClientInfo info() {
public AccumuloClient changeUser(String principal, AuthenticationToken token)
throws AccumuloSecurityException, AccumuloException {
ensureOpen();
- return Accumulo.newClient().usingClientInfo(info()).usingToken(principal, token).build();
+ return Accumulo.newClient().from(info()).as(principal, token).build();
}
@Override
@@ -313,20 +314,20 @@ public ClientInfo info() {
}
@Override
- public AuthenticationArgs forInstance(String instanceName, String zookeepers) {
+ public AuthenticationArgs to(CharSequence instanceName, CharSequence zookeepers) {
setProperty(ClientProperty.INSTANCE_NAME, instanceName);
setProperty(ClientProperty.INSTANCE_ZOOKEEPERS, zookeepers);
return this;
}
@Override
- public SslOptions withTruststore(String path) {
+ public SslOptions truststore(CharSequence path) {
setProperty(ClientProperty.SSL_TRUSTSTORE_PATH, path);
return this;
}
@Override
- public SslOptions withTruststore(String path, String password, String type) {
+ public SslOptions truststore(CharSequence path, CharSequence password, CharSequence type) {
setProperty(ClientProperty.SSL_TRUSTSTORE_PATH, path);
setProperty(ClientProperty.SSL_TRUSTSTORE_PASSWORD, password);
setProperty(ClientProperty.SSL_TRUSTSTORE_TYPE, type);
@@ -334,13 +335,13 @@ public SslOptions withTruststore(String path, String password, String type) {
}
@Override
- public SslOptions withKeystore(String path) {
+ public SslOptions keystore(CharSequence path) {
setProperty(ClientProperty.SSL_KEYSTORE_PATH, path);
return this;
}
@Override
- public SslOptions withKeystore(String path, String password, String type) {
+ public SslOptions keystore(CharSequence path, CharSequence password, CharSequence type) {
setProperty(ClientProperty.SSL_KEYSTORE_PATH, path);
setProperty(ClientProperty.SSL_KEYSTORE_PASSWORD, password);
setProperty(ClientProperty.SSL_KEYSTORE_TYPE, type);
@@ -354,25 +355,25 @@ public SslOptions useJsse() {
}
@Override
- public ConnectionOptions withZkTimeout(int timeout) {
+ public ConnectionOptions zkTimeout(int timeout) {
setProperty(ClientProperty.INSTANCE_ZOOKEEPERS_TIMEOUT, Integer.toString(timeout) + "ms");
return this;
}
@Override
- public SslOptions withSsl() {
+ public SslOptions useSsl() {
setProperty(ClientProperty.SSL_ENABLED, "true");
return this;
}
@Override
- public SaslOptions withSasl() {
+ public SaslOptions useSasl() {
setProperty(ClientProperty.SASL_ENABLED, "true");
return this;
}
@Override
- public ConnectionOptions withBatchWriterConfig(BatchWriterConfig batchWriterConfig) {
+ public ConnectionOptions batchWriterConfig(BatchWriterConfig batchWriterConfig) {
setProperty(ClientProperty.BATCH_WRITER_MAX_MEMORY_BYTES, batchWriterConfig.getMaxMemory());
setProperty(ClientProperty.BATCH_WRITER_MAX_LATENCY_SEC,
batchWriterConfig.getMaxLatency(TimeUnit.SECONDS));
@@ -386,69 +387,74 @@ public ConnectionOptions withBatchWriterConfig(BatchWriterConfig batchWriterConf
}
@Override
- public ConnectionOptions withBatchScannerQueryThreads(int numQueryThreads) {
+ public ConnectionOptions batchScannerQueryThreads(int numQueryThreads) {
setProperty(ClientProperty.BATCH_SCANNER_NUM_QUERY_THREADS, numQueryThreads);
return this;
}
@Override
- public ConnectionOptions withScannerBatchSize(int batchSize) {
+ public ConnectionOptions scannerBatchSize(int batchSize) {
setProperty(ClientProperty.SCANNER_BATCH_SIZE, batchSize);
return this;
}
@Override
- public SaslOptions withPrimary(String kerberosServerPrimary) {
+ public SaslOptions primary(CharSequence kerberosServerPrimary) {
setProperty(ClientProperty.SASL_KERBEROS_SERVER_PRIMARY, kerberosServerPrimary);
return this;
}
@Override
- public SaslOptions withQop(String qualityOfProtection) {
+ public SaslOptions qop(CharSequence qualityOfProtection) {
setProperty(ClientProperty.SASL_QOP, qualityOfProtection);
return this;
}
@Override
- public AccumuloClientFactory usingProperties(String configFile) {
- return usingProperties(ClientInfoImpl.toProperties(configFile));
+ public AccumuloClientFactory from(String propertiesFilePath) {
+ return from(ClientInfoImpl.toProperties(propertiesFilePath));
}
@Override
- public AccumuloClientFactory usingProperties(Properties properties) {
+ public AccumuloClientFactory from(Path propertiesFile) {
+ return from(ClientInfoImpl.toProperties(propertiesFile));
+ }
+
+ @Override
+ public AccumuloClientFactory from(Properties properties) {
this.properties = properties;
return this;
}
@Override
- public ConnectionOptions usingPassword(String principal, CharSequence password) {
- setProperty(ClientProperty.AUTH_PRINCIPAL, principal);
- ClientProperty.setPassword(properties, password.toString());
+ public ConnectionOptions as(CharSequence username, CharSequence password) {
+ setProperty(ClientProperty.AUTH_PRINCIPAL, username);
+ ClientProperty.setPassword(properties, password);
return this;
}
@Override
- public ConnectionOptions usingKerberos(String principal, String keyTabFile) {
+ public ConnectionOptions as(CharSequence principal, Path keyTabFile) {
setProperty(ClientProperty.AUTH_PRINCIPAL, principal);
- ClientProperty.setKerberosKeytab(properties, keyTabFile);
+ ClientProperty.setKerberosKeytab(properties, keyTabFile.toString());
return this;
}
@Override
- public ConnectionOptions usingToken(String principal, AuthenticationToken token) {
- setProperty(ClientProperty.AUTH_PRINCIPAL, principal);
+ public ConnectionOptions as(CharSequence principal, AuthenticationToken token) {
+ setProperty(ClientProperty.AUTH_PRINCIPAL, principal.toString());
this.token = token;
return this;
}
@Override
- public FromOptions usingClientInfo(ClientInfo clientInfo) {
+ public FromOptions from(ClientInfo clientInfo) {
this.properties = clientInfo.getProperties();
return this;
}
- public void setProperty(ClientProperty property, String value) {
- properties.setProperty(property.getKey(), value);
+ public void setProperty(ClientProperty property, CharSequence value) {
+ properties.setProperty(property.getKey(), value.toString());
}
public void setProperty(ClientProperty property, Long value) {
diff --git a/core/src/main/java/org/apache/accumulo/core/client/impl/ClientInfoImpl.java b/core/src/main/java/org/apache/accumulo/core/client/impl/ClientInfoImpl.java
index ff4cccafd5..29e42bbbec 100644
--- a/core/src/main/java/org/apache/accumulo/core/client/impl/ClientInfoImpl.java
+++ b/core/src/main/java/org/apache/accumulo/core/client/impl/ClientInfoImpl.java
@@ -19,6 +19,8 @@
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
+import java.nio.file.Path;
+import java.nio.file.Paths;
import java.util.Properties;
import org.apache.accumulo.core.client.ClientInfo;
@@ -33,8 +35,8 @@
private Properties properties;
private AuthenticationToken token;
- public ClientInfoImpl(String configFile) {
- this(ClientInfoImpl.toProperties(configFile));
+ public ClientInfoImpl(Path propertiesFile) {
+ this(ClientInfoImpl.toProperties(propertiesFile));
}
public ClientInfoImpl(Properties properties) {
@@ -92,13 +94,19 @@ private String getString(ClientProperty property) {
}
@SuppressFBWarnings(value = "PATH_TRAVERSAL_IN",
- justification = "code runs in same security context as user who provided configFile")
- public static Properties toProperties(String configFile) {
+ justification = "code runs in same security context as user who provided propertiesFilePath")
+ public static Properties toProperties(String propertiesFilePath) {
+ return toProperties(Paths.get(propertiesFilePath));
+ }
+
+ @SuppressFBWarnings(value = "PATH_TRAVERSAL_IN",
+ justification = "code runs in same security context as user who provided propertiesFile")
+ public static Properties toProperties(Path propertiesFile) {
Properties properties = new Properties();
- try (InputStream is = new FileInputStream(configFile)) {
+ try (InputStream is = new FileInputStream(propertiesFile.toFile())) {
properties.load(is);
} catch (IOException e) {
- throw new IllegalArgumentException("Failed to load properties from " + configFile, e);
+ throw new IllegalArgumentException("Failed to load properties from " + propertiesFile, e);
}
return properties;
}
diff --git a/core/src/main/java/org/apache/accumulo/core/client/mapred/AbstractInputFormat.java b/core/src/main/java/org/apache/accumulo/core/client/mapred/AbstractInputFormat.java
index 138ccd4710..09787f5910 100644
--- a/core/src/main/java/org/apache/accumulo/core/client/mapred/AbstractInputFormat.java
+++ b/core/src/main/java/org/apache/accumulo/core/client/mapred/AbstractInputFormat.java
@@ -181,8 +181,8 @@ public static void setConnectorInfo(JobConf job, String principal, Authenticatio
if (token instanceof KerberosToken) {
log.info("Received KerberosToken, attempting to fetch DelegationToken");
try {
- AccumuloClient client = Accumulo.newClient().usingClientInfo(getClientInfo(job))
- .usingToken(principal, token).build();
+ AccumuloClient client = Accumulo.newClient().from(getClientInfo(job)).as(principal, token)
+ .build();
token = client.securityOperations().getDelegationToken(new DelegationTokenConfig());
} catch (Exception e) {
log.warn("Failed to automatically obtain DelegationToken, Mappers/Reducers will likely"
diff --git a/core/src/main/java/org/apache/accumulo/core/client/mapred/AccumuloOutputFormat.java b/core/src/main/java/org/apache/accumulo/core/client/mapred/AccumuloOutputFormat.java
index dd3c7e8dd8..293a9f2303 100644
--- a/core/src/main/java/org/apache/accumulo/core/client/mapred/AccumuloOutputFormat.java
+++ b/core/src/main/java/org/apache/accumulo/core/client/mapred/AccumuloOutputFormat.java
@@ -427,7 +427,7 @@ protected AccumuloRecordWriter(JobConf job)
this.defaultTableName = (tname == null) ? null : new Text(tname);
if (!simulate) {
- this.client = Accumulo.newClient().usingClientInfo(getClientInfo(job)).build();
+ this.client = Accumulo.newClient().from(getClientInfo(job)).build();
mtbw = client.createMultiTableBatchWriter(getBatchWriterOptions(job));
}
}
@@ -564,7 +564,7 @@ public void checkOutputSpecs(FileSystem ignored, JobConf job) throws IOException
throw new IOException("Connector info has not been set.");
try {
// if the instance isn't configured, it will complain here
- AccumuloClient c = Accumulo.newClient().usingClientInfo(getClientInfo(job)).build();
+ AccumuloClient c = Accumulo.newClient().from(getClientInfo(job)).build();
String principal = getPrincipal(job);
AuthenticationToken token = getAuthenticationToken(job);
if (!c.securityOperations().authenticateUser(principal, token))
diff --git a/core/src/main/java/org/apache/accumulo/core/client/mapreduce/AbstractInputFormat.java b/core/src/main/java/org/apache/accumulo/core/client/mapreduce/AbstractInputFormat.java
index 2c4b934d89..1c76e5da36 100644
--- a/core/src/main/java/org/apache/accumulo/core/client/mapreduce/AbstractInputFormat.java
+++ b/core/src/main/java/org/apache/accumulo/core/client/mapreduce/AbstractInputFormat.java
@@ -183,8 +183,8 @@ public static void setConnectorInfo(Job job, String principal, AuthenticationTok
if (token instanceof KerberosToken) {
log.info("Received KerberosToken, attempting to fetch DelegationToken");
try {
- AccumuloClient client = Accumulo.newClient().usingClientInfo(getClientInfo(job))
- .usingToken(principal, token).build();
+ AccumuloClient client = Accumulo.newClient().from(getClientInfo(job)).as(principal, token)
+ .build();
token = client.securityOperations().getDelegationToken(new DelegationTokenConfig());
} catch (Exception e) {
log.warn("Failed to automatically obtain DelegationToken, "
diff --git a/core/src/main/java/org/apache/accumulo/core/client/mapreduce/AccumuloOutputFormat.java b/core/src/main/java/org/apache/accumulo/core/client/mapreduce/AccumuloOutputFormat.java
index c07846ecf8..07c437c010 100644
--- a/core/src/main/java/org/apache/accumulo/core/client/mapreduce/AccumuloOutputFormat.java
+++ b/core/src/main/java/org/apache/accumulo/core/client/mapreduce/AccumuloOutputFormat.java
@@ -430,7 +430,7 @@ protected AccumuloRecordWriter(TaskAttemptContext context)
this.defaultTableName = (tname == null) ? null : new Text(tname);
if (!simulate) {
- this.client = Accumulo.newClient().usingClientInfo(getClientInfo(context)).build();
+ this.client = Accumulo.newClient().from(getClientInfo(context)).build();
mtbw = client.createMultiTableBatchWriter(getBatchWriterOptions(context));
}
}
@@ -569,7 +569,7 @@ public void checkOutputSpecs(JobContext job) throws IOException {
// if the instance isn't configured, it will complain here
String principal = getPrincipal(job);
AuthenticationToken token = getAuthenticationToken(job);
- AccumuloClient c = Accumulo.newClient().usingClientInfo(getClientInfo(job)).build();
+ AccumuloClient c = Accumulo.newClient().from(getClientInfo(job)).build();
if (!c.securityOperations().authenticateUser(principal, token))
throw new IOException("Unable to authenticate user");
} catch (AccumuloException | AccumuloSecurityException e) {
diff --git a/core/src/main/java/org/apache/accumulo/core/client/mapreduce/lib/impl/ConfiguratorBase.java b/core/src/main/java/org/apache/accumulo/core/client/mapreduce/lib/impl/ConfiguratorBase.java
index 71f2cdcc9a..86fc95ddc1 100644
--- a/core/src/main/java/org/apache/accumulo/core/client/mapreduce/lib/impl/ConfiguratorBase.java
+++ b/core/src/main/java/org/apache/accumulo/core/client/mapreduce/lib/impl/ConfiguratorBase.java
@@ -119,11 +119,10 @@ public static ClientInfo updateToken(org.apache.hadoop.security.Credentials cred
if (info.getAuthenticationToken() instanceof KerberosToken) {
log.info("Received KerberosToken, attempting to fetch DelegationToken");
try {
- AccumuloClient client = Accumulo.newClient().usingClientInfo(info).build();
+ AccumuloClient client = Accumulo.newClient().from(info).build();
AuthenticationToken token = client.securityOperations()
.getDelegationToken(new DelegationTokenConfig());
- result = Accumulo.newClient().usingClientInfo(info).usingToken(info.getPrincipal(), token)
- .info();
+ result = Accumulo.newClient().from(info).as(info.getPrincipal(), token).info();
} catch (Exception e) {
log.warn("Failed to automatically obtain DelegationToken, "
+ "Mappers/Reducers will likely fail to communicate with Accumulo", e);
@@ -353,7 +352,7 @@ public static void setZooKeeperInstance(Class<?> implementingClass, Configuratio
*/
public static AccumuloClient getClient(Class<?> implementingClass, Configuration conf) {
try {
- return Accumulo.newClient().usingClientInfo(getClientInfo(implementingClass, conf)).build();
+ return Accumulo.newClient().from(getClientInfo(implementingClass, conf)).build();
} catch (AccumuloException | AccumuloSecurityException e) {
throw new IllegalStateException(e);
}
diff --git a/core/src/main/java/org/apache/accumulo/core/client/mapreduce/lib/impl/MapReduceClientOpts.java b/core/src/main/java/org/apache/accumulo/core/client/mapreduce/lib/impl/MapReduceClientOpts.java
index fae11f39db..d3d28201b2 100644
--- a/core/src/main/java/org/apache/accumulo/core/client/mapreduce/lib/impl/MapReduceClientOpts.java
+++ b/core/src/main/java/org/apache/accumulo/core/client/mapreduce/lib/impl/MapReduceClientOpts.java
@@ -61,8 +61,8 @@ public AuthenticationToken getToken() {
log.info("Obtaining delegation token for {}", newPrincipal);
setPrincipal(newPrincipal);
- AccumuloClient client = Accumulo.newClient().usingClientInfo(getClientInfo())
- .usingToken(newPrincipal, krbToken).build();
+ AccumuloClient client = Accumulo.newClient().from(getClientInfo())
+ .as(newPrincipal, krbToken).build();
// Do the explicit check to see if the user has the permission to get a delegation token
if (!client.securityOperations().hasSystemPermission(client.whoami(),
diff --git a/core/src/main/java/org/apache/accumulo/core/conf/ClientProperty.java b/core/src/main/java/org/apache/accumulo/core/conf/ClientProperty.java
index 911079b936..8801507828 100644
--- a/core/src/main/java/org/apache/accumulo/core/conf/ClientProperty.java
+++ b/core/src/main/java/org/apache/accumulo/core/conf/ClientProperty.java
@@ -222,9 +222,9 @@ public static AuthenticationToken decodeToken(String className, String tokenStri
Base64.getDecoder().decode(tokenString));
}
- public static void setPassword(Properties properties, String password) {
+ public static void setPassword(Properties properties, CharSequence password) {
properties.setProperty(ClientProperty.AUTH_TYPE.getKey(), "password");
- properties.setProperty(ClientProperty.AUTH_TOKEN.getKey(), password);
+ properties.setProperty(ClientProperty.AUTH_TOKEN.getKey(), password.toString());
}
public static void setKerberosKeytab(Properties properties, String keytabPath) {
diff --git a/core/src/test/java/org/apache/accumulo/core/client/mapreduce/lib/impl/ConfiguratorBaseTest.java b/core/src/test/java/org/apache/accumulo/core/client/mapreduce/lib/impl/ConfiguratorBaseTest.java
index 3c022d7109..671526e672 100644
--- a/core/src/test/java/org/apache/accumulo/core/client/mapreduce/lib/impl/ConfiguratorBaseTest.java
+++ b/core/src/test/java/org/apache/accumulo/core/client/mapreduce/lib/impl/ConfiguratorBaseTest.java
@@ -79,8 +79,8 @@ public void testSetConnectorInfoClassOfQConfigurationStringString()
@Test
public void testSetClientInfo() {
Configuration conf = new Configuration();
- ClientInfo info = Accumulo.newClient().forInstance("myinstance", "myzookeepers")
- .usingPassword("user", "pass").info();
+ ClientInfo info = Accumulo.newClient().to("myinstance", "myzookeepers").as("user", "pass")
+ .info();
ConfiguratorBase.setClientInfo(this.getClass(), conf, info);
ClientInfo info2 = ConfiguratorBase.getClientInfo(this.getClass(), conf);
assertEquals("myinstance", info2.getInstanceName());
diff --git a/hadoop-mapreduce/src/main/java/org/apache/accumulo/hadoop/mapred/AccumuloOutputFormat.java b/hadoop-mapreduce/src/main/java/org/apache/accumulo/hadoop/mapred/AccumuloOutputFormat.java
index 9fb903a0cc..dca05a44b6 100644
--- a/hadoop-mapreduce/src/main/java/org/apache/accumulo/hadoop/mapred/AccumuloOutputFormat.java
+++ b/hadoop-mapreduce/src/main/java/org/apache/accumulo/hadoop/mapred/AccumuloOutputFormat.java
@@ -63,7 +63,7 @@ public void checkOutputSpecs(FileSystem ignored, JobConf job) throws IOException
ClientInfo clientInfo = getClientInfo(job);
String principal = clientInfo.getPrincipal();
AuthenticationToken token = clientInfo.getAuthenticationToken();
- AccumuloClient c = Accumulo.newClient().usingClientInfo(clientInfo).build();
+ AccumuloClient c = Accumulo.newClient().from(clientInfo).build();
if (!c.securityOperations().authenticateUser(principal, token))
throw new IOException("Unable to authenticate user");
} catch (AccumuloException | AccumuloSecurityException e) {
diff --git a/hadoop-mapreduce/src/main/java/org/apache/accumulo/hadoop/mapreduce/AccumuloOutputFormat.java b/hadoop-mapreduce/src/main/java/org/apache/accumulo/hadoop/mapreduce/AccumuloOutputFormat.java
index 41818ee05b..a285988103 100644
--- a/hadoop-mapreduce/src/main/java/org/apache/accumulo/hadoop/mapreduce/AccumuloOutputFormat.java
+++ b/hadoop-mapreduce/src/main/java/org/apache/accumulo/hadoop/mapreduce/AccumuloOutputFormat.java
@@ -64,7 +64,7 @@ public void checkOutputSpecs(JobContext job) throws IOException {
ClientInfo clientInfo = getClientInfo(job);
String principal = clientInfo.getPrincipal();
AuthenticationToken token = clientInfo.getAuthenticationToken();
- AccumuloClient c = Accumulo.newClient().usingClientInfo(clientInfo).build();
+ AccumuloClient c = Accumulo.newClient().from(clientInfo).build();
if (!c.securityOperations().authenticateUser(principal, token))
throw new IOException("Unable to authenticate user");
diff --git a/hadoop-mapreduce/src/main/java/org/apache/accumulo/hadoop/mapreduce/InputInfo.java b/hadoop-mapreduce/src/main/java/org/apache/accumulo/hadoop/mapreduce/InputInfo.java
index a5bdc89d6e..d443ce4363 100644
--- a/hadoop-mapreduce/src/main/java/org/apache/accumulo/hadoop/mapreduce/InputInfo.java
+++ b/hadoop-mapreduce/src/main/java/org/apache/accumulo/hadoop/mapreduce/InputInfo.java
@@ -16,6 +16,7 @@
*/
package org.apache.accumulo.hadoop.mapreduce;
+import java.nio.file.Path;
import java.util.Collection;
import java.util.Map;
import java.util.Optional;
@@ -140,7 +141,7 @@
interface ClientParams {
/**
* Set the connection information needed to communicate with Accumulo in this job. ClientInfo
- * param can be created using {@link ClientInfo#from(String)} or
+ * param can be created using {@link ClientInfo#from(Path)} or
* {@link ClientInfo#from(Properties)}
*
* @param clientInfo
diff --git a/hadoop-mapreduce/src/main/java/org/apache/accumulo/hadoop/mapreduce/OutputInfo.java b/hadoop-mapreduce/src/main/java/org/apache/accumulo/hadoop/mapreduce/OutputInfo.java
index 20f9667b64..0ca744363e 100644
--- a/hadoop-mapreduce/src/main/java/org/apache/accumulo/hadoop/mapreduce/OutputInfo.java
+++ b/hadoop-mapreduce/src/main/java/org/apache/accumulo/hadoop/mapreduce/OutputInfo.java
@@ -16,6 +16,7 @@
*/
package org.apache.accumulo.hadoop.mapreduce;
+import java.nio.file.Path;
import java.util.Optional;
import java.util.Properties;
@@ -83,7 +84,7 @@
interface ClientParams {
/**
* Set the connection information needed to communicate with Accumulo in this job. ClientInfo
- * param can be created using {@link ClientInfo#from(String)} or
+ * param can be created using {@link ClientInfo#from(Path)} or
* {@link ClientInfo#from(Properties)}
*
* @param clientInfo
diff --git a/hadoop-mapreduce/src/main/java/org/apache/accumulo/hadoopImpl/mapred/AccumuloOutputFormatImpl.java b/hadoop-mapreduce/src/main/java/org/apache/accumulo/hadoopImpl/mapred/AccumuloOutputFormatImpl.java
index 7e8f4d80aa..0f52588dcc 100644
--- a/hadoop-mapreduce/src/main/java/org/apache/accumulo/hadoopImpl/mapred/AccumuloOutputFormatImpl.java
+++ b/hadoop-mapreduce/src/main/java/org/apache/accumulo/hadoopImpl/mapred/AccumuloOutputFormatImpl.java
@@ -248,7 +248,7 @@ public AccumuloRecordWriter(JobConf job) throws AccumuloException, AccumuloSecur
this.defaultTableName = (tname == null) ? null : new Text(tname);
if (!simulate) {
- this.client = Accumulo.newClient().usingClientInfo(getClientInfo(job)).build();
+ this.client = Accumulo.newClient().from(getClientInfo(job)).build();
mtbw = client.createMultiTableBatchWriter(getBatchWriterOptions(job));
}
}
diff --git a/hadoop-mapreduce/src/main/java/org/apache/accumulo/hadoopImpl/mapreduce/AccumuloOutputFormatImpl.java b/hadoop-mapreduce/src/main/java/org/apache/accumulo/hadoopImpl/mapreduce/AccumuloOutputFormatImpl.java
index 54a0042fad..c51efa6d89 100644
--- a/hadoop-mapreduce/src/main/java/org/apache/accumulo/hadoopImpl/mapreduce/AccumuloOutputFormatImpl.java
+++ b/hadoop-mapreduce/src/main/java/org/apache/accumulo/hadoopImpl/mapreduce/AccumuloOutputFormatImpl.java
@@ -251,7 +251,7 @@ public AccumuloRecordWriter(TaskAttemptContext context)
this.defaultTableName = (tname == null) ? null : new Text(tname);
if (!simulate) {
- this.client = Accumulo.newClient().usingClientInfo(getClientInfo(context)).build();
+ this.client = Accumulo.newClient().from(getClientInfo(context)).build();
mtbw = client.createMultiTableBatchWriter(getBatchWriterOptions(context));
}
}
diff --git a/hadoop-mapreduce/src/main/java/org/apache/accumulo/hadoopImpl/mapreduce/lib/ConfiguratorBase.java b/hadoop-mapreduce/src/main/java/org/apache/accumulo/hadoopImpl/mapreduce/lib/ConfiguratorBase.java
index 3032d2784f..ea4dc134b4 100644
--- a/hadoop-mapreduce/src/main/java/org/apache/accumulo/hadoopImpl/mapreduce/lib/ConfiguratorBase.java
+++ b/hadoop-mapreduce/src/main/java/org/apache/accumulo/hadoopImpl/mapreduce/lib/ConfiguratorBase.java
@@ -118,11 +118,10 @@ public static ClientInfo updateToken(org.apache.hadoop.security.Credentials cred
if (info.getAuthenticationToken() instanceof KerberosToken) {
log.info("Received KerberosToken, attempting to fetch DelegationToken");
try {
- AccumuloClient client = Accumulo.newClient().usingClientInfo(info).build();
+ AccumuloClient client = Accumulo.newClient().from(info).build();
AuthenticationToken token = client.securityOperations()
.getDelegationToken(new DelegationTokenConfig());
- result = Accumulo.newClient().usingClientInfo(info).usingToken(info.getPrincipal(), token)
- .info();
+ result = Accumulo.newClient().from(info).as(info.getPrincipal(), token).info();
} catch (Exception e) {
log.warn("Failed to automatically obtain DelegationToken, "
+ "Mappers/Reducers will likely fail to communicate with Accumulo", e);
@@ -308,7 +307,7 @@ public static AuthenticationToken getAuthenticationToken(Class<?> implementingCl
*/
public static AccumuloClient getClient(Class<?> implementingClass, Configuration conf) {
try {
- return Accumulo.newClient().usingClientInfo(getClientInfo(implementingClass, conf)).build();
+ return Accumulo.newClient().from(getClientInfo(implementingClass, conf)).build();
} catch (AccumuloException | AccumuloSecurityException e) {
throw new IllegalStateException(e);
}
diff --git a/hadoop-mapreduce/src/main/java/org/apache/accumulo/hadoopImpl/mapreduce/lib/MapReduceClientOpts.java b/hadoop-mapreduce/src/main/java/org/apache/accumulo/hadoopImpl/mapreduce/lib/MapReduceClientOpts.java
index ebf5d5dd50..bbea6c3e92 100644
--- a/hadoop-mapreduce/src/main/java/org/apache/accumulo/hadoopImpl/mapreduce/lib/MapReduceClientOpts.java
+++ b/hadoop-mapreduce/src/main/java/org/apache/accumulo/hadoopImpl/mapreduce/lib/MapReduceClientOpts.java
@@ -56,8 +56,8 @@ public AuthenticationToken getToken() {
log.info("Obtaining delegation token for {}", newPrincipal);
setPrincipal(newPrincipal);
- AccumuloClient client = Accumulo.newClient().usingClientInfo(getClientInfo())
- .usingToken(newPrincipal, krbToken).build();
+ AccumuloClient client = Accumulo.newClient().from(getClientInfo())
+ .as(newPrincipal, krbToken).build();
// Do the explicit check to see if the user has the permission to get a delegation token
if (!client.securityOperations().hasSystemPermission(client.whoami(),
diff --git a/hadoop-mapreduce/src/test/java/org/apache/accumulo/hadoopImpl/mapreduce/lib/ConfiguratorBaseTest.java b/hadoop-mapreduce/src/test/java/org/apache/accumulo/hadoopImpl/mapreduce/lib/ConfiguratorBaseTest.java
index f4fcee462a..3dcf05a331 100644
--- a/hadoop-mapreduce/src/test/java/org/apache/accumulo/hadoopImpl/mapreduce/lib/ConfiguratorBaseTest.java
+++ b/hadoop-mapreduce/src/test/java/org/apache/accumulo/hadoopImpl/mapreduce/lib/ConfiguratorBaseTest.java
@@ -74,8 +74,8 @@ public void testSetConnectorInfoClassOfQConfigurationStringString()
@Test
public void testSetClientInfo() {
Configuration conf = new Configuration();
- ClientInfo info = Accumulo.newClient().forInstance("myinstance", "myzookeepers")
- .usingPassword("user", "pass").info();
+ ClientInfo info = Accumulo.newClient().to("myinstance", "myzookeepers").as("user", "pass")
+ .info();
ConfiguratorBase.setClientInfo(this.getClass(), conf, info);
ClientInfo info2 = ConfiguratorBase.getClientInfo(this.getClass(), conf);
assertEquals("myinstance", info2.getInstanceName());
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 0733fe054e..af5abf2324 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
@@ -142,8 +142,7 @@ public synchronized ServerContext getServerContext() {
@Override
public AccumuloClient getAccumuloClient(String user, AuthenticationToken token)
throws AccumuloException, AccumuloSecurityException {
- return Accumulo.newClient().forInstance(getInstanceName(), getZooKeepers())
- .usingToken(user, token).build();
+ return Accumulo.newClient().to(getInstanceName(), getZooKeepers()).as(user, token).build();
}
@Override
diff --git a/minicluster/src/main/java/org/apache/accumulo/minicluster/MiniAccumuloCluster.java b/minicluster/src/main/java/org/apache/accumulo/minicluster/MiniAccumuloCluster.java
index 5660f70b50..5d70e33b75 100644
--- a/minicluster/src/main/java/org/apache/accumulo/minicluster/MiniAccumuloCluster.java
+++ b/minicluster/src/main/java/org/apache/accumulo/minicluster/MiniAccumuloCluster.java
@@ -20,7 +20,6 @@
import java.io.IOException;
import java.util.Set;
-import org.apache.accumulo.core.client.Accumulo;
import org.apache.accumulo.core.client.AccumuloClient;
import org.apache.accumulo.core.client.AccumuloException;
import org.apache.accumulo.core.client.AccumuloSecurityException;
@@ -165,6 +164,6 @@ public ClientInfo getClientInfo() {
public static ClientInfo getClientInfo(File directory) {
File clientProps = new File(new File(directory, "conf"), "accumulo-client.properties");
Preconditions.checkArgument(clientProps.exists());
- return Accumulo.newClient().usingProperties(clientProps.getAbsolutePath()).info();
+ return ClientInfo.from(clientProps.toPath());
}
}
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 63d3c49d48..c1b60435af 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
@@ -783,7 +783,7 @@ public MiniAccumuloConfigImpl getConfig() {
@Override
public AccumuloClient getAccumuloClient(String user, AuthenticationToken token)
throws AccumuloException, AccumuloSecurityException {
- return Accumulo.newClient().usingClientInfo(getClientInfo()).usingToken(user, token).build();
+ return Accumulo.newClient().from(getClientInfo()).as(user, token).build();
}
@SuppressWarnings("deprecation")
@@ -796,8 +796,7 @@ public AccumuloClient getAccumuloClient(String user, AuthenticationToken token)
@Override
public ClientInfo getClientInfo() {
if (clientInfo == null) {
- clientInfo = Accumulo.newClient()
- .usingProperties(config.getClientPropsFile().getAbsolutePath()).info();
+ clientInfo = ClientInfo.from(config.getClientPropsFile().toPath());
}
return clientInfo;
}
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 3c7e847ba1..91bf091e99 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
@@ -246,7 +246,7 @@ public synchronized AccumuloClient getClient()
public AccumuloClient getClient(String principal, AuthenticationToken token)
throws AccumuloSecurityException, AccumuloException {
- return Accumulo.newClient().usingClientInfo(info).usingToken(principal, token).build();
+ return Accumulo.newClient().from(info).as(principal, token).build();
}
public synchronized TableManager getTableManager() {
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 27ea5345e5..fd4c130231 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
@@ -273,8 +273,8 @@ private AccumuloClient ensureTraceTableExists(final AccumuloConfiguration conf)
at = token;
}
- accumuloClient = Accumulo.newClient().usingClientInfo(context.getClientInfo())
- .usingToken(principal, at).build();
+ accumuloClient = Accumulo.newClient().from(context.getClientInfo()).as(principal, at)
+ .build();
if (!accumuloClient.tableOperations().exists(tableName)) {
accumuloClient.tableOperations().create(tableName);
IteratorSetting setting = new IteratorSetting(10, "ageoff", AgeOffFilter.class.getName());
diff --git a/shell/src/main/java/org/apache/accumulo/shell/Shell.java b/shell/src/main/java/org/apache/accumulo/shell/Shell.java
index 1f9b5610fc..9b8943a524 100644
--- a/shell/src/main/java/org/apache/accumulo/shell/Shell.java
+++ b/shell/src/main/java/org/apache/accumulo/shell/Shell.java
@@ -341,8 +341,7 @@ public boolean config(String... args) throws IOException {
try {
DistributedTrace.enable(InetAddress.getLocalHost().getHostName(), "shell", properties);
this.setTableName("");
- accumuloClient = Accumulo.newClient().usingClientInfo(info).usingToken(principal, token)
- .build();
+ accumuloClient = Accumulo.newClient().from(info).as(principal, token).build();
context = new ClientContext(accumuloClient.info());
} catch (Exception e) {
printException(e);
diff --git a/shell/src/main/java/org/apache/accumulo/shell/ShellOptionsJC.java b/shell/src/main/java/org/apache/accumulo/shell/ShellOptionsJC.java
index cdfc89e0d8..18a69ffc2f 100644
--- a/shell/src/main/java/org/apache/accumulo/shell/ShellOptionsJC.java
+++ b/shell/src/main/java/org/apache/accumulo/shell/ShellOptionsJC.java
@@ -256,7 +256,7 @@ public boolean isAuthTimeoutDisabled() {
return unrecognizedOptions;
}
- public String getClientConfigFile() {
+ public String getClientPropertiesFile() {
if (clientConfigFile == null) {
List<String> searchPaths = new LinkedList<>();
searchPaths.add(System.getProperty("user.home") + "/.accumulo/accumulo-client.properties");
@@ -278,8 +278,8 @@ public String getClientConfigFile() {
public Properties getClientProperties() {
Properties props = new Properties();
- if (getClientConfigFile() != null) {
- props = ClientInfoImpl.toProperties(getClientConfigFile());
+ if (getClientPropertiesFile() != null) {
+ props = ClientInfoImpl.toProperties(getClientPropertiesFile());
}
for (Map.Entry<String,String> entry : commandLineProperties.entrySet()) {
props.setProperty(entry.getKey(), entry.getValue());
diff --git a/test/src/main/java/org/apache/accumulo/harness/conf/StandaloneAccumuloClusterConfiguration.java b/test/src/main/java/org/apache/accumulo/harness/conf/StandaloneAccumuloClusterConfiguration.java
index b27286260b..d228c5f96b 100644
--- a/test/src/main/java/org/apache/accumulo/harness/conf/StandaloneAccumuloClusterConfiguration.java
+++ b/test/src/main/java/org/apache/accumulo/harness/conf/StandaloneAccumuloClusterConfiguration.java
@@ -104,8 +104,8 @@ public StandaloneAccumuloClusterConfiguration(File clientPropsFile) {
this.conf = getConfiguration(type);
this.clientPropsFile = clientPropsFile;
- clientInfo = Accumulo.newClient().forInstance(getInstanceName(), getZooKeepers())
- .usingToken(getAdminPrincipal(), getAdminToken()).info();
+ clientInfo = Accumulo.newClient().to(getInstanceName(), getZooKeepers())
+ .as(getAdminPrincipal(), getAdminToken()).info();
// The user Accumulo is running as
serverUser = conf.get(ACCUMULO_STANDALONE_SERVER_USER);
diff --git a/test/src/main/java/org/apache/accumulo/test/BatchWriterIterator.java b/test/src/main/java/org/apache/accumulo/test/BatchWriterIterator.java
index 0ada27ec90..42118ba2ee 100644
--- a/test/src/main/java/org/apache/accumulo/test/BatchWriterIterator.java
+++ b/test/src/main/java/org/apache/accumulo/test/BatchWriterIterator.java
@@ -167,8 +167,8 @@ private void parseOptions(Map<String,String> options) {
private void initBatchWriter() {
try {
- accumuloClient = Accumulo.newClient().forInstance(instanceName, zookeeperHost)
- .usingToken(username, auth).withZkTimeout(zookeeperTimeout).build();
+ accumuloClient = Accumulo.newClient().to(instanceName, zookeeperHost).as(username, auth)
+ .zkTimeout(zookeeperTimeout).build();
} catch (Exception e) {
log.error("failed to connect to Accumulo instance " + instanceName, e);
throw new RuntimeException(e);
diff --git a/test/src/main/java/org/apache/accumulo/test/IMMLGBenchmark.java b/test/src/main/java/org/apache/accumulo/test/IMMLGBenchmark.java
index d249691c5b..4384e2108a 100644
--- a/test/src/main/java/org/apache/accumulo/test/IMMLGBenchmark.java
+++ b/test/src/main/java/org/apache/accumulo/test/IMMLGBenchmark.java
@@ -51,8 +51,8 @@
public class IMMLGBenchmark {
public static void main(String[] args) throws Exception {
- AccumuloClient client = Accumulo.newClient().forInstance("test16", "localhost")
- .usingPassword("root", "secret").build();
+ AccumuloClient client = Accumulo.newClient().to("test16", "localhost").as("root", "secret")
+ .build();
int numlg = Integer.parseInt(args[0]);
diff --git a/test/src/main/java/org/apache/accumulo/test/ShellServerIT.java b/test/src/main/java/org/apache/accumulo/test/ShellServerIT.java
index cf08e06968..802419b59e 100644
--- a/test/src/main/java/org/apache/accumulo/test/ShellServerIT.java
+++ b/test/src/main/java/org/apache/accumulo/test/ShellServerIT.java
@@ -55,7 +55,6 @@
import java.util.concurrent.TimeUnit;
import org.apache.accumulo.core.Constants;
-import org.apache.accumulo.core.client.Accumulo;
import org.apache.accumulo.core.client.AccumuloClient;
import org.apache.accumulo.core.client.AccumuloException;
import org.apache.accumulo.core.client.AccumuloSecurityException;
@@ -176,7 +175,7 @@ public String getErrorMessage() {
TestShell(String user, String rootPass, String instanceName, String zookeepers, File configFile)
throws IOException {
- ClientInfo info = Accumulo.newClient().usingProperties(configFile.getAbsolutePath()).info();
+ ClientInfo info = ClientInfo.from(configFile.toPath());
// start the shell
output = new TestOutputStream();
input = new StringInputStream();
diff --git a/test/src/main/java/org/apache/accumulo/test/functional/AccumuloClientIT.java b/test/src/main/java/org/apache/accumulo/test/functional/AccumuloClientIT.java
index 487cdca7da..e006d7cc84 100644
--- a/test/src/main/java/org/apache/accumulo/test/functional/AccumuloClientIT.java
+++ b/test/src/main/java/org/apache/accumulo/test/functional/AccumuloClientIT.java
@@ -81,16 +81,15 @@ public void testAccumuloClientBuilder() throws Exception {
final String password = "testpassword";
c.securityOperations().createLocalUser(user, new PasswordToken(password));
- AccumuloClient client = Accumulo.newClient().forInstance(instanceName, zookeepers)
- .usingPassword(user, password).withZkTimeout(1234).build();
+ AccumuloClient client = Accumulo.newClient().to(instanceName, zookeepers).as(user, password)
+ .zkTimeout(1234).build();
assertEquals(instanceName, client.info().getInstanceName());
assertEquals(zookeepers, client.info().getZooKeepers());
assertEquals(user, client.whoami());
assertEquals(1234, client.info().getZooKeepersSessionTimeOut());
- ClientInfo info = Accumulo.newClient().forInstance(instanceName, zookeepers)
- .usingPassword(user, password).info();
+ ClientInfo info = Accumulo.newClient().to(instanceName, zookeepers).as(user, password).info();
assertEquals(instanceName, info.getInstanceName());
assertEquals(zookeepers, info.getZooKeepers());
assertEquals(user, info.getPrincipal());
@@ -103,7 +102,7 @@ public void testAccumuloClientBuilder() throws Exception {
props.put(ClientProperty.INSTANCE_ZOOKEEPERS_TIMEOUT.getKey(), "22s");
ClientProperty.setPassword(props, password);
client.close();
- client = Accumulo.newClient().usingProperties(props).build();
+ client = Accumulo.newClient().from(props).build();
assertEquals(instanceName, client.info().getInstanceName());
assertEquals(zookeepers, client.info().getZooKeepers());
@@ -114,8 +113,8 @@ public void testAccumuloClientBuilder() throws Exception {
final String password2 = "testpassword2";
c.securityOperations().createLocalUser(user2, new PasswordToken(password2));
- AccumuloClient client2 = Accumulo.newClient().usingClientInfo(client.info())
- .usingToken(user2, new PasswordToken(password2)).build();
+ AccumuloClient client2 = Accumulo.newClient().from(client.info())
+ .as(user2, new PasswordToken(password2)).build();
assertEquals(instanceName, client2.info().getInstanceName());
assertEquals(zookeepers, client2.info().getZooKeepers());
assertEquals(user2, client2.whoami());
@@ -152,7 +151,7 @@ public void testClose() throws Exception {
assertEquals(0, SingletonManager.getReservationCount());
assertEquals(Mode.CLIENT, SingletonManager.getMode());
- try (AccumuloClient c = Accumulo.newClient().usingClientInfo(getClientInfo()).build()) {
+ try (AccumuloClient c = Accumulo.newClient().from(getClientInfo()).build()) {
assertEquals(1, SingletonManager.getReservationCount());
c.tableOperations().create(tableName);
@@ -171,7 +170,7 @@ public void testClose() throws Exception {
assertEquals(0, SingletonManager.getReservationCount());
- AccumuloClient c = Accumulo.newClient().usingClientInfo(getClientInfo()).build();
+ AccumuloClient c = Accumulo.newClient().from(getClientInfo()).build();
assertEquals(1, SingletonManager.getReservationCount());
// ensure client created after everything was closed works
diff --git a/test/src/main/java/org/apache/accumulo/test/functional/ConfigurableMacBase.java b/test/src/main/java/org/apache/accumulo/test/functional/ConfigurableMacBase.java
index 98f664d345..f62dd2f3b1 100644
--- a/test/src/main/java/org/apache/accumulo/test/functional/ConfigurableMacBase.java
+++ b/test/src/main/java/org/apache/accumulo/test/functional/ConfigurableMacBase.java
@@ -201,9 +201,8 @@ protected ClientContext getClientContext() {
}
protected ClientInfo getClientInfo() {
- return Accumulo.newClient()
- .forInstance(getCluster().getInstanceName(), getCluster().getZooKeepers())
- .usingPassword("root", ROOT_PASSWORD).info();
+ return Accumulo.newClient().to(getCluster().getInstanceName(), getCluster().getZooKeepers())
+ .as("root", ROOT_PASSWORD).info();
}
protected ServerContext getServerContext() {
diff --git a/test/src/main/java/org/apache/accumulo/test/functional/ReadWriteIT.java b/test/src/main/java/org/apache/accumulo/test/functional/ReadWriteIT.java
index 29418a51c5..3d00a845bc 100644
--- a/test/src/main/java/org/apache/accumulo/test/functional/ReadWriteIT.java
+++ b/test/src/main/java/org/apache/accumulo/test/functional/ReadWriteIT.java
@@ -127,8 +127,8 @@ protected int defaultTimeoutSeconds() {
@Test(expected = RuntimeException.class)
public void invalidInstanceName() throws Exception {
- Accumulo.newClient().forInstance("fake_instance_name", cluster.getZooKeepers())
- .usingToken(getAdminPrincipal(), getAdminToken()).build();
+ Accumulo.newClient().to("fake_instance_name", cluster.getZooKeepers())
+ .as(getAdminPrincipal(), getAdminToken()).build();
}
@SuppressFBWarnings(value = {"PATH_TRAVERSAL_IN", "URLCONNECTION_SSRF_FD"},
diff --git a/test/src/main/java/org/apache/accumulo/test/mapred/AccumuloOutputFormatIT.java b/test/src/main/java/org/apache/accumulo/test/mapred/AccumuloOutputFormatIT.java
index e311c4afea..91867db5f9 100644
--- a/test/src/main/java/org/apache/accumulo/test/mapred/AccumuloOutputFormatIT.java
+++ b/test/src/main/java/org/apache/accumulo/test/mapred/AccumuloOutputFormatIT.java
@@ -169,8 +169,7 @@ public int run(String[] args) throws Exception {
job.setInputFormat(AccumuloInputFormat.class);
- ClientInfo info = Accumulo.newClient().forInstance(instanceName, zooKeepers)
- .usingPassword(user, pass).info();
+ ClientInfo info = Accumulo.newClient().to(instanceName, zooKeepers).as(user, pass).info();
AccumuloInputFormat.setClientInfo(job, info);
AccumuloInputFormat.setInputTableName(job, table1);
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services