当前位置: 首页>>代码示例>>Java>>正文


Java IGroupExecutor.getRemotingExecutableObject方法代码示例

本文整理汇总了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;
}
 
开发者ID:loye168,项目名称:tddl5,代码行数:28,代码来源:DatasourceMySQLImplement.java

示例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;
}
 
开发者ID:loye168,项目名称:tddl5,代码行数:30,代码来源:TDatabaseMetaData.java

示例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;

}
 
开发者ID:loye168,项目名称:tddl5,代码行数:63,代码来源:ShowDatasourcesHandler.java

示例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();
    }

}
 
开发者ID:loye168,项目名称:tddl5,代码行数:42,代码来源:TConnection.java


注:本文中的com.taobao.tddl.executor.spi.IGroupExecutor.getRemotingExecutableObject方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。