本文整理了Java中org.apache.helix.ZNRecord.setSimpleFields()
方法的一些代码示例,展示了ZNRecord.setSimpleFields()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ZNRecord.setSimpleFields()
方法的具体详情如下:
包路径:org.apache.helix.ZNRecord
类名称:ZNRecord
方法名:setSimpleFields
[英]Set all plain key, value fields
[中]设置所有普通键、值字段
代码示例来源:origin: apache/incubator-pinot
@Nonnull
public static ZNRecord toZnRecord(@Nonnull TableConfig tableConfig) {
ZNRecord znRecord = new ZNRecord(tableConfig.getTableName());
Map<String, String> simpleFields = new HashMap<>();
simpleFields.put(TABLE_NAME_KEY, tableConfig._tableName);
simpleFields.put(TABLE_TYPE_KEY, tableConfig._tableType.toString());
try {
simpleFields.put(VALIDATION_CONFIG_KEY, JsonUtils.objectToString(tableConfig._validationConfig));
simpleFields.put(TENANT_CONFIG_KEY, JsonUtils.objectToString(tableConfig._tenantConfig));
simpleFields.put(INDEXING_CONFIG_KEY, JsonUtils.objectToString(tableConfig._indexingConfig));
simpleFields.put(CUSTOM_CONFIG_KEY, JsonUtils.objectToString(tableConfig._customConfig));
if (tableConfig._quotaConfig != null) {
simpleFields.put(QUOTA_CONFIG_KEY, JsonUtils.objectToString(tableConfig._quotaConfig));
}
if (tableConfig._taskConfig != null) {
simpleFields.put(TASK_CONFIG_KEY, JsonUtils.objectToString(tableConfig._taskConfig));
}
if (tableConfig._routingConfig != null) {
simpleFields.put(ROUTING_CONFIG_KEY, JsonUtils.objectToString(tableConfig._routingConfig));
}
} catch (IOException e) {
throw new RuntimeException(e);
}
znRecord.setSimpleFields(simpleFields);
return znRecord;
}
代码示例来源:origin: apache/helix
/**
* Get relay message attached for the given instance.
*
* @param instance
* @return null if no message for the instance
*/
public Message getRelayMessage(String instance) {
Map<String, String> messageInfo = _record.getMapField(instance);
if (messageInfo != null) {
String id = messageInfo.get(Attributes.RELAY_MSG_ID.name());
if (id == null) {
id = messageInfo.get(Attributes.MSG_ID.name());
if (id == null) {
return null;
}
}
ZNRecord record = new ZNRecord(id);
record.setSimpleFields(messageInfo);
return new Message(record);
}
return null;
}
代码示例来源:origin: org.apache.helix/helix-core
/**
* Get relay message attached for the given instance.
*
* @param instance
* @return null if no message for the instance
*/
public Message getRelayMessage(String instance) {
Map<String, String> messageInfo = _record.getMapField(instance);
if (messageInfo != null) {
String id = messageInfo.get(Attributes.RELAY_MSG_ID.name());
if (id == null) {
id = messageInfo.get(Attributes.MSG_ID.name());
if (id == null) {
return null;
}
}
ZNRecord record = new ZNRecord(id);
record.setSimpleFields(messageInfo);
return new Message(record);
}
return null;
}
代码示例来源:origin: org.apache.helix/helix-core
metaRecord.setSimpleFields(value.getRecord().getSimpleFields());
records.add(metaRecord);
代码示例来源:origin: apache/helix
metaRecord.setSimpleFields(value.getRecord().getSimpleFields());
records.add(metaRecord);
代码示例来源:origin: org.apache.helix/helix-core
bucketizedRecord.setSimpleFields(record.getSimpleFields());
代码示例来源:origin: apache/helix
bucketizedRecord.setSimpleFields(record.getSimpleFields());
代码示例来源:origin: apache/helix
private void setNodes(ZkHelixPropertyStore<ZNRecord> store, char c, boolean needTimestamp) {
char[] data = new char[bufSize];
for (int i = 0; i < bufSize; i++) {
data[i] = c;
}
Map<String, String> map = new TreeMap<String, String>();
for (int i = 0; i < mapNr; i++) {
map.put("key_" + i, new String(data));
}
for (int i = 0; i < firstLevelNr; i++) {
for (int j = 0; j < secondLevelNr; j++) {
String nodeId = getNodeId(i, j);
ZNRecord record = new ZNRecord(nodeId);
record.setSimpleFields(map);
if (needTimestamp) {
long now = System.currentTimeMillis();
record.setSimpleField("SetTimestamp", Long.toString(now));
}
String key = getSecondLevelKey(i, j);
store.set(key, record, AccessOption.PERSISTENT);
}
}
}
代码示例来源:origin: apache/helix
ZNRecord record = new ZNRecord(provider.getReportName());
if (report != null) {
record.setSimpleFields(report);
代码示例来源:origin: org.apache.helix/helix-core
ZNRecord record = new ZNRecord(provider.getReportName());
if (report != null) {
record.setSimpleFields(report);
代码示例来源:origin: apache/helix
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;
}
代码示例来源:origin: org.apache.helix/helix-core
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;
}
代码示例来源:origin: org.apache.helix/helix-core
metaRecord.setSimpleFields(value.getRecord().getSimpleFields());
success = _baseDataAccessor.set(path, metaRecord, options);
if (success) {
代码示例来源:origin: org.apache.helix/helix-core
@Override
public ZNRecord update(ZNRecord currentData) {
CurrentState curState = null;
if (currentData == null) {
curState = new CurrentState(_lastCurState.getId());
// copy all simple fields settings and overwrite session-id to current session
curState.getRecord().setSimpleFields(_lastCurState.getRecord().getSimpleFields());
curState.setSessionId(_curSessionId);
} else {
curState = new CurrentState(currentData);
}
for (String partitionName : _lastCurState.getPartitionStateMap().keySet()) {
// carry-over only when current-state not exist
if (curState.getState(partitionName) == null) {
curState.setState(partitionName, _initState);
}
}
return curState.getRecord();
}
代码示例来源:origin: apache/helix
metaRecord.setSimpleFields(value.getRecord().getSimpleFields());
success = _baseDataAccessor.set(path, metaRecord, options);
if (success) {
代码示例来源:origin: apache/helix
@Override
public ZNRecord update(ZNRecord currentData) {
CurrentState curState = null;
if (currentData == null) {
curState = new CurrentState(_lastCurState.getId());
// copy all simple fields settings and overwrite session-id to current session
curState.getRecord().setSimpleFields(_lastCurState.getRecord().getSimpleFields());
curState.setSessionId(_curSessionId);
} else {
curState = new CurrentState(currentData);
}
for (String partitionName : _lastCurState.getPartitionStateMap().keySet()) {
// carry-over only when current-state not exist
if (curState.getState(partitionName) == null) {
curState.setState(partitionName, _initState);
}
}
return curState.getRecord();
}
代码示例来源:origin: apache/helix
private void setNodes(HelixZkClient zkClient, String root, char c, boolean needTimestamp) {
char[] data = new char[bufSize];
for (int i = 0; i < bufSize; i++) {
data[i] = c;
}
Map<String, String> map = new TreeMap<String, String>();
for (int i = 0; i < mapNr; i++) {
map.put("key_" + i, new String(data));
}
for (int i = 0; i < firstLevelNr; i++) {
String firstLevelKey = getFirstLevelKey(i);
for (int j = 0; j < secondLevelNr; j++) {
String nodeId = getNodeId(i, j);
ZNRecord record = new ZNRecord(nodeId);
record.setSimpleFields(map);
if (needTimestamp) {
long now = System.currentTimeMillis();
record.setSimpleField("SetTimestamp", Long.toString(now));
}
String key = getSecondLevelKey(i, j);
try {
zkClient.writeData(root + key, record);
} catch (ZkNoNodeException e) {
zkClient.createPersistent(root + firstLevelKey, true);
zkClient.createPersistent(root + key, record);
}
}
}
}
代码示例来源:origin: org.apache.helix/helix-core
metaRecord.setSimpleFields(lastCurState.getRecord().getSimpleFields());
DataUpdater<ZNRecord> metaRecordUpdater =
new CurStateCarryOverUpdater(_sessionId, initState, new CurrentState(metaRecord));
代码示例来源:origin: apache/helix
StringRepresentation getConfigs(ConfigScopeProperty scopeProperty, String... keys)
throws Exception {
StringRepresentation representation = null;
ZkClient zkClient =
ResourceUtil.getAttributeFromCtx(getContext(), ResourceUtil.ContextKey.ZKCLIENT);
ClusterSetup setupTool = new ClusterSetup(zkClient);
HelixAdmin admin = setupTool.getClusterManagementTool();
ZNRecord record = new ZNRecord(scopeProperty + " Config");
HelixConfigScope scope = new HelixConfigScopeBuilder(scopeProperty, keys).build();
List<String> configKeys = admin.getConfigKeys(scope);
Map<String, String> configs = admin.getConfig(scope, configKeys);
record.setSimpleFields(configs);
representation =
new StringRepresentation(ClusterRepresentationUtil.ZNRecordToJson(record),
MediaType.APPLICATION_JSON);
return representation;
}
代码示例来源:origin: apache/helix
newIdealState.getRecord().setSimpleFields(idealState.getRecord().getSimpleFields());
newIdealState.setPartitionState("0", "localhost_12918", "ONLINE");
newIdealState.setPartitionState("0", "localhost_12919", "ONLINE");
内容来源于网络,如有侵权,请联系作者删除!