Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 43 additions & 19 deletions src/main/java/com/alipay/oceanbase/rpc/ObTableClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -457,7 +457,7 @@ private <T> T execute(String tableName, TableExecuteCallback<T> callback, ObServ
int tryTimes = 0;
boolean needRefreshPartitionLocation = false;
long startExecute = System.currentTimeMillis();
Row rowKey = transformToRow(tableName, callback.getRowKey());
Row rowKey = odpMode ? null : transformToRow(tableName, callback.getRowKey());
while (true) {
checkStatus();
long currentExecute = System.currentTimeMillis();
Expand Down Expand Up @@ -946,7 +946,6 @@ public void setRpcExecuteTimeout(int rpcExecuteTimeout) {

/**
* Get or refresh table entry meta information.
* work for both OcpMode and OdpMode
* @param tableName table name
* @return TableEntry
* @throws Exception if fail
Expand All @@ -962,15 +961,19 @@ public TableEntry getOrRefreshTableEntry(final String tableName, boolean forceRe

/**
* refresh table meta information except location
* work for both OcpMode and OdpMode
* @param tableName table name
* */
private TableEntry refreshMeta(String tableName) throws Exception {
if (odpMode) {
return tableRoute.refreshODPMeta(tableName, true);
} else {
return tableRoute.refreshMeta(tableName);
}
return tableRoute.refreshMeta(tableName);
}

/**
* refresh table meta information except location
* only support by ODP version after 4.3.2
* @param tableName table name
* */
public TableEntry refreshOdpMeta(String tableName) throws Exception {
return tableRoute.refreshOdpMeta(tableName, true);
}

/**
Expand Down Expand Up @@ -1076,6 +1079,19 @@ public ObTableParam getTableParamWithPartId(String tableName, long partId, ObSer
return tableRoute.getTableWithPartId(tableName, partId, route);
}

/**
* get addr by pardId in ODP mode
* only support by ODP version after 4.3.2
* @param tableName table want to get
* @param partId logic of table
* @return ObPair of partId and table
* @throws Exception exception
*/
public ObTableParam getOdpTableParamWithPartId(String tableName, long partId)
throws Exception {
return tableRoute.getOdpTableWithPartId(tableName, partId);
}

/**
*
* @param moveResponse reRoute response
Expand Down Expand Up @@ -1910,14 +1926,17 @@ private Partition getSinglePartitionInternal(String tableName, Row rowKey, boole
addRowKeyElement(tableName, rowKey.getColumns());
}
ObTableParam tableParam = null;
if (refresh) {
if (odpMode) {
tableRoute.refreshODPMeta(tableName, true);
} else {
if (odpMode) {
if (refresh) {
tableRoute.refreshOdpMeta(tableName, true);
}
tableParam = tableRoute.getOdpTableParam(tableName, rowKey);
} else {
if (refresh) {
tableRoute.refreshMeta(tableName);
}
tableParam = tableRoute.getTableParam(tableName, rowKey);
}
tableParam = tableRoute.getTableParam(tableName, rowKey);
return new Partition(tableParam.getPartitionId(), tableParam.getPartId(),
tableParam.getTableId(), tableParam.getObTable().getIp(), tableParam.getObTable()
.getPort(), tableParam.getLsId());
Expand All @@ -1941,15 +1960,20 @@ public List<Partition> getPartition(String tableName, boolean refresh) throws Ex
*/
private List<Partition> getAllPartitionInternal(String tableName, boolean refresh) throws Exception {
List<Partition> partitions = new ArrayList<>();
if (refresh) {
if (odpMode) {
tableRoute.refreshODPMeta(tableName, true);
} else {
List<ObTableParam> allTables;
if (odpMode) {
if (refresh) {
tableRoute.refreshOdpMeta(tableName, true);
}
allTables = tableRoute.getOdpTableParams(tableName, new ObTableQuery(), new Object[]{ ObObj.getMin() }, true,
new Object[]{ ObObj.getMax() }, true);
} else {
if (refresh) {
tableRoute.refreshMeta(tableName);
}
allTables = tableRoute.getTableParams(tableName, new ObTableQuery(), new Object[]{ ObObj.getMin() }, true,
new Object[]{ ObObj.getMax() }, true);
}
List<ObTableParam> allTables = tableRoute.getTableParams(tableName, new ObTableQuery(), new Object[]{ ObObj.getMin() }, true,
new Object[]{ ObObj.getMax() }, true);
for (ObTableParam tableParam : allTables) {
Partition partition = new Partition(tableParam.getPartitionId(), tableParam.getPartId(), tableParam.getTableId(),
tableParam.getObTable().getIp(), tableParam.getObTable().getPort(), tableParam.getLsId());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -533,13 +533,14 @@ private long getTableLevelRefreshInterval(ServerRoster serverRoster) {

/**
* fetch ODP partition meta information
* only support by ODP version after 4.3.2
* @param tableName table name to query
* @param forceRefresh flag to force ODP to fetch the latest partition meta information
* @param odpTable odp table to execute refreshing
* @return TableEntry ODPTableEntry
* @throws Exception Exception
*/
public TableEntry refreshODPMeta(String tableName, boolean forceRefresh, ObTable odpTable)
public TableEntry refreshOdpMeta(String tableName, boolean forceRefresh, ObTable odpTable)
throws Exception {
if (tableName == null || tableName.isEmpty()) {
throw new IllegalArgumentException("table name is null");
Expand Down
Loading