本文整理汇总了Java中org.apache.helix.HelixAdmin.getResourceExternalView方法的典型用法代码示例。如果您正苦于以下问题:Java HelixAdmin.getResourceExternalView方法的具体用法?Java HelixAdmin.getResourceExternalView怎么用?Java HelixAdmin.getResourceExternalView使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.helix.HelixAdmin
的用法示例。
在下文中一共展示了HelixAdmin.getResourceExternalView方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: printStatus
import org.apache.helix.HelixAdmin; //导入方法依赖的package包/类
private static void printStatus(HelixAdmin admin, String cluster, String resource) {
ExternalView externalView = admin.getResourceExternalView(cluster, resource);
// System.out.println(externalView);
TreeSet<String> treeSet = new TreeSet<String>(externalView.getPartitionSet());
System.out.println("lockName" + "\t" + "acquired By");
System.out.println("======================================");
for (String lockName : treeSet) {
Map<String, String> stateMap = externalView.getStateMap(lockName);
String acquiredBy = null;
if (stateMap != null) {
for (String instanceName : stateMap.keySet()) {
if ("ONLINE".equals(stateMap.get(instanceName))) {
acquiredBy = instanceName;
break;
}
}
}
System.out.println(lockName + "\t" + ((acquiredBy != null) ? acquiredBy : "NONE"));
}
}
示例2: getCurrentPartitionsOnInstance
import org.apache.helix.HelixAdmin; //导入方法依赖的package包/类
private Set<String> getCurrentPartitionsOnInstance(String cluster, String dbName, String instance) {
HelixAdmin admin = _setupTool.getClusterManagementTool();
Set<String> partitionSet = new HashSet<String>();
ExternalView ev = admin.getResourceExternalView(cluster, dbName);
for (String partition : ev.getRecord().getMapFields().keySet()) {
Map<String, String> assignments = ev.getRecord().getMapField(partition);
for (String ins : assignments.keySet()) {
if (ins.equals(instance)) {
partitionSet.add(partition);
}
}
}
return partitionSet;
}
示例3: getResource
import org.apache.helix.HelixAdmin; //导入方法依赖的package包/类
@GET
@Path("{resourceName}")
public Response getResource(@PathParam("clusterId") String clusterId,
@PathParam("resourceName") String resourceName) throws IOException {
ConfigAccessor accessor = getConfigAccessor();
HelixAdmin admin = getHelixAdmin();
ResourceConfig resourceConfig = accessor.getResourceConfig(clusterId, resourceName);
IdealState idealState = admin.getResourceIdealState(clusterId, resourceName);
ExternalView externalView = admin.getResourceExternalView(clusterId, resourceName);
Map<String, ZNRecord> resourceMap = new HashMap<>();
if (idealState != null) {
resourceMap.put(ResourceProperties.idealState.name(), idealState.getRecord());
} else {
return notFound();
}
resourceMap.put(ResourceProperties.resourceConfig.name(), null);
resourceMap.put(ResourceProperties.externalView.name(), null);
if (resourceConfig != null) {
resourceMap.put(ResourceProperties.resourceConfig.name(), resourceConfig.getRecord());
}
if (externalView != null) {
resourceMap.put(ResourceProperties.externalView.name(), externalView.getRecord());
}
return JSONRepresentation(resourceMap);
}
示例4: getResourceExternalView
import org.apache.helix.HelixAdmin; //导入方法依赖的package包/类
@GET
@Path("{resourceName}/externalView")
public Response getResourceExternalView(@PathParam("clusterId") String clusterId,
@PathParam("resourceName") String resourceName) {
HelixAdmin admin = getHelixAdmin();
ExternalView externalView = admin.getResourceExternalView(clusterId, resourceName);
if (externalView != null) {
return JSONRepresentation(externalView.getRecord());
}
return notFound();
}
示例5: getAssignedInstances
import org.apache.helix.HelixAdmin; //导入方法依赖的package包/类
@Override
public List<String> getAssignedInstances(HelixAdmin helixAdmin, String helixClusterName,
SegmentMetadata segmentMetadata, int numReplicas, String tenantName) {
String serverTenantName;
String tableName;
if ("realtime".equalsIgnoreCase(segmentMetadata.getIndexType())) {
tableName = TableNameBuilder.REALTIME_TABLE_NAME_BUILDER.forTable(segmentMetadata.getTableName());
serverTenantName = ControllerTenantNameBuilder.getRealtimeTenantNameForTenant(tenantName);
} else {
tableName = TableNameBuilder.OFFLINE_TABLE_NAME_BUILDER.forTable(segmentMetadata.getTableName());
serverTenantName = ControllerTenantNameBuilder.getOfflineTenantNameForTenant(tenantName);
}
List<String> selectedInstances = new ArrayList<String>();
Map<String, Integer> currentNumSegmentsPerInstanceMap = new HashMap<String, Integer>();
List<String> allTaggedInstances = helixAdmin.getInstancesInClusterWithTag(helixClusterName, serverTenantName);
for (String instance : allTaggedInstances) {
currentNumSegmentsPerInstanceMap.put(instance, 0);
}
ExternalView externalView = helixAdmin.getResourceExternalView(helixClusterName, tableName);
if (externalView != null) {
for (String partitionName : externalView.getPartitionSet()) {
Map<String, String> instanceToStateMap = externalView.getStateMap(partitionName);
for (String instanceName : instanceToStateMap.keySet()) {
if (currentNumSegmentsPerInstanceMap.containsKey(instanceName)) {
currentNumSegmentsPerInstanceMap.put(instanceName, currentNumSegmentsPerInstanceMap.get(instanceName) + 1);
} else {
currentNumSegmentsPerInstanceMap.put(instanceName, 1);
}
}
}
}
PriorityQueue<Number2ObjectPair<String>> priorityQueue =
new PriorityQueue<Number2ObjectPair<String>>(numReplicas, Pairs.getDescendingnumber2ObjectPairComparator());
for (String key : currentNumSegmentsPerInstanceMap.keySet()) {
priorityQueue.add(new Number2ObjectPair<String>(currentNumSegmentsPerInstanceMap.get(key), key));
if (priorityQueue.size() > numReplicas) {
priorityQueue.poll();
}
}
while (!priorityQueue.isEmpty()) {
selectedInstances.add(priorityQueue.poll().getB());
}
LOGGER.info("Segment assignment result for : " + segmentMetadata.getName() + ", in resource : "
+ segmentMetadata.getTableName() + ", selected instances: " + Arrays.toString(selectedInstances.toArray()));
return selectedInstances;
}
示例6: getExternalViewForResouce
import org.apache.helix.HelixAdmin; //导入方法依赖的package包/类
public static ExternalView getExternalViewForResouce(HelixAdmin admin, String clusterName, String resourceName) {
return admin.getResourceExternalView(clusterName, resourceName);
}
示例7: getExternalViewForResource
import org.apache.helix.HelixAdmin; //导入方法依赖的package包/类
public static ExternalView getExternalViewForResource(HelixAdmin admin, String clusterName, String resourceName) {
return admin.getResourceExternalView(clusterName, resourceName);
}