wangyang0918 commented on a change in pull request #12054:
URL: https://github.com/apache/flink/pull/12054#discussion_r442032969



##########
File path: 
flink-runtime/src/main/java/org/apache/flink/runtime/taskexecutor/TaskManagerRunner.java
##########
@@ -293,7 +295,15 @@ public static void main(String[] args) throws Exception {
                        LOG.info("Cannot determine the maximum number of open 
file descriptors");
                }
 
-               runTaskManagerSecurely(args, ResourceID.generate());
+               final Configuration config = loadConfiguration(args);
+               final String resourceIDPrefix = 
config.get(TaskManagerOptions.TASK_MANAGER_RESOURCE_ID_PREFIX);
+               ResourceID taskManagerResourceID;
+               if (resourceIDPrefix == null) {
+                       taskManagerResourceID = new ResourceID(new 
AbstractID().toString());

Review comment:
       Use `ResourceID.generate()`.

##########
File path: 
flink-runtime/src/main/java/org/apache/flink/runtime/taskexecutor/TaskManagerRunner.java
##########
@@ -293,7 +295,15 @@ public static void main(String[] args) throws Exception {
                        LOG.info("Cannot determine the maximum number of open 
file descriptors");
                }
 
-               runTaskManagerSecurely(args, ResourceID.generate());
+               final Configuration config = loadConfiguration(args);
+               final String resourceIDPrefix = 
config.get(TaskManagerOptions.TASK_MANAGER_RESOURCE_ID_PREFIX);
+               ResourceID taskManagerResourceID;
+               if (resourceIDPrefix == null) {
+                       taskManagerResourceID = new ResourceID(new 
AbstractID().toString());
+               } else {
+                       taskManagerResourceID = new ResourceID(resourceIDPrefix 
+ "-" + UUID.randomUUID().toString().substring(0, 6));

Review comment:
       Could use `new AbstractID().toString().substring(0, 6)` here.

##########
File path: 
flink-runtime/src/main/java/org/apache/flink/runtime/taskexecutor/TaskManagerRunner.java
##########
@@ -293,7 +295,15 @@ public static void main(String[] args) throws Exception {
                        LOG.info("Cannot determine the maximum number of open 
file descriptors");
                }
 
-               runTaskManagerSecurely(args, ResourceID.generate());
+               final Configuration config = loadConfiguration(args);
+               final String resourceIDPrefix = 
config.get(TaskManagerOptions.TASK_MANAGER_RESOURCE_ID_PREFIX);
+               ResourceID taskManagerResourceID;

Review comment:
       Add `final` for `taskManagerResourceID` here.

##########
File path: 
flink-runtime/src/main/java/org/apache/flink/runtime/taskexecutor/TaskManagerRunner.java
##########
@@ -293,7 +295,15 @@ public static void main(String[] args) throws Exception {
                        LOG.info("Cannot determine the maximum number of open 
file descriptors");
                }
 
-               runTaskManagerSecurely(args, ResourceID.generate());
+               final Configuration config = loadConfiguration(args);
+               final String resourceIDPrefix = 
config.get(TaskManagerOptions.TASK_MANAGER_RESOURCE_ID_PREFIX);
+               ResourceID taskManagerResourceID;

Review comment:
       Could we wrap the logic to get the `resourceID` into a separate method? 
Also we could add some tests for it.
   * Do not specify prefix
   * Specify prefix
     * get more than once and should have two different resource id

##########
File path: 
flink-core/src/main/java/org/apache/flink/configuration/TaskManagerOptions.java
##########
@@ -257,6 +257,18 @@
                                        text("\"ip\" - uses host's ip address 
as binding address"))
                                .build());
 
+       /**
+        * The config options defined the prefix of the TaskManager's 
ResourceID. If configured, the ResourceID will be spliced
+        * with the prefix and an uuid. Otherwise, the ResourceID would be a 
random hex string. Only valid in standalone mode.
+        */
+       @Documentation.Section(Documentation.Sections.ALL_TASK_MANAGER)
+       public static final ConfigOption<String> 
TASK_MANAGER_RESOURCE_ID_PREFIX =
+               key("taskmanager.resource-id.prefix")
+                       .stringType()
+                       .noDefaultValue()
+                       .withDescription("The config options defined the prefix 
of the TaskManager's ResourceID. If configured, the ResourceID "

Review comment:
       "The prefix of the TaskManager's ResourceID. If configured, the 
ResourceID will be generated with the prefix and a 6-character random string. 
Otherwise, a 32-character random string will be used. Only valid in standalone 
mode."




----------------------------------------------------------------
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:
[email protected]


Reply via email to