You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@ozone.apache.org by GitBox <gi...@apache.org> on 2021/06/02 18:37:42 UTC

[GitHub] [ozone] xiaoyuyao commented on a change in pull request #2216: HDDS-5154. Add SCM GRPC server to publish CRL update.

xiaoyuyao commented on a change in pull request #2216:
URL: https://github.com/apache/ozone/pull/2216#discussion_r644225922



##########
File path: hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/update/server/SCMUpdateClientManager.java
##########
@@ -0,0 +1,133 @@
+/*
+ * 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.hadoop.hdds.scm.update.server;
+
+import org.apache.ratis.thirdparty.io.grpc.Status;
+import org.apache.ratis.thirdparty.io.grpc.stub.StreamObserver;
+import org.apache.hadoop.hdds.protocol.scm.proto.SCMUpdateServiceProtos.Type;
+import org.apache.hadoop.hdds.protocol.scm.proto.SCMUpdateServiceProtos.UpdateRequest;
+import org.apache.hadoop.hdds.protocol.scm.proto.SCMUpdateServiceProtos.UpdateResponse;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.Map;
+import java.util.UUID;
+import java.util.concurrent.ConcurrentHashMap;
+
+public class SCMUpdateClientManager {
+  private static final Logger LOG =
+      LoggerFactory.getLogger(SCMUpdateClientManager.class);
+  private Map<UUID, SCMUpdateClientInfo> clients;
+  private Map<Type, SCMUpdateHandler> handlers;
+
+  public SCMUpdateClientManager() {
+    clients = new ConcurrentHashMap<>();
+    handlers = new ConcurrentHashMap<>();
+  }
+
+  public void registerHandler(SCMUpdateHandler handler) {
+    handlers.put(handler.getType(), handler);
+  }
+
+  public void unRegisterHandler(Type type) {
+    handlers.remove(type);
+  }
+
+  public UUID addClient() {
+    UUID clientId = UUID.randomUUID();

Review comment:
       good point! Add a retry with log to handle collision even chance is low. 




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

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org