Search in sources :

Example 1 with ClusterDbSqlContext

use of com.ctrip.platform.dal.dao.datasource.log.ClusterDbSqlContext in project dal by ctripcorp.

the class ClusterDataSource method createSqlContext.

@Override
protected SqlContext createSqlContext() {
    SqlContext context = id.createSqlContext();
    if (context instanceof ClusterDbSqlContext) {
        ((ClusterDbSqlContext) context).populateShard(getShardIndex());
        ((ClusterDbSqlContext) context).populateRole(DatabaseRole.MASTER);
    }
    return context;
}
Also used : SqlContext(com.ctrip.platform.dal.dao.datasource.log.SqlContext) ClusterDbSqlContext(com.ctrip.platform.dal.dao.datasource.log.ClusterDbSqlContext) ClusterDbSqlContext(com.ctrip.platform.dal.dao.datasource.log.ClusterDbSqlContext)

Example 2 with ClusterDbSqlContext

use of com.ctrip.platform.dal.dao.datasource.log.ClusterDbSqlContext in project dal by ctripcorp.

the class TraceableClusterDataSourceIdentity method createSqlContext.

@Override
public SqlContext createSqlContext() {
    Cluster cluster = getDatabase().getCluster();
    ClusterDbSqlContext context = new ClusterDbSqlContext(cluster, getShardIndex(), getDatabaseRole());
    if (cluster != null && cluster.getLocalizationConfig() != null)
        context.populateDbZone(cluster.getLocalizationConfig().getZoneId());
    return context;
}
Also used : ClusterDbSqlContext(com.ctrip.platform.dal.dao.datasource.log.ClusterDbSqlContext) Cluster(com.ctrip.framework.dal.cluster.client.Cluster)

Aggregations

ClusterDbSqlContext (com.ctrip.platform.dal.dao.datasource.log.ClusterDbSqlContext)2 Cluster (com.ctrip.framework.dal.cluster.client.Cluster)1 SqlContext (com.ctrip.platform.dal.dao.datasource.log.SqlContext)1