jihoonson commented on a change in pull request #12012:
URL: https://github.com/apache/druid/pull/12012#discussion_r761551860
##########
File path: services/src/main/java/org/apache/druid/cli/CliRouter.java
##########
@@ -75,6 +80,12 @@ public CliRouter()
super(log);
}
+ @Override
+ protected Set<NodeRole> getNodeRoles(Properties properties)
+ {
+ return ImmutableSet.of(NodeRole.ROUTER);
+ }
Review comment:
I suppose you mean `GuiceRunnable.configure()`? That method is called at
https://github.com/apache/druid/blob/master/services/src/main/java/org/apache/druid/cli/Main.java#L111
which is always called before `GuiceRunnable.run()`.
##########
File path:
services/src/main/java/org/apache/druid/guice/AbstractDruidServiceModule.java
##########
@@ -0,0 +1,54 @@
+/*
+ * 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.druid.guice;
+
+import com.google.inject.Binder;
+import com.google.inject.Module;
+import com.google.inject.multibindings.MultibindingsScanner;
+
+/**
+ * An abstract module for dynamic registration of {@link
org.apache.druid.discovery.DruidService}.
+ * DruidServices are bound to a set which is mapped to a certain {@link
org.apache.druid.discovery.NodeRole}.
+ * See {@link org.apache.druid.cli.ServerRunnable#bindDruidServiceType} for
how the map is bound.
+ *
+ * To register a DruidService, create a class something like below:
+ *
+ * <pre>
+ * public class MyModule extends AbstractDruidServiceModule
+ * {
+ * @ProvidesIntoSet
+ * @Named("myNodeTypeKey")
+ * public Class<? extends DruidService> getDataNodeService()
+ * {
+ * return DataNodeService.class;
+ * }
+ * }
+ * </pre>
+ *
+ * and add it in {@link org.apache.druid.cli.ServerRunnable#getModules}.
+ */
Review comment:
To make it more obvious, I added `NodeRole.getDruidServiceInjectName()`
as below:
```java
public Named getDruidServiceInjectName()
{
return Names.named(jsonName);
}
```
Custom modules now can use the JSON name of node roles as the key.
```
public class BrokerServiceModule extends AbstractDruidServiceModule
{
@ProvidesIntoSet
@Named(NodeRole.BROKER_JSON_NAME)
public Class<? extends DruidService> getDataNodeService()
{
return DataNodeService.class;
}
}
```
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]