private ZKClient getCoordinatorZKClient() { return ZKClients.namespace(zkClient, Constants.Stream.STREAM_ZK_COORDINATION_NAMESPACE); } }
private ZKClient getCoordinatorZKClient() { return ZKClients.namespace(zkClient, Constants.Stream.STREAM_ZK_COORDINATION_NAMESPACE); }
public SynchronizedZKMap(ZKClient zkClient, String namespace, Serializer<T> serializer) { this(namespace == null ? zkClient : ZKClients.namespace(zkClient, namespace), serializer); }
/** * Returns a {@link ZKClient} that namespaced under the given run id. */ private static ZKClient getAppRunZKClient(ZKClient zkClient, RunId appRunId) { return ZKClients.namespace(zkClient, String.format("/%s", appRunId)); }
/** * Returns a {@link ZKClient} that namespaced under the given run id. */ private static ZKClient getAppRunZKClient(ZKClient zkClient, RunId appRunId) { return ZKClients.namespace(zkClient, String.format("/%s", appRunId)); }
private static ZKClient getContainerZKClient(ZKClient zkClient, RunId appRunId, String runnableName) { return ZKClients.namespace(zkClient, String.format("/%s/runnables/%s", appRunId, runnableName)); }
private static ZKClient getContainerZKClient(ZKClient zkClient, RunId appRunId, String runnableName) { return ZKClients.namespace(zkClient, String.format("/%s/runnables/%s", appRunId, runnableName)); }
@Override public ZKDiscoveryService load(String key) { String ns = String.format("%s/%s", twillNamespace, key); LOG.info("Create ZKDiscoveryClient for {}", ns); return new ZKDiscoveryService(ZKClients.namespace(zkClient, ns)); } };
public ZKMap(ZKClient zkClient, String namespace, Serializer<T> serializer) throws ExecutionException, InterruptedException { this.zkClient = namespace == null ? zkClient : ZKClients.namespace(zkClient, namespace); this.serializer = serializer; this.currentView = new AtomicReference<Map<String, T>>(Collections.<String, T>emptyMap()); this.waitingForElements = Maps.newHashMap(); setExternalChangeWatcher(); }
/** * Creates an instance of {@link ZKPropertyStore} with nodes created under the given namespace. * * @param zkClient client for interacting with ZooKeeper * @param namespace Namespace for zk nodes to reside in * @param codec The codec for encode/decode property */ public static <T> ZKPropertyStore<T> create(ZKClient zkClient, String namespace, Codec<T> codec) { return new ZKPropertyStore<>(ZKClients.namespace(zkClient, namespace), codec); }
@Override public DiscoveryServiceClient load(String key) throws Exception { String ns = String.format("%s/%s", twillNamespace, key); LOG.debug("Create ZKDiscoveryClient for " + ns); return new ZKDiscoveryService(ZKClients.namespace(zkClient, ns)); } };
/** * Creates an instance of {@link ZKPropertyStore} with nodes created under the given namespace. * * @param zkClient client for interacting with ZooKeeper * @param namespace Namespace for zk nodes to reside in * @param codec The codec for encode/decode property */ public static <T> ZKPropertyStore<T> create(ZKClient zkClient, String namespace, Codec<T> codec) { return new ZKPropertyStore<>(ZKClients.namespace(zkClient, namespace), codec); }
@Override public DiscoveryServiceClient load(String key) throws Exception { int idx = key.indexOf('.'); // It must be found as checked in the discover method String ns = String.format("%s/%s%s", twillNamespace, key.substring(0, idx), key.substring(idx)); LOG.debug("Create ZKDiscoveryClient for " + ns); return new ZKDiscoveryService(ZKClients.namespace(zkClient, ns)); } };
public ZKCollection(ZKClient zkClient, String namespace, Serializer<T> serializer) throws ExecutionException, InterruptedException { this.zkClient = namespace == null ? zkClient : ZKClients.namespace(zkClient, namespace); this.serializer = serializer; this.currentView = new AtomicReference<Collection<T>>(Collections.<T>emptyList()); setExternalChangeWatcher(); }
@Inject SparkServiceAnnouncer(CConfiguration cConf, ZKClient zKClient, ProgramId programId) { // Use the ZK path that points to the Twill application of the Spark client. String ns = String.format("%s/%s", cConf.get(Constants.CFG_TWILL_ZK_NAMESPACE), ServiceDiscoverable.getName(programId)); this.zkClient = ZKClients.namespace(zKClient, ns); }
@Inject SparkServiceAnnouncer(CConfiguration cConf, ZKClient zKClient, ProgramId programId) { // Use the ZK path that points to the Twill application of the Spark client. String ns = String.format("%s/%s", cConf.get(Constants.CFG_TWILL_ZK_NAMESPACE), ServiceDiscoverable.getName(programId)); this.zkClient = ZKClients.namespace(zKClient, ns); }
@Inject SparkServiceAnnouncer(CConfiguration cConf, ZKClient zKClient, ProgramId programId) { // Use the ZK path that points to the Twill application of the Spark client. String ns = String.format("%s/%s", cConf.get(Constants.CFG_TWILL_ZK_NAMESPACE), ServiceDiscoverable.getName(programId)); this.zkClient = ZKClients.namespace(zKClient, ns); }
@Override protected Lock getLock(StreamId streamId) { // It's ok to create new locks every time as it's backed by ZK for distributed lock ZKClient lockZKClient = ZKClients.namespace(zkClient, "/" + Constants.Service.STREAMS + "/locks"); return new ReentrantDistributedLock(lockZKClient, streamId.toString()); }
public DistributedKeyManager(CConfiguration conf, Codec<KeyIdentifier> codec, ZKClient zookeeper, List<ACL> acls) { super(conf); this.parentZNode = conf.get(Constants.Security.DIST_KEY_PARENT_ZNODE); this.keyExpirationPeriod = conf.getLong(Constants.Security.TOKEN_DIGEST_KEY_EXPIRATION); this.maxTokenExpiration = Math.max( conf.getLong(Constants.Security.EXTENDED_TOKEN_EXPIRATION), conf.getLong(Constants.Security.TOKEN_EXPIRATION)); this.zookeeper = ZKClients.namespace(zookeeper, parentZNode); if (acls.isEmpty()) { LOG.warn("ZooKeeper ACL list is empty for keys!"); acls = ZooDefs.Ids.OPEN_ACL_UNSAFE; } LOG.debug("ZooKeeper ACLs {} for keys", acls); this.keyCache = new SharedResourceCache<>(zookeeper, codec, "/keys", acls); }
/** * Creates a {@link ZKClientService}. */ protected final ZKClientService createZKClient() { TwillRuntimeSpecification twillRuntimeSpec = getTwillRuntimeSpecification(); return ZKClientServices.delegate( ZKClients.namespace( ZKClients.reWatchOnExpire( ZKClients.retryOnFailure( ZKClientService.Builder.of(twillRuntimeSpec.getZkConnectStr()).build(), RetryStrategies.fixDelay(1, TimeUnit.SECONDS) ) ), "/" + twillRuntimeSpec.getTwillAppName() ) ); }