org.apache.storm.utils.Utils.isZkAuthenticationConfiguredTopology()方法的使用及代码示例

x33g5p2x  于2022-02-01 转载在 其他  
字(3.3k)|赞(0)|评价(0)|浏览(116)

本文整理了Java中org.apache.storm.utils.Utils.isZkAuthenticationConfiguredTopology()方法的一些代码示例,展示了Utils.isZkAuthenticationConfiguredTopology()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Utils.isZkAuthenticationConfiguredTopology()方法的具体详情如下:
包路径:org.apache.storm.utils.Utils
类名称:Utils
方法名:isZkAuthenticationConfiguredTopology

Utils.isZkAuthenticationConfiguredTopology介绍

[英]Is the topology configured to have ZooKeeper authentication.
[中]拓扑配置为具有ZooKeeper身份验证。

代码示例

代码示例来源:origin: apache/storm

/**
 * Get the ZK ACLs that a worker should use when writing to ZK.
 *
 * @param conf the config for the topology.
 * @return the ACLs
 */
public static List<ACL> getWorkerACL(Map<String, Object> conf) {
  if (!isZkAuthenticationConfiguredTopology(conf)) {
    return null;
  }
  ArrayList<ACL> ret = new ArrayList<>(ZooDefs.Ids.CREATOR_ALL_ACL);
  ret.add(getSuperUserAcl(conf));
  return ret;
}

代码示例来源:origin: apache/storm

private static List<ACL> mkTopoAcls(Map<String, Object> topoConf, int perms) {
  List<ACL> aclList = null;
  String payload = (String) topoConf.get(Config.STORM_ZOOKEEPER_TOPOLOGY_AUTH_PAYLOAD);
  if (Utils.isZkAuthenticationConfiguredTopology(topoConf)) {
    aclList = new ArrayList<>();
    ACL acl1 = ZooDefs.Ids.CREATOR_ALL_ACL.get(0);
    aclList.add(acl1);
    try {
      ACL acl2 = new ACL(perms, new Id("digest", DigestAuthenticationProvider.generateDigest(payload)));
      aclList.add(acl2);
    } catch (NoSuchAlgorithmException e) {
      //Should only happen on a badly configured system
      throw new RuntimeException(e);
    }
  }
  return aclList;
}

代码示例来源:origin: apache/storm

@Test
public void isZkAuthenticationConfiguredTopologyTest() {
  Assert.assertFalse(
    "Returns null if given null config",
    Utils.isZkAuthenticationConfiguredTopology(null));
  Assert.assertFalse(
    "Returns false if scheme key is missing",
    Utils.isZkAuthenticationConfiguredTopology(emptyMockMap()));
  Assert.assertFalse(
    "Returns false if scheme value is null",
    Utils.isZkAuthenticationConfiguredTopology(topologyMockMap(null)));
  Assert.assertTrue(
    "Returns true if scheme value is string",
    Utils.isZkAuthenticationConfiguredTopology(topologyMockMap("foobar")));
}

代码示例来源:origin: apache/storm

&& !Utils.isZkAuthenticationConfiguredTopology(topoConf)) {
throw new IllegalArgumentException("The cluster is configured for zookeeper authentication, but no payload was provided.");

代码示例来源:origin: org.apache.storm/storm-core

/**
 * Get the ZK ACLs that a worker should use when writing to ZK.
 * @param conf the config for the topology.
 * @return the ACLs
 */
public static List<ACL> getWorkerACL(Map<String, Object> conf) {
  if (!isZkAuthenticationConfiguredTopology(conf)) {
    return null;
  }
  ArrayList<ACL> ret = new ArrayList<ACL>(ZooDefs.Ids.CREATOR_ALL_ACL);
  ret.add(getSuperUserAcl(conf));
return ret;
}

代码示例来源:origin: org.apache.storm/storm-core

private static List<ACL> mkTopoAcls(Map<String, Object> topoConf, int perms) {
  List<ACL> aclList = null;
  String payload = (String) topoConf.get(Config.STORM_ZOOKEEPER_TOPOLOGY_AUTH_PAYLOAD);
  if (Utils.isZkAuthenticationConfiguredTopology(topoConf)) {
    aclList = new ArrayList<>();
    ACL acl1 = ZooDefs.Ids.CREATOR_ALL_ACL.get(0);
    aclList.add(acl1);
    try {
      ACL acl2 = new ACL(perms, new Id("digest", DigestAuthenticationProvider.generateDigest(payload)));
      aclList.add(acl2);
    } catch (NoSuchAlgorithmException e) {
      //Should only happen on a badly configured system
      throw new RuntimeException(e);
    }
  }
  return aclList;
}

相关文章

Utils类方法