use of org.apache.flink.shaded.zookeeper3.org.apache.zookeeper.data.Stat in project pinot by linkedin.
the class PinotSegmentRebalancer method rebalanceTable.
/**
* Rebalances a table
* @param tableName
* @throws Exception
*/
public void rebalanceTable(String tableName) throws Exception {
String tableConfigPath = "/CONFIGS/TABLE/" + tableName;
Stat stat = new Stat();
ZNRecord znRecord = propertyStore.get(tableConfigPath, stat, 0);
AbstractTableConfig tableConfig = AbstractTableConfig.fromZnRecord(znRecord);
String tenantName = tableConfig.getTenantConfig().getServer().replaceAll(TableType.OFFLINE.toString(), "").replace(TableType.OFFLINE.toString(), "");
rebalanceTable(tableName, tenantName);
}
use of org.apache.flink.shaded.zookeeper3.org.apache.zookeeper.data.Stat in project pulsar by yahoo.
the class MockZooKeeper method setData.
@Override
public Stat setData(final String path, byte[] data, int version) throws KeeperException, InterruptedException {
final Set<Watcher> toNotify = Sets.newHashSet();
int newVersion;
synchronized (this) {
checkProgrammedFail();
if (stopped) {
throw new KeeperException.ConnectionLossException();
}
if (!tree.containsKey(path)) {
throw new KeeperException.NoNodeException();
}
int currentVersion = tree.get(path).second;
// Check version
if (version != -1 && version != currentVersion) {
throw new KeeperException.BadVersionException(path);
}
newVersion = currentVersion + 1;
log.debug("[{}] Updating -- current version: {}", path, currentVersion);
tree.put(path, Pair.create(new String(data), newVersion));
toNotify.addAll(watchers.get(path));
watchers.removeAll(path);
}
executor.execute(() -> {
toNotify.forEach(watcher -> watcher.process(new WatchedEvent(EventType.NodeDataChanged, KeeperState.SyncConnected, path)));
});
Stat stat = new Stat();
stat.setVersion(newVersion);
return stat;
}
use of org.apache.flink.shaded.zookeeper3.org.apache.zookeeper.data.Stat in project pulsar by yahoo.
the class MockZooKeeper method exists.
@Override
public synchronized Stat exists(String path, Watcher watcher) throws KeeperException, InterruptedException {
checkProgrammedFail();
if (stopped)
throw new KeeperException.ConnectionLossException();
if (watcher != null) {
watchers.put(path, watcher);
}
if (tree.containsKey(path)) {
Stat stat = new Stat();
stat.setVersion(tree.get(path).second);
return stat;
} else {
return null;
}
}
use of org.apache.flink.shaded.zookeeper3.org.apache.zookeeper.data.Stat in project pulsar by yahoo.
the class MockZooKeeper method exists.
@Override
public synchronized Stat exists(String path, boolean watch) throws KeeperException, InterruptedException {
checkProgrammedFail();
if (stopped)
throw new KeeperException.ConnectionLossException();
if (tree.containsKey(path)) {
Stat stat = new Stat();
stat.setVersion(tree.get(path).second);
return stat;
} else {
return null;
}
}
use of org.apache.flink.shaded.zookeeper3.org.apache.zookeeper.data.Stat in project pulsar by yahoo.
the class LocalZooKeeperConnectionService method createIfAbsent.
public static String createIfAbsent(ZooKeeper zk, String path, byte[] data, CreateMode createMode, boolean gc) throws KeeperException, InterruptedException {
String pathCreated = null;
try {
pathCreated = zk.create(path, data, Ids.OPEN_ACL_UNSAFE, createMode);
} catch (NodeExistsException e) {
// OK
LOG.debug("Create skipped for existing znode: path={}", path);
}
// reset if what exists is the ephemeral garbage.
if (gc && (pathCreated == null) && CreateMode.EPHEMERAL.equals(createMode)) {
Stat stat = zk.exists(path, false);
if (stat != null && zk.getSessionId() != stat.getEphemeralOwner()) {
deleteIfExists(zk, path, -1);
pathCreated = zk.create(path, data, Ids.OPEN_ACL_UNSAFE, createMode);
}
}
return pathCreated;
}
Aggregations