Skip to content

Commit c4323a7

Browse files
committed
Revert "RATIS-2325. Create GrpcStubPool for GrpcServerProtocolClient (#1283)"
This reverts commit d11604c.
1 parent 6c761f4 commit c4323a7

File tree

4 files changed

+4
-156
lines changed

4 files changed

+4
-156
lines changed

ratis-grpc/src/main/java/org/apache/ratis/grpc/GrpcConfigKeys.java

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -282,15 +282,6 @@ static GrpcTlsConfig tlsConf(Parameters parameters) {
282282
static void setTlsConf(Parameters parameters, GrpcTlsConfig conf) {
283283
parameters.put(TLS_CONF_PARAMETER, conf, TLS_CONF_CLASS);
284284
}
285-
286-
String STUB_POOL_SIZE_KEY = PREFIX + ".stub.pool.size";
287-
int STUB_POOL_SIZE_DEFAULT = 10;
288-
static int stubPoolSize(RaftProperties properties) {
289-
return get(properties::getInt, STUB_POOL_SIZE_KEY, STUB_POOL_SIZE_DEFAULT, getDefaultLog());
290-
}
291-
static void setStubPoolSize(RaftProperties properties, int size) {
292-
setInt(properties::setInt, STUB_POOL_SIZE_KEY, size);
293-
}
294285
}
295286

296287
String MESSAGE_SIZE_MAX_KEY = PREFIX + ".message.size.max";

ratis-grpc/src/main/java/org/apache/ratis/grpc/server/GrpcServerProtocolClient.java

Lines changed: 3 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@
4545
class GrpcServerProtocolClient implements Closeable {
4646
// Common channel
4747
private final ManagedChannel channel;
48-
private final GrpcStubPool<RaftServerProtocolServiceStub> pool;
4948
// Channel and stub for heartbeat
5049
private ManagedChannel hbChannel;
5150
private RaftServerProtocolServiceStub hbAsyncStub;
@@ -58,7 +57,7 @@ class GrpcServerProtocolClient implements Closeable {
5857
//visible for using in log / error messages AND to use in instrumented tests
5958
private final RaftPeerId raftPeerId;
6059

61-
GrpcServerProtocolClient(RaftPeer target, int connections, int flowControlWindow,
60+
GrpcServerProtocolClient(RaftPeer target, int flowControlWindow,
6261
TimeDuration requestTimeout, SslContext sslContext, boolean separateHBChannel) {
6362
raftPeerId = target.getId();
6463
LOG.info("Build channel for {}", target);
@@ -71,7 +70,6 @@ class GrpcServerProtocolClient implements Closeable {
7170
hbAsyncStub = RaftServerProtocolServiceGrpc.newStub(hbChannel);
7271
}
7372
requestTimeoutDuration = requestTimeout;
74-
this.pool = new GrpcStubPool<>(target, connections, RaftServerProtocolServiceGrpc::newStub, sslContext);
7573
}
7674

7775
private ManagedChannel buildChannel(RaftPeer target, int flowControlWindow, SslContext sslContext) {
@@ -96,7 +94,6 @@ public void close() {
9694
GrpcUtil.shutdownManagedChannel(hbChannel);
9795
}
9896
GrpcUtil.shutdownManagedChannel(channel);
99-
pool.close();
10097
}
10198

10299
public RequestVoteReplyProto requestVote(RequestVoteRequestProto request) {
@@ -115,36 +112,8 @@ public StartLeaderElectionReplyProto startLeaderElection(StartLeaderElectionRequ
115112
}
116113

117114
void readIndex(ReadIndexRequestProto request, StreamObserver<ReadIndexReplyProto> s) {
118-
GrpcStubPool.PooledStub<RaftServerProtocolServiceStub> p;
119-
try {
120-
p = pool.acquire();
121-
} catch (InterruptedException e) {
122-
Thread.currentThread().interrupt();
123-
s.onError(e); return;
124-
}
125-
p.getStub().withDeadlineAfter(requestTimeoutDuration.getDuration(), requestTimeoutDuration.getUnit())
126-
.readIndex(request, new StreamObserver<ReadIndexReplyProto>() {
127-
@Override
128-
public void onNext(ReadIndexReplyProto v) {
129-
s.onNext(v);
130-
}
131-
@Override
132-
public void onError(Throwable t) {
133-
try {
134-
s.onError(t);
135-
} finally {
136-
p.release();
137-
}
138-
}
139-
@Override
140-
public void onCompleted() {
141-
try {
142-
s.onCompleted();
143-
} finally {
144-
p.release();
145-
}
146-
}
147-
});
115+
asyncStub.withDeadlineAfter(requestTimeoutDuration.getDuration(), requestTimeoutDuration.getUnit())
116+
.readIndex(request, s);
148117
}
149118

150119
CallStreamObserver<AppendEntriesRequestProto> appendEntries(

ratis-grpc/src/main/java/org/apache/ratis/grpc/server/GrpcServicesImpl.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,6 @@ public static final class Builder {
108108
private int serverPort;
109109
private SslContext serverSslContextForServer;
110110
private SslContext serverSslContextForClient;
111-
private int serverStubPoolSize;
112111

113112
private SizeInBytes messageSizeMax;
114113
private SizeInBytes flowControlWindow;
@@ -131,7 +130,6 @@ public Builder setServer(RaftServer raftServer) {
131130
this.flowControlWindow = GrpcConfigKeys.flowControlWindow(properties, LOG::info);
132131
this.requestTimeoutDuration = RaftServerConfigKeys.Rpc.requestTimeout(properties);
133132
this.separateHeartbeatChannel = GrpcConfigKeys.Server.heartbeatChannel(properties);
134-
this.serverStubPoolSize = GrpcConfigKeys.Server.stubPoolSize(properties);
135133

136134
final SizeInBytes appenderBufferSize = RaftServerConfigKeys.Log.Appender.bufferByteLimit(properties);
137135
final SizeInBytes gap = SizeInBytes.ONE_MB;
@@ -152,7 +150,7 @@ public Builder setCustomizer(Customizer customizer) {
152150
}
153151

154152
private GrpcServerProtocolClient newGrpcServerProtocolClient(RaftPeer target) {
155-
return new GrpcServerProtocolClient(target, serverStubPoolSize, flowControlWindow.getSizeInt(),
153+
return new GrpcServerProtocolClient(target, flowControlWindow.getSizeInt(),
156154
requestTimeoutDuration, serverSslContextForClient, separateHeartbeatChannel);
157155
}
158156

ratis-grpc/src/main/java/org/apache/ratis/grpc/server/GrpcStubPool.java

Lines changed: 0 additions & 110 deletions
This file was deleted.

0 commit comments

Comments
 (0)