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

Adjust path tracing of sharding-opentracing #1172 #1249

Merged
merged 116 commits into from
Sep 11, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
116 commits
Select commit Hold shift + click to select a range
64031f8
#1172, move Merge under Overall span
tuohai666 Aug 31, 2018
ff619a0
#1172, move Route under Overall span
tuohai666 Aug 31, 2018
35df260
#1172, update name for SQLExecute span
tuohai666 Aug 31, 2018
cf13d50
Merge remote-tracking branch 'upstream/dev' into dev
tuohai666 Aug 31, 2018
5db52d3
#1172, resolve conflict
tuohai666 Aug 31, 2018
225ee2b
#1172, add overall span in ShardingDataSource
tuohai666 Aug 31, 2018
189a900
#1172, remove overall span in SQLExecuteTemplate
tuohai666 Aug 31, 2018
72d9ea0
Revert: #1172, remove overall span in ShardingDataSource
tuohai666 Aug 31, 2018
a02036a
#1172, first success
tuohai666 Sep 6, 2018
8a152d0
Merge remote-tracking branch 'upstream/dev' into dev
tuohai666 Sep 6, 2018
78c3b38
#1172, resolve conflicts
tuohai666 Sep 6, 2018
6761e0f
#1172, display main thread
tuohai666 Sep 6, 2018
29e41c2
#1172, add ParsingEvent
tuohai666 Sep 6, 2018
a710f2b
#1172, add ParsingEventListener
tuohai666 Sep 6, 2018
de2f675
#1172, add ParsingEventListenerTest
tuohai666 Sep 6, 2018
6052945
#1172, add SqlParsingEventListenerTest
tuohai666 Sep 6, 2018
a2a6ee8
#1172, refine
tuohai666 Sep 6, 2018
ddf28eb
#1172, post event from ParsingSQLRouter
tuohai666 Sep 7, 2018
00a2a66
#1172, register ParsingEventListener
tuohai666 Sep 7, 2018
354824d
#1172, refine
tuohai666 Sep 7, 2018
de9e15a
#1172, ignore main thread
tuohai666 Sep 7, 2018
4e50c72
#1172, add GetConnectionEvent
tuohai666 Sep 7, 2018
44e35d6
#1172, add GetConnectionEventListener
tuohai666 Sep 7, 2018
ad84b91
#1172, post getConnection Event
tuohai666 Sep 7, 2018
185e0dc
#1172, post getConnection Event
tuohai666 Sep 7, 2018
bd50e88
#1172, post getConnection Event
tuohai666 Sep 7, 2018
29dfe9f
#1172, add ConnectionCloseEvent
tuohai666 Sep 7, 2018
7f02448
#1172, add ConnectionCloseEventListener
tuohai666 Sep 7, 2018
effcb98
#1172, post ConnectionCloseEvent
tuohai666 Sep 7, 2018
3c39f89
#1172, rm import
tuohai666 Sep 7, 2018
de4ba2c
#1172, for checkstyle
tuohai666 Sep 7, 2018
485104a
#1172, for checkstyle
tuohai666 Sep 7, 2018
f3db715
#1172, refine
tuohai666 Sep 7, 2018
8dd1ae9
#1172, for checkstyle
tuohai666 Sep 7, 2018
6af3a30
#1172, refine
tuohai666 Sep 7, 2018
9666b30
#1172, adjust structure
tuohai666 Sep 7, 2018
01bb4e9
#1172, create connection packet
tuohai666 Sep 7, 2018
e6982af
#1172, adjust structure
tuohai666 Sep 7, 2018
a9df967
#1172, adjust structure
tuohai666 Sep 7, 2018
eb1437f
#1172, adjust structure
tuohai666 Sep 7, 2018
b84ca37
#1172, adjust structure
tuohai666 Sep 7, 2018
393a278
#1172, adjust structure
tuohai666 Sep 7, 2018
afed6a9
#1172, delete MergeEvent
tuohai666 Sep 7, 2018
fbc06c0
#1172, delete RouteEvent
tuohai666 Sep 7, 2018
31339c7
#1172, for checkstyle
tuohai666 Sep 7, 2018
7ee5258
#1172, for checkstyle
tuohai666 Sep 7, 2018
586ebe1
#1172, for checkstyle
tuohai666 Sep 7, 2018
5dc3f3f
#1172, for checkstyle
tuohai666 Sep 7, 2018
87ce517
#1172, for checkstyle
tuohai666 Sep 7, 2018
f22e66a
#1172, refine
tuohai666 Sep 7, 2018
737c50a
#1172, recover
tuohai666 Sep 7, 2018
e9d243f
#1172, for checkstyle
tuohai666 Sep 7, 2018
db22886
#1172, refine
tuohai666 Sep 7, 2018
82405b2
#1172, refine
tuohai666 Sep 7, 2018
17a40ab
#1172, add try catch finally
tuohai666 Sep 7, 2018
3a484a8
#1172, for checkstyle
tuohai666 Sep 7, 2018
1171388
#1172, remove comment
tuohai666 Sep 7, 2018
151fee8
#1172, remove MergeEventListener and RouteEventListener
tuohai666 Sep 7, 2018
8e59712
#1172, remove MergeEvent and RouteEvent
tuohai666 Sep 7, 2018
0a8977a
#1172, remove MergeEventListener and RouteEventListener from Sharding…
tuohai666 Sep 7, 2018
c5fe052
#1172, remove MergeEventListener and RouteEventListener from test case
tuohai666 Sep 7, 2018
f5f4a4b
#1172, remove MergeEvent and RouteEvent from ShardingPreparedStatement
tuohai666 Sep 7, 2018
767e5b9
#1172, remove MergeEvent and RouteEvent from ShardingStatement
tuohai666 Sep 7, 2018
a38989d
#1172, structure for test
tuohai666 Sep 10, 2018
8099e4e
#1172, fix test case
tuohai666 Sep 10, 2018
16917e2
#1172, fix test case
tuohai666 Sep 10, 2018
6e14da6
#1172, use url for peer tag instead of datasource name
tuohai666 Sep 11, 2018
291c09b
#1172, use url for peer tag instead of null
tuohai666 Sep 11, 2018
7cf9b75
#1172, use url for peer tag instead of null
tuohai666 Sep 11, 2018
7e60d13
#1172, use url for peer tag instead of null
tuohai666 Sep 11, 2018
4def6b0
#1172, refine
tuohai666 Sep 11, 2018
ec5884e
#1172, refine peer.hostname
tuohai666 Sep 11, 2018
8fca675
#1172, refine peer.hostname for getConnection
tuohai666 Sep 11, 2018
e640ad5
#1172, refine peer.hostname for getConnection
tuohai666 Sep 11, 2018
b7f102e
#1172, refine peer.hostname for getConnection
tuohai666 Sep 11, 2018
fcc1b3b
#1172, refine peer.hostname for getConnection
tuohai666 Sep 11, 2018
8b85b78
#1172, for checkstyle
tuohai666 Sep 11, 2018
e0f3daa
#1172, for checkstyle
tuohai666 Sep 11, 2018
8f74281
#1172, fix test case
tuohai666 Sep 11, 2018
85358f0
#1172, fix test case
tuohai666 Sep 11, 2018
e8838e9
#1172, fix test case
tuohai666 Sep 11, 2018
b22315f
#1172, fix test case
tuohai666 Sep 11, 2018
60c771b
#1172, fix test case
tuohai666 Sep 11, 2018
42de111
#1172, fix test case
tuohai666 Sep 11, 2018
5a78166
#1172, fix test case
tuohai666 Sep 11, 2018
a3949c4
#1172, fix test case
tuohai666 Sep 11, 2018
6390e64
#1172, fix test case
tuohai666 Sep 11, 2018
490a2bf
#1172, fix test case
tuohai666 Sep 11, 2018
6807ed3
#1172, fix test case
tuohai666 Sep 11, 2018
c645fe1
#1172, fix test case
tuohai666 Sep 11, 2018
e0d8aba
#1172, fix test case
tuohai666 Sep 11, 2018
39aec64
#1172, fix test case
tuohai666 Sep 11, 2018
924fbbb
#1172, fix test case
tuohai666 Sep 11, 2018
cba2982
#1172, fix test case
tuohai666 Sep 11, 2018
41370c3
#1172, fix test case
tuohai666 Sep 11, 2018
bb8241b
#1172, fix test case
tuohai666 Sep 11, 2018
c3c1c32
#1172, fix test case
tuohai666 Sep 11, 2018
4585551
#1172, fix test case
tuohai666 Sep 11, 2018
0916aa5
#1172, fix test case
tuohai666 Sep 11, 2018
7480260
#1172, fix test case
tuohai666 Sep 11, 2018
1cfa334
#1172, fix test case
tuohai666 Sep 11, 2018
9a6c0dc
#1172, fix test case
tuohai666 Sep 11, 2018
d55a684
#1172, fix test case
tuohai666 Sep 11, 2018
54d84ad
#1172, fix test case
tuohai666 Sep 11, 2018
ecb8912
#1172, fix test case
tuohai666 Sep 11, 2018
3a830dc
#1172, fix test case
tuohai666 Sep 11, 2018
2016838
#1172, fix test case
tuohai666 Sep 11, 2018
c8da870
#1172, fix test case
tuohai666 Sep 11, 2018
2db40db
#1172, fix test case
tuohai666 Sep 11, 2018
112d156
#1172, fix test case
tuohai666 Sep 11, 2018
0623252
#1172, fix test case
tuohai666 Sep 11, 2018
c123728
#1172, fix test case
tuohai666 Sep 11, 2018
4674315
#1172, fix test case
tuohai666 Sep 11, 2018
7f4abe0
#1172, fix test case
tuohai666 Sep 11, 2018
e955ec9
#1172, fix test case
tuohai666 Sep 11, 2018
f86dc7e
#1172, fix test case
tuohai666 Sep 11, 2018
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 @@ -15,14 +15,22 @@
* </p>
*/

