use of org.apache.flink.shaded.zookeeper3.org.apache.zookeeper.data.ACL in project fabric8 by jboss-fuse.
the class CreateAction method doExecute.
@Override
protected void doExecute(CuratorFramework curator) throws Exception {
List<ACL> acls = acl == null ? ZooDefs.Ids.OPEN_ACL_UNSAFE : parseACLs(acl);
CreateMode mode;
if (ephemeral && sequential) {
mode = CreateMode.EPHEMERAL_SEQUENTIAL;
} else if (ephemeral) {
mode = CreateMode.EPHEMERAL;
} else if (sequential) {
mode = CreateMode.PERSISTENT_SEQUENTIAL;
} else {
mode = CreateMode.PERSISTENT;
}
String nodeData = data;
if (importUrl) {
nodeData = loadUrl(new URL(data));
}
try {
CreateBuilder createBuilder = curator.create();
if (recursive) {
createBuilder.creatingParentsIfNeeded();
}
BackgroundPathAndBytesable<String> create = createBuilder.withMode(mode).withACL(acls);
if (nodeData == null) {
create.forPath(path);
} else {
create.forPath(path, nodeData.getBytes());
}
} catch (KeeperException.NodeExistsException e) {
if (overwrite) {
curator.setData().forPath(path, nodeData.getBytes());
} else {
throw e;
}
}
}
use of org.apache.flink.shaded.zookeeper3.org.apache.zookeeper.data.ACL in project knox by apache.
the class RemoteConfigurationRegistryClientServiceTest method initializeTestClientAndZNodes.
/**
* Create a ZooKeeper client with SASL digest auth configured, and initialize the test znodes.
*/
private CuratorFramework initializeTestClientAndZNodes(TestingCluster zkCluster, String principal) throws Exception {
// Create the client for the test cluster
CuratorFramework setupClient = CuratorFrameworkFactory.builder().connectString(zkCluster.getConnectString()).retryPolicy(new ExponentialBackoffRetry(100, 3)).build();
assertNotNull(setupClient);
setupClient.start();
List<ACL> acls = new ArrayList<>();
if (principal != null) {
acls.add(new ACL(ZooDefs.Perms.ALL, new Id("sasl", principal)));
} else {
acls.add(new ACL(ZooDefs.Perms.ALL, ZooDefs.Ids.ANYONE_ID_UNSAFE));
}
setupClient.create().creatingParentsIfNeeded().withACL(acls).forPath("/knox/config/descriptors");
setupClient.create().creatingParentsIfNeeded().withACL(acls).forPath("/knox/config/shared-providers");
List<ACL> negativeACLs = new ArrayList<>();
if (principal != null) {
negativeACLs.add(new ACL(ZooDefs.Perms.ALL, new Id("sasl", "notyou")));
} else {
negativeACLs.add(new ACL(ZooDefs.Perms.ALL, ZooDefs.Ids.ANYONE_ID_UNSAFE));
}
setupClient.create().creatingParentsIfNeeded().withACL(negativeACLs).forPath("/someotherconfig");
return setupClient;
}
use of org.apache.flink.shaded.zookeeper3.org.apache.zookeeper.data.ACL in project phoenix by apache.
the class LoadBalanceZookeeperConfImpl method getAcls.
@Override
public List<ACL> getAcls() {
ACL acl = new ACL();
acl.setId(new Id("digest", getZkLbUserName() + ":" + getZkLbPassword()));
acl.setPerms(ZooDefs.Perms.READ);
return Arrays.asList(acl);
}
use of org.apache.flink.shaded.zookeeper3.org.apache.zookeeper.data.ACL in project atlas by apache.
the class ActiveInstanceState method update.
/**
* Update state of the active server instance.
*
* This method writes this instance's Server Address to a shared node in Zookeeper.
* This information is used by other passive instances to locate the current active server.
* @throws Exception
* @param serverId ID of this server instance
*/
public void update(String serverId) throws AtlasBaseException {
try {
CuratorFramework client = curatorFactory.clientInstance();
HAConfiguration.ZookeeperProperties zookeeperProperties = HAConfiguration.getZookeeperProperties(configuration);
String atlasServerAddress = HAConfiguration.getBoundAddressForId(configuration, serverId);
List<ACL> acls = Arrays.asList(new ACL[] { AtlasZookeeperSecurityProperties.parseAcl(zookeeperProperties.getAcl(), ZooDefs.Ids.OPEN_ACL_UNSAFE.get(0)) });
Stat serverInfo = client.checkExists().forPath(getZnodePath(zookeeperProperties));
if (serverInfo == null) {
client.create().withMode(CreateMode.EPHEMERAL).withACL(acls).forPath(getZnodePath(zookeeperProperties));
}
client.setData().forPath(getZnodePath(zookeeperProperties), atlasServerAddress.getBytes(Charset.forName("UTF-8")));
} catch (Exception e) {
throw new AtlasBaseException(AtlasErrorCode.CURATOR_FRAMEWORK_UPDATE, e, "forPath: getZnodePath");
}
}
use of org.apache.flink.shaded.zookeeper3.org.apache.zookeeper.data.ACL in project atlas by apache.
the class ActiveInstanceStateTest method testSharedPathIsCreatedWithRightACLIfNotExists.
@Test
public void testSharedPathIsCreatedWithRightACLIfNotExists() throws Exception {
when(configuration.getString(HAConfiguration.ATLAS_SERVER_ADDRESS_PREFIX + "id1")).thenReturn(HOST_PORT);
when(configuration.getString(HAConfiguration.HA_ZOOKEEPER_ACL)).thenReturn("sasl:myclient@EXAMPLE.COM");
when(configuration.getString(HAConfiguration.ATLAS_SERVER_HA_ZK_ROOT_KEY, HAConfiguration.ATLAS_SERVER_ZK_ROOT_DEFAULT)).thenReturn(HAConfiguration.ATLAS_SERVER_ZK_ROOT_DEFAULT);
when(curatorFactory.clientInstance()).thenReturn(curatorFramework);
ExistsBuilder existsBuilder = mock(ExistsBuilder.class);
when(curatorFramework.checkExists()).thenReturn(existsBuilder);
when(existsBuilder.forPath(getPath())).thenReturn(null);
CreateBuilder createBuilder = mock(CreateBuilder.class);
when(curatorFramework.create()).thenReturn(createBuilder);
when(createBuilder.withMode(CreateMode.EPHEMERAL)).thenReturn(createBuilder);
ACL expectedAcl = new ACL(ZooDefs.Perms.ALL, new Id("sasl", "myclient@EXAMPLE.COM"));
when(createBuilder.withACL(Arrays.asList(new ACL[] { expectedAcl }))).thenReturn(createBuilder);
SetDataBuilder setDataBuilder = mock(SetDataBuilder.class);
when(curatorFramework.setData()).thenReturn(setDataBuilder);
ActiveInstanceState activeInstanceState = new ActiveInstanceState(configuration, curatorFactory);
activeInstanceState.update("id1");
verify(createBuilder).forPath(getPath());
}
Aggregations