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


Java HelixAdmin.getResourceExternalView方法代码示例

本文整理汇总了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"));
  }
}
 
开发者ID:apache,项目名称:helix,代码行数:21,代码来源:LockManagerDemo.java

示例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;
}
 
开发者ID:apache,项目名称:helix,代码行数:16,代码来源:TestAutoRebalanceWithDisabledInstance.java

示例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);
}
 
开发者ID:apache,项目名称:helix,代码行数:32,代码来源:ResourceAccessor.java

示例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();
}
 
开发者ID:apache,项目名称:helix,代码行数:13,代码来源:ResourceAccessor.java

示例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;
}
 
开发者ID:Hanmourang,项目名称:Pinot,代码行数:50,代码来源:BalanceNumSegmentAssignmentStrategy.java

示例6: getExternalViewForResouce

import org.apache.helix.HelixAdmin; //导入方法依赖的package包/类
public static ExternalView getExternalViewForResouce(HelixAdmin admin, String clusterName, String resourceName) {
  return admin.getResourceExternalView(clusterName, resourceName);
}
 
开发者ID:Hanmourang,项目名称:Pinot,代码行数:4,代码来源:HelixHelper.java

示例7: getExternalViewForResource

import org.apache.helix.HelixAdmin; //导入方法依赖的package包/类
public static ExternalView getExternalViewForResource(HelixAdmin admin, String clusterName, String resourceName) {
  return admin.getResourceExternalView(clusterName, resourceName);
}
 
开发者ID:linkedin,项目名称:pinot,代码行数:4,代码来源:HelixHelper.java


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