Skip to content

Commit 6c891a2

Browse files
JackShi148WeiXinChanmaochongxin
authored
OBKV 442 features (#421)
* Hbase metrics management (#404) * add OHOperationType enum * set hbaseOpType to requests and encode to server * set hbase op type to query * fix retry for meeting ObTableNotExists when query tableGroup * support weak read (#406) * modify weak read interface (#412) * recover Get default construction function (#413) * fix read policy (#414) * fix set setRpcExecuteTimeout nullpointer (#415) * fix weak read in batch get (#416) * support weak in old interface (#417) * fix weak read in BatchOperation (#418) * add get_optimized flag for obtablequery --------- Co-authored-by: vanson <43193589+WeiXinChan@users.noreply.github.com> Co-authored-by: maochongxin <maochongxin@gmail.com>
1 parent 4b2a54f commit 6c891a2

File tree

59 files changed

+4126
-1629
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

59 files changed

+4126
-1629
lines changed

src/main/java/com/alipay/oceanbase/rpc/ObClusterTableBatchOps.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,12 @@ public void setReturnOneResult(boolean returnOneResult) {
184184
tableBatchOps.setReturnOneResult(returnOneResult);
185185
}
186186

187+
@Override
188+
public void setIsWeakRead(boolean isWeakRead) {
189+
super.setIsWeakRead(isWeakRead);
190+
tableBatchOps.setIsWeakRead(isWeakRead);
191+
}
192+
187193
void preCheck() {
188194
List<ObTableOperation> operations = this.tableBatchOps.getObTableBatchOperation()
189195
.getTableOperations();

src/main/java/com/alipay/oceanbase/rpc/ObClusterTableQuery.java

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
import com.alipay.oceanbase.rpc.location.model.partition.Partition;
2121
import com.alipay.oceanbase.rpc.mutation.Row;
2222
import com.alipay.oceanbase.rpc.protocol.payload.impl.ObObj;
23+
import com.alipay.oceanbase.rpc.protocol.payload.impl.execute.ObReadConsistency;
2324
import com.alipay.oceanbase.rpc.protocol.payload.impl.execute.ObTableEntityType;
2425
import com.alipay.oceanbase.rpc.protocol.payload.impl.execute.aggregation.ObTableAggregationType;
2526
import com.alipay.oceanbase.rpc.protocol.payload.impl.execute.query.ObHTableFilter;
@@ -271,6 +272,26 @@ public TableQuery setSearchText(String searchText) {
271272
return this;
272273
}
273274

275+
@Override
276+
public TableQuery setReadConsistency(ObReadConsistency readConsistency) {
277+
// 同时设置父类和内部 tableClientQuery 的 readConsistency
278+
super.setReadConsistency(readConsistency);
279+
tableClientQuery.setReadConsistency(readConsistency);
280+
return this;
281+
}
282+
283+
@Override
284+
public ObReadConsistency getReadConsistency() {
285+
// 返回内部 tableClientQuery 的 readConsistency
286+
return tableClientQuery.getReadConsistency();
287+
}
288+
289+
@Override
290+
public TableQuery setScanRangeColumns(String... columns) {
291+
tableClientQuery.setScanRangeColumns(columns);
292+
return this;
293+
}
294+
274295
public void setAllowDistributeScan(boolean allowDistributeScan) {
275296
tableClientQuery.setAllowDistributeScan(allowDistributeScan);
276297
}

src/main/java/com/alipay/oceanbase/rpc/ObTableClient.java

Lines changed: 98 additions & 229 deletions
Large diffs are not rendered by default.

src/main/java/com/alipay/oceanbase/rpc/bolt/protocol/ObTablePacketCode.java

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@
1717

1818
package com.alipay.oceanbase.rpc.bolt.protocol;
1919

20-
import com.alipay.oceanbase.rpc.exception.ObTableRoutingWrongException;
21-
import com.alipay.oceanbase.rpc.meta.ObTableMetaRequest;
2220
import com.alipay.oceanbase.rpc.meta.ObTableMetaResponse;
2321
import com.alipay.oceanbase.rpc.protocol.packet.ObRpcPacketHeader;
2422
import com.alipay.oceanbase.rpc.protocol.payload.ObPayload;
@@ -36,9 +34,6 @@
3634
import com.alipay.oceanbase.rpc.protocol.payload.impl.login.ObTableLoginResult;
3735
import com.alipay.remoting.CommandCode;
3836

39-
import static com.alipay.oceanbase.rpc.protocol.payload.Pcodes.OB_TABLE_API_HBASE_EXECUTE;
40-
import static com.alipay.oceanbase.rpc.protocol.payload.Pcodes.OB_TABLE_API_META_INFO_EXECUTE;
41-
4237
public enum ObTablePacketCode implements CommandCode {
4338

4439
OB_TABLE_API_LOGIN(Pcodes.OB_TABLE_API_LOGIN) {

src/main/java/com/alipay/oceanbase/rpc/bolt/transport/ObClientFuture.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
import com.alipay.remoting.InvokeContext;
2323
import com.alipay.remoting.InvokeFuture;
2424
import com.alipay.remoting.RemotingCommand;
25-
import com.alipay.oceanbase.rpc.exception.ObTableTimeoutExcetion;
2625
import io.netty.util.Timeout;
2726

2827
import java.net.InetSocketAddress;

src/main/java/com/alipay/oceanbase/rpc/bolt/transport/ObTableConnection.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,8 @@ private boolean connect() throws Exception {
119119

120120
if (tries >= maxTryTimes) {
121121
if (!obTable.isOdpMode()) {
122-
RouteTableRefresher.SuspectObServer suspectAddr = new RouteTableRefresher.SuspectObServer(obTable.getObServerAddr());
122+
RouteTableRefresher.SuspectObServer suspectAddr = new RouteTableRefresher.SuspectObServer(
123+
obTable.getObServerAddr());
123124
RouteTableRefresher.addIntoSuspectIPs(suspectAddr);
124125
}
125126
LOGGER.warn("connect failed after max " + maxTryTimes + " tries "

src/main/java/com/alipay/oceanbase/rpc/exception/ObTableSessionNotExistException.java

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,20 @@
1+
/*-
2+
* #%L
3+
* com.oceanbase:obkv-table-client
4+
* %%
5+
* Copyright (C) 2021 - 2025 OceanBase
6+
* %%
7+
* OBKV Table Client Framework is licensed under Mulan PSL v2.
8+
* You can use this software according to the terms and conditions of the Mulan PSL v2.
9+
* You may obtain a copy of Mulan PSL v2 at:
10+
* http://license.coscl.org.cn/MulanPSL2
11+
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
12+
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
13+
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
14+
* See the Mulan PSL v2 for more details.
15+
* #L%
16+
*/
17+
118
package com.alipay.oceanbase.rpc.exception;
219

320
public class ObTableSessionNotExistException extends ObTableException {

src/main/java/com/alipay/oceanbase/rpc/get/Get.java

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,21 +20,24 @@
2020
import com.alipay.oceanbase.rpc.ObTableClient;
2121
import com.alipay.oceanbase.rpc.mutation.ColumnValue;
2222
import com.alipay.oceanbase.rpc.mutation.Row;
23+
import com.alipay.oceanbase.rpc.protocol.payload.impl.execute.ObReadConsistency;
2324
import com.alipay.oceanbase.rpc.table.api.Table;
2425

2526
import java.util.Map;
2627

2728
public class Get {
28-
private Table client;
29-
private String tableName;
30-
protected Row rowKey;
31-
protected String[] selectColumns;
29+
private Table client = null;
30+
private String tableName = null;
31+
private Row rowKey = null;
32+
private String[] selectColumns = null;
33+
private ObReadConsistency readConsistency = null;
3234

3335
public Get() {
34-
tableName = null;
35-
client = null;
36-
rowKey = null;
37-
selectColumns = null;
36+
this.client = null;
37+
this.tableName = null;
38+
this.rowKey = null;
39+
this.selectColumns = null;
40+
this.readConsistency = null;
3841
}
3942

4043
public Get(Table client, String tableName) {
@@ -67,6 +70,15 @@ public Get select(String... columns) {
6770
return this;
6871
}
6972

73+
public Get setReadConsistency(ObReadConsistency readConsistency) {
74+
this.readConsistency = readConsistency;
75+
return this;
76+
}
77+
78+
public ObReadConsistency getReadConsistency() {
79+
return readConsistency;
80+
}
81+
7082
public String[] getSelectColumns() {
7183
return selectColumns;
7284
}
@@ -75,6 +87,6 @@ public Map<String, Object> execute() throws Exception {
7587
if (client == null) {
7688
throw new IllegalArgumentException("client is null");
7789
}
78-
return ((ObTableClient) client).get(tableName, rowKey, selectColumns);
90+
return ((ObTableClient) client).get(tableName, rowKey, selectColumns, readConsistency);
7991
}
8092
}

0 commit comments

Comments
 (0)