Skip to content
Merged
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,8 +18,11 @@
package org.apache.hadoop.ozone.container.replication;

import java.io.IOException;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

import com.google.common.util.concurrent.ThreadFactoryBuilder;
import org.apache.hadoop.hdds.conf.Config;
import org.apache.hadoop.hdds.conf.ConfigGroup;
import org.apache.hadoop.hdds.conf.ConfigType;
Expand Down Expand Up @@ -62,6 +65,8 @@ public class ReplicationServer {
private int port;
private final ContainerImporter importer;

private ThreadPoolExecutor executor;

public ReplicationServer(ContainerController controller,
ReplicationConfig replicationConfig, SecurityConfig secConf,
CertificateClient caClient, ContainerImporter importer) {
Expand All @@ -70,6 +75,18 @@ public ReplicationServer(ContainerController controller,
this.controller = controller;
this.importer = importer;
this.port = replicationConfig.getPort();

int replicationServerWorkers =
replicationConfig.getReplicationMaxStreams();
this.executor =
new ThreadPoolExecutor(replicationServerWorkers,
replicationServerWorkers,
60, TimeUnit.SECONDS,
new LinkedBlockingQueue<>(),
new ThreadFactoryBuilder().setDaemon(true)
.setNameFormat("ReplicationContainerReader-%d")
.build());

init();
}

Expand All @@ -79,7 +96,8 @@ public void init() {
.addService(ServerInterceptors.intercept(new GrpcReplicationService(
new OnDemandContainerReplicationSource(controller),
importer
), new GrpcServerInterceptor()));
), new GrpcServerInterceptor()))
.executor(executor);

if (secConf.isSecurityEnabled() && secConf.isGrpcTlsEnabled()) {
try {
Expand Down Expand Up @@ -112,6 +130,8 @@ public void start() throws IOException {

public void stop() {
try {
executor.shutdown();
executor.awaitTermination(5L, TimeUnit.SECONDS);
server.shutdown().awaitTermination(10L, TimeUnit.SECONDS);
} catch (InterruptedException ex) {
LOG.warn("{} couldn't be stopped gracefully", getClass().getSimpleName());
Expand Down