Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#1172, start SkyWalking configurable #1304

Merged
merged 10 commits into from
Sep 26, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ public enum ShardingPropertiesConstant {

PROXY_TRANSACTION_ENABLED("proxy.transaction.enabled", String.valueOf(Boolean.FALSE), boolean.class),

PROXY_OPENTRACING_ENABLED("proxy.opentracing.enabled", String.valueOf(Boolean.FALSE), boolean.class),

PROXY_BACKEND_USE_NIO("proxy.backend.use.nio", String.valueOf(Boolean.FALSE), boolean.class),

PROXY_BACKEND_MAX_CONNECTIONS("proxy.backend.max.connections", String.valueOf(8), int.class),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
@NoArgsConstructor(access = AccessLevel.PRIVATE)
public final class ShardingTracer {

private static final String OPENTRACING_TRACER_CLASS_NAME = "shardingsphere.opentracing.tracer.class";
private static final String OPENTRACING_TRACER_CLASS_NAME = "io.shardingsphere.opentracing.tracer.class";

/**
* Initialize sharding tracer.
Expand Down
10 changes: 0 additions & 10 deletions sharding-proxy/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -79,16 +79,6 @@
<groupId>commons-codec</groupId>
<artifactId>commons-codec</artifactId>
</dependency>
<dependency>
<groupId>org.apache.skywalking</groupId>
<artifactId>apm-toolkit-opentracing</artifactId>
<version>5.0.0-RC2</version>
</dependency>
<dependency>
<groupId>org.apache.skywalking</groupId>
<artifactId>apm-collector-core</artifactId>
<version>5.0.0-RC2</version>
</dependency>
</dependencies>

<build>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
import io.shardingsphere.proxy.listener.ProxyListenerRegister;
import lombok.AccessLevel;
import lombok.NoArgsConstructor;
import org.apache.skywalking.apm.toolkit.opentracing.SkywalkingTracer;

import java.io.IOException;
import java.util.HashMap;
Expand All @@ -58,7 +57,6 @@ public final class Bootstrap {
* @throws IOException IO exception
*/
public static void main(final String[] args) throws InterruptedException, IOException {
ShardingTracer.init(new SkywalkingTracer());
ProxyConfiguration proxyConfig = new ProxyYamlConfigurationLoader().load();
int port = getPort(args);
new ProxyListenerRegister().register();
Expand All @@ -83,6 +81,7 @@ private static int getPort(final String[] args) {
private static void startWithoutRegistryCenter(
final ProxyYamlServerConfiguration serverConfig, final Map<String, ProxyYamlRuleConfiguration> ruleConfigs, final int port) throws InterruptedException {
ProxyContext.getInstance().init(getYamlServerConfiguration(serverConfig), getSchemaDataSourceMap(ruleConfigs), getRuleConfiguration(ruleConfigs));
initOpenTracing();
new ShardingProxy().start(port);
}

Expand All @@ -94,10 +93,17 @@ private static void startWithRegistryCenter(
}
ProxyContext.getInstance().init(orchestrationFacade.getConfigService().loadYamlServerConfiguration(),
orchestrationFacade.getConfigService().loadProxyDataSources(), orchestrationFacade.getConfigService().loadProxyConfiguration());
initOpenTracing();
new ShardingProxy().start(port);
}
}

private static void initOpenTracing() {
if (ProxyContext.getInstance().isOpenTracingEnable()) {
ShardingTracer.init();
}
}

private static YamlServerConfiguration getYamlServerConfiguration(final ProxyYamlServerConfiguration serverConfig) {
YamlServerConfiguration result = new YamlServerConfiguration();
result.setProxyAuthority(serverConfig.getProxyAuthority());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ public final class ProxyContext {

private TransactionType transactionType;

private boolean openTracingEnable;

private BackendNIOConfiguration backendNIOConfig;

private boolean isCircuitBreak;
Expand Down Expand Up @@ -113,6 +115,7 @@ private void initServerConfiguration(final YamlServerConfiguration serverConfig)
maxConnectionsSizePerQuery = shardingProperties.getValue(ShardingPropertiesConstant.MAX_CONNECTIONS_SIZE_PER_QUERY);
// TODO just config proxy.transaction.enable here, in future(3.1.0)
transactionType = shardingProperties.<Boolean>getValue(ShardingPropertiesConstant.PROXY_TRANSACTION_ENABLED) ? TransactionType.XA : TransactionType.LOCAL;
openTracingEnable = shardingProperties.<Boolean>getValue(ShardingPropertiesConstant.PROXY_OPENTRACING_ENABLED);
showSQL = shardingProperties.getValue(ShardingPropertiesConstant.SQL_SHOW);
acceptorSize = shardingProperties.getValue(ShardingPropertiesConstant.ACCEPTOR_SIZE);
executorSize = shardingProperties.getValue(ShardingPropertiesConstant.EXECUTOR_SIZE);
Expand Down
1 change: 1 addition & 0 deletions sharding-proxy/src/main/resources/conf/server.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,5 @@
# acceptor.size: 16 # The default value is available processors count * 2.
# executor.size: 16 # Infinite by default.
# proxy.transaction.enabled: false
# proxy.opentracing.enabled: false
# sql.show: false