本文整理匯總了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;
}