示例#1
0
 @Override
 public boolean verify() {
   HelixDataAccessor accessor =
       new ZKHelixDataAccessor(_clusterName, new ZkBaseDataAccessor(_client));
   Builder keyBuilder = accessor.keyBuilder();
   int numberOfPartitions =
       accessor
           .getProperty(keyBuilder.idealStates(_resourceName))
           .getRecord()
           .getListFields()
           .size();
   ClusterDataCache cache = new ClusterDataCache();
   cache.refresh(accessor);
   String masterValue =
       cache
           .getStateModelDef(cache.getIdealState(_resourceName).getStateModelDefRef())
           .getStatesPriorityList()
           .get(0);
   int replicas = Integer.parseInt(cache.getIdealState(_resourceName).getReplicas());
   return verifyBalanceExternalView(
       accessor.getProperty(keyBuilder.externalView(_resourceName)).getRecord(),
       numberOfPartitions,
       masterValue,
       replicas,
       cache.getLiveInstances().size());
 }
 private int getNumPartitions(String dbName) {
   logger.debug("dbName: " + dbName);
   HelixDataAccessor helixDataAccessor = _cmConnector.getManager().getHelixDataAccessor();
   Builder keyBuilder = helixDataAccessor.keyBuilder();
   ZNRecord rec = helixDataAccessor.getProperty(keyBuilder.idealStates(dbName)).getRecord();
   if (rec == null) {
     logger.debug("rec is null");
   }
   IdealState state = new IdealState(rec);
   return state.getNumPartitions();
 }