Search in sources :

Example 6 with PlacementDriverClient

use of com.alipay.sofa.jraft.rhea.client.pd.PlacementDriverClient in project sofa-jraft by sofastack.

the class ChaosTestCluster method removePeer.

public synchronized void removePeer(final PeerId peerId) {
    for (int i = this.stores.size() - 1; i >= 0; i--) {
        final RheaKVStore store = this.stores.get(i);
        if (peerId.getEndpoint().equals(getSelfEndpoint(store))) {
            final PlacementDriverClient pdClient = store.getPlacementDriverClient();
            if (!pdClient.removeReplica(Constants.DEFAULT_REGION_ID, JRaftHelper.toPeer(peerId), true)) {
                throw new RuntimeException("fail to remove peer: " + peerId);
            }
            store.shutdown();
            this.stores.remove(i);
            this.peerIds.remove(i);
            LOG.info("Shutdown and remove peer: {}", peerId);
            return;
        }
    }
    LOG.info("Could not find peer: {}", peerId);
}
Also used : RheaKVStore(com.alipay.sofa.jraft.rhea.client.RheaKVStore) DefaultRheaKVStore(com.alipay.sofa.jraft.rhea.client.DefaultRheaKVStore) PlacementDriverClient(com.alipay.sofa.jraft.rhea.client.pd.PlacementDriverClient) Endpoint(com.alipay.sofa.jraft.util.Endpoint)

Example 7 with PlacementDriverClient

use of com.alipay.sofa.jraft.rhea.client.pd.PlacementDriverClient in project sofa-jraft by sofastack.

the class PlacementDriverServer method awaitReady.

public boolean awaitReady(final long timeoutMillis) {
    final PlacementDriverClient pdClient = this.rheaKVStore.getPlacementDriverClient();
    final Endpoint endpoint = pdClient.getLeader(this.regionEngine.getRegion().getId(), true, timeoutMillis);
    return endpoint != null;
}
Also used : Endpoint(com.alipay.sofa.jraft.util.Endpoint) PlacementDriverClient(com.alipay.sofa.jraft.rhea.client.pd.PlacementDriverClient)

Aggregations

PlacementDriverClient (com.alipay.sofa.jraft.rhea.client.pd.PlacementDriverClient)7 Endpoint (com.alipay.sofa.jraft.util.Endpoint)6 DefaultRheaKVStore (com.alipay.sofa.jraft.rhea.client.DefaultRheaKVStore)5 RheaKVStore (com.alipay.sofa.jraft.rhea.client.RheaKVStore)5 RheaKVStoreOptions (com.alipay.sofa.jraft.rhea.options.RheaKVStoreOptions)3 Configuration (com.alipay.sofa.jraft.conf.Configuration)2 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)2 YAMLFactory (com.fasterxml.jackson.dataformat.yaml.YAMLFactory)2 File (java.io.File)2 PeerId (com.alipay.sofa.jraft.entity.PeerId)1 Peer (com.alipay.sofa.jraft.rhea.metadata.Peer)1 BatchingOptions (com.alipay.sofa.jraft.rhea.options.BatchingOptions)1 PlacementDriverOptions (com.alipay.sofa.jraft.rhea.options.PlacementDriverOptions)1 RegionEngineOptions (com.alipay.sofa.jraft.rhea.options.RegionEngineOptions)1 RegionRouteTableOptions (com.alipay.sofa.jraft.rhea.options.RegionRouteTableOptions)1 StoreEngineOptions (com.alipay.sofa.jraft.rhea.options.StoreEngineOptions)1 InputStream (java.io.InputStream)1 ArrayDeque (java.util.ArrayDeque)1 HashSet (java.util.HashSet)1