This is an automated email from the ASF dual-hosted git repository.

adoroszlai pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/ozone.git


The following commit(s) were added to refs/heads/master by this push:
     new 68c709d4c81 HDDS-15243. Remove unused GenericRefreshProtocol, 
RefreshCallQueueProtocol (#10244)
68c709d4c81 is described below

commit 68c709d4c8106ad84404ed281953f634b9ae6c0b
Author: Doroszlai, Attila <[email protected]>
AuthorDate: Wed May 13 07:51:49 2026 +0200

    HDDS-15243. Remove unused GenericRefreshProtocol, RefreshCallQueueProtocol 
(#10244)
---
 .../org/apache/hadoop/ipc_/CallQueueManager.java   |  75 ------------
 .../apache/hadoop/ipc_/GenericRefreshProtocol.java |  49 --------
 .../hadoop/ipc_/RefreshCallQueueProtocol.java      |  44 -------
 .../org/apache/hadoop/ipc_/RefreshHandler.java     |  32 -----
 .../org/apache/hadoop/ipc_/RefreshRegistry.java    | 134 ---------------------
 .../org/apache/hadoop/ipc_/RefreshResponse.java    |  76 ------------
 .../main/java/org/apache/hadoop/ipc_/Server.java   |  14 ---
 7 files changed, 424 deletions(-)

diff --git 
a/hadoop-hdds/common/src/main/java/org/apache/hadoop/ipc_/CallQueueManager.java 
b/hadoop-hdds/common/src/main/java/org/apache/hadoop/ipc_/CallQueueManager.java
index f52a606bdca..a2d53def35f 100644
--- 
a/hadoop-hdds/common/src/main/java/org/apache/hadoop/ipc_/CallQueueManager.java
+++ 
b/hadoop-hdds/common/src/main/java/org/apache/hadoop/ipc_/CallQueueManager.java
@@ -43,10 +43,6 @@ public class CallQueueManager<E extends Schedulable>
     extends AbstractQueue<E> implements BlockingQueue<E> {
   public static final Logger LOG =
       LoggerFactory.getLogger(CallQueueManager.class);
-  // Number of checkpoints for empty queue.
-  private static final int CHECKPOINT_NUM = 20;
-  // Interval to check empty queue.
-  private static final long CHECKPOINT_INTERVAL_MS = 10;
 
   @SuppressWarnings("unchecked")
   static <E> Class<? extends BlockingQueue<E>> convertQueueClass(
@@ -86,14 +82,6 @@ public CallQueueManager(Class<? extends BlockingQueue<E>> 
backingClass,
         backingClass, maxQueueSize, schedulerClass, clientBackOffEnabled);
   }
 
-  CallQueueManager(BlockingQueue<E> queue, RpcScheduler scheduler,
-      boolean clientBackOffEnabled) {
-    this.putRef = new AtomicReference<BlockingQueue<E>>(queue);
-    this.takeRef = new AtomicReference<BlockingQueue<E>>(queue);
-    this.scheduler = scheduler;
-    this.clientBackOffEnabled = clientBackOffEnabled;
-  }
-
   private static <T extends RpcScheduler> T createScheduler(
       Class<T> theClass, int priorityLevels, String ns, Configuration conf) {
     // Used for custom, configurable scheduler
@@ -346,69 +334,6 @@ private static int parseNumLevels(String ns, Configuration 
conf) {
     return retval;
   }
 
-  /**
-   * Replaces active queue with the newly requested one and transfers
-   * all calls to the newQ before returning.
-   *
-   * @param schedulerClass input schedulerClass.
-   * @param queueClassToUse input queueClassToUse.
-   * @param maxSize input maxSize.
-   * @param ns input ns.
-   * @param conf input configuration.
-   */
-  public synchronized void swapQueue(
-      Class<? extends RpcScheduler> schedulerClass,
-      Class<? extends BlockingQueue<E>> queueClassToUse, int maxSize,
-      String ns, Configuration conf) {
-    int priorityLevels = parseNumLevels(ns, conf);
-    this.scheduler.stop();
-    RpcScheduler newScheduler = createScheduler(schedulerClass, priorityLevels,
-        ns, conf);
-    BlockingQueue<E> newQ = createCallQueueInstance(queueClassToUse,
-        priorityLevels, maxSize, ns, conf);
-
-    // Our current queue becomes the old queue
-    BlockingQueue<E> oldQ = putRef.get();
-
-    // Swap putRef first: allow blocked puts() to be unblocked
-    putRef.set(newQ);
-
-    // Wait for handlers to drain the oldQ
-    while (!queueIsReallyEmpty(oldQ)) {}
-
-    // Swap takeRef to handle new calls
-    takeRef.set(newQ);
-
-    this.scheduler = newScheduler;
-
-    LOG.info("Old Queue: " + stringRepr(oldQ) + ", " +
-      "Replacement: " + stringRepr(newQ));
-  }
-
-  /**
-   * Checks if queue is empty by checking at CHECKPOINT_NUM points with
-   * CHECKPOINT_INTERVAL_MS interval.
-   * This doesn't mean the queue might not fill up at some point later, but
-   * it should decrease the probability that we lose a call this way.
-   */
-  private boolean queueIsReallyEmpty(BlockingQueue<?> q) {
-    for (int i = 0; i < CHECKPOINT_NUM; i++) {
-      try {
-        Thread.sleep(CHECKPOINT_INTERVAL_MS);
-      } catch (InterruptedException ie) {
-        return false;
-      }
-      if (!q.isEmpty()) {
-        return false;
-      }
-    }
-    return true;
-  }
-
-  private String stringRepr(Object o) {
-    return o.getClass().getName() + '@' + Integer.toHexString(o.hashCode());
-  }
-
   @Override
   public int drainTo(Collection<? super E> c) {
     return takeRef.get().drainTo(c);
diff --git 
a/hadoop-hdds/common/src/main/java/org/apache/hadoop/ipc_/GenericRefreshProtocol.java
 
b/hadoop-hdds/common/src/main/java/org/apache/hadoop/ipc_/GenericRefreshProtocol.java
deleted file mode 100644
index 68027aa7ef4..00000000000
--- 
a/hadoop-hdds/common/src/main/java/org/apache/hadoop/ipc_/GenericRefreshProtocol.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/**
- * 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.ipc_;
-
-import java.io.IOException;
-import java.util.Collection;
-
-import org.apache.hadoop.fs.CommonConfigurationKeys;
-import org.apache.hadoop.io.retry.Idempotent;
-import org.apache.hadoop.security.KerberosInfo;
-
-/**
- * Protocol which is used to refresh arbitrary things at runtime.
- */
-@KerberosInfo(
-    
serverPrincipal=CommonConfigurationKeys.HADOOP_SECURITY_SERVICE_USER_NAME_KEY)
-public interface GenericRefreshProtocol {
-  /**
-   * Version 1: Initial version.
-   */
-  public static final long versionID = 1L;
-
-  /**
-   * Refresh the resource based on identity passed in.
-   *
-   * @param identifier input identifier.
-   * @param args input args.
-   * @throws IOException raised on errors performing I/O.
-   * @return Collection RefreshResponse.
-   */
-  @Idempotent
-  Collection<RefreshResponse> refresh(String identifier, String[] args)
-      throws IOException;
-}
diff --git 
a/hadoop-hdds/common/src/main/java/org/apache/hadoop/ipc_/RefreshCallQueueProtocol.java
 
b/hadoop-hdds/common/src/main/java/org/apache/hadoop/ipc_/RefreshCallQueueProtocol.java
deleted file mode 100644
index b5348c8dfbc..00000000000
--- 
a/hadoop-hdds/common/src/main/java/org/apache/hadoop/ipc_/RefreshCallQueueProtocol.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/**
- * 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.ipc_;
-
-import java.io.IOException;
-
-import org.apache.hadoop.fs.CommonConfigurationKeys;
-import org.apache.hadoop.io.retry.Idempotent;
-import org.apache.hadoop.security.KerberosInfo;
-
-/**
- * Protocol which is used to refresh the call queue in use currently.
- */
-@KerberosInfo(
-    
serverPrincipal=CommonConfigurationKeys.HADOOP_SECURITY_SERVICE_USER_NAME_KEY)
-public interface RefreshCallQueueProtocol {
-  
-  /**
-   * Version 1: Initial version
-   */
-  public static final long versionID = 1L;
-
-  /**
-   * Refresh the callqueue.
-   * @throws IOException raised on errors performing I/O.
-   */
-  @Idempotent
-  void refreshCallQueue() throws IOException;
-}
diff --git 
a/hadoop-hdds/common/src/main/java/org/apache/hadoop/ipc_/RefreshHandler.java 
b/hadoop-hdds/common/src/main/java/org/apache/hadoop/ipc_/RefreshHandler.java
deleted file mode 100644
index ededbcb9b9b..00000000000
--- 
a/hadoop-hdds/common/src/main/java/org/apache/hadoop/ipc_/RefreshHandler.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/**
- * 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.ipc_;
-
-
-/**
- * Used to registry custom methods to refresh at runtime.
- */
-public interface RefreshHandler {
-  /**
-   * Implement this method to accept refresh requests from the administrator.
-   * @param identifier is the identifier you registered earlier
-   * @param args contains a list of string args from the administrator
-   * @return a RefreshResponse
-   */
-  RefreshResponse handleRefresh(String identifier, String[] args);
-}
diff --git 
a/hadoop-hdds/common/src/main/java/org/apache/hadoop/ipc_/RefreshRegistry.java 
b/hadoop-hdds/common/src/main/java/org/apache/hadoop/ipc_/RefreshRegistry.java
deleted file mode 100644
index 3f39f0680a1..00000000000
--- 
a/hadoop-hdds/common/src/main/java/org/apache/hadoop/ipc_/RefreshRegistry.java
+++ /dev/null
@@ -1,134 +0,0 @@
-/**
- * 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.ipc_;
-
-import java.util.ArrayList;
-import java.util.Collection;
-
-import com.google.common.base.Joiner;
-import com.google.common.collect.HashMultimap;
-import com.google.common.collect.Multimap;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * Used to registry custom methods to refresh at runtime.
- * Each identifier maps to one or more RefreshHandlers.
- */
-public class RefreshRegistry {
-  public static final Logger LOG =
-      LoggerFactory.getLogger(RefreshRegistry.class);
-
-  // Used to hold singleton instance
-  private static class RegistryHolder {
-    @SuppressWarnings("All")
-    public static RefreshRegistry registry = new RefreshRegistry();
-  }
-
-  // Singleton access
-  public static RefreshRegistry defaultRegistry() {
-    return RegistryHolder.registry;
-  }
-
-  private final Multimap<String, RefreshHandler> handlerTable;
-
-  public RefreshRegistry() {
-    handlerTable = HashMultimap.create();
-  }
-
-  /**
-   * Registers an object as a handler for a given identity.
-   * Note: will prevent handler from being GC'd, object should unregister 
itself
-   *  when done
-   * @param identifier a unique identifier for this resource,
-   *                   such as org.apache.hadoop.blacklist
-   * @param handler the object to register
-   */
-  public synchronized void register(String identifier, RefreshHandler handler) 
{
-    if (identifier == null) {
-      throw new NullPointerException("Identifier cannot be null");
-    }
-    handlerTable.put(identifier, handler);
-  }
-
-  /**
-   * Remove the registered object for a given identity.
-   * @param identifier the resource to unregister
-   * @param handler input handler.
-   * @return the true if removed
-   */
-  public synchronized boolean unregister(String identifier, RefreshHandler 
handler) {
-    return handlerTable.remove(identifier, handler);
-  }
-
-  public synchronized void unregisterAll(String identifier) {
-    handlerTable.removeAll(identifier);
-  }
-
-  /**
-   * Lookup the responsible handler and return its result.
-   * This should be called by the RPC server when it gets a refresh request.
-   * @param identifier the resource to refresh
-   * @param args the arguments to pass on, not including the program name
-   * @throws IllegalArgumentException on invalid identifier
-   * @return the response from the appropriate handler
-   */
-  public synchronized Collection<RefreshResponse> dispatch(String identifier, 
String[] args) {
-    Collection<RefreshHandler> handlers = handlerTable.get(identifier);
-
-    if (handlers.size() == 0) {
-      String msg = "Identifier '" + identifier +
-        "' does not exist in RefreshRegistry. Valid options are: " +
-        Joiner.on(", ").join(handlerTable.keySet());
-
-      throw new IllegalArgumentException(msg);
-    }
-
-    ArrayList<RefreshResponse> responses =
-      new ArrayList<RefreshResponse>(handlers.size());
-
-    // Dispatch to each handler and store response
-    for(RefreshHandler handler : handlers) {
-      RefreshResponse response;
-
-      // Run the handler
-      try {
-        response = handler.handleRefresh(identifier, args);
-        if (response == null) {
-          throw new NullPointerException("Handler returned null.");
-        }
-
-        LOG.info(handlerName(handler) + " responds to '" + identifier +
-          "', says: '" + response.getMessage() + "', returns " +
-          response.getReturnCode());
-      } catch (Exception e) {
-        response = new RefreshResponse(-1, e.getLocalizedMessage());
-      }
-
-      response.setSenderName(handlerName(handler));
-      responses.add(response);
-    }
-
-    return responses;
-  }
-
-  private String handlerName(RefreshHandler h) {
-    return h.getClass().getName() + '@' + Integer.toHexString(h.hashCode());
-  }
-}
diff --git 
a/hadoop-hdds/common/src/main/java/org/apache/hadoop/ipc_/RefreshResponse.java 
b/hadoop-hdds/common/src/main/java/org/apache/hadoop/ipc_/RefreshResponse.java
deleted file mode 100644
index 8d9ce4387d1..00000000000
--- 
a/hadoop-hdds/common/src/main/java/org/apache/hadoop/ipc_/RefreshResponse.java
+++ /dev/null
@@ -1,76 +0,0 @@
-/**
- * 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.ipc_;
-
-
-/**
- * Return a response in the handler method for the user to see.
- * Useful since you may want to display status to a user even though an
- * error has not occurred.
- */
-public class RefreshResponse {
-  private int returnCode = -1;
-  private String message;
-  private String senderName;
-
-  /**
-   * Convenience method to create a response for successful refreshes.
-   * @return void response
-   */
-  public static RefreshResponse successResponse() {
-    return new RefreshResponse(0, "Success");
-  }
-
-  // Most RefreshHandlers will use this
-  public RefreshResponse(int returnCode, String message) {
-    this.returnCode = returnCode;
-    this.message = message;
-  }
-
-  /**
-   * Optionally set the sender of this RefreshResponse.
-   * This helps clarify things when multiple handlers respond.
-   * @param name The name of the sender
-   */
-  public void setSenderName(String name) {
-    senderName = name;
-  }
-  public String getSenderName() { return senderName; }
-
-  public int getReturnCode() { return returnCode; }
-  public void setReturnCode(int rc) { returnCode = rc; }
-
-  public void setMessage(String m) { message = m; }
-  public String getMessage() { return message; }
-
-  @Override
-  public String toString() {
-    String ret = "";
-
-    if (senderName != null) {
-      ret += senderName + ": ";
-    }
-
-    if (message != null) {
-      ret += message;
-    }
-
-    ret += " (exit " + returnCode + ")";
-    return ret;
-  }
-}
diff --git 
a/hadoop-hdds/common/src/main/java/org/apache/hadoop/ipc_/Server.java 
b/hadoop-hdds/common/src/main/java/org/apache/hadoop/ipc_/Server.java
index bc0c829ed92..aabe01b1762 100644
--- a/hadoop-hdds/common/src/main/java/org/apache/hadoop/ipc_/Server.java
+++ b/hadoop-hdds/common/src/main/java/org/apache/hadoop/ipc_/Server.java
@@ -737,20 +737,6 @@ static Class<? extends RpcScheduler> getSchedulerClass(
     return CallQueueManager.convertSchedulerClass(schedulerClass);
   }
 
-  /*
-   * Refresh the call queue
-   */
-  public synchronized void refreshCallQueue(Configuration conf) {
-    // Create the next queue
-    String prefix = getQueueClassPrefix();
-    this.maxQueueSize = handlerCount * conf.getInt(
-        CommonConfigurationKeys.IPC_SERVER_HANDLER_QUEUE_SIZE_KEY,
-        CommonConfigurationKeys.IPC_SERVER_HANDLER_QUEUE_SIZE_DEFAULT);
-    callQueue.swapQueue(getSchedulerClass(prefix, conf),
-        getQueueClass(prefix, conf), maxQueueSize, prefix, conf);
-    callQueue.setClientBackoffEnabled(getClientBackoffEnable(prefix, conf));
-  }
-
   /**
    * Get from config if client backoff is enabled on that port.
    */


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to