Search in sources :

Example 6 with DHTRingCurTargetZK

use of com.ms.silverking.cloud.dht.meta.DHTRingCurTargetZK in project SilverKing by Morgan-Stanley.

the class SKAdmin method readCurrentTree.

public InstantiatedRingTree readCurrentTree() throws KeeperException, IOException {
    DHTRingCurTargetZK curTargetZK;
    Triple<String, Long, Long> curRingAndVersionPair;
    InstantiatedRingTree ringTree;
    curTargetZK = new DHTRingCurTargetZK(dhtMC, dhtConfig);
    curRingAndVersionPair = curTargetZK.getCurRingAndVersionPair();
    ringTree = SingleRingZK.readTree(new com.ms.silverking.cloud.toporing.meta.MetaClient(new NamedRingConfiguration(dhtConfig.getRingName(), ringConfig), dhtMC.getZooKeeper().getZKConfig()), curRingAndVersionPair.getTail());
    return ringTree;
}
Also used : DHTRingCurTargetZK(com.ms.silverking.cloud.dht.meta.DHTRingCurTargetZK) NamedRingConfiguration(com.ms.silverking.cloud.toporing.meta.NamedRingConfiguration) InstantiatedRingTree(com.ms.silverking.cloud.toporing.InstantiatedRingTree)

Example 7 with DHTRingCurTargetZK

use of com.ms.silverking.cloud.dht.meta.DHTRingCurTargetZK in project SilverKing by Morgan-Stanley.

the class NodeRingMaster2 method initializeMap.

public void initializeMap(DHTConfiguration dhtConfig) throws IOException, KeeperException {
    Triple<String, Long, Long> curRingAndVersionPair;
    ConvergencePoint currentCP;
    long creationTime;
    int attemptIndex;
    String ringName;
    Pair<Long, Long> configAndInstance;
    curRingAndVersionPair = new DHTRingCurTargetZK(dhtMetaReader.getMetaClient(), dhtMetaReader.getDHTConfig()).getCurRingAndVersionPair();
    ringName = curRingAndVersionPair.getHead();
    configAndInstance = curRingAndVersionPair.getTail();
    creationTime = Long.MIN_VALUE;
    attemptIndex = 0;
    do {
        String instanceBase;
        instanceBase = MetaPaths.getRingConfigInstancePath(ringName, configAndInstance.getV1());
        try {
            creationTime = dhtMetaReader.getMetaClient().getZooKeeper().getCreationTime(ZooKeeperExtended.padVersionPath(instanceBase, configAndInstance.getV2()));
        } catch (KeeperException e) {
            Log.logErrorWarning(e);
        }
        if (creationTime < 0) {
            ThreadUtil.sleep(zkReadRetryIntervalMillis);
        }
        ++attemptIndex;
    } while (creationTime < 0 && attemptIndex < zkReadAttempts);
    if (creationTime < 0) {
        throw new RuntimeException("Unable to initialize map: " + curRingAndVersionPair);
    }
    currentCP = new ConvergencePoint(dhtConfig.getVersion(), RingIDAndVersionPair.fromRingNameAndVersionPair(curRingAndVersionPair), creationTime);
    setCurMapState(newMapState(currentCP));
}
Also used : DHTRingCurTargetZK(com.ms.silverking.cloud.dht.meta.DHTRingCurTargetZK) ConvergencePoint(com.ms.silverking.cloud.dht.daemon.storage.convergence.ConvergencePoint) ConvergencePoint(com.ms.silverking.cloud.dht.daemon.storage.convergence.ConvergencePoint) KeeperException(org.apache.zookeeper.KeeperException)

Example 8 with DHTRingCurTargetZK

use of com.ms.silverking.cloud.dht.meta.DHTRingCurTargetZK in project SilverKing by Morgan-Stanley.

the class NodeRingMaster2 method getRingNameFromCP.

// /////////////////////////////////////////////////////////////////////////
private String getRingNameFromCP(ConvergencePoint cp) throws KeeperException {
    Triple<String, Long, Long> t;
    DHTRingCurTargetZK ctZK;
    ctZK = new DHTRingCurTargetZK(dhtMetaReader.getMetaClient(), dhtMetaReader.getDHTConfig());
    t = ctZK.getCurRingAndVersionPair();
    if (!t.getTail().equals(cp.getRingIDAndVersionPair().getRingVersionPair())) {
        t = ctZK.getTargetRingAndVersionPair();
        if (!t.getTail().equals(cp.getRingIDAndVersionPair().getRingVersionPair())) {
            Log.warning(t.getTail());
            Log.warning(cp.getRingIDAndVersionPair().getRingVersionPair());
            throw new RuntimeException("cp version mismatch");
        } else {
            return t.getV1();
        }
    } else {
        return t.getV1();
    }
}
Also used : DHTRingCurTargetZK(com.ms.silverking.cloud.dht.meta.DHTRingCurTargetZK)

Aggregations

DHTRingCurTargetZK (com.ms.silverking.cloud.dht.meta.DHTRingCurTargetZK)8 InstantiatedRingTree (com.ms.silverking.cloud.toporing.InstantiatedRingTree)2 NamedRingConfiguration (com.ms.silverking.cloud.toporing.meta.NamedRingConfiguration)2 Pair (com.ms.silverking.collection.Pair)2 DHTNode (com.ms.silverking.cloud.dht.daemon.DHTNode)1 ConvergencePoint (com.ms.silverking.cloud.dht.daemon.storage.convergence.ConvergencePoint)1 DHTConfiguration (com.ms.silverking.cloud.dht.meta.DHTConfiguration)1 DHTConfigurationZK (com.ms.silverking.cloud.dht.meta.DHTConfigurationZK)1 IneligibleServerException (com.ms.silverking.cloud.dht.meta.IneligibleServerException)1 InstanceExclusionZK (com.ms.silverking.cloud.dht.meta.InstanceExclusionZK)1 MetaClient (com.ms.silverking.cloud.dht.meta.MetaClient)1 RingConfiguration (com.ms.silverking.cloud.toporing.meta.RingConfiguration)1 RingConfigurationZK (com.ms.silverking.cloud.toporing.meta.RingConfigurationZK)1 ZooKeeperConfig (com.ms.silverking.cloud.zookeeper.ZooKeeperConfig)1 File (java.io.File)1 IOException (java.io.IOException)1 Path (java.nio.file.Path)1 HashMap (java.util.HashMap)1 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)1 KeeperException (org.apache.zookeeper.KeeperException)1