@Override public WatchedThriftNode<ConnectedServerMetadata> load(ZooKeeperPlus zk, String basePath, String relPath) throws KeeperException, InterruptedException, IOException { return new WatchedThriftNode<>(zk, ZkPath.append(basePath, relPath), true, null, null, emptyConnectedServerMetadata); } });
@Override public WatchedThriftNode<ClientMetadata> load(ZooKeeperPlus zk, String basePath, String relPath) throws KeeperException, InterruptedException, IOException { return new WatchedThriftNode<ClientMetadata>(zk, ZkPath.append(basePath, relPath), true, null, null, emptyClientMetadata); } });
@Override public void registerServer(ConnectedServerMetadata metadata) throws IOException { try { new WatchedThriftNode<ConnectedServerMetadata>(zk, ZkPath.append(ringGroupPath, SERVERS_PATH, SERVER_NODE), false, CreateMode.EPHEMERAL_SEQUENTIAL, metadata, emptyConnectedServerMetadata ); }catch(KeeperException e){ throw new IOException(e); }catch(InterruptedException e){ throw new IOException(e); } }
@Override public void registerClient(ClientMetadata client) throws IOException { try { new WatchedThriftNode<ClientMetadata>(zk, ZkPath.append(ringGroupPath, CLIENTS_PATH, CLIENT_NODE), false, CreateMode.EPHEMERAL_SEQUENTIAL, client, emptyClientMetadata); } catch (KeeperException e) { throw new IOException(e); } catch (InterruptedException e) { throw new IOException(e); } }
public ZkDomainVersion(ZooKeeperPlus zk, String path, DomainVersionPropertiesSerialization domainVersionPropertiesSerialization, boolean create, DomainVersionMetadata initialMetadata) throws KeeperException, InterruptedException { this.zk = zk; this.path = path; this.domainVersionPropertiesSerialization = domainVersionPropertiesSerialization; this.versionNumber = Integer.parseInt(ZkPath.getFilename(path)); metadata = new WatchedThriftNode<DomainVersionMetadata>(zk, path, true, create ? CreateMode.PERSISTENT : null, initialMetadata, new DomainVersionMetadata()); }
public ZkDomainGroup(final ZooKeeperPlus zk, final Coordinator coordinator, final String path, final boolean create, final DomainGroupMetadata initialMetadata) throws InterruptedException, KeeperException, IOException { this.zk = zk; this.coordinator = coordinator; this.path = path; this.name = ZkPath.getFilename(path); this.metadata = new WatchedThriftNode<DomainGroupMetadata>(zk, path, true, create ? CreateMode.PERSISTENT : null, initialMetadata, new DomainGroupMetadata()); this.metadata.addListener(new WatchedNodeListener<DomainGroupMetadata>() { @Override public void onWatchedNodeChange(DomainGroupMetadata value) { synchronized (listeners) { for (DomainGroupListener listener : listeners) { listener.onDomainGroupChange(ZkDomainGroup.this); } } } }); }
this.path = path; this.dataLocationChangeListener = dataLocationChangeListener; this.metadata = new WatchedThriftNode<HostMetadata>(zk, path, true, create ? CreateMode.PERSISTENT : null, initialMetadata, new HostMetadata()); this.metadata.addListener(new HostMetadataDataLocationChangeNotifier()); this.assignments = new WatchedThriftNode<HostAssignmentsMetadata>(zk, ZkPath.append(path, ASSIGNMENTS_PATH), true, create ? CreateMode.PERSISTENT : null, initialAssignments, new HostAssignmentsMetadata()); if (create) { this.statistics = new WatchedThriftNode<StatisticsMetadata>(zk, ZkPath.append(path, STATISTICS_PATH), false, null, null, new StatisticsMetadata()); commandQueueWatcher = new CommandQueueWatcher(); this.summary = new WatchedThriftNode<>(zk, ZkPath.append(path, RUNTIME_STATISTICS_PATH), false, null, null, new RuntimeStatisticsSummary());
public ZkDomain(ZooKeeperPlus zk, String path, boolean create, DomainMetadata initialMetadata) throws KeeperException, InterruptedException { this.zk = zk; this.path = path; this.name = ZkPath.getFilename(path); metadata = new WatchedThriftNode<DomainMetadata>(zk, path, true, create ? CreateMode.PERSISTENT : null, initialMetadata, new DomainMetadata()); if (create) { zk.ensureCreated(ZkPath.append(path, VERSIONS_PATH), null); } this.versions = new WatchedMap<ZkDomainVersion>(zk, ZkPath.append(path, VERSIONS_PATH), new WatchedMap.ElementLoader<ZkDomainVersion>() { @Override public ZkDomainVersion load(ZooKeeperPlus zk, String basePath, String relPath) throws KeeperException, InterruptedException { return new ZkDomainVersion(zk, ZkPath.append(basePath, relPath), getDomainVersionPropertiesSerialization()); } } ); }