当前位置: 首页>>代码示例>>Java>>正文


Java ConfigScopeProperty.valueOf方法代码示例

本文整理汇总了Java中org.apache.helix.model.HelixConfigScope.ConfigScopeProperty.valueOf方法的典型用法代码示例。如果您正苦于以下问题:Java ConfigScopeProperty.valueOf方法的具体用法?Java ConfigScopeProperty.valueOf怎么用?Java ConfigScopeProperty.valueOf使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.helix.model.HelixConfigScope.ConfigScopeProperty的用法示例。


在下文中一共展示了ConfigScopeProperty.valueOf方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: build

import org.apache.helix.model.HelixConfigScope.ConfigScopeProperty; //导入方法依赖的package包/类
public ConfigScope build(String scopePairs) {
  String[] scopes = scopePairs.split("[\\s,]+");
  for (String scope : scopes) {
    try {
      int idx = scope.indexOf('=');
      if (idx == -1) {
        LOG.error("Invalid scope string: " + scope);
        continue;
      }

      String scopeStr = scope.substring(0, idx);
      String value = scope.substring(idx + 1);
      ConfigScopeProperty scopeProperty = ConfigScopeProperty.valueOf(scopeStr);
      _scopeMap.put(scopeProperty, value);
    } catch (Exception e) {
      LOG.error("Invalid scope string: " + scope);
      continue;
    }
  }

  return build();
}
 
开发者ID:apache,项目名称:helix,代码行数:23,代码来源:ConfigScopeBuilder.java

示例2: post

import org.apache.helix.model.HelixConfigScope.ConfigScopeProperty; //导入方法依赖的package包/类
/**
 * Set/remove scoped configs
 * <p>
 * Usage:
 * <p>
 * <li>Set cluster level configs:
 * <code>curl -d 'jsonParameters={"command":"setConfig","configs":"{key1=value1,key2=value2}"}'
 * -H "Content-Type: application/json" http://{host:port}/clusters/{clusterName}/configs/cluster
 * <li>Remove cluster level configs:
 * <code>curl -d 'jsonParameters={"command":"removeConfig","configs":"{key1,key2}"}'
 * -H "Content-Type: application/json" http://{host:port}/clusters/{clusterName}/configs/cluster
 * <li>Set instance level configs:
 * <code>curl -d 'jsonParameters={"command":"setConfig","configs":"{key1=value1,key2=value2}"}'
 * -H "Content-Type: application/json" http://{host:port}/clusters/{clusterName}/configs/participant/{instanceName}
 * <li>Remove instance level configs:
 * <code>curl -d 'jsonParameters={"command":"removeConfig","configs":"{key1,key2}"}'
 * -H "Content-Type: application/json" http://{host:port}/clusters/{clusterName}/configs/participant/{instanceName}
 * <li>Set resource level configs:
 * <code>curl -d 'jsonParameters={"command":"setConfig","configs":"{key1=value1,key2=value2}"}'
 * -H "Content-Type: application/json" http://{host:port}/clusters/{clusterName}/configs/resource/{resourceName}
 * <li>Remove resource level configs:
 * <code>curl -d 'jsonParameters={"command":"removeConfig","configs":"{key1,key2}"}'
 * -H "Content-Type: application/json" http://{host:port}/clusters/{clusterName}/configs/resource/{resourceName}
 */
@Override
public Representation post(Representation entity) {
  String clusterName = getValue("clusterName");

  String scopeStr = getValue("scope").toUpperCase();
  try {
    ConfigScopeProperty scopeProperty = ConfigScopeProperty.valueOf(scopeStr);

    switch (scopeProperty) {
    case CLUSTER:
      String scopeArgs = clusterName;
      setConfigs(entity, scopeProperty, scopeArgs);
      break;
    case PARTICIPANT:
    case RESOURCE:
      String scopeKey1 = getValue("scopeKey1");

      if (scopeKey1 == null) {
        throw new HelixException("Missing resourceName|participantName");
      } else {
        scopeArgs = clusterName + "," + scopeKey1;
        setConfigs(entity, scopeProperty, scopeArgs);
      }
      break;
    case PARTITION:
      scopeKey1 = getValue("scopeKey1");
      String scopeKey2 = getValue("scopeKey2");
      if (scopeKey1 == null || scopeKey2 == null) {
        throw new HelixException("Missing resourceName|partitionName");
      } else {
        scopeArgs = clusterName + "," + scopeKey1 + "," + scopeKey2;
        setConfigs(entity, scopeProperty, scopeArgs);
      }
      break;
    default:
      break;
    }
  } catch (Exception e) {
    LOG.error("Error in posting " + entity, e);
    getResponse().setEntity(ClusterRepresentationUtil.getErrorAsJsonStringFromException(e),
        MediaType.APPLICATION_JSON);
    getResponse().setStatus(Status.SUCCESS_OK);
  }
  return null;
}
 
开发者ID:apache,项目名称:helix,代码行数:70,代码来源:ConfigResource.java


注:本文中的org.apache.helix.model.HelixConfigScope.ConfigScopeProperty.valueOf方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。