public ZNRecord toZNRecord() { ZNRecord record = new ZNRecord(_tableNameWithType); record.setListFields(_parentGroupToChildrenGroupsMap); Map<String, Map<String, String>> groupToSegmentsMap = new HashMap<>(); for (Map.Entry<Integer, Map<String, List<String>>> entry : _levelToGroupToSegmentsMap.entrySet()) { String key = LEVEL_KEY_PREFIX + entry.getKey(); Map<String, String> groupSegmentsForLevel = new HashMap<>(); for (Map.Entry<String, List<String>> groupEntry : entry.getValue().entrySet()) { String groupId = groupEntry.getKey(); String segments = String.join(SEGMENT_DELIMITER, groupEntry.getValue()); groupSegmentsForLevel.put(groupId, segments); } groupToSegmentsMap.put(key, groupSegmentsForLevel); } record.setMapFields(groupToSegmentsMap); return record; }
/** * Write the replica group partition assignment to property store * * @param partitionAssignment a replica group partition assignment */ public void writeReplicaGroupPartitionAssignment(ReplicaGroupPartitionAssignment partitionAssignment) { String tableNameWithType = partitionAssignment.getTableName(); ZNRecord znRecord = new ZNRecord(tableNameWithType); znRecord.setListFields(partitionAssignment.getPartitionToInstances()); String path = ZKMetadataProvider.constructPropertyStorePathForInstancePartitions(tableNameWithType); _propertyStore.set(path, znRecord, AccessOption.PERSISTENT); }
/** * Set the preference lists for all partitions in this resource. * * @param instanceLists the map of instance preference lists. */ public void setPreferenceLists(Map<String, List<String>> instanceLists) { _record.setListFields(instanceLists); }
/** * Set the preference lists for all partitions in this resource. * * @param instanceLists the map of instance preference lists. */ public void setPreferenceLists(Map<String, List<String>> instanceLists) { _record.setListFields(instanceLists); }
/** * Set the user-specified preference lists for all partitions in this resource. * * @param instanceLists the map of instance preference lists.N */ public void setPreferenceLists(Map<String, List<String>> instanceLists) { _record.setListFields(instanceLists); }
/** * Set the user-specified preference lists for all partitions in this resource. * * @param instanceLists the map of instance preference lists.N */ public void setPreferenceLists(Map<String, List<String>> instanceLists) { _record.setListFields(instanceLists); }
private ZNRecord generateZNRecord(String resource, List<String> partitions, Map<String, Map<String, List<Node>>> partitionStateMapping) { Map<String, List<String>> newPreferences = new HashMap<String, List<String>>(); for (int i = 0; i < partitions.size(); i++) { String partitionName = partitions.get(i); Map<String, List<Node>> stateNodeMap = partitionStateMapping.get(partitionName); for (String state : _stateCountMap.keySet()) { List<Node> nodes = stateNodeMap.get(state); List<String> nodeList = new ArrayList<String>(); for (int j = 0; j < nodes.size(); j++) { nodeList.add(nodes.get(j).getName()); } if (!newPreferences.containsKey(partitionName)) { newPreferences.put(partitionName, new ArrayList<String>()); } newPreferences.get(partitionName).addAll(nodeList); } } ZNRecord result = new ZNRecord(resource); result.setListFields(newPreferences); return result; }
private ZNRecord generateZNRecord(String resource, List<String> partitions, Map<String, Map<String, List<Node>>> partitionStateMapping, String eventId) { Map<String, List<String>> newPreferences = new HashMap<>(); for (int i = 0; i < partitions.size(); i++) { String partitionName = partitions.get(i); Map<String, List<Node>> stateNodeMap = partitionStateMapping.get(partitionName); for (String state : _stateCountMap.keySet()) { List<Node> nodes = stateNodeMap.get(state); List<String> nodeList = new ArrayList<>(); for (int j = 0; j < nodes.size(); j++) { Node selectedNode = nodes.get(j); if (selectedNode instanceof InstanceNode) { nodeList.add(((InstanceNode) selectedNode).getInstanceName()); } else { LogUtil.logError(Log, eventId, "Selected node is not associated with an instance: " + selectedNode.toString()); } } if (!newPreferences.containsKey(partitionName)) { newPreferences.put(partitionName, new ArrayList<String>()); } newPreferences.get(partitionName).addAll(nodeList); } } ZNRecord result = new ZNRecord(resource); result.setListFields(newPreferences); return result; }
result.setListFields(newPreferences);
result.setListFields(preferenceList); result.setMapFields(idealStateMap); return result;
result.setListFields(newPreferences);
newIdealState.getRecord().setSimpleFields(currentIdealState.getRecord().getSimpleFields()); newIdealState.setRebalanceMode(RebalanceMode.FULL_AUTO); newIdealState.getRecord().setListFields(newMapping.getListFields());
private IdealState generateNewIdealState(String resourceName, IdealState currentIdealState, ZNRecord newMapping) { IdealState newIdealState = new IdealState(resourceName); newIdealState.getRecord().setSimpleFields(currentIdealState.getRecord().getSimpleFields()); newIdealState.setRebalanceMode(currentIdealState.getRebalanceMode()); newIdealState.getRecord().setListFields(newMapping.getListFields()); return newIdealState; }
private IdealState generateNewIdealState(String resourceName, IdealState currentIdealState, ZNRecord newMapping) { IdealState newIdealState = new IdealState(resourceName); newIdealState.getRecord().setSimpleFields(currentIdealState.getRecord().getSimpleFields()); newIdealState.setRebalanceMode(currentIdealState.getRebalanceMode()); newIdealState.getRecord().setListFields(newMapping.getListFields()); return newIdealState; }
idealState.getRecord().setListFields(newIdealState.getListFields());
curIdealState.setListFields(idealState.getListFields()); _gZkClient.writeData(idealPath, curIdealState);
targetExternalView.getRecord().setListFields(preferenceLists); needPersist = true;
targetExternalView.getRecord().setListFields(preferenceLists); needPersist = true;
_record.setListFields(listFields);
_record.setListFields(listFields);