本文整理汇总了Java中com.taobao.tddl.executor.spi.IGroupExecutor类的典型用法代码示例。如果您正苦于以下问题:Java IGroupExecutor类的具体用法?Java IGroupExecutor怎么用?Java IGroupExecutor使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
IGroupExecutor类属于com.taobao.tddl.executor.spi包,在下文中一共展示了IGroupExecutor类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: doInit
import com.taobao.tddl.executor.spi.IGroupExecutor; //导入依赖的package包/类
@Override
public void doInit() throws TddlException {
this.cursorFactory = new CursorFactoryDemoImp();
this.commandExecutorFactory = new CommandExecutorFactoryDemoImp();
executors = CacheBuilder.newBuilder().build(new CacheLoader<Group, IGroupExecutor>() {
@Override
public IGroupExecutor load(Group group) throws Exception {
DemoGroupExecutor executor = new DemoGroupExecutor(getRepo());
executor.setGroup(group);
return executor;
}
});
}
示例2: get
import com.taobao.tddl.executor.spi.IGroupExecutor; //导入依赖的package包/类
public IGroupExecutor get(String key) {
IGroupExecutor groupExecutor = executorMap.get(key);
if (groupExecutor == null) {
Group group = matrix.getGroup(key);
if (group != null) {
synchronized (executorMap) {
// double-check,避免并发创建
groupExecutor = executorMap.get(key);
if (groupExecutor == null) {
return createOne(group);
} else {
return executorMap.get(key);
}
}
}
}
return groupExecutor;
}
示例3: createOne
import com.taobao.tddl.executor.spi.IGroupExecutor; //导入依赖的package包/类
/**
* 指定Group配置,创建一个GroupExecutor
*
* @param group
* @return
*/
public IGroupExecutor createOne(Group group) {
group.setAppName(this.appName);
group.setUnitName(this.unitName);
IRepository repo = repositoryHolder.getOrCreateRepository(group, matrix.getProperties(), cp);
IGroupExecutor groupExecutor = repo.getGroupExecutor(group);
putOne(group.getName(), groupExecutor);
return groupExecutor;
}
示例4: putOne
import com.taobao.tddl.executor.spi.IGroupExecutor; //导入依赖的package包/类
public IGroupExecutor putOne(String groupKey, IGroupExecutor groupExecutor, boolean singleton) {
if (singleton && executorMap.containsKey(groupKey)) {
throw new IllegalArgumentException("group key is already exists . group key : " + groupKey + " . map "
+ executorMap);
}
return executorMap.put(groupKey, groupExecutor);
}
示例5: get
import com.taobao.tddl.executor.spi.IGroupExecutor; //导入依赖的package包/类
public IGroupExecutor get(String key) {
IGroupExecutor groupExecutor = executorMap.get(key);
if (groupExecutor == null) {
for (TopologyHandler sub : this.subTopologyHandlers) {
groupExecutor = sub.get(key);
if (groupExecutor != null) {
return groupExecutor;
}
}
Group group = matrix.getGroup(key);
if (group != null) {
synchronized (executorMap) {
// double-check,避免并发创建
groupExecutor = executorMap.get(key);
if (groupExecutor == null) {
return createOne(group);
} else {
return executorMap.get(key);
}
}
}
}
return groupExecutor;
}
示例6: 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;
}
示例7: doDestroy
import com.taobao.tddl.executor.spi.IGroupExecutor; //导入依赖的package包/类
@Override
protected void doDestroy() throws TddlException {
tables.cleanUp();
for (IGroupExecutor executor : executors.asMap().values()) {
executor.destroy();
}
}
示例8: getGroupExecutor
import com.taobao.tddl.executor.spi.IGroupExecutor; //导入依赖的package包/类
@Override
public IGroupExecutor getGroupExecutor(final Group group) {
try {
return executors.get(group);
} catch (ExecutionException e) {
throw new TddlNestableRuntimeException(e);
}
}
示例9: 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;
}
示例10: getGroupExecutor
import com.taobao.tddl.executor.spi.IGroupExecutor; //导入依赖的package包/类
@Override
public IGroupExecutor getGroupExecutor(Group group) {
try {
return executors.get(group);
} catch (ExecutionException e) {
throw new TddlNestableRuntimeException(e);
}
}
示例11: doInit
import com.taobao.tddl.executor.spi.IGroupExecutor; //导入依赖的package包/类
@Override
public void doInit() {
tables = CacheBuilder.newBuilder().build(new CacheLoader<String, LoadingCache<TableMeta, ITable>>() {
@Override
public LoadingCache<TableMeta, ITable> load(final String groupNode) throws Exception {
return CacheBuilder.newBuilder().build(new CacheLoader<TableMeta, ITable>() {
@Override
public ITable load(TableMeta meta) throws Exception {
try {
HbTable table = new HbTable(meta, groupNameAndExecutors.get(groupNode)
.getRemotingExecutableObject(), physicalSchema.get(meta.getTableName()));
return table;
} catch (Exception ex) {
throw new TddlNestableRuntimeException(ex);
}
}
});
}
});
executors = CacheBuilder.newBuilder().build(new CacheLoader<Group, IGroupExecutor>() {
@Override
public IGroupExecutor load(Group group) throws Exception {
HBaseGroupExecutor executor = new HBaseGroupExecutor(getRepo());
group.getProperties().put(HbaseConf.cluster_name, group.getName());
executor.setGroup(group);
executor.setHbOperate(getHBCluster(group.getProperties()));
groupNameAndExecutors.put(group.getName(), executor);
return executor;
}
});
}
示例12: createOne
import com.taobao.tddl.executor.spi.IGroupExecutor; //导入依赖的package包/类
/**
* 指定Group配置,创建一个GroupExecutor
*
* @param group
* @return
*/
public IGroupExecutor createOne(Group group) {
group.setAppName(this.appName);
IRepository repo = ExecutorContext.getContext()
.getRepositoryHolder()
.getOrCreateRepository(group.getType().toString(), matrix.getProperties());
IGroupExecutor groupExecutor = repo.getGroupExecutor(group);
putOne(group.getName(), groupExecutor);
return groupExecutor;
}
示例13: doDestory
import com.taobao.tddl.executor.spi.IGroupExecutor; //导入依赖的package包/类
@Override
protected void doDestory() throws TddlException {
tables.cleanUp();
for (IGroupExecutor executor : executors.asMap().values()) {
executor.destory();
}
}
示例14: getGroupExecutor
import com.taobao.tddl.executor.spi.IGroupExecutor; //导入依赖的package包/类
@Override
public IGroupExecutor getGroupExecutor(final Group group) {
try {
return executors.get(group);
} catch (ExecutionException e) {
throw new TddlRuntimeException(e);
}
}
示例15: getGroupExecutor
import com.taobao.tddl.executor.spi.IGroupExecutor; //导入依赖的package包/类
@Override
public IGroupExecutor getGroupExecutor(Group group) {
// TODO Auto-generated method stub
return null;
}