Search in sources :

Example 21 with ZooKeeperExtended

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

the class ExclusionZKBase method readFromZK.

@Override
public ExclusionSet readFromZK(long version, MetaToolOptions options) throws KeeperException {
    String vBase;
    // List<String>    nodes;
    String[] nodes;
    Stat stat;
    ZooKeeperExtended _zk;
    _zk = mc.getZooKeeper();
    if (version == VersionedDefinition.NO_VERSION) {
        version = _zk.getLatestVersion(base);
    }
    vBase = getVBase(version);
    // nodes = zk.getChildren(vBase);
    stat = new Stat();
    nodes = _zk.getString(vBase, null, stat).split("\n");
    return new ExclusionSet(ImmutableSet.copyOf(nodes), version, stat.getMzxid());
}
Also used : Stat(org.apache.zookeeper.data.Stat) ZooKeeperExtended(com.ms.silverking.cloud.zookeeper.ZooKeeperExtended)

Example 22 with ZooKeeperExtended

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

the class ExclusionZKBase method getLatestZKPath.

public String getLatestZKPath() throws KeeperException {
    long version;
    ZooKeeperExtended _zk;
    _zk = mc.getZooKeeper();
    version = _zk.getLatestVersion(exclusionsPath);
    if (version < 0) {
        return null;
    } else {
        return getVBase(version);
    }
}
Also used : ZooKeeperExtended(com.ms.silverking.cloud.zookeeper.ZooKeeperExtended)

Example 23 with ZooKeeperExtended

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

the class ExclusionZKBase method readNodesAsSet.

private Set<String> readNodesAsSet(String path, Stat stat) throws KeeperException {
    String[] nodes;
    ZooKeeperExtended _zk;
    _zk = mc.getZooKeeper();
    nodes = _zk.getString(path, null, stat).split("\n");
    return ImmutableSet.copyOf(nodes);
}
Also used : ZooKeeperExtended(com.ms.silverking.cloud.zookeeper.ZooKeeperExtended)

Example 24 with ZooKeeperExtended

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

the class MetaClient method getSKFSConfig.

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

Example 25 with ZooKeeperExtended

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

the class VersionWatcherTest method main.

/**
 * @param args
 */
public static void main(String[] args) {
    try {
        if (args.length < 3) {
            System.out.println("<zkConfig> <intervalSeconds> <path...>");
        } else {
            ZooKeeperConfig zkConfig;
            long intervalMillis;
            VersionWatcherTest vwTest;
            zkConfig = new ZooKeeperConfig(args[0]);
            intervalMillis = Integer.parseInt(args[1]) * 1000;
            vwTest = new VersionWatcherTest(new ZooKeeperExtended(zkConfig, 2 * 60 * 1000, null));
            for (int i = 2; i < args.length; i++) {
                vwTest.addWatch(args[i], intervalMillis);
            }
            Thread.sleep(60 * 60 * 1000);
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
}
Also used : ZooKeeperConfig(com.ms.silverking.cloud.zookeeper.ZooKeeperConfig) ZooKeeperExtended(com.ms.silverking.cloud.zookeeper.ZooKeeperExtended) KeeperException(org.apache.zookeeper.KeeperException) IOException(java.io.IOException)

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