Search in sources :

Example 31 with ZooKeeperExtended

use of com.ms.silverking.cloud.zookeeper.ZooKeeperExtended in project SilverKing by Morgan-Stanley.

the class SuspectsZK method _readAccuserSuspectsFromZKAsString.

/**
 * Read accuser->suspects map from zookeeper as strings.
 * @return accuser->suspects map
 * @throws KeeperException
 */
private SetMultimap<String, String> _readAccuserSuspectsFromZKAsString() throws KeeperException {
    String basePath;
    List<String> accusers;
    SetMultimap<String, String> accuserSuspectsMap;
    ZooKeeperExtended _zk;
    basePath = mc.getMetaPaths().getInstanceSuspectsPath();
    _zk = mc.getZooKeeper();
    accusers = _zk.getChildren(basePath);
    accuserSuspectsMap = HashMultimap.create();
    for (String accuser : accusers) {
        String suspectsDef;
        suspectsDef = _zk.getString(basePath + "/" + accuser.toString());
        if (!suspectsDef.equals(emptySetDef)) {
            suspectsDef.trim();
            suspectsDef = suspectsDef.substring(1, suspectsDef.length() - 1);
            for (String suspect : suspectsDef.split(suspectsDelimiterString)) {
                accuserSuspectsMap.put(accuser, suspect);
            }
        }
    }
    return accuserSuspectsMap;
}
Also used : ZooKeeperExtended(com.ms.silverking.cloud.zookeeper.ZooKeeperExtended)

Example 32 with ZooKeeperExtended

use of com.ms.silverking.cloud.zookeeper.ZooKeeperExtended in project SilverKing by Morgan-Stanley.

the class SuspectsZK method readActiveNodesFromZK.

public Set<IPAndPort> readActiveNodesFromZK() throws KeeperException {
    String basePath;
    ZooKeeperExtended _zk;
    basePath = mc.getMetaPaths().getInstanceSuspectsPath();
    _zk = mc.getZooKeeper();
    return ImmutableSet.copyOf(IPAndPort.list(_zk.getChildren(basePath)));
}
Also used : ZooKeeperExtended(com.ms.silverking.cloud.zookeeper.ZooKeeperExtended)

Example 33 with ZooKeeperExtended

use of com.ms.silverking.cloud.zookeeper.ZooKeeperExtended in project SilverKing by Morgan-Stanley.

the class MetaClient method getDHTConfiguration.

public DHTConfiguration getDHTConfiguration() throws KeeperException {
    String def;
    long version;
    String latestPath;
    long zkid;
    ZooKeeperExtended zk;
    zk = getZooKeeper();
    latestPath = zk.getLatestVersionPath(getMetaPaths().getInstanceConfigPath());
    version = zk.getLatestVersionFromPath(latestPath);
    def = zk.getString(latestPath);
    zkid = zk.getStat(latestPath).getMzxid();
    // System.out.printf("\tzkid %x\n", zkid);
    return DHTConfiguration.parse(def, version, zkid);
}
Also used : ZooKeeperExtended(com.ms.silverking.cloud.zookeeper.ZooKeeperExtended)

Aggregations

ZooKeeperExtended (com.ms.silverking.cloud.zookeeper.ZooKeeperExtended)33 KeeperException (org.apache.zookeeper.KeeperException)9 IOException (java.io.IOException)7 Stat (org.apache.zookeeper.data.Stat)4 NamedRingConfiguration (com.ms.silverking.cloud.toporing.meta.NamedRingConfiguration)3 RingConfiguration (com.ms.silverking.cloud.toporing.meta.RingConfiguration)3 RingConfigurationZK (com.ms.silverking.cloud.toporing.meta.RingConfigurationZK)3 CmdLineException (org.kohsuke.args4j.CmdLineException)3 ExclusionSet (com.ms.silverking.cloud.meta.ExclusionSet)2 ServerSetExtensionZK (com.ms.silverking.cloud.meta.ServerSetExtensionZK)2 Topology (com.ms.silverking.cloud.topology.Topology)2 TopologyZK (com.ms.silverking.cloud.topology.TopologyZK)2 InstantiatedRingTree (com.ms.silverking.cloud.toporing.InstantiatedRingTree)2 ZooKeeperConfig (com.ms.silverking.cloud.zookeeper.ZooKeeperConfig)2 IPAndPort (com.ms.silverking.net.IPAndPort)2 Lock (java.util.concurrent.locks.Lock)2 ReentrantLock (java.util.concurrent.locks.ReentrantLock)2 OperationTimeoutException (org.apache.zookeeper.KeeperException.OperationTimeoutException)2 ImmutableSet (com.google.common.collect.ImmutableSet)1 HostGroupTable (com.ms.silverking.cloud.config.HostGroupTable)1