File tree Expand file tree Collapse file tree 2 files changed +12
-3
lines changed
main/java/cloud/xline/jxline/impl Expand file tree Collapse file tree 2 files changed +12
-3
lines changed Original file line number Diff line number Diff line change @@ -252,6 +252,10 @@ int recoverQuorum(int size) {
252252 return quorum (size ) / 2 + 1 ;
253253 }
254254
255+ static final int RETRY_TIMEOUT = 3 ;
256+ static final int RETRY_LIMIT = 5 ;
257+
258+ // TODO: Need to be refactored within retry policy...
255259 State getInitState () {
256260 ManagedChannel initChannel = this .connectionManager ().getInitChannel ();
257261 VertxProtocolGrpc .ProtocolVertxStub initStub = VertxProtocolGrpc .newVertxStub (initChannel );
@@ -261,11 +265,13 @@ State getInitState() {
261265 int retries = -1 ;
262266 do {
263267 retries ++;
264- if (retries > 5 ) {
268+ if (retries > RETRY_LIMIT ) {
265269 throw new RuntimeException ("connection failed" );
266270 }
267271 try {
268- response = completable (initStub .fetchCluster (request )).get (3 , TimeUnit .SECONDS );
272+ response =
273+ completable (initStub .fetchCluster (request ))
274+ .get (RETRY_TIMEOUT , TimeUnit .SECONDS );
269275 } catch (Exception e ) {
270276 logger ().warn ("fetch cluster failed, " + e );
271277 }
Original file line number Diff line number Diff line change 55import org .junit .jupiter .api .BeforeAll ;
66import org .junit .jupiter .api .Test ;
77import org .junit .jupiter .api .Timeout ;
8+
89import static org .assertj .core .api .Assertions .*;
910
1011@ Timeout (value = 20 )
1112public class ProtocolTest {
1213 static ProtocolClient client ;
1314
15+ static String INIT_ENDPOINT = "http://172.20.0.5:2379" ;
16+
1417 @ BeforeAll
1518 static void onConnect () {
16- client = Client .builder ().endpoints ("http://172.20.0.5:2379" ).build ().getProtocolClient ();
19+ client = Client .builder ().endpoints (INIT_ENDPOINT ).build ().getProtocolClient ();
1720 }
1821
1922 @ Test
You can’t perform that action at this time.
0 commit comments