本文整理匯總了Java中com.taobao.tddl.executor.spi.IGroupExecutor.getRemotingExecutableObject方法的典型用法代碼示例。如果您正苦於以下問題:Java IGroupExecutor.getRemotingExecutableObject方法的具體用法?Java IGroupExecutor.getRemotingExecutableObject怎麽用?Java IGroupExecutor.getRemotingExecutableObject使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.taobao.tddl.executor.spi.IGroupExecutor
的用法示例。
在下文中一共展示了IGroupExecutor.getRemotingExecutableObject方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getDatasourceByGroupNode
import com.taobao.tddl.executor.spi.IGroupExecutor; //導入方法依賴的package包/類
public DataSource getDatasourceByGroupNode(TopologyHandler topology, String groupNode) {
if ("undecided".equals(groupNode)) {
return null;
}
IGroupExecutor matrixExecutor = topology.get(groupNode);
if (matrixExecutor == null) return null;
/*
* 這裏做個hack吧。 原因是在構造topologic的時候,默認全部使用mysql作為type了。
* 這樣就造成所有的Datasource都是由RemotingExecutor
* com.taobao.ustore.jdbc.mysql.My_Reponsitory.buildRemoting(Group
* group) 創建的,type都是mysql.
* 但實際上這裏的type需要根據實際的DataSource來決定是個oracle還是個mysql.
* 如果是oracle那麽type需要改成oracle..
*/
Group.GroupType type = matrixExecutor.getGroupInfo().getType();
DataSource ds = (DataSource) matrixExecutor.getRemotingExecutableObject();
if (isNotValidateNode(type)) {
throw new IllegalArgumentException("target node is not a validated Jdbc node");
}
if (ds == null) {
throw new IllegalArgumentException("can't find ds by group name ");
}
return ds;
}
示例2: getDatabaseMetaData
import com.taobao.tddl.executor.spi.IGroupExecutor; //導入方法依賴的package包/類
public DatabaseMetaData getDatabaseMetaData() throws SQLException {
Connection conn = null;
DatabaseMetaData dbMa = null;
try {
// 找到默認的主庫
String defaultDbIndex = this.dataSource.getConfigHolder()
.getOptimizerContext()
.getRule()
.getDefaultDbIndex(null);
// 找到對應的執行器
IGroupExecutor groupExecutor = this.dataSource.getConfigHolder()
.getExecutorContext()
.getTopologyHandler()
.get(defaultDbIndex);
Object groupDataSource = groupExecutor.getRemotingExecutableObject();
if (groupDataSource instanceof DataSource) {
// 指定到主庫上執行
conn = ((DataSource) groupDataSource).getConnection();
dbMa = conn.getMetaData();
}
} finally {
if (conn != null) {
conn.close();
}
}
return dbMa;
}
示例3: handle
import com.taobao.tddl.executor.spi.IGroupExecutor; //導入方法依賴的package包/類
@Override
public ISchematicCursor handle(IDataNodeExecutor executor, ExecutionContext executionContext) throws TddlException {
ArrayResultCursor result = new ArrayResultCursor("TRACE", executionContext);
result.addColumn("ID", DataType.IntegerType);
result.addColumn("SCHEMA", DataType.StringType);
result.addColumn("NAME", DataType.StringType);
result.addColumn("GROUP", DataType.StringType);
result.addColumn("URL", DataType.StringType);
result.addColumn("USER", DataType.StringType);
result.addColumn("TYPE", DataType.StringType);
result.addColumn("INIT", DataType.StringType);
result.addColumn("MIN", DataType.StringType);
result.addColumn("MAX", DataType.StringType);
result.addColumn("IDLE_TIMEOUT", DataType.StringType);
result.addColumn("MAX_WAIT", DataType.StringType);
result.addColumn("ACTIVE_COUNT", DataType.StringType);
result.addColumn("POOLING_COUNT", DataType.StringType);
result.initMeta();
int index = 0;
Matrix matrix = ExecutorContext.getContext().getTopologyHandler().getMatrix();
TopologyHandler topology = ExecutorContext.getContext().getTopologyHandler();
for (Group group : matrix.getGroups()) {
IGroupExecutor groupExecutor = topology.get(group.getName());
Object o = groupExecutor.getRemotingExecutableObject();
if (o != null && o instanceof TGroupDataSource) {
TGroupDataSource ds = (TGroupDataSource) o;
for (DataSource atom : ds.getDataSourceMap().values()) {
TAtomDataSource atomDs = this.getAtomDatasource(atom);
DruidDataSource d;
try {
if (!(atomDs.getDataSource().getTargetDataSource() instanceof DruidDataSource)) {
logger.warn("atom datasource is not druid?"
+ atomDs.getDataSource().getTargetDataSource().getClass());
continue;
}
d = (DruidDataSource) atomDs.getDataSource().getTargetDataSource();
result.addRow(new Object[] { index++, topology.getAppName(), d.getName(), group.getName(),
d.getUrl(), d.getUsername(), d.getDbType(), d.getInitialSize(), d.getMinIdle(),
d.getMaxActive(), d.getTimeBetweenEvictionRunsMillis() / (1000 * 60), d.getMaxWait(),
d.getActiveCount(), d.getPoolingCount() });
} catch (SQLException e) {
logger.error("", e);
}
}
}
}
return result;
}
示例4: prepareCall
import com.taobao.tddl.executor.spi.IGroupExecutor; //導入方法依賴的package包/類
@Override
public CallableStatement prepareCall(String sql, int resultSetType, int resultSetConcurrency,
int resultSetHoldability) throws SQLException {
checkClosed();
// 先檢查下是否有db hint
DirectlyRouteCondition route = (DirectlyRouteCondition) SimpleHintParser.getRouteContiongFromThreadLocal(ThreadLocalString.DB_SELECTOR);
String defaultDbIndex = null;
if (route != null) {
defaultDbIndex = route.getDbId();
} else {
// 針對存儲過程,直接下推到default庫上執行
defaultDbIndex = this.ds.getConfigHolder().getOptimizerContext().getRule().getDefaultDbIndex(null);
}
IGroupExecutor groupExecutor = this.ds.getConfigHolder()
.getExecutorContext()
.getTopologyHandler()
.get(defaultDbIndex);
Object groupDataSource = groupExecutor.getRemotingExecutableObject();
if (groupDataSource instanceof DataSource) {
GroupDataSourceRouteHelper.executeByGroupDataSourceIndex(0);
Connection conn = ((DataSource) groupDataSource).getConnection();
CallableStatement target = null;
if (resultSetType != Integer.MIN_VALUE && resultSetHoldability != Integer.MIN_VALUE) {
target = conn.prepareCall(sql, resultSetType, resultSetConcurrency, resultSetHoldability);
} else if (resultSetType != Integer.MIN_VALUE) {
target = conn.prepareCall(sql, resultSetType, resultSetConcurrency);
} else {
target = conn.prepareCall(sql);
}
ExecutionContext context = prepareExecutionContext();
TCallableStatement stmt = new TCallableStatement(ds, this, sql, context, target);
openedStatements.add(stmt);
return stmt;
} else {
throw new UnsupportedOperationException();
}
}