本文整理汇总了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();
}
示例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;
}