提交 136f02ff 编写于 作者: T tristaZero

temporary code

上级 7e9631e9
......@@ -118,8 +118,9 @@ public final class SchemaChangedListener extends PostShardingCenterRepositoryEve
}
private ShardingOrchestrationEvent createRuleChangedEvent(final String shardingSchemaName, final DataChangedEvent event) {
YamlRootRuleConfigurations configurations = YamlEngine.unmarshal(event.getValue(), YamlRootRuleConfigurations.class);
return new RuleConfigurationsChangedEvent(
shardingSchemaName, new YamlRuleConfigurationSwapperEngine().swapToRuleConfigurations(YamlEngine.unmarshal(event.getValue(), YamlRootRuleConfigurations.class).getRules()));
shardingSchemaName, new YamlRuleConfigurationSwapperEngine().swapToRuleConfigurations(null == configurations ? new LinkedList<>() : configurations.getRules()));
}
private ShardingOrchestrationEvent createUpdatedEventForNewSchema(final String shardingSchemaName) {
......
......@@ -63,5 +63,4 @@ public final class MetaDataCenter {
}
return Optional.of(new RuleSchemaMetaDataYamlSwapper().swapToObject(YamlEngine.unmarshal(path, YamlRuleSchemaMetaData.class)));
}
}
......@@ -151,9 +151,11 @@ public abstract class OrchestrationSchemaContexts implements SchemaContextsAware
*/
@Subscribe
public synchronized void renew(final SchemaAddedEvent schemaAddedEvent) throws Exception {
String schemaName = schemaAddedEvent.getShardingSchemaName();
Map<String, SchemaContext> schemas = new HashMap<>(schemaContexts.getSchemaContexts());
schemas.put(schemaAddedEvent.getShardingSchemaName(), getAddedSchemaContext(schemaAddedEvent));
schemas.put(schemaName, getAddedSchemaContext(schemaAddedEvent));
schemaContexts = new SchemaContexts(schemas, schemaContexts.getProps(), schemaContexts.getAuthentication());
ShardingOrchestrationFacade.getInstance().getMetaDataCenter().persistMetaDataCenterNode(schemaName, schemaContexts.getSchemaContexts().get(schemaName).getSchema().getMetaData().getSchema());
}
/**
......
......@@ -83,7 +83,7 @@ public final class YamlEngine {
* @return object from YAML
*/
public static <T> T unmarshal(final String yamlContent, final Class<T> classType) {
return Strings.isNullOrEmpty(yamlContent) ? null : new Yaml(new ShardingSphereYamlConstructor(classType)).loadAs(yamlContent, classType);
return new Yaml(new ShardingSphereYamlConstructor(classType)).loadAs(yamlContent, classType);
}
/**
......
......@@ -21,26 +21,26 @@
#
######################################################################################################
#
#orchestration:
# orchestration_ds:
# orchestrationType: registry_center,config_center,metadata_center
# instanceType: zookeeper
# serverLists: localhost:2181
# namespace: orchestration
# props:
# overwrite: false
# retryIntervalMilliseconds: 500
# timeToLiveSeconds: 60
# maxRetries: 3
# operationTimeoutMilliseconds: 500
#
#authentication:
# users:
# root:
# password: root
# sharding:
# password: sharding
# authorizedSchemas: sharding_db
orchestration:
orchestration_ds:
orchestrationType: registry_center,config_center,metadata_center
instanceType: zookeeper
serverLists: localhost:2181
namespace: orchestration1
props:
overwrite: false
retryIntervalMilliseconds: 500
timeToLiveSeconds: 60
maxRetries: 3
operationTimeoutMilliseconds: 500
authentication:
users:
root:
password: root
sharding:
password: sharding
authorizedSchemas: sharding_db
#
#metrics:
# name: prometheus
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册