Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ISSUE #4796] Use ThreadPoolFactory to create single thread executor for SourceWorker #4798

Merged
merged 1 commit into from
Mar 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
package org.apache.eventmesh.common;

import java.util.concurrent.BlockingQueue;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.ScheduledExecutorService;
Expand Down Expand Up @@ -57,4 +58,8 @@
public static ScheduledExecutorService createScheduledExecutor(int core, ThreadFactory threadFactory) {
return Executors.newScheduledThreadPool(core, threadFactory);
}

public static ExecutorService createSingleExecutor(final String threadName) {
return Executors.newSingleThreadExecutor(new EventMeshThreadFactory(threadName));

Check warning on line 63 in eventmesh-common/src/main/java/org/apache/eventmesh/common/ThreadPoolFactory.java

View check run for this annotation

Codecov / codecov/patch

eventmesh-common/src/main/java/org/apache/eventmesh/common/ThreadPoolFactory.java#L63

Added line #L63 was not covered by tests
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import org.apache.eventmesh.client.tcp.EventMeshTCPClientFactory;
import org.apache.eventmesh.client.tcp.common.MessageUtils;
import org.apache.eventmesh.client.tcp.conf.EventMeshTCPClientConfig;
import org.apache.eventmesh.common.ThreadPoolFactory;
import org.apache.eventmesh.common.exception.EventMeshException;
import org.apache.eventmesh.common.protocol.tcp.OPStatus;
import org.apache.eventmesh.common.protocol.tcp.Package;
Expand Down Expand Up @@ -56,7 +57,6 @@
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.TimeUnit;
Expand Down Expand Up @@ -87,9 +87,11 @@ public class SourceWorker implements ConnectorWorker {

private volatile RecordOffsetManagement.CommittableOffsets committableOffsets;

private final ExecutorService pollService = Executors.newSingleThreadExecutor();
private final ExecutorService pollService =
ThreadPoolFactory.createSingleExecutor("eventMesh-sourceWorker-pollService");

private final ExecutorService startService = Executors.newSingleThreadExecutor();
private final ExecutorService startService =
ThreadPoolFactory.createSingleExecutor("eventMesh-sourceWorker-startService");

private final BlockingQueue<ConnectRecord> queue;
private final EventMeshTCPClient<CloudEvent> eventMeshTCPClient;
Expand Down
Loading