You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@accumulo.apache.org by "keith-turner (via GitHub)" <gi...@apache.org> on 2023/07/18 20:53:22 UTC
[GitHub] [accumulo] keith-turner commented on a diff in pull request #3626: Deprecate InstanceOperations methods that take a String for server
keith-turner commented on code in PR #3626:
URL: https://github.com/apache/accumulo/pull/3626#discussion_r1267278602
##########
core/src/main/java/org/apache/accumulo/core/client/admin/InstanceOperations.java:
##########
@@ -172,20 +174,31 @@ Map<String,String> modifyProperties(Consumer<Map<String,String>> mapMutator)
* @return a list of locations in <code>hostname:port</code> form.
* @since 2.1.0
*/
+ @Deprecated
List<String> getManagerLocations();
/**
* Returns the locations of the active scan servers
*
* @return A set of currently active scan servers.
*/
+ @Deprecated
Set<String> getScanServers();
+ /**
+ * Returns the locations of the active scan servers
+ *
+ * @return A set of currently active scan servers.
+ * @since 3.0.0
+ */
+ Set<Server> getServers(ServerType type);
Review Comment:
Wondering how this method could also return information about a servers group. Was thinking through the following possible options.
1. Group info could be added to the Sever class.
2. This method could return something like Map<Server, ServerInfo> where ServerInfo includes the group
3. Could add a new method to `String getGroup(Server server)` to InstanceOperations.
##########
core/src/main/java/org/apache/accumulo/core/client/admin/servers/Server.java:
##########
@@ -0,0 +1,110 @@
+/*
+ * 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
+ *
+ * https://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.client.admin.servers;
+
+import java.util.Comparator;
+import java.util.Objects;
+
+import com.google.common.base.Preconditions;
+
+public abstract class Server implements Comparator<Server>, Comparable<Server> {
Review Comment:
Wonder if this should have a more specific name. Could be ServerAddress or AccumuloServerAddress. If the group info were to be included in this class, then maybe AccumuloServer or AccumuloServerInfo
##########
core/src/main/java/org/apache/accumulo/core/client/admin/InstanceOperations.java:
##########
@@ -195,9 +208,20 @@ Map<String,String> modifyProperties(Consumer<Map<String,String>> mapMutator)
* {@code <ip address>:<port>}
* @return A list of active scans on tablet server.
*/
+ @Deprecated
List<ActiveScan> getActiveScans(String tserver)
throws AccumuloException, AccumuloSecurityException;
+ /**
+ * List the active scans on a tablet server.
+ *
+ * @param server server type and address
+ * @return A list of active scans on tablet server.
+ * @since 3.0.0
+ */
+ List<ActiveScan> getActiveScans(Server server)
Review Comment:
Unless there is a specific reason to use list, using a more generic type gives more flexibility w/ changing the impl
```suggestion
Collection<ActiveScan> getActiveScans(Server server)
```
##########
core/src/main/java/org/apache/accumulo/core/client/admin/servers/Server.java:
##########
@@ -0,0 +1,110 @@
+/*
+ * 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
+ *
+ * https://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.client.admin.servers;
+
+import java.util.Comparator;
+import java.util.Objects;
+
+import com.google.common.base.Preconditions;
+
+public abstract class Server implements Comparator<Server>, Comparable<Server> {
+
+ private final ServerType type;
+ private final String host;
+ private final int port;
+
+ protected Server(ServerType type, String host, int port) {
+ super();
+ Preconditions.checkArgument(port > 0);
+ this.type = Objects.requireNonNull(type);
+ this.host = Objects.requireNonNull(host);
+ this.port = port;
+ }
+
+ public ServerType getType() {
+ return type;
+ }
+
+ public String getHost() {
+ return host;
+ }
+
+ public int getPort() {
+ return port;
+ }
+
+ @Override
+ public int compare(Server first, Server second) {
+ if (first == second) {
+ return 0;
+ }
+ if (first != null && second == null) {
Review Comment:
Why handle nulls here?
##########
core/src/main/java/org/apache/accumulo/core/client/admin/InstanceOperations.java:
##########
@@ -172,20 +174,31 @@ Map<String,String> modifyProperties(Consumer<Map<String,String>> mapMutator)
* @return a list of locations in <code>hostname:port</code> form.
* @since 2.1.0
*/
+ @Deprecated
Review Comment:
Somehow information can be added to the deprecation annotation that indicates the version where the deprecation happened.
##########
core/src/main/java/org/apache/accumulo/core/clientImpl/InstanceOperationsImpl.java:
##########
@@ -236,12 +246,61 @@ public List<String> getTabletServers() {
}
@Override
+ public Set<Server> getServers(ServerType type) {
+ Set<Server> results = new HashSet<>();
+ switch (type) {
+ case COMPACTOR:
+ throw new IllegalArgumentException(
+ "Use ExternalCompactionUtil.getCompactorAddrs instead as it will return the compactor grouping");
Review Comment:
ExternalCompactionUtil.getCompactorAddrs is not public API, should not recommend calling it from public API method.
##########
core/src/main/java/org/apache/accumulo/core/client/admin/servers/Server.java:
##########
@@ -0,0 +1,110 @@
+/*
+ * 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
+ *
+ * https://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.client.admin.servers;
+
+import java.util.Comparator;
+import java.util.Objects;
+
+import com.google.common.base.Preconditions;
+
+public abstract class Server implements Comparator<Server>, Comparable<Server> {
+
+ private final ServerType type;
+ private final String host;
+ private final int port;
+
+ protected Server(ServerType type, String host, int port) {
+ super();
+ Preconditions.checkArgument(port > 0);
+ this.type = Objects.requireNonNull(type);
+ this.host = Objects.requireNonNull(host);
+ this.port = port;
+ }
+
+ public ServerType getType() {
+ return type;
+ }
+
+ public String getHost() {
+ return host;
+ }
+
+ public int getPort() {
+ return port;
+ }
+
+ @Override
+ public int compare(Server first, Server second) {
+ if (first == second) {
+ return 0;
+ }
+ if (first != null && second == null) {
+ return 1;
+ }
+ if (first == null && second != null) {
+ return -1;
+ }
+ int result = first.getHost().compareTo(second.getHost());
+ if (result == 0) {
+ result = Integer.compare(first.getPort(), second.getPort());
+ if (result == 0) {
+ result = first.getType().compareTo(second.getType());
+ }
+ }
+ return result;
+ }
+
+ @Override
+ public int compareTo(Server other) {
+ return compare(this, other);
+ }
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((host == null) ? 0 : host.hashCode());
Review Comment:
The constructor does not allow null, so do not need to check for it here.
##########
core/src/main/java/org/apache/accumulo/core/client/admin/InstanceOperations.java:
##########
@@ -195,9 +208,20 @@ Map<String,String> modifyProperties(Consumer<Map<String,String>> mapMutator)
* {@code <ip address>:<port>}
* @return A list of active scans on tablet server.
*/
+ @Deprecated
List<ActiveScan> getActiveScans(String tserver)
throws AccumuloException, AccumuloSecurityException;
+ /**
+ * List the active scans on a tablet server.
+ *
+ * @param server server type and address
+ * @return A list of active scans on tablet server.
+ * @since 3.0.0
Review Comment:
It would be nice to have something like the following, not sure if the following javadoc syntax is correct.
```suggestion
* @throws IllegalArgumentException when the type of server is not SCAN_SERVER or TABLET_SERVER
* @since 3.0.0
```
##########
core/src/main/java/org/apache/accumulo/core/clientImpl/InstanceOperationsImpl.java:
##########
@@ -344,9 +433,19 @@ public List<ActiveCompaction> getActiveCompactions()
}
@Override
+ @Deprecated
public void ping(String tserver) throws AccumuloException {
- try (
- TTransport transport = createTransport(AddressUtil.parseAddress(tserver, false), context)) {
+ HostAndPort hp = HostAndPort.fromString(tserver);
+ ping(new TabletServer(hp.getHost(), hp.getPort()));
+ }
+
+ @Override
+ public void ping(Server server) throws AccumuloException {
+ @SuppressWarnings("unused")
+ var unused = Objects.nonNull(server);
+ Preconditions.checkArgument(server.getType() == ServerType.TABLET_SERVER);
Review Comment:
Would be a follow on issue, would be nice to make this work w/ all the serer types.
##########
core/src/main/java/org/apache/accumulo/core/summary/Gatherer.java:
##########
@@ -158,6 +158,11 @@ private TSummaryRequest getRequest() {
return request;
}
+ @SuppressWarnings("deprecation")
+ private List<String> getTabletServers() {
+ return ctx.instanceOperations().getTabletServers();
Review Comment:
Could this use the new method and avoid the suppression?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@accumulo.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org