Zhuoxi2000 commented on code in PR #1028: URL: https://github.com/apache/flink-agents/pull/1028#discussion_r3827056055
########## runtime/src/main/java/org/apache/flink/agents/runtime/async/AsyncExecutorThreadFactory.java: ########## @@ -0,0 +1,49 @@ +/* + * 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.flink.agents.runtime.async; + +import java.util.concurrent.ThreadFactory; +import java.util.concurrent.atomic.AtomicInteger; + +/** + * {@link ThreadFactory} for the Flink Agents Java async executor, producing descriptive, + * collision-resistant thread names of the form {@code + * flink-agents-java-async-<pool-id>-thread-<worker-id>}. + * + * <p>Default executor names such as {@code pool-N-thread-M} make Flink Agents async workers hard to + * attribute in TaskManager thread dumps and profiler output, where many unrelated pools coexist. + * The pool id is process-unique so multiple executor instances in one TaskManager remain + * distinguishable; only the name changes — thread priority and daemon status follow the default + * factory behavior. + */ +public final class AsyncExecutorThreadFactory implements ThreadFactory { + + private static final AtomicInteger POOL_ID = new AtomicInteger(); Review Comment: Done thread names now look like `flink-agents-java-async-pool-N-thread-M`, and the extra counters are gone. ########## runtime/src/main/java/org/apache/flink/agents/runtime/async/AsyncExecutorThreadFactory.java: ########## @@ -0,0 +1,49 @@ +/* + * 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.flink.agents.runtime.async; + +import java.util.concurrent.ThreadFactory; +import java.util.concurrent.atomic.AtomicInteger; + +/** + * {@link ThreadFactory} for the Flink Agents Java async executor, producing descriptive, + * collision-resistant thread names of the form {@code + * flink-agents-java-async-<pool-id>-thread-<worker-id>}. + * + * <p>Default executor names such as {@code pool-N-thread-M} make Flink Agents async workers hard to + * attribute in TaskManager thread dumps and profiler output, where many unrelated pools coexist. + * The pool id is process-unique so multiple executor instances in one TaskManager remain + * distinguishable; only the name changes — thread priority and daemon status follow the default + * factory behavior. + */ +public final class AsyncExecutorThreadFactory implements ThreadFactory { + + private static final AtomicInteger POOL_ID = new AtomicInteger(); + + private final String namePrefix; + private final AtomicInteger workerId = new AtomicInteger(); + + public AsyncExecutorThreadFactory() { + this.namePrefix = "flink-agents-java-async-" + POOL_ID.incrementAndGet() + "-thread-"; + } + + @Override Review Comment: Good catch switched to `Executors.defaultThreadFactory()` so daemon status and priority keep the JDK defaults, and only the name is changed. Added a regression test for that as well. -- 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]
