Skip to content

Commit

Permalink
refresh configuration for membership change (#652)
Browse files Browse the repository at this point in the history
* refresh configuration for membership change

* by CR
  • Loading branch information
block authored Aug 10, 2021
1 parent 1ef3067 commit 17cbbd0
Showing 1 changed file with 17 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

import java.util.List;
import java.util.Map;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;

import org.slf4j.Logger;
Expand Down Expand Up @@ -60,9 +61,12 @@
*/
public abstract class AbstractPlacementDriverClient implements PlacementDriverClient {

private static final Logger LOG = LoggerFactory.getLogger(AbstractPlacementDriverClient.class);
private static final Logger LOG = LoggerFactory
.getLogger(AbstractPlacementDriverClient.class);

protected final RegionRouteTable regionRouteTable = new RegionRouteTable();
private static final long AT_LEAST_REQUIRED_MILLIS = TimeUnit.SECONDS.toMillis(1);

protected final RegionRouteTable regionRouteTable = new RegionRouteTable();
protected final long clusterId;
protected final String clusterName;

Expand Down Expand Up @@ -277,6 +281,17 @@ protected PeerId getLeader(final String raftGroupId, final boolean forceRefresh,
: new RouteTableException(error.toString());
}
}

// we need refresh configuration for membership change
final long leftTime = deadline - System.currentTimeMillis();
if (leftTime > AT_LEAST_REQUIRED_MILLIS) {
try {
RouteTable.getInstance().refreshConfiguration(this.cliClientService, raftGroupId, (int) leftTime);
} catch (final InterruptedException e) {
ThrowUtil.throwException(e);
} catch (final TimeoutException ignored) {
}
}
}
return routeTable.selectLeader(raftGroupId);
}
Expand Down

0 comments on commit 17cbbd0

Please sign in to comment.