use of org.apache.flink.shaded.curator5.org.apache.curator.framework.CuratorFramework in project fabric8 by jboss-fuse.
the class ClusterList method createNewAction.
@Override
public Action createNewAction() {
assertValid();
// this is how we get hold of the curator framework
CuratorFramework curator = CuratorFrameworkLocator.getCuratorFramework();
return new ClusterListAction(fabricService.get(), curator);
}
use of org.apache.flink.shaded.curator5.org.apache.curator.framework.CuratorFramework in project fabric8 by jboss-fuse.
the class JoinAction method registerContainer.
/**
* Checks if there is an existing container using the same name.
*
* @param name
* @return
* @throws InterruptedException
* @throws KeeperException
*/
private boolean registerContainer(String name, String registryPassword, String profile, boolean force) throws Exception {
boolean exists = false;
CuratorFramework curator = null;
try {
CuratorFrameworkFactory.Builder builder = CuratorFrameworkFactory.builder().connectString(zookeeperUrl).retryPolicy(new RetryOneTime(1000)).connectionTimeoutMs(60000);
if (registryPassword != null && !registryPassword.isEmpty()) {
builder.authorization("digest", ("fabric:" + registryPassword).getBytes());
}
curator = builder.build();
curator.start();
curator.getZookeeperClient().blockUntilConnectedOrTimedOut();
exists = exists(curator, ZkPath.CONTAINER.getPath(name)) != null;
if (version == null) {
// ENTESB-7554: let's find default version
version = getStringData(curator, ZkPath.CONFIG_DEFAULT_VERSION.getPath());
System.out.println("No version specified, using default version: " + version);
} else {
// ENTESB-7554: verify the version exists - not that easy, because after deleting a version
// we still have it in ZK... to do?
}
if (!exists || force) {
ZkPath.createContainerPaths(curator, containerName, version, profile);
}
} finally {
if (curator != null) {
curator.close();
}
}
return !exists || force;
}
use of org.apache.flink.shaded.curator5.org.apache.curator.framework.CuratorFramework in project fabric8 by jboss-fuse.
the class ZKComponentSupport method doStart.
@Override
protected void doStart() throws Exception {
super.doStart();
if (curator == null) {
try {
CuratorFramework _curator = (CuratorFramework) getCamelContext().getRegistry().lookupByName("curator");
setCurator(_curator);
if (curator != null) {
LOG.debug("Zookeeper client found in camel registry. " + curator);
}
} catch (Exception exception) {
LOG.warn(exception);
}
}
managedGroupFactory = ManagedGroupFactoryBuilder.create(curator, getClass().getClassLoader(), this);
}
use of org.apache.flink.shaded.curator5.org.apache.curator.framework.CuratorFramework in project fabric8 by jboss-fuse.
the class EncryptionAlgorithmGet method createNewAction.
@Override
public Action createNewAction() {
assertValid();
// this is how we get hold of the curator framework
CuratorFramework curator = CuratorFrameworkLocator.getCuratorFramework();
return new EncryptionAlgorithmGetAction(curator);
}
use of org.apache.flink.shaded.curator5.org.apache.curator.framework.CuratorFramework in project fabric8 by jboss-fuse.
the class EnsemblePasswordAction method doExecute.
@Override
protected Object doExecute() throws Exception {
if (!commit) {
if (newPassword == null) {
System.out.println(fabricService.getZookeeperPassword());
} else {
String zookeeperUrl = fabricService.getZookeeperUrl();
String oldPassword = fabricService.getZookeeperPassword();
System.out.println("Updating the password...");
// Since we will be changing the password, create a new ZKClient that won't
// be getting update by the password change.
CuratorACLManager aclManager = new CuratorACLManager();
CuratorFramework curator = CuratorFrameworkFactory.builder().connectString(zookeeperUrl).retryPolicy(new RetryOneTime(500)).aclProvider(aclManager).authorization("digest", ("fabric:" + oldPassword).getBytes()).sessionTimeoutMs(30000).build();
curator.start();
try {
// Lets first adjust the acls so that the new password and old passwords work against the ZK paths.
String digestedIdPass = DigestAuthenticationProvider.generateDigest("fabric:" + newPassword);
aclManager.registerAcl("/fabric", "auth::acdrw,world:anyone:,digest:" + digestedIdPass + ":acdrw");
aclManager.fixAcl(curator, "/fabric", true);
// Ok now lets push out a config update of what the password is.
curator.setData().forPath(ZkPath.CONFIG_ENSEMBLE_PASSWORD.getPath(), PasswordEncoder.encode(newPassword).getBytes(Charsets.UTF_8));
} finally {
curator.close();
}
// Refresh the default profile to cause all nodes to pickup the new password.
ProfileService profileService = fabricService.adapt(ProfileService.class);
for (String ver : profileService.getVersions()) {
Version version = profileService.getVersion(ver);
if (version != null) {
Profile profile = version.getProfile("default");
if (profile != null) {
Profiles.refreshProfile(fabricService, profile);
}
}
}
System.out.println("");
System.out.println("Password updated. Please wait a little while for the new password to");
System.out.println("get delivered as a config update to all the fabric nodes. Once, the ");
System.out.println("nodes all updated (nodes must be online), please run:");
System.out.println("");
System.out.println(" fabric:ensemble-password --commit ");
System.out.println("");
}
} else {
// Now lets connect with the new password and reset the ACLs so that the old password
// does not work anymore.
CuratorACLManager aclManager = new CuratorACLManager();
CuratorFramework curator = CuratorFrameworkFactory.builder().connectString(fabricService.getZookeeperUrl()).retryPolicy(new RetryOneTime(500)).aclProvider(aclManager).authorization("digest", ("fabric:" + fabricService.getZookeeperPassword()).getBytes()).sessionTimeoutMs(30000).build();
curator.start();
try {
aclManager.fixAcl(curator, "/fabric", true);
System.out.println("Only the current password is allowed access to fabric now.");
} finally {
curator.close();
}
}
return null;
}
Aggregations