You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@accumulo.apache.org by mm...@apache.org on 2020/03/24 19:23:36 UTC
[accumulo] branch master updated: Drop overloaded ClientContext
constructors (#1570)
This is an automated email from the ASF dual-hosted git repository.
mmiller 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 35e6d6b Drop overloaded ClientContext constructors (#1570)
35e6d6b is described below
commit 35e6d6bc1ea7a7080b2b7f190539d4d592667edf
Author: Mike Miller <mm...@apache.org>
AuthorDate: Tue Mar 24 15:23:30 2020 -0400
Drop overloaded ClientContext constructors (#1570)
* Moved some logic to classes creating ClientContext objects
* Overloaded constructors obscured the object creation and static
singleton management
---
.../accumulo/core/client/ZooKeeperInstance.java | 7 +++++-
.../accumulo/core/clientImpl/ClientContext.java | 26 ++++++++--------------
.../org/apache/accumulo/server/ServerContext.java | 3 ++-
.../tserver/replication/AccumuloReplicaSystem.java | 4 +++-
4 files changed, 20 insertions(+), 20 deletions(-)
diff --git a/core/src/main/java/org/apache/accumulo/core/client/ZooKeeperInstance.java b/core/src/main/java/org/apache/accumulo/core/client/ZooKeeperInstance.java
index 748587b..a477d87 100644
--- a/core/src/main/java/org/apache/accumulo/core/client/ZooKeeperInstance.java
+++ b/core/src/main/java/org/apache/accumulo/core/client/ZooKeeperInstance.java
@@ -28,8 +28,10 @@ import java.util.concurrent.TimeUnit;
import org.apache.accumulo.core.client.security.tokens.AuthenticationToken;
import org.apache.accumulo.core.clientImpl.ClientConfConverter;
import org.apache.accumulo.core.clientImpl.ClientContext;
+import org.apache.accumulo.core.clientImpl.ClientInfo;
import org.apache.accumulo.core.clientImpl.ClientInfoImpl;
import org.apache.accumulo.core.clientImpl.InstanceOperationsImpl;
+import org.apache.accumulo.core.conf.AccumuloConfiguration;
import org.apache.accumulo.core.conf.ClientProperty;
import org.apache.accumulo.core.conf.ConfigurationTypeHelper;
import org.apache.accumulo.core.metadata.schema.TabletMetadata.Location;
@@ -37,6 +39,7 @@ import org.apache.accumulo.core.metadata.schema.TabletMetadata.LocationType;
import org.apache.accumulo.core.metadata.schema.TabletsMetadata;
import org.apache.accumulo.core.singletons.SingletonManager;
import org.apache.accumulo.core.singletons.SingletonManager.Mode;
+import org.apache.accumulo.core.singletons.SingletonReservation;
import org.apache.accumulo.core.util.OpTimer;
import org.apache.accumulo.fate.zookeeper.ZooCache;
import org.apache.accumulo.fate.zookeeper.ZooCacheFactory;
@@ -186,8 +189,10 @@ public class ZooKeeperInstance implements Instance {
Properties properties = ClientConfConverter.toProperties(clientConf);
properties.setProperty(ClientProperty.AUTH_PRINCIPAL.getKey(), principal);
properties.setProperty(ClientProperty.INSTANCE_NAME.getKey(), getInstanceName());
+ ClientInfo info = new ClientInfoImpl(properties, token);
+ AccumuloConfiguration serverConf = ClientConfConverter.toAccumuloConf(properties);
return new org.apache.accumulo.core.clientImpl.ConnectorImpl(
- new ClientContext(new ClientInfoImpl(properties, token)));
+ new ClientContext(SingletonReservation.noop(), info, serverConf));
}
@Override
diff --git a/core/src/main/java/org/apache/accumulo/core/clientImpl/ClientContext.java b/core/src/main/java/org/apache/accumulo/core/clientImpl/ClientContext.java
index d5adef6..39239a0 100644
--- a/core/src/main/java/org/apache/accumulo/core/clientImpl/ClientContext.java
+++ b/core/src/main/java/org/apache/accumulo/core/clientImpl/ClientContext.java
@@ -128,22 +128,12 @@ public class ClientContext implements AccumuloClient {
return () -> Suppliers.memoizeWithExpiration(s::get, 100, TimeUnit.MILLISECONDS).get();
}
- public ClientContext(Properties clientProperties) {
- this(ClientInfo.from(clientProperties));
- }
-
- public ClientContext(SingletonReservation reservation, ClientInfo info) {
- this(reservation, info, ClientConfConverter.toAccumuloConf(info.getProperties()));
- }
-
- public ClientContext(ClientInfo info) {
- this(info, ClientConfConverter.toAccumuloConf(info.getProperties()));
- }
-
- public ClientContext(ClientInfo info, AccumuloConfiguration serverConf) {
- this(SingletonReservation.noop(), info, serverConf);
- }
-
+ /**
+ * Create a client context with the provided configuration. Legacy client code must provide a
+ * no-op SingletonReservation to preserve behavior prior to 2.x. Clients since 2.x should call
+ * Accumulo.newClient() builder, which will create a client reservation in
+ * {@link ClientBuilderImpl#buildClient}
+ */
public ClientContext(SingletonReservation reservation, ClientInfo info,
AccumuloConfiguration serverConf) {
this.info = info;
@@ -684,7 +674,9 @@ public class ClientContext implements AccumuloClient {
SingletonReservation reservation = SingletonManager.getClientReservation();
try {
// ClientContext closes reservation unless a RuntimeException is thrown
- return new ClientContext(reservation, cbi.getClientInfo());
+ ClientInfo info = cbi.getClientInfo();
+ AccumuloConfiguration config = ClientConfConverter.toAccumuloConf(info.getProperties());
+ return new ClientContext(reservation, info, config);
} catch (RuntimeException e) {
reservation.close();
throw e;
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 d7c6150..7a48eac 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
@@ -30,6 +30,7 @@ import org.apache.accumulo.core.crypto.CryptoServiceFactory;
import org.apache.accumulo.core.crypto.CryptoServiceFactory.ClassloaderType;
import org.apache.accumulo.core.metadata.schema.Ample;
import org.apache.accumulo.core.rpc.SslConnectionParams;
+import org.apache.accumulo.core.singletons.SingletonReservation;
import org.apache.accumulo.core.spi.crypto.CryptoService;
import org.apache.accumulo.fate.zookeeper.ZooReaderWriter;
import org.apache.accumulo.server.conf.ServerConfigurationFactory;
@@ -62,7 +63,7 @@ public class ServerContext extends ClientContext {
}
private ServerContext(ServerInfo info) {
- super(info, info.getSiteConfiguration());
+ super(SingletonReservation.noop(), info, info.getSiteConfiguration());
this.info = info;
zooReaderWriter = new ZooReaderWriter(info.getSiteConfiguration());
}
diff --git a/server/tserver/src/main/java/org/apache/accumulo/tserver/replication/AccumuloReplicaSystem.java b/server/tserver/src/main/java/org/apache/accumulo/tserver/replication/AccumuloReplicaSystem.java
index 1e11adf..770d177 100644
--- a/server/tserver/src/main/java/org/apache/accumulo/tserver/replication/AccumuloReplicaSystem.java
+++ b/server/tserver/src/main/java/org/apache/accumulo/tserver/replication/AccumuloReplicaSystem.java
@@ -59,6 +59,7 @@ import org.apache.accumulo.core.replication.thrift.ReplicationServicer;
import org.apache.accumulo.core.replication.thrift.ReplicationServicer.Client;
import org.apache.accumulo.core.replication.thrift.WalEdits;
import org.apache.accumulo.core.securityImpl.thrift.TCredentials;
+import org.apache.accumulo.core.singletons.SingletonReservation;
import org.apache.accumulo.core.trace.TraceUtil;
import org.apache.accumulo.core.util.HostAndPort;
import org.apache.accumulo.server.ServerContext;
@@ -585,7 +586,8 @@ public class AccumuloReplicaSystem implements ReplicaSystem {
properties.setProperty(ClientProperty.AUTH_PRINCIPAL.getKey(), principal);
ClientProperty.setAuthenticationToken(properties, token);
- return new ClientContext(ClientInfo.from(properties, token), localConf);
+ return new ClientContext(SingletonReservation.noop(), ClientInfo.from(properties, token),
+ localConf);
}
protected Set<Integer> consumeWalPrefix(ReplicationTarget target, DataInputStream wal,