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 2022/02/01 20:01:48 UTC

[GitHub] [accumulo] milleruntime opened a new pull request #2451: Create InstanceId to replace use of String

milleruntime opened a new pull request #2451:
URL: https://github.com/apache/accumulo/pull/2451


   * Create InstanceId object to replace use of String across the code
   * Create new API method on InstanceOperations called getInstanceId()
   * Deprecate API method InstanceOperations getInstanceID()


-- 
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



[GitHub] [accumulo] milleruntime merged pull request #2451: Create InstanceId to replace use of String

Posted by GitBox <gi...@apache.org>.
milleruntime merged pull request #2451:
URL: https://github.com/apache/accumulo/pull/2451


   


-- 
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



[GitHub] [accumulo] milleruntime commented on pull request #2451: Create InstanceId to replace use of String

Posted by GitBox <gi...@apache.org>.
milleruntime commented on pull request #2451:
URL: https://github.com/apache/accumulo/pull/2451#issuecomment-1027910414


   > I was thinking that we might want to make `AbstractId.toString` final, so it always returns `.canonical()`, so that it's contractually consistent, just because there's lots of places where it's logged/concatenated/etc. with other strings, and it's assuming that it's the same as `.canonical()`, but that's not necessarily guaranteed.
   
   That is a good idea. It will help with the other *Id types as well.


-- 
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



[GitHub] [accumulo] milleruntime commented on pull request #2451: Create InstanceId to replace use of String

Posted by GitBox <gi...@apache.org>.
milleruntime commented on pull request #2451:
URL: https://github.com/apache/accumulo/pull/2451#issuecomment-1027290175


   I actually think this may have already found a bug in `AuthenticationTokenIdentifier` that is being exposed by the now failing test `SaslDigestCallbackHandlerTest`.


-- 
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



[GitHub] [accumulo] DomGarguilo commented on a change in pull request #2451: Create InstanceId to replace use of String

Posted by GitBox <gi...@apache.org>.
DomGarguilo commented on a change in pull request #2451:
URL: https://github.com/apache/accumulo/pull/2451#discussion_r796990059



##########
File path: core/src/main/java/org/apache/accumulo/core/data/InstanceId.java
##########
@@ -0,0 +1,71 @@
+/*
+ * 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.data;
+
+import java.util.Objects;
+import java.util.UUID;
+import java.util.concurrent.ExecutionException;
+
+import com.google.common.cache.Cache;
+import com.google.common.cache.CacheBuilder;
+
+/**
+ * A strongly typed representation of an Accumulo instance ID. The constructor for this class will
+ * throw an error if the canonical parameter is null.
+ *
+ * @since 2.1.0
+ */
+public class InstanceId extends AbstractId<InstanceId> {
+  private static final long serialVersionUID = 1L;
+  // cache is for canonicalization/deduplication of created objects,
+  // to limit the number of InstanceId objects in the JVM at any given moment
+  // WeakReferences are used because we don't need them to stick around any longer than they need to
+  static final Cache<String,InstanceId> cache = CacheBuilder.newBuilder().weakValues().build();
+
+  private InstanceId(String canonical) {
+    super(canonical);
+  }
+
+  /**
+   * Get a InstanceId object for the provided canonical string. This is guaranteed to be non-null
+   *
+   * @param canonical
+   *          Instance ID string
+   * @return InstanceId object
+   */
+  public static InstanceId of(final String canonical) {
+    try {

Review comment:
       Should we check that `canonical` is non null here? Similar to how `uuid` is checked in the method below?
   




-- 
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



[GitHub] [accumulo] milleruntime commented on a change in pull request #2451: Create InstanceId to replace use of String

Posted by GitBox <gi...@apache.org>.
milleruntime commented on a change in pull request #2451:
URL: https://github.com/apache/accumulo/pull/2451#discussion_r796993694



##########
File path: core/src/main/java/org/apache/accumulo/core/data/InstanceId.java
##########
@@ -0,0 +1,71 @@
+/*
+ * 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.data;
+
+import java.util.Objects;
+import java.util.UUID;
+import java.util.concurrent.ExecutionException;
+
+import com.google.common.cache.Cache;
+import com.google.common.cache.CacheBuilder;
+
+/**
+ * A strongly typed representation of an Accumulo instance ID. The constructor for this class will
+ * throw an error if the canonical parameter is null.
+ *
+ * @since 2.1.0
+ */
+public class InstanceId extends AbstractId<InstanceId> {
+  private static final long serialVersionUID = 1L;
+  // cache is for canonicalization/deduplication of created objects,
+  // to limit the number of InstanceId objects in the JVM at any given moment
+  // WeakReferences are used because we don't need them to stick around any longer than they need to
+  static final Cache<String,InstanceId> cache = CacheBuilder.newBuilder().weakValues().build();
+
+  private InstanceId(String canonical) {
+    super(canonical);
+  }
+
+  /**
+   * Get a InstanceId object for the provided canonical string. This is guaranteed to be non-null
+   *
+   * @param canonical
+   *          Instance ID string
+   * @return InstanceId object
+   */
+  public static InstanceId of(final String canonical) {
+    try {

Review comment:
       This is done in the constructor of the parent class `AbstractId`




-- 
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