本文整理汇总了Java中com.taobao.tddl.executor.spi.ITable类的典型用法代码示例。如果您正苦于以下问题:Java ITable类的具体用法?Java ITable怎么用?Java ITable使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ITable类属于com.taobao.tddl.executor.spi包,在下文中一共展示了ITable类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: handle
import com.taobao.tddl.executor.spi.ITable; //导入依赖的package包/类
@Override
public ISchematicCursor handle(IDataNodeExecutor executor, ExecutionContext executionContext) throws TddlException {
long time = System.currentTimeMillis();
IPut put = (IPut) executor;
My_JdbcHandler jdbcHandler = ((My_Repository) executionContext.getCurrentRepository()).getJdbcHandler(dsGetter,
executor,
executionContext);
TableAndIndex ti = new TableAndIndex();
buildTableAndMeta(put, ti, executionContext);
ITable table = ti.table;
IndexMeta meta = ti.index;
ISchematicCursor result = null;
try {
result = executePut(executionContext, put, table, meta, jdbcHandler);
} catch (Exception e) {
time = Monitor.monitorAndRenewTime(Monitor.KEY1, Monitor.KEY2_TDDL_EXECUTE, Monitor.Key3Fail, time);
throw new TddlException(e);
}
time = Monitor.monitorAndRenewTime(Monitor.KEY1, Monitor.KEY2_TDDL_EXECUTE, Monitor.Key3Success, time);
return result;
}
示例2: getTable
import com.taobao.tddl.executor.spi.ITable; //导入依赖的package包/类
@Override
public ITable getTable(TableMeta table_schema, String groupNode, String actualTableName) throws TddlException {
ITable table = tables.get(table_schema.getTableName());
if (table == null) {
synchronized (this) {
table = tables.get(table_schema.getTableName());
if (table == null) {
try {
table = initTable(table_schema);
} catch (ReplicaWriteException ex) {
throw new TddlNestableRuntimeException(ex);
}
if (!table_schema.isTmp()) {
tables.put(table_schema.getTableName(), table);
}
}
}
}
return table;
}
示例3: getTable
import com.taobao.tddl.executor.spi.ITable; //导入依赖的package包/类
@Override
public ITable getTable(TableMeta table_schema, String groupNode) throws TddlException {
ITable table = tables.get(table_schema.getTableName());
if (table == null) {
synchronized (this) {
table = tables.get(table_schema.getTableName());
if (table == null) {
try {
table = initTable(table_schema);
} catch (ReplicaWriteException ex) {
throw new TddlException(ExceptionErrorCodeUtils.Read_only, ex);
}
if (!table_schema.isTmp()) {
tables.put(table_schema.getTableName(), table);
}
}
}
}
return table;
}
示例4: manageToReverseIndex
import com.taobao.tddl.executor.spi.ITable; //导入依赖的package包/类
protected ISchematicCursor manageToReverseIndex(ExecutionContext executionContext, ISchematicCursor cursor,
IDataNodeExecutor executor, IRepository repo,
ITransaction transaction, ITable table, IndexMeta meta,
IFilter keyFilter) throws TddlException {
throw new IllegalArgumentException("should not be here");
}
示例5: handle
import com.taobao.tddl.executor.spi.ITable; //导入依赖的package包/类
@Override
public ISchematicCursor handle(IDataNodeExecutor executor, ExecutionContext executionContext) throws TddlException {
if (executionContext.getParams() != null && executionContext.getParams().isBatch()) {
throw new ExecutorException("batch is not supported for :"
+ executionContext.getCurrentRepository().getClass());
}
long time = System.currentTimeMillis();
IPut put = (IPut) executor;
TableAndIndex ti = new TableAndIndex();
buildTableAndMeta(put, ti, executionContext);
int affect_rows = 0;
ITransaction transaction = executionContext.getTransaction();
ITable table = ti.table;
IndexMeta meta = ti.index;
try {
if (transaction == null) {// 客户端没有用事务,这里手动加上。
throw new IllegalAccessError("txn is null");
}
affect_rows = executePut(executionContext, put, table, meta);
} catch (Exception e) {
time = Monitor.monitorAndRenewTime(Monitor.KEY1, Monitor.KEY2_TDDL_EXECUTE, Monitor.Key3Fail, time);
throw new TddlNestableRuntimeException(e);
}
// 这里返回key->value的方式的东西,类似Key=affectRow val=1 这样的软编码
IAffectRowCursor affectrowCursor = executionContext.getCurrentRepository()
.getCursorFactory()
.affectRowCursor(executionContext, affect_rows);
time = Monitor.monitorAndRenewTime(Monitor.KEY1, Monitor.KEY2_TDDL_EXECUTE, Monitor.Key3Success, time);
return affectrowCursor;
}
示例6: cleanTempTables
import com.taobao.tddl.executor.spi.ITable; //导入依赖的package包/类
public void cleanTempTables() {
for (ITable tempTable : getTempTables().asMap().values()) {
try {
tempTable.close();
} catch (Throwable e) {
logger.warn("temp table close failed", e);
}
}
}
示例7: getTable
import com.taobao.tddl.executor.spi.ITable; //导入依赖的package包/类
@Override
public ITable getTable(final TableMeta meta, final String groupNode, String actualTableName) throws TddlException {
if (meta.isTmp()) {
return getTempTable(meta);
} else {
try {
return tables.get(groupNode).get(meta);
} catch (ExecutionException e) {
throw new TddlNestableRuntimeException(e);
}
}
}
示例8: executePut
import com.taobao.tddl.executor.spi.ITable; //导入依赖的package包/类
@Override
protected ISchematicCursor executePut(ExecutionContext executionContext, IPut put, ITable table, IndexMeta meta,
My_JdbcHandler myJdbcHandler) throws TddlException {
try {
return myJdbcHandler.executeUpdate(executionContext, put, table, meta);
} catch (SQLException e) {
throw new TddlException(e);
}
}
示例9: executePut
import com.taobao.tddl.executor.spi.ITable; //导入依赖的package包/类
@SuppressWarnings("rawtypes")
@Override
protected ISchematicCursor executePut(ExecutionContext executionContext, IPut put, ITable table, IndexMeta meta,
My_JdbcHandler myJdbcHandler) throws TddlException {
try {
return myJdbcHandler.executeUpdate(executionContext, put, table, meta);
} catch (SQLException e) {
throw new TddlException(e);
}
}
示例10: doDestroy
import com.taobao.tddl.executor.spi.ITable; //导入依赖的package包/类
@Override
public void doDestroy() throws TddlException {
for (Entry<String, ITable> t : tables.entrySet()) {
t.getValue().close();
}
env.close();
if (env_tmp != null) {
env_tmp.close();
}
}
示例11: getTable
import com.taobao.tddl.executor.spi.ITable; //导入依赖的package包/类
@Override
public ITable getTable(TableMeta meta, String groupNode, String actualTableName) throws TddlException {
DemoTable table = null;
table = dbMap.get(actualTableName);
if (table == null) {
table = new DemoTable(meta);
dbMap.put(actualTableName, table);
}
return table;
}
示例12: doInit
import com.taobao.tddl.executor.spi.ITable; //导入依赖的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;
}
});
}
示例13: executePut
import com.taobao.tddl.executor.spi.ITable; //导入依赖的package包/类
@Override
protected int executePut(ExecutionContext executionContext, IPut put, ITable table, IndexMeta meta)
throws Exception {
int affect_rows = 0;
IPut delete = put;
ISchematicCursor conditionCursor = null;
conditionCursor = ExecutorContext.getContext()
.getTopologyExecutor()
.execByExecPlanNode(put.getQueryTree(), executionContext);
IRowSet rowSet = null;
try {
while ((rowSet = conditionCursor.next()) != null) {
affect_rows++;
CloneableRecord key = ExecUtils.convertToClonableRecord(rowSet);
// prepare(transaction, table, rowSet, null, null,
// PUT_TYPE.DELETE);
table.delete(null, key, meta, put.getTableName());
}
} catch (Exception e) {
throw e;
} finally {
List<TddlException> exs = conditionCursor.close(null);
if (!exs.isEmpty()) throw GeneralUtil.mergeException(exs);
}
return affect_rows;
}
示例14: executePut
import com.taobao.tddl.executor.spi.ITable; //导入依赖的package包/类
@SuppressWarnings("rawtypes")
@Override
protected int executePut(ExecutionContext executionContext, IPut put, ITable table, IndexMeta meta)
throws Exception {
ITransaction transaction = executionContext.getTransaction();
int affect_rows = 0;
IPut delete = put;
ISchematicCursor conditionCursor = null;
IRowSet rowSet = null;
CloneableRecord key = CodecFactory.getInstance(CodecFactory.FIXED_LENGTH)
.getCodec(meta.getKeyColumns())
.newEmptyRecord();
try {
conditionCursor = ExecutorContext.getContext()
.getTopologyExecutor()
.execByExecPlanNode(delete.getQueryTree(), executionContext);
while ((rowSet = conditionCursor.next()) != null) {
affect_rows++;
for (ColumnMeta cm : meta.getKeyColumns()) {
Object val = getValByColumnMeta(rowSet, cm);
key.put(cm.getName(), val);
}
// CloneableRecord key =
// ExecUtils.convertToClonableRecord(rowSet);
prepare(transaction, table, rowSet, null, null, PUT_TYPE.DELETE);
table.delete(executionContext, key, meta, put.getTableName());
}
} catch (Exception e) {
throw e;
} finally {
if (conditionCursor != null) {
List<TddlException> exs = new ArrayList();
exs = conditionCursor.close(exs);
if (!exs.isEmpty()) {
throw GeneralUtil.mergeException(exs);
}
}
}
return affect_rows;
}
示例15: prepare
import com.taobao.tddl.executor.spi.ITable; //导入依赖的package包/类
protected void prepare(ITransaction transaction, ITable table, IRowSet oldkv, CloneableRecord key,
CloneableRecord value, IPut.PUT_TYPE putType) throws TddlException {
ITHLog historyLog = transaction.getHistoryLog();
if (historyLog != null) {
historyLog.parepare(transaction.getId(), table.getSchema(), putType, oldkv, new KVPair(key, value));
}
}