本文整理了Java中org.apache.kylin.storage.hbase.util.ZookeeperAclBuilder
类的一些代码示例,展示了ZookeeperAclBuilder
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ZookeeperAclBuilder
类的具体详情如下:
包路径:org.apache.kylin.storage.hbase.util.ZookeeperAclBuilder
类名称:ZookeeperAclBuilder
[英]Created by peng.jianhua on 17-6-5.
[中]彭先生创作。建华17-6-5。
代码示例来源:origin: apache/kylin
private static CuratorFramework getZKClient(KylinConfig config) {
CuratorFramework zkClient = CACHE.get(config);
if (zkClient == null) {
synchronized (ZookeeperDistributedLock.class) {
zkClient = CACHE.get(config);
if (zkClient == null) {
RetryPolicy retryPolicy = new ExponentialBackoffRetry(1000, 3);
String zkConnectString = getZKConnectString(config);
ZookeeperAclBuilder zookeeperAclBuilder = new ZookeeperAclBuilder().invoke();
zkClient = zookeeperAclBuilder.setZKAclBuilder(CuratorFrameworkFactory.builder()).connectString(zkConnectString).sessionTimeoutMs(120000).connectionTimeoutMs(15000).retryPolicy(retryPolicy).build();
zkClient.start();
CACHE.put(config, zkClient);
if (CACHE.size() > 1) {
logger.warn("More than one singleton exist");
}
}
}
}
return zkClient;
}
代码示例来源:origin: apache/kylin
public ZookeeperAclBuilder invoke() {
try {
if (isNeedAcl()) {
zkAcls = getZKAcls();
zkAuthInfo = getZKAuths();
}
} catch (Exception e) {
isNeedAcl = false;
return this;
}
return this;
}
代码示例来源:origin: apache/kylin
@Test
public void testAclEnabled() {
KylinConfig testConfig = KylinConfig.getInstanceFromEnv();
testConfig.setProperty("kylin.env.zookeeper-acl-enabled", "true");
ZookeeperAclBuilder zookeeperAclBuilder = new ZookeeperAclBuilder().invoke();
Assert.assertNotNull(zookeeperAclBuilder);
Assert.assertTrue(zookeeperAclBuilder.isNeedAcl());
List<ACL> zkAcls = Lists.newArrayList();
try {
zkAcls = ZookeeperAclBuilder.getZKAcls();
Assert.assertFalse(zkAcls.isEmpty());
} catch (Exception e) {
fail("Couldn't read ACLs based on 'kylin.env.zookeeper.zk-acl' in kylin.properties");
}
List<ZKUtil.ZKAuthInfo> zkAuthInfo = Lists.newArrayList();
try {
zkAuthInfo = ZookeeperAclBuilder.getZKAuths();
Assert.assertFalse(zkAuthInfo.isEmpty());
} catch (Exception e) {
fail("Couldn't read Auth based on 'kylin.env.zookeeper.zk-auth' in kylin.properties");
}
Builder builder = zookeeperAclBuilder.setZKAclBuilder(CuratorFrameworkFactory.builder());
Assert.assertNotNull(builder);
Assert.assertEquals(zkAcls, builder.getAclProvider().getDefaultAcl());
Assert.assertNotNull(builder.getAuthInfos());
}
代码示例来源:origin: apache/kylin
@Test
public void testAclDisabled() {
KylinConfig testConfig = KylinConfig.getInstanceFromEnv();
testConfig.setProperty("kylin.env.zookeeper-acl-enabled", "false");
ZookeeperAclBuilder zookeeperAclBuilder = new ZookeeperAclBuilder().invoke();
Assert.assertNotNull(zookeeperAclBuilder);
Assert.assertFalse(zookeeperAclBuilder.isNeedAcl());
Builder builder = zookeeperAclBuilder.setZKAclBuilder(CuratorFrameworkFactory.builder());
Assert.assertNotNull(builder);
Assert.assertEquals(ZooDefs.Ids.OPEN_ACL_UNSAFE, builder.getAclProvider().getDefaultAcl());
Assert.assertNull(builder.getAuthInfos());
}
代码示例来源:origin: apache/kylin
public Builder setZKAclBuilder(Builder builder) {
Builder aclBuilder;
ACLProvider aclProvider;
if (!isNeedAcl()) {
return builder;
}
aclProvider = new ACLProvider() {
private List<ACL> acl;
@Override
public List<ACL> getDefaultAcl() {
if (acl == null) {
this.acl = zkAcls;
}
return acl;
}
@Override
public List<ACL> getAclForPath(String path) {
return acl;
}
};
aclBuilder = builder.aclProvider(aclProvider);
for (ZKUtil.ZKAuthInfo auth : zkAuthInfo) {
aclBuilder = aclBuilder.authorization(auth.getScheme(), auth.getAuth());
}
return aclBuilder;
}
代码示例来源:origin: org.apache.kylin/kylin-storage-hbase
public Builder setZKAclBuilder(Builder builder) {
Builder aclBuilder;
ACLProvider aclProvider;
if (!isNeedAcl()) {
return builder;
}
aclProvider = new ACLProvider() {
private List<ACL> acl;
@Override
public List<ACL> getDefaultAcl() {
if (acl == null) {
this.acl = zkAcls;
}
return acl;
}
@Override
public List<ACL> getAclForPath(String path) {
return acl;
}
};
aclBuilder = builder.aclProvider(aclProvider);
for (ZKUtil.ZKAuthInfo auth : zkAuthInfo) {
aclBuilder = aclBuilder.authorization(auth.getScheme(), auth.getAuth());
}
return aclBuilder;
}
代码示例来源:origin: org.apache.kylin/kylin-storage-hbase
public ZookeeperAclBuilder invoke() {
try {
if (isNeedAcl()) {
zkAcls = getZKAcls();
zkAuthInfo = getZKAuths();
}
} catch (Exception e) {
isNeedAcl = false;
return this;
}
return this;
}
代码示例来源:origin: org.apache.kylin/kylin-storage-hbase
private static CuratorFramework getZKClient(KylinConfig config) {
CuratorFramework zkClient = CACHE.get(config);
if (zkClient == null) {
synchronized (ZookeeperDistributedLock.class) {
zkClient = CACHE.get(config);
if (zkClient == null) {
RetryPolicy retryPolicy = new ExponentialBackoffRetry(1000, 3);
String zkConnectString = getZKConnectString(config);
ZookeeperAclBuilder zookeeperAclBuilder = new ZookeeperAclBuilder().invoke();
zkClient = zookeeperAclBuilder.setZKAclBuilder(CuratorFrameworkFactory.builder()).connectString(zkConnectString).sessionTimeoutMs(120000).connectionTimeoutMs(15000).retryPolicy(retryPolicy).build();
zkClient.start();
CACHE.put(config, zkClient);
if (CACHE.size() > 1) {
logger.warn("More than one singleton exist");
}
}
}
}
return zkClient;
}
内容来源于网络,如有侵权,请联系作者删除!