|
@@ -714,6 +714,7 @@ public abstract class Server {
|
|
|
return CommonConfigurationKeys.IPC_NAMESPACE + "." + port;
|
|
|
}
|
|
|
|
|
|
+ @Deprecated
|
|
|
static Class<? extends BlockingQueue<Call>> getQueueClass(
|
|
|
String prefix, Configuration conf) {
|
|
|
String name = prefix + "." + CommonConfigurationKeys.IPC_CALLQUEUE_IMPL_KEY;
|
|
@@ -721,6 +722,32 @@ public abstract class Server {
|
|
|
return CallQueueManager.convertQueueClass(queueClass, Call.class);
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * Return class configured by property 'ipc.<port>.callqueue.impl' if it is
|
|
|
+ * present. If the config is not present, default config (without port) is
|
|
|
+ * used to derive class i.e 'ipc.callqueue.impl', and derived class is
|
|
|
+ * returned if class value is present and valid. If default config is also
|
|
|
+ * not present, default class {@link LinkedBlockingQueue} is returned.
|
|
|
+ *
|
|
|
+ * @param namespace Namespace "ipc".
|
|
|
+ * @param port Server's listener port.
|
|
|
+ * @param conf Configuration properties.
|
|
|
+ * @return Class returned based on configuration.
|
|
|
+ */
|
|
|
+ static Class<? extends BlockingQueue<Call>> getQueueClass(
|
|
|
+ String namespace, int port, Configuration conf) {
|
|
|
+ String nameWithPort = namespace + "." + port + "."
|
|
|
+ + CommonConfigurationKeys.IPC_CALLQUEUE_IMPL_KEY;
|
|
|
+ String nameWithoutPort = namespace + "."
|
|
|
+ + CommonConfigurationKeys.IPC_CALLQUEUE_IMPL_KEY;
|
|
|
+ Class<?> queueClass = conf.getClass(nameWithPort, null);
|
|
|
+ if(queueClass == null) {
|
|
|
+ queueClass = conf.getClass(nameWithoutPort, LinkedBlockingQueue.class);
|
|
|
+ }
|
|
|
+ return CallQueueManager.convertQueueClass(queueClass, Call.class);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Deprecated
|
|
|
static Class<? extends RpcScheduler> getSchedulerClass(
|
|
|
String prefix, Configuration conf) {
|
|
|
String schedulerKeyname = prefix + "." + CommonConfigurationKeys
|
|
@@ -746,6 +773,51 @@ public abstract class Server {
|
|
|
return CallQueueManager.convertSchedulerClass(schedulerClass);
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * Return class configured by property 'ipc.<port>.scheduler.impl' if it is
|
|
|
+ * present. If the config is not present, and if property
|
|
|
+ * 'ipc.<port>.callqueue.impl' represents FairCallQueue class,
|
|
|
+ * return DecayRpcScheduler. If config 'ipc.<port>.callqueue.impl'
|
|
|
+ * does not have value FairCallQueue, default config (without port) is used
|
|
|
+ * to derive class i.e 'ipc.scheduler.impl'. If default config is also not
|
|
|
+ * present, default class {@link DefaultRpcScheduler} is returned.
|
|
|
+ *
|
|
|
+ * @param namespace Namespace "ipc".
|
|
|
+ * @param port Server's listener port.
|
|
|
+ * @param conf Configuration properties.
|
|
|
+ * @return Class returned based on configuration.
|
|
|
+ */
|
|
|
+ static Class<? extends RpcScheduler> getSchedulerClass(
|
|
|
+ String namespace, int port, Configuration conf) {
|
|
|
+ String schedulerKeyNameWithPort = namespace + "." + port + "."
|
|
|
+ + CommonConfigurationKeys.IPC_SCHEDULER_IMPL_KEY;
|
|
|
+ String schedulerKeyNameWithoutPort = namespace + "."
|
|
|
+ + CommonConfigurationKeys.IPC_SCHEDULER_IMPL_KEY;
|
|
|
+
|
|
|
+ Class<?> schedulerClass = conf.getClass(schedulerKeyNameWithPort, null);
|
|
|
+ // Patch the configuration for legacy fcq configuration that does not have
|
|
|
+ // a separate scheduler setting
|
|
|
+ if (schedulerClass == null) {
|
|
|
+ String queueKeyNameWithPort = namespace + "." + port + "."
|
|
|
+ + CommonConfigurationKeys.IPC_CALLQUEUE_IMPL_KEY;
|
|
|
+ Class<?> queueClass = conf.getClass(queueKeyNameWithPort, null);
|
|
|
+ if (queueClass != null) {
|
|
|
+ if (queueClass.getCanonicalName().equals(
|
|
|
+ FairCallQueue.class.getCanonicalName())) {
|
|
|
+ conf.setClass(schedulerKeyNameWithPort, DecayRpcScheduler.class,
|
|
|
+ RpcScheduler.class);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ schedulerClass = conf.getClass(schedulerKeyNameWithPort, null);
|
|
|
+ if (schedulerClass == null) {
|
|
|
+ schedulerClass = conf.getClass(schedulerKeyNameWithoutPort,
|
|
|
+ DefaultRpcScheduler.class);
|
|
|
+ }
|
|
|
+ return CallQueueManager.convertSchedulerClass(schedulerClass);
|
|
|
+ }
|
|
|
+
|
|
|
/*
|
|
|
* Refresh the call queue
|
|
|
*/
|
|
@@ -755,8 +827,10 @@ public abstract class Server {
|
|
|
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.swapQueue(
|
|
|
+ getSchedulerClass(CommonConfigurationKeys.IPC_NAMESPACE, port, conf),
|
|
|
+ getQueueClass(CommonConfigurationKeys.IPC_NAMESPACE, port, conf),
|
|
|
+ maxQueueSize, prefix, conf);
|
|
|
callQueue.setClientBackoffEnabled(getClientBackoffEnable(prefix, conf));
|
|
|
}
|
|
|
|
|
@@ -3107,8 +3181,9 @@ public abstract class Server {
|
|
|
|
|
|
// Setup appropriate callqueue
|
|
|
final String prefix = getQueueClassPrefix();
|
|
|
- this.callQueue = new CallQueueManager<Call>(getQueueClass(prefix, conf),
|
|
|
- getSchedulerClass(prefix, conf),
|
|
|
+ this.callQueue = new CallQueueManager<>(
|
|
|
+ getQueueClass(CommonConfigurationKeys.IPC_NAMESPACE, port, conf),
|
|
|
+ getSchedulerClass(CommonConfigurationKeys.IPC_NAMESPACE, port, conf),
|
|
|
getClientBackoffEnable(prefix, conf), maxQueueSize, prefix, conf);
|
|
|
|
|
|
this.secretManager = (SecretManager<TokenIdentifier>) secretManager;
|