use of org.apache.flink.shaded.curator5.org.apache.curator.framework.CuratorFramework in project fabric8 by jboss-fuse.
the class EncryptedPropertyResolverTest method testResolveZkEnc.
@Test
public void testResolveZkEnc() throws Exception {
CuratorFramework curator = createMock(CuratorFramework.class);
GetDataBuilder getDataBuilder = createMock(GetDataBuilder.class);
expect(curator.getData()).andReturn(getDataBuilder).anyTimes();
expect(getDataBuilder.forPath(AUTHENTICATION_CRYPT_ALGORITHM.getPath())).andReturn("PBEWithMD5AndDES".getBytes()).anyTimes();
expect(getDataBuilder.forPath(AUTHENTICATION_CRYPT_PASSWORD.getPath())).andReturn("ZKENC=bXlwYXNzd29yZA==".getBytes()).anyTimes();
replay(curator);
replay(getDataBuilder);
FabricService fabricService = createMock(FabricService.class);
expect(fabricService.adapt(CuratorFramework.class)).andReturn(curator).anyTimes();
replay(fabricService);
PlaceholderResolver resolver = getEncryptedPropertyResolver();
assertEquals("encryptedpassword", resolver.resolve(fabricService, null, null, null, "crypt:URdoo9++D3tsoC9ODrTfLNK5WzviknO3Ig6qbI2HuvQ="));
verify(curator);
verify(getDataBuilder);
}
use of org.apache.flink.shaded.curator5.org.apache.curator.framework.CuratorFramework in project fabric8 by jboss-fuse.
the class ZooKeeperClusterServiceImpl method obtainValid.
private CuratorFramework obtainValid(ValidatingReference<CuratorFramework> curator) throws InterruptedException {
int counter = 1;
while (true) {
if (counter > 18) {
throw new IllegalStateException("Unable to obtain a valid reference of Curator after " + counter + " tries");
}
LOGGER.debug("Getting CuratorFramework reference. Attempt {}", counter);
CuratorFramework result = curator.getOptional();
if (result == null) {
LOGGER.warn("Curator instance not ready");
counter++;
Thread.sleep(5 * 1000);
} else {
return curator.get();
}
}
}
use of org.apache.flink.shaded.curator5.org.apache.curator.framework.CuratorFramework in project fabric8 by jboss-fuse.
the class FabricLoadBalancerFeature method getCurator.
public synchronized CuratorFramework getCurator() throws Exception {
if (curator == null) {
String connectString = getZooKeeperUrl();
if (connectString == null) {
connectString = System.getProperty(ZOOKEEPER_URL, "localhost:2181");
}
String password = getZooKeeperPassword();
if (password == null) {
System.getProperty(ZOOKEEPER_PASSWORD);
}
LOG.debug("Zookeeper client not find in camel registry, creating new with connection " + connectString);
CuratorFrameworkFactory.Builder builder = CuratorFrameworkFactory.builder().connectString(connectString).retryPolicy(new RetryOneTime(1000)).connectionTimeoutMs(maximumConnectionTimeout);
if (password != null && !password.isEmpty()) {
builder.authorization("digest", ("fabric:" + password).getBytes());
}
CuratorFramework client = builder.build();
LOG.debug("Starting curator " + curator);
client.start();
curator = client;
setShouldCloseZkClient(true);
}
curator.getZookeeperClient().blockUntilConnectedOrTimedOut();
return curator;
}
use of org.apache.flink.shaded.curator5.org.apache.curator.framework.CuratorFramework in project fabric8 by jboss-fuse.
the class FabricServiceImpl method getGitUrl.
@Override
public String getGitUrl() {
assertValid();
String gitServers = ZkPath.GIT.getPath();
try {
CuratorFramework curatorFramework = curator.get();
if (curatorFramework != null) {
List<String> servers = getChildrenSafe(curatorFramework, gitServers);
for (String server : servers) {
String serverPath = gitServers + "/" + server;
String answer = getFirstService(serverPath);
if (!Strings.isNullOrEmpty(answer)) {
return answer;
}
}
}
} catch (Exception e) {
// On exception just return uri.
LOGGER.warn("Failed to find Git URL " + gitServers + ". " + e, e);
}
return null;
}
use of org.apache.flink.shaded.curator5.org.apache.curator.framework.CuratorFramework in project fabric8 by jboss-fuse.
the class ZooKeeperFacade method getCurator.
/**
* Returns the ZooKeeper client or throwns an exception if its not configured properly
*/
protected CuratorFramework getCurator() {
CuratorFramework curator = fabricService.adapt(CuratorFramework.class);
notNull(curator, "curator");
return curator;
}
Aggregations