Set<String> liveParticipants = accessor.getChildValuesMap(keyBuilder.liveInstances()).keySet(); List<ZNRecordRow> result = Lists.newArrayList(); for (ZNRecordRow row : allRows) {
/** * Batch get the configurations of all workflows in this cluster. * * @return */ public Map<String, WorkflowConfig> getWorkflows() { Map<String, WorkflowConfig> workflowConfigMap = new HashMap<String, WorkflowConfig>(); Map<String, ResourceConfig> resourceConfigMap = _accessor.getChildValuesMap(_accessor.keyBuilder().resourceConfigs()); for (Map.Entry<String, ResourceConfig> resource : resourceConfigMap.entrySet()) { try { WorkflowConfig config = WorkflowConfig.fromHelixProperty(resource.getValue()); workflowConfigMap.put(resource.getKey(), config); } catch (IllegalArgumentException ex) { // ignore if it is not a workflow config. } } return workflowConfigMap; }
/** * Batch get the configurations of all workflows in this cluster. * * @return */ public Map<String, WorkflowConfig> getWorkflows() { Map<String, WorkflowConfig> workflowConfigMap = new HashMap<String, WorkflowConfig>(); Map<String, ResourceConfig> resourceConfigMap = _accessor.getChildValuesMap(_accessor.keyBuilder().resourceConfigs()); for (Map.Entry<String, ResourceConfig> resource : resourceConfigMap.entrySet()) { try { WorkflowConfig config = WorkflowConfig.fromHelixProperty(resource.getValue()); workflowConfigMap.put(resource.getKey(), config); } catch (IllegalArgumentException ex) { // ignore if it is not a workflow config. } } return workflowConfigMap; }
long start = System.currentTimeMillis(); _propertyDataChangedMap.put(HelixConstants.ChangeType.LIVE_INSTANCE, Boolean.valueOf(false)); _liveInstanceMap = accessor.getChildValuesMap(keyBuilder.liveInstances(), true); LOG.info("Reload LiveInstances: " + _liveInstanceMap.keySet() + ". Takes " + ( System.currentTimeMillis() - start) + " ms"); _propertyDataChangedMap .put(HelixConstants.ChangeType.INSTANCE_CONFIG, Boolean.valueOf(false)); _instanceConfigMap = accessor.getChildValuesMap(keyBuilder.instanceConfigs(), true); LOG.info("Reload InstanceConfig: " + _instanceConfigMap.keySet() + ". Takes " + ( System.currentTimeMillis() - start) + " ms");
private boolean verifyMasterNbInExtView(HelixDataAccessor accessor) { Builder keyBuilder = accessor.keyBuilder(); Map<String, IdealState> idealStates = accessor.getChildValuesMap(keyBuilder.idealStates()); if (idealStates == null || idealStates.size() == 0) { LOG.info("No resource idealState"); Map<String, ExternalView> extViews = accessor.getChildValuesMap(keyBuilder.externalViews()); if (extViews == null || extViews.size() < idealStates.size()) { LOG.info("No externalViews | externalView.size() < idealState.size()");
long start = System.currentTimeMillis(); _propertyDataChangedMap.put(HelixConstants.ChangeType.LIVE_INSTANCE, Boolean.valueOf(false)); _liveInstanceMap = accessor.getChildValuesMap(keyBuilder.liveInstances(), true); LOG.info("Reload LiveInstances: " + _liveInstanceMap.keySet() + ". Takes " + ( System.currentTimeMillis() - start) + " ms"); _propertyDataChangedMap .put(HelixConstants.ChangeType.INSTANCE_CONFIG, Boolean.valueOf(false)); _instanceConfigMap = accessor.getChildValuesMap(keyBuilder.instanceConfigs(), true); LOG.info("Reload InstanceConfig: " + _instanceConfigMap.keySet() + ". Takes " + ( System.currentTimeMillis() - start) + " ms");
private boolean verifyMasterNbInExtView(HelixDataAccessor accessor) { Builder keyBuilder = accessor.keyBuilder(); Map<String, IdealState> idealStates = accessor.getChildValuesMap(keyBuilder.idealStates()); if (idealStates == null || idealStates.size() == 0) { LOG.info("No resource idealState"); Map<String, ExternalView> extViews = accessor.getChildValuesMap(keyBuilder.externalViews()); if (extViews == null || extViews.size() < idealStates.size()) { LOG.info("No externalViews | externalView.size() < idealState.size()");
Map<String, ExternalView> extViews = _accessor.getChildValuesMap(keyBuilder.externalViews()); if (extViews == null) { extViews = Collections.emptyMap();
ClusterRepresentationUtil.getClusterDataAccessor(zkClient, clusterName); Map<String, LiveInstance> liveInstancesMap = accessor.getChildValuesMap(accessor.keyBuilder().liveInstances()); Map<String, InstanceConfig> instanceConfigsMap = accessor.getChildValuesMap(accessor.keyBuilder().instanceConfigs());
@Override public boolean verify() throws Exception { ClusterDataCache cache = new ClusterDataCache(); cache.refresh(_accessor); List<String> liveInstances = new ArrayList<String>(); liveInstances.addAll(cache.getLiveInstances().keySet()); boolean success = verifyLiveNodes(liveInstances); if (!success) { LOG.info("liveNodes not match, expect: " + _expectSortedLiveNodes + ", actual: " + liveInstances); return false; } BestPossibleStateOutput bestPossbileStates = calculateBestPossibleState(cache); Map<String, ExternalView> externalViews = _accessor.getChildValuesMap(_keyBuilder.externalViews()); // TODO all ideal-states should be included in external-views for (String resourceName : externalViews.keySet()) { ExternalView externalView = externalViews.get(resourceName); Map<Partition, Map<String, String>> bestPossbileState = bestPossbileStates.getResourceMap(resourceName); success = verifyExternalView(externalView, bestPossbileState); if (!success) { LOG.info("external-view for resource: " + resourceName + " not match"); return false; } } return true; }
@Override public boolean verify() throws Exception { ClusterDataCache cache = new ClusterDataCache(); cache.refresh(_accessor); List<String> liveInstances = new ArrayList<String>(); liveInstances.addAll(cache.getLiveInstances().keySet()); boolean success = verifyLiveNodes(liveInstances); if (!success) { LOG.info("liveNodes not match, expect: " + _expectSortedLiveNodes + ", actual: " + liveInstances); return false; } BestPossibleStateOutput bestPossbileStates = calculateBestPossibleState(cache); Map<String, ExternalView> externalViews = _accessor.getChildValuesMap(_keyBuilder.externalViews()); // TODO all ideal-states should be included in external-views for (String resourceName : externalViews.keySet()) { ExternalView externalView = externalViews.get(resourceName); Map<Partition, Map<String, String>> bestPossbileState = bestPossbileStates.getResourceMap(resourceName); success = verifyExternalView(externalView, bestPossbileState); if (!success) { LOG.info("external-view for resource: " + resourceName + " not match"); return false; } } return true; }
StringRepresentation getHostedEntitiesRepresentation(String clusterName) throws JsonGenerationException, JsonMappingException, IOException { // Get all resources ZkClient zkClient = (ZkClient) getContext().getAttributes().get(RestAdminApplication.ZKCLIENT); HelixDataAccessor accessor = ClusterRepresentationUtil.getClusterDataAccessor(zkClient, clusterName); PropertyKey.Builder keyBuilder = accessor.keyBuilder(); Map<String, HelixProperty> resourceConfigMap = accessor.getChildValuesMap(keyBuilder.resourceConfigs()); // Create the result ZNRecord hostedEntitiesRecord = new ZNRecord("Workflows"); // Filter out non-workflow resources Iterator<Map.Entry<String, HelixProperty>> it = resourceConfigMap.entrySet().iterator(); while (it.hasNext()) { Map.Entry<String, HelixProperty> e = it.next(); HelixProperty resource = e.getValue(); Map<String, String> simpleFields = resource.getRecord().getSimpleFields(); if (!simpleFields.containsKey(WorkflowConfig.WorkflowConfigProperty.TargetState.name()) || !simpleFields.containsKey(WorkflowConfig.WorkflowConfigProperty.Dag.name())) { it.remove(); } } // Populate the result List<String> allResources = Lists.newArrayList(resourceConfigMap.keySet()); hostedEntitiesRecord.setListField("WorkflowList", allResources); StringRepresentation representation = new StringRepresentation(ClusterRepresentationUtil.ZNRecordToJson(hostedEntitiesRecord), MediaType.APPLICATION_JSON); return representation; }
Set<String> liveParticipants = accessor.getChildValuesMap(keyBuilder.liveInstances()).keySet(); List<ZNRecordRow> result = Lists.newArrayList(); for (ZNRecordRow row : allRows) {
Set<String> liveParticipants = accessor.getChildValuesMap(keyBuilder.liveInstances()).keySet(); List<ZNRecordRow> result = Lists.newArrayList(); for (ZNRecordRow row : allRows) {
PropertyKey.Builder keyBuilder = accessor.keyBuilder(); Map<String, HelixProperty> resourceConfigMap = accessor.getChildValuesMap(keyBuilder.resourceConfigs());
@Test public void testHelixDataAccessorReadData() { accessor.getProperty(new ArrayList<>(propertyKeys), false); try { accessor.getProperty(new ArrayList<>(propertyKeys), true); Assert.fail(); } catch (HelixMetaDataAccessException ex) { } PropertyKey idealStates = accessor.keyBuilder().idealStates(); accessor.getChildValues(idealStates, false); try { accessor.getChildValues(idealStates, true); Assert.fail(); } catch (HelixMetaDataAccessException ex) { } accessor.getChildValuesMap(idealStates, false); try { accessor.getChildValuesMap(idealStates, true); Assert.fail(); } catch (HelixMetaDataAccessException ex) { } }
Set<String> liveParticipants = accessor.getChildValuesMap(keyBuilder.liveInstances()).keySet(); List<ZNRecordRow> result = Lists.newArrayList(); for (ZNRecordRow row : allRows) {
Set<String> liveParticipants = accessor.getChildValuesMap(keyBuilder.liveInstances()).keySet(); List<ZNRecordRow> result = Lists.newArrayList(); for (ZNRecordRow row : allRows) {
PropertyKey.Builder keyBuilder = accessor.keyBuilder(); PropertyKey path = keyBuilder.currentStates(manager.getInstanceName(), manager.getSessionId()); Map<String, CurrentState> currentStateMap = accessor.getChildValuesMap(path);
ExternalView ev = accessor.getProperty(kb.externalView(TEST_DB)); Map<String, LiveInstance> liveinstanceMap = accessor.getChildValuesMap(accessor.keyBuilder().liveInstances());