Skip to content

Commit 545948a

Browse files
IHEIIchenweixin.cwx
authored andcommitted
[Feat] Support 4.x observer
Link: https://code.alibaba-inc.com/oceanbase/obkv-table-client-java/codereview/12086430 * [Feat] Support 4.x observer * [Fix] fix comments
1 parent 937b2d3 commit 545948a

Some content is hidden

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

42 files changed

+1007
-409
lines changed

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
import com.alipay.oceanbase.rpc.table.AbstractTableQuery;
2828
import com.alipay.oceanbase.rpc.table.ObTable;
2929
import com.alipay.oceanbase.rpc.table.ObTableClientQueryAsyncImpl;
30+
import com.alipay.oceanbase.rpc.table.ObTableParam;
3031
import com.alipay.oceanbase.rpc.table.api.TableQuery;
3132

3233
public class ObClusterTableAsyncQuery extends AbstractTableQuery {
@@ -52,12 +53,12 @@ public QueryResultSet execute() throws Exception {
5253
}
5354

5455
@Override
55-
public QueryResultSet executeInit(ObPair<Long, ObTable> entry) throws Exception {
56+
public QueryResultSet executeInit(ObPair<Long, ObTableParam> entry) throws Exception {
5657
return tableClientQuerySync.executeInit(entry);
5758
}
5859

5960
@Override
60-
public QueryResultSet executeNext(ObPair<Long, ObTable> entry) throws Exception {
61+
public QueryResultSet executeNext(ObPair<Long, ObTableParam> entry) throws Exception {
6162
return tableClientQuerySync.executeNext(entry);
6263
}
6364

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
import com.alipay.oceanbase.rpc.table.AbstractTableQuery;
2828
import com.alipay.oceanbase.rpc.table.ObTable;
2929
import com.alipay.oceanbase.rpc.table.ObTableClientQueryImpl;
30+
import com.alipay.oceanbase.rpc.table.ObTableParam;
3031
import com.alipay.oceanbase.rpc.table.api.TableQuery;
3132

3233
import java.util.List;
@@ -78,12 +79,12 @@ public QueryResultSet execute() throws Exception {
7879
}
7980

8081
@Override
81-
public QueryResultSet executeInit(ObPair<Long, ObTable> entry) throws Exception {
82+
public QueryResultSet executeInit(ObPair<Long, ObTableParam> entry) throws Exception {
8283
throw new IllegalArgumentException("not support executeInit");
8384
}
8485

8586
@Override
86-
public QueryResultSet executeNext(ObPair<Long, ObTable> entry) throws Exception {
87+
public QueryResultSet executeNext(ObPair<Long, ObTableParam> entry) throws Exception {
8788
throw new IllegalArgumentException("not support executeNext");
8889
}
8990

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
/*-
2+
* #%L
3+
* OBKV Table Client Framework
4+
* %%
5+
* Copyright (C) 2021 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+
18+
package com.alipay.oceanbase.rpc;
19+
20+
public class ObGlobal {
21+
public static long OB_VERSION = 0;
22+
}

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

Lines changed: 171 additions & 123 deletions
Large diffs are not rendered by default.

src/main/java/com/alipay/oceanbase/rpc/batch/QueryByBatch.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
import com.alipay.oceanbase.rpc.protocol.payload.impl.execute.query.ObTableQuery;
2727
import com.alipay.oceanbase.rpc.stream.QueryResultSet;
2828
import com.alipay.oceanbase.rpc.table.ObTable;
29+
import com.alipay.oceanbase.rpc.table.ObTableParam;
2930
import com.alipay.oceanbase.rpc.table.api.TableQuery;
3031
import java.util.Arrays;
3132
import java.util.HashSet;
@@ -69,12 +70,12 @@ public QueryResultSet execute() {
6970
}
7071

7172
@Override
72-
public QueryResultSet executeInit(ObPair<Long, ObTable> entry) throws Exception {
73+
public QueryResultSet executeInit(ObPair<Long, ObTableParam> entry) throws Exception {
7374
throw new IllegalArgumentException("not support executeInit");
7475
}
7576

7677
@Override
77-
public QueryResultSet executeNext(ObPair<Long, ObTable> entry) throws Exception {
78+
public QueryResultSet executeNext(ObPair<Long, ObTableParam> entry) throws Exception {
7879
throw new IllegalArgumentException("not support executeNext");
7980
}
8081

src/main/java/com/alipay/oceanbase/rpc/constant/Constants.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,4 +32,5 @@ public interface Constants {
3232
String OB_ROUTE_POLICY = "ob_route_policy";
3333
String OCP_ROOT_SERVICE_ACTION = "ObRootServiceInfo";
3434
String OCP_IDC_REGION_ACTION = "ObIDCRegionInfo";
35+
Long INVALID_TABLET_ID = 0L;
3536
}

src/main/java/com/alipay/oceanbase/rpc/location/LocationUtil.java

Lines changed: 368 additions & 114 deletions
Large diffs are not rendered by default.

src/main/java/com/alipay/oceanbase/rpc/location/model/partition/ObPartFuncType.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ public boolean isHashPart() {
127127
*/
128128
public boolean isKeyPart() {
129129
return this.index == KEY_IMPLICIT.getIndex() || this.index == KEY_V2.getIndex()
130-
|| this.index == KEY_V3.getIndex();
130+
|| this.index == KEY_V3.getIndex() || this.index == KEY.getIndex();
131131
}
132132

133133
/*

src/main/java/com/alipay/oceanbase/rpc/location/model/partition/ObPartitionEntry.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,21 @@ public ObPartitionLocation putPartitionLocationWithPartId(long partId,
5151
return partitionLocation.put(partId, ObpartitionLocation);
5252
}
5353

54+
/*
55+
* Get partition location with tablet id.
56+
*/
57+
public ObPartitionLocation getPartitionLocationWithTabletId(long tabletId) {
58+
return partitionLocation.get(tabletId);
59+
}
60+
61+
/*
62+
* Put partition location with part id.
63+
*/
64+
public ObPartitionLocation putPartitionLocationWithTabletId(long tabletId,
65+
ObPartitionLocation ObpartitionLocation) {
66+
return partitionLocation.put(tabletId, ObpartitionLocation);
67+
}
68+
5469
/*
5570
* Prepare for weak read.
5671
* @param ldcLocation

src/main/java/com/alipay/oceanbase/rpc/location/model/partition/ObPartitionInfo.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ public class ObPartitionInfo {
3030
private ObPartDesc firstPartDesc = null;
3131
private ObPartDesc subPartDesc = null;
3232
private List<ObColumn> partColumns = new ArrayList<ObColumn>(1);
33+
private Map<Long, Long> partTabletIdMap = null;
3334
private Map<String, Long> partNameIdMap = null;
3435
private Map<String, Integer> rowKeyElement = null;
3536

@@ -150,4 +151,15 @@ public Map<String, Long> getPartNameIdMap() {
150151
public void setPartNameIdMap(Map<String, Long> partNameIdMap) {
151152
this.partNameIdMap = partNameIdMap;
152153
}
154+
155+
public Map<Long, Long> getPartTabletIdMap() {
156+
return this.partTabletIdMap;
157+
}
158+
159+
/*
160+
* Set part tablet id map.
161+
*/
162+
public void setPartTabletIdMap(Map<Long, Long> partTabletIdMap) {
163+
this.partTabletIdMap = partTabletIdMap;
164+
}
153165
}

0 commit comments

Comments
 (0)