com.hazelcast.config.Config.getMemberAttributeConfig()方法的使用及代码示例

x33g5p2x  于2022-01-18 转载在 其他  
字(5.0k)|赞(0)|评价(0)|浏览(110)

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

Config.getMemberAttributeConfig介绍

[英]Returns the member attribute configuration. Unlike the config properties (see #setProperties(Properties)), member attributes are exchanged with other members, e.g. on membership events.
[中]返回成员属性配置。与配置属性不同(请参见#setProperties(properties)),成员属性与其他成员交换,例如在成员资格事件上。

代码示例

代码示例来源:origin: SonarSource/sonarqube

MemberAttributeConfig attributes = config.getMemberAttributeConfig();
attributes.setStringAttribute(Attribute.NODE_NAME.getKey(), requireNonNull(nodeName, "Node name is missing"));
attributes.setStringAttribute(Attribute.PROCESS_KEY.getKey(), requireNonNull(processId, "Process key is missing").getKey());

代码示例来源:origin: hazelcast/hazelcast-jet

@Override
public MemberAttributeConfig getMemberAttributeConfig() {
  return staticConfig.getMemberAttributeConfig();
}

代码示例来源:origin: com.hazelcast/hazelcast-all

@Override
public MemberAttributeConfig getMemberAttributeConfig() {
  return staticConfig.getMemberAttributeConfig();
}

代码示例来源:origin: hazelcast/hazelcast-jet

private void handleMemberAttributes(Node node) {
  for (Node n : childElements(node)) {
    String name = cleanNodeName(n);
    if (!"attribute".equals(name)) {
      continue;
    }
    String attributeName = getTextContent(n.getAttributes().getNamedItem("name"));
    String attributeType = getTextContent(n.getAttributes().getNamedItem("type"));
    String value = getTextContent(n);
    if ("string".equals(attributeType)) {
      config.getMemberAttributeConfig().setStringAttribute(attributeName, value);
    } else if ("boolean".equals(attributeType)) {
      config.getMemberAttributeConfig().setBooleanAttribute(attributeName, parseBoolean(value));
    } else if ("byte".equals(attributeType)) {
      config.getMemberAttributeConfig().setByteAttribute(attributeName, Byte.parseByte(value));
    } else if ("double".equals(attributeType)) {
      config.getMemberAttributeConfig().setDoubleAttribute(attributeName, Double.parseDouble(value));
    } else if ("float".equals(attributeType)) {
      config.getMemberAttributeConfig().setFloatAttribute(attributeName, Float.parseFloat(value));
    } else if ("int".equals(attributeType)) {
      config.getMemberAttributeConfig().setIntAttribute(attributeName, parseInt(value));
    } else if ("long".equals(attributeType)) {
      config.getMemberAttributeConfig().setLongAttribute(attributeName, parseLong(value));
    } else if ("short".equals(attributeType)) {
      config.getMemberAttributeConfig().setShortAttribute(attributeName, Short.parseShort(value));
    } else {
      config.getMemberAttributeConfig().setStringAttribute(attributeName, value);
    }
  }
}

代码示例来源:origin: com.hazelcast/hazelcast-all

private void handleMemberAttributes(Node node) {
  for (Node n : childElements(node)) {
    String name = cleanNodeName(n);
    if (!"attribute".equals(name)) {
      continue;
    }
    String attributeName = getTextContent(n.getAttributes().getNamedItem("name"));
    String attributeType = getTextContent(n.getAttributes().getNamedItem("type"));
    String value = getTextContent(n);
    if ("string".equals(attributeType)) {
      config.getMemberAttributeConfig().setStringAttribute(attributeName, value);
    } else if ("boolean".equals(attributeType)) {
      config.getMemberAttributeConfig().setBooleanAttribute(attributeName, parseBoolean(value));
    } else if ("byte".equals(attributeType)) {
      config.getMemberAttributeConfig().setByteAttribute(attributeName, Byte.parseByte(value));
    } else if ("double".equals(attributeType)) {
      config.getMemberAttributeConfig().setDoubleAttribute(attributeName, Double.parseDouble(value));
    } else if ("float".equals(attributeType)) {
      config.getMemberAttributeConfig().setFloatAttribute(attributeName, Float.parseFloat(value));
    } else if ("int".equals(attributeType)) {
      config.getMemberAttributeConfig().setIntAttribute(attributeName, parseInt(value));
    } else if ("long".equals(attributeType)) {
      config.getMemberAttributeConfig().setLongAttribute(attributeName, parseLong(value));
    } else if ("short".equals(attributeType)) {
      config.getMemberAttributeConfig().setShortAttribute(attributeName, Short.parseShort(value));
    } else {
      config.getMemberAttributeConfig().setStringAttribute(attributeName, value);
    }
  }
}

代码示例来源:origin: hazelcast/hazelcast-code-samples

public static void main(String[] args) throws Exception {
  Config config = new Config();
  config.getMemberAttributeConfig().setBooleanAttribute("EAST", true);
  HazelcastInstance node = Hazelcast.newHazelcastInstance(config);
  IExecutorService executorService = node.getExecutorService(ForceLocalMemberToBeSafe.class.getName());
  Future<Boolean> result = executorService.submit(new MemberSafe(), new MemberSelector() {
    @Override
    public boolean select(Member member) {
      Boolean east = member.getBooleanAttribute("EAST");
      return Boolean.TRUE.equals(east);
    }
  });
  System.out.printf("# Is forcing member to be safe is successful\t: %s\n", result.get());
}

相关文章

Config类方法