Skip to content

Commit

Permalink
for #1172, remove tracing for get connection and close connection
Browse files Browse the repository at this point in the history
  • Loading branch information
terrymanu committed Sep 25, 2018
1 parent 0f20445 commit 5b3faaf
Show file tree
Hide file tree
Showing 14 changed files with 6 additions and 583 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,13 @@

import com.google.common.collect.Lists;
import io.shardingsphere.core.constant.ConnectionMode;
import io.shardingsphere.core.constant.DatabaseType;
import io.shardingsphere.core.executor.ShardingExecuteCallback;
import io.shardingsphere.core.executor.ShardingExecuteEngine;
import io.shardingsphere.core.executor.ShardingExecuteGroup;
import io.shardingsphere.core.executor.StatementExecuteUnit;
import io.shardingsphere.core.executor.sql.execute.threadlocal.ExecutorDataMap;
import io.shardingsphere.core.metadata.datasource.DataSourceMetaDataFactory;
import io.shardingsphere.core.routing.RouteUnit;
import io.shardingsphere.core.routing.SQLUnit;
import io.shardingsphere.core.spi.connection.get.GetConnectionHook;
import io.shardingsphere.core.spi.connection.get.SPIGetConnectionHook;
import lombok.AllArgsConstructor;
import lombok.RequiredArgsConstructor;

Expand All @@ -53,14 +49,10 @@
@AllArgsConstructor
public final class SQLExecutePrepareTemplate {

private final DatabaseType databaseType;

private final int maxConnectionsSizePerQuery;

private ShardingExecuteEngine shardingExecuteEngine;

private final GetConnectionHook getConnectionHook = new SPIGetConnectionHook();

/**
* Get execute unit groups.
*
Expand Down Expand Up @@ -120,15 +112,7 @@ private List<ShardingExecuteGroup<StatementExecuteUnit>> getSQLExecuteGroups(
int desiredPartitionSize = Math.max(sqlUnits.size() / maxConnectionsSizePerQuery, 1);
List<List<SQLUnit>> sqlUnitGroups = Lists.partition(sqlUnits, desiredPartitionSize);
ConnectionMode connectionMode = maxConnectionsSizePerQuery < sqlUnits.size() ? ConnectionMode.CONNECTION_STRICTLY : ConnectionMode.MEMORY_STRICTLY;
getConnectionHook.start(dataSourceName);
List<Connection> connections;
try {
connections = callback.getConnections(connectionMode, dataSourceName, sqlUnitGroups.size());
} catch (final SQLException ex) {
getConnectionHook.finishFailure(ex);
throw ex;
}
getConnectionHook.finishSuccess(DataSourceMetaDataFactory.newInstance(databaseType, connections.get(0).getMetaData().getURL()), connections.size());
List<Connection> connections = callback.getConnections(connectionMode, dataSourceName, sqlUnitGroups.size());
int count = 0;
for (List<SQLUnit> each : sqlUnitGroups) {
result.add(getSQLExecuteGroup(connectionMode, connections.get(count++), dataSourceName, each, callback));
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -88,11 +88,10 @@ public AbstractStatementExecutor(final int resultSetType, final int resultSetCon
this.resultSetConcurrency = resultSetConcurrency;
this.resultSetHoldability = resultSetHoldability;
this.connection = shardingConnection;
DatabaseType databaseType = connection.getShardingContext().getDatabaseType();
int maxConnectionsSizePerQuery = connection.getShardingContext().getMaxConnectionsSizePerQuery();
ShardingExecuteEngine executeEngine = connection.getShardingContext().getExecuteEngine();
sqlExecutePrepareTemplate = TransactionType.XA == TransactionTypeHolder.get()
? new SQLExecutePrepareTemplate(databaseType, maxConnectionsSizePerQuery) : new SQLExecutePrepareTemplate(databaseType, maxConnectionsSizePerQuery, executeEngine);
? new SQLExecutePrepareTemplate(maxConnectionsSizePerQuery) : new SQLExecutePrepareTemplate(maxConnectionsSizePerQuery, executeEngine);
sqlExecuteTemplate = new SQLExecuteTemplate(executeEngine);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,7 @@
import io.shardingsphere.core.jdbc.adapter.executor.ForceExecuteCallback;
import io.shardingsphere.core.jdbc.adapter.executor.ForceExecuteTemplate;
import io.shardingsphere.core.jdbc.unsupported.AbstractUnsupportedOperationConnection;
import io.shardingsphere.core.metadata.datasource.DataSourceMetaDataFactory;
import io.shardingsphere.core.routing.router.masterslave.MasterVisitedManager;
import io.shardingsphere.core.spi.connection.close.CloseConnectionHook;
import io.shardingsphere.core.spi.connection.close.SPICloseConnectionHook;
import io.shardingsphere.core.spi.root.RootInvokeHook;
import io.shardingsphere.core.spi.root.SPIRootInvokeHook;
import io.shardingsphere.core.transaction.TransactionTypeHolder;
Expand Down Expand Up @@ -78,8 +75,6 @@ public abstract class AbstractConnectionAdapter extends AbstractUnsupportedOpera

private final RootInvokeHook rootInvokeHook = new SPIRootInvokeHook();

private final CloseConnectionHook closeConnectionHook = new SPICloseConnectionHook();

/**
* Get database connection.
*
Expand Down Expand Up @@ -226,17 +221,7 @@ public final void close() throws SQLException {

@Override
public void execute(final Entry<String, Connection> cachedConnections) throws SQLException {
Connection connection = cachedConnections.getValue();
closeConnectionHook.start(cachedConnections.getKey(), DataSourceMetaDataFactory.newInstance(databaseType, connection.getMetaData().getURL()));
try {
connection.close();
closeConnectionHook.finishSuccess();
// CHECKSTYLE:OFF
} catch (final Exception ex) {
// CHECKSTYLE:ON
closeConnectionHook.finishFailure(ex);
throw ex;
}
cachedConnections.getValue().close();
}
});
rootInvokeHook.finish(connectionSize);
Expand Down

This file was deleted.

Loading

0 comments on commit 5b3faaf

Please sign in to comment.