package io.shardingsphere.core.event.merger;
package io.shardingsphere.core.event.connection;

import io.shardingsphere.core.event.ShardingEvent;
import lombok.Getter;
import lombok.RequiredArgsConstructor;

/**
* Merge event.
*
* @author chenqingyang
* Connection close event.
*
* @author zhangyonglun
*/
public final class MergeEvent extends ShardingEvent {
@RequiredArgsConstructor
@Getter
public final class ConnectionCloseEvent extends ShardingEvent {

private final String dataSource;

private final String url;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/*
* Copyright 2016-2018 shardingsphere.io.
* <p>
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* </p>
*/

package io.shardingsphere.core.event.connection;

import io.shardingsphere.core.event.ShardingEvent;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
import lombok.Setter;

/**
* Get connection event.
*
* @author zhangyonglun
*/
@RequiredArgsConstructor
@Getter
public final class GetConnectionEvent extends ShardingEvent {

private final String dataSource;

@Setter
private String url = "";
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
*/
public final class DMLExecutionEvent extends SQLExecutionEvent {

public DMLExecutionEvent(final RouteUnit routeUnit, final List<Object> parameters) {
super(routeUnit, parameters);
public DMLExecutionEvent(final RouteUnit routeUnit, final List<Object> parameters, final String url) {
super(routeUnit, parameters, url);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
*/
public final class DQLExecutionEvent extends SQLExecutionEvent {

public DQLExecutionEvent(final RouteUnit routeUnit, final List<Object> parameters) {
super(routeUnit, parameters);
public DQLExecutionEvent(final RouteUnit routeUnit, final List<Object> parameters, final String url) {
super(routeUnit, parameters, url);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,6 @@ public class SQLExecutionEvent extends ShardingEvent {
private final RouteUnit routeUnit;

private final List<Object> parameters;

private final String url;
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@

/**
* SQL execution event.
*
*
* @author gaohongtao
* @author maxiaoguang
*/
Expand All @@ -35,19 +35,20 @@ public final class SQLExecutionEventFactory {

/**
* Create SQL execution event.
*
* @param sqlType SQL type
*
* @param sqlType SQL type
* @param sqlExecuteUnit SQL execute unit
* @param parameters parameters
* @param parameters parameters
* @param url url
* @return SQL execution event
*/
public static SQLExecutionEvent createEvent(final SQLType sqlType, final SQLExecuteUnit sqlExecuteUnit, final List<Object> parameters) {
public static SQLExecutionEvent createEvent(final SQLType sqlType, final SQLExecuteUnit sqlExecuteUnit, final List<Object> parameters, final String url) {
if (SQLType.DQL == sqlType) {
return new DQLExecutionEvent(sqlExecuteUnit.getRouteUnit(), parameters);
return new DQLExecutionEvent(sqlExecuteUnit.getRouteUnit(), parameters, url);
}
if (SQLType.DML == sqlType) {
return new DMLExecutionEvent(sqlExecuteUnit.getRouteUnit(), parameters);
return new DMLExecutionEvent(sqlExecuteUnit.getRouteUnit(), parameters, url);
}
return new SQLExecutionEvent(sqlExecuteUnit.getRouteUnit(), parameters);
return new SQLExecutionEvent(sqlExecuteUnit.getRouteUnit(), parameters, url);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,20 @@
* </p>
*/

package io.shardingsphere.core.event.routing;
package io.shardingsphere.core.event.parsing;

import io.shardingsphere.core.event.ShardingEvent;
import lombok.Getter;
import lombok.RequiredArgsConstructor;

/**
* Routing event.
* Parsing event.
*
* @author chenqingyang
* @author zhangyonglun
*/
@RequiredArgsConstructor
@Getter
public final class RoutingEvent extends ShardingEvent {
public final class ParsingEvent extends ShardingEvent {

private final String sql;
}
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ private T execute0(final SQLExecuteUnit sqlExecuteUnit) throws SQLException {
ExecutorDataMap.setDataMap(dataMap);
List<SQLExecutionEvent> events = new LinkedList<>();
for (List<Object> each : sqlExecuteUnit.getRouteUnit().getSqlUnit().getParameterSets()) {
SQLExecutionEvent event = SQLExecutionEventFactory.createEvent(sqlType, sqlExecuteUnit, each);
SQLExecutionEvent event = SQLExecutionEventFactory.createEvent(sqlType, sqlExecuteUnit, each, sqlExecuteUnit.getStatement().getConnection().getMetaData().getURL());
events.add(event);
shardingEventBus.post(event);
}
Expand All @@ -88,8 +88,8 @@ private T execute0(final SQLExecuteUnit sqlExecuteUnit) throws SQLException {
for (SQLExecutionEvent each : events) {
each.setExecuteFailure(ex);
shardingEventBus.post(each);
ExecutorExceptionHandler.handleException(ex);
}
ExecutorExceptionHandler.handleException(ex);
return null;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@

package io.shardingsphere.core.executor.sql.execute;

import io.shardingsphere.core.event.ShardingEventBusInstance;
import io.shardingsphere.core.event.executor.overall.OverallExecutionEvent;
import io.shardingsphere.core.executor.ShardingExecuteEngine;
import io.shardingsphere.core.executor.ShardingExecuteGroup;
import io.shardingsphere.core.executor.sql.SQLExecuteUnit;
Expand All @@ -32,7 +30,7 @@

/**
* SQL execute template.
*
*
* @author gaohongtao
* @author zhangliang
* @author maxiaoguang
Expand All @@ -47,8 +45,8 @@ public final class SQLExecuteTemplate {
* Execute.
*
* @param sqlExecuteUnits SQL execute units
* @param callback SQL execute callback
* @param <T> class type of return value
* @param callback SQL execute callback
* @param <T> class type of return value
* @return execute result
* @throws SQLException SQL exception
*/
Expand All @@ -59,39 +57,30 @@ public <T> List<T> execute(final Collection<? extends SQLExecuteUnit> sqlExecute
/**
* Execute.
*
* @param sqlExecuteUnits SQL execute units
* @param sqlExecuteUnits SQL execute units
* @param firstExecuteCallback first SQL execute callback
* @param callback SQL execute callback
* @param <T> class type of return value
* @param callback SQL execute callback
* @param <T> class type of return value
* @return execute result
* @throws SQLException SQL exception
*/
@SuppressWarnings("unchecked")
public <T> List<T> execute(final Collection<? extends SQLExecuteUnit> sqlExecuteUnits,
final SQLExecuteCallback<T> firstExecuteCallback, final SQLExecuteCallback<T> callback) throws SQLException {
OverallExecutionEvent event = new OverallExecutionEvent(sqlExecuteUnits.size() > 1);
ShardingEventBusInstance.getInstance().post(event);
try {
List<T> result = executeEngine.execute((Collection) sqlExecuteUnits, firstExecuteCallback, callback);
event.setExecuteSuccess();
return result;
// CHECKSTYLE:OFF
} catch (final Exception ex) {
// CHECKSTYLE:ON
event.setExecuteFailure(ex);
return executeEngine.execute((Collection) sqlExecuteUnits, firstExecuteCallback, callback);
} catch (final SQLException ex) {
ExecutorExceptionHandler.handleException(ex);
return Collections.emptyList();
} finally {
ShardingEventBusInstance.getInstance().post(event);
}
}

/**
* Execute group.
*
* @param sqlExecuteGroups SQL execute groups
* @param callback SQL execute callback
* @param <T> class type of return value
* @param callback SQL execute callback
* @param <T> class type of return value
* @return execute result
* @throws SQLException SQL exception
*/
Expand All @@ -103,29 +92,20 @@ public <T> List<T> executeGroup(final Collection<ShardingExecuteGroup<? extends
* Execute group.
*
* @param sqlExecuteGroups SQL execute groups
* @param firstCallback first SQL execute callback
* @param callback SQL execute callback
* @param <T> class type of return value
* @param firstCallback first SQL execute callback
* @param callback SQL execute callback
* @param <T> class type of return value
* @return execute result
* @throws SQLException SQL exception
*/
@SuppressWarnings("unchecked")
public <T> List<T> executeGroup(final Collection<ShardingExecuteGroup<? extends SQLExecuteUnit>> sqlExecuteGroups,
final SQLExecuteCallback<T> firstCallback, final SQLExecuteCallback<T> callback) throws SQLException {
OverallExecutionEvent event = new OverallExecutionEvent(sqlExecuteGroups.size() > 1);
ShardingEventBusInstance.getInstance().post(event);
public <T> List<T> executeGroup(final Collection<ShardingExecuteGroup<? extends SQLExecuteUnit>> sqlExecuteGroups,
final SQLExecuteCallback<T> firstCallback, final SQLExecuteCallback<T> callback) throws SQLException {
try {
List<T> result = executeEngine.groupExecute((Collection) sqlExecuteGroups, firstCallback, callback);
event.setExecuteSuccess();
return result;
// CHECKSTYLE:OFF
} catch (final Exception ex) {
// CHECKSTYLE:ON
event.setExecuteFailure(ex);
return executeEngine.groupExecute((Collection) sqlExecuteGroups, firstCallback, callback);
} catch (final SQLException ex) {
ExecutorExceptionHandler.handleException(ex);
return Collections.emptyList();
} finally {
ShardingEventBusInstance.getInstance().post(event);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@

import com.google.common.base.Optional;
import io.shardingsphere.core.constant.DatabaseType;
import io.shardingsphere.core.event.ShardingEventBusInstance;
import io.shardingsphere.core.event.parsing.ParsingEvent;
import io.shardingsphere.core.metadata.datasource.ShardingDataSourceMetaData;
import io.shardingsphere.core.metadata.table.ShardingTableMetaData;
import io.shardingsphere.core.optimizer.OptimizeEngineFactory;
import io.shardingsphere.core.optimizer.condition.ShardingConditions;
Expand All @@ -34,7 +37,6 @@
import io.shardingsphere.core.parsing.parser.sql.ddl.DDLStatement;
import io.shardingsphere.core.parsing.parser.sql.dml.insert.InsertStatement;
import io.shardingsphere.core.parsing.parser.sql.dql.select.SelectStatement;
import io.shardingsphere.core.metadata.datasource.ShardingDataSourceMetaData;
import io.shardingsphere.core.rewrite.SQLBuilder;
import io.shardingsphere.core.rewrite.SQLRewriteEngine;
import io.shardingsphere.core.routing.RouteUnit;
Expand All @@ -60,7 +62,7 @@

/**
* Sharding router with parse.
*
*
* @author zhangiang
* @author maxiaoguang
* @author panjuan
Expand All @@ -82,7 +84,20 @@ public final class ParsingSQLRouter implements ShardingRouter {

@Override
public SQLStatement parse(final String logicSQL, final boolean useCache) {
return new SQLParsingEngine(databaseType, logicSQL, shardingRule, shardingTableMetaData).parse(useCache);
ParsingEvent event = new ParsingEvent(logicSQL);
ShardingEventBusInstance.getInstance().post(event);
try {
SQLStatement sqlStatement = new SQLParsingEngine(databaseType, logicSQL, shardingRule, shardingTableMetaData).parse(useCache);
event.setExecuteSuccess();
return sqlStatement;
// CHECKSTYLE:OFF
} catch (final Exception ex) {
// CHECKSTYLE:ON
event.setExecuteFailure(ex);
throw ex;
} finally {
ShardingEventBusInstance.getInstance().post(event);
}
}

@Override
Expand Down
Loading