@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(); }
private void addLiveInstance() { if (!isClusterSetup(_clusterName)) { throw new HelixException( "Initial cluster structure is not set up for cluster:" + _clusterName); } if (!isInstanceSetup()) { throw new HelixException( "Instance is not configured for instance:" + _instanceName + " instanceType:" + _instanceType); } LiveInstance liveInstance = new LiveInstance(_instanceName); liveInstance.setSessionId(_sessionId); // _fileDataAccessor.setProperty(PropertyType.LIVEINSTANCES, liveInstance.getRecord(), // _instanceName); Builder keyBuilder = _accessor.keyBuilder(); _accessor.setProperty(keyBuilder.liveInstance(_instanceName), liveInstance); }