You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by du...@apache.org on 2022/07/21 11:56:33 UTC
[shardingsphere] branch master updated: Add proxy instance type property (#19446)
This is an automated email from the ASF dual-hosted git repository.
duanzhengqiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/shardingsphere.git
The following commit(s) were added to refs/heads/master by this push:
new 9f6aca013bb Add proxy instance type property (#19446)
9f6aca013bb is described below
commit 9f6aca013bbe661e9b0ab0751432d67c69f71e6d
Author: Haoran Meng <me...@gmail.com>
AuthorDate: Thu Jul 21 19:56:27 2022 +0800
Add proxy instance type property (#19446)
* Add proxy instance type property
* Add proxy instance type property
---
.../infra/config/props/ConfigurationPropertyKey.java | 7 ++++++-
.../proxy/initializer/BootstrapInitializer.java | 11 +++++++++--
2 files changed, 15 insertions(+), 3 deletions(-)
diff --git a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/config/props/ConfigurationPropertyKey.java b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/config/props/ConfigurationPropertyKey.java
index 38ab3166d6f..99d7ca0ead1 100644
--- a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/config/props/ConfigurationPropertyKey.java
+++ b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/config/props/ConfigurationPropertyKey.java
@@ -122,7 +122,12 @@ public enum ConfigurationPropertyKey implements TypedPropertyKey {
/**
* Proxy Netty backlog size.
*/
- PROXY_NETTY_BACKLOG("proxy-netty-backlog", "1024", int.class, false);
+ PROXY_NETTY_BACKLOG("proxy-netty-backlog", "1024", int.class, false),
+
+ /**
+ * Proxy instance type.
+ */
+ PROXY_INSTANCE_TYPE("proxy-instance-type", "Proxy", String.class, true);
private final String key;
diff --git a/shardingsphere-proxy/shardingsphere-proxy-bootstrap/src/main/java/org/apache/shardingsphere/proxy/initializer/BootstrapInitializer.java b/shardingsphere-proxy/shardingsphere-proxy-bootstrap/src/main/java/org/apache/shardingsphere/proxy/initializer/BootstrapInitializer.java
index 5c991b29a8f..8a5a49cbe45 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-bootstrap/src/main/java/org/apache/shardingsphere/proxy/initializer/BootstrapInitializer.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-bootstrap/src/main/java/org/apache/shardingsphere/proxy/initializer/BootstrapInitializer.java
@@ -20,6 +20,7 @@ package org.apache.shardingsphere.proxy.initializer;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.shardingsphere.infra.config.mode.ModeConfiguration;
+import org.apache.shardingsphere.infra.config.props.ConfigurationPropertyKey;
import org.apache.shardingsphere.infra.instance.metadata.InstanceMetaData;
import org.apache.shardingsphere.infra.instance.metadata.InstanceMetaDataBuilderFactory;
import org.apache.shardingsphere.infra.yaml.config.swapper.mode.ModeConfigurationYamlSwapper;
@@ -60,12 +61,18 @@ public final class BootstrapInitializer {
private ContextManager createContextManager(final YamlProxyConfiguration yamlConfig, final ModeConfiguration modeConfig, final int port) throws SQLException {
ProxyConfiguration proxyConfig = new YamlProxyConfigurationSwapper().swap(yamlConfig);
- InstanceMetaData instanceMetaData = InstanceMetaDataBuilderFactory.create("Proxy", port);
ContextManagerBuilderParameter parameter = new ContextManagerBuilderParameter(modeConfig, proxyConfig.getDatabaseConfigurations(),
- proxyConfig.getGlobalConfiguration().getRules(), proxyConfig.getGlobalConfiguration().getProperties(), proxyConfig.getGlobalConfiguration().getLabels(), instanceMetaData);
+ proxyConfig.getGlobalConfiguration().getRules(), proxyConfig.getGlobalConfiguration().getProperties(), proxyConfig.getGlobalConfiguration().getLabels(),
+ createInstanceMetaData(proxyConfig, port));
return ContextManagerBuilderFactory.getInstance(modeConfig).build(parameter);
}
+ private InstanceMetaData createInstanceMetaData(final ProxyConfiguration proxyConfig, final int port) {
+ String instanceType = proxyConfig.getGlobalConfiguration().getProperties().getProperty(ConfigurationPropertyKey.PROXY_INSTANCE_TYPE.getKey(),
+ ConfigurationPropertyKey.PROXY_INSTANCE_TYPE.getDefaultValue());
+ return InstanceMetaDataBuilderFactory.create(instanceType, port);
+ }
+
private void contextManagerInitializedCallback(final ModeConfiguration modeConfig, final ContextManager contextManager) {
for (ContextManagerLifecycleListener each : ContextManagerLifecycleListenerFactory.getAllInstances()) {
try {