Skip to content

Commit f78d0d3

Browse files
committed
add ObFetchPartitionMetaType in request, pass re-fetch meta
1 parent c692b0b commit f78d0d3

File tree

3 files changed

+58
-8
lines changed

3 files changed

+58
-8
lines changed

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2955,7 +2955,8 @@ private TableEntry getOrFetchODPPartitionMeta(String tableName, boolean needRene
29552955
do {
29562956
try {
29572957
ObFetchPartitionMetaRequest request = ObFetchPartitionMetaRequest.getInstance(
2958-
tableName, clusterName, tenantName, database, forceRenew,
2958+
ObFetchPartitionMetaType.GET_PARTITION_META.getIndex(),
2959+
tableName, clusterName, tenantName, database, forceRenew,
29592960
odpTable.getObTableOperationTimeout()); // TODO: timeout setting need to be verified
29602961
ObPayload result = odpTable.execute(request);
29612962
checkObFetchPartitionMetaResult(lastOdpRefreshTimeMills, request, result);

src/main/java/com/alipay/oceanbase/rpc/protocol/payload/impl/execute/ObFetchPartitionMetaRequest.java

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@
3030
* header_,
3131
* private String credential_,
3232
* private String tableName_,
33-
* private long createTime_,
3433
* private String clusterName_,
3534
* private String tenantName_,
3635
* private String databaseName_,
@@ -39,7 +38,7 @@
3938
*
4039
*/
4140
public class ObFetchPartitionMetaRequest extends AbstractPayload implements Credentialable {
42-
private long createTime = System.currentTimeMillis();
41+
private ObFetchPartitionMetaType obFetchPartitionMetaType;
4342
private ObBytesString credential;
4443
private String tableName;
4544
private String clusterName;
@@ -52,8 +51,12 @@ public int getPcode() {
5251
return Pcodes.OB_TABLE_API_PART_META_QUERY;
5352
}
5453

55-
public long getCreateTime() {
56-
return this.createTime;
54+
public void setObFetchPartitionMetaType(ObFetchPartitionMetaType type) {
55+
this.obFetchPartitionMetaType = type;
56+
}
57+
58+
public void setObFetchPartitionMetaType(int index) {
59+
this.obFetchPartitionMetaType = ObFetchPartitionMetaType.valueOf(index);
5760
}
5861

5962
public void setClusterName(String clusterName) {
@@ -95,6 +98,11 @@ public byte[] encode() {
9598
// ver + plen + payload
9699
idx = encodeHeader(bytes, idx);
97100

101+
// encode type
102+
int len = Serialization.getNeedBytes(obFetchPartitionMetaType.getIndex());
103+
System.arraycopy(Serialization.encodeVi32(obFetchPartitionMetaType.getIndex()), 0, bytes, idx, len);
104+
idx += len;
105+
98106
// encode credential
99107
idx = encodeCredential(bytes, idx);
100108

@@ -119,7 +127,7 @@ public byte[] encode() {
119127
idx += strbytes.length;
120128

121129
// encode force_renew for ODP route
122-
System.arraycopy(Serialization.encodeI8(forceRenew ? (byte) 1 : (byte) 0), 0, bytes, idx, 1);
130+
System.arraycopy(Serialization.encodeI8(forceRenew ? ((byte) 1) : ((byte) 0)), 0, bytes, idx, 1);
123131

124132
return bytes;
125133
}
@@ -140,7 +148,8 @@ public Object decode(ByteBuf buf) {
140148

141149
@Override
142150
public long getPayloadContentSize() {
143-
return Serialization.getNeedBytes(credential)
151+
return Serialization.getNeedBytes(obFetchPartitionMetaType.getIndex())
152+
+ Serialization.getNeedBytes(credential)
144153
+ Serialization.getNeedBytes(tableName)
145154
+ Serialization.getNeedBytes(clusterName)
146155
+ Serialization.getNeedBytes(tenantName)
@@ -154,10 +163,11 @@ private int encodeCredential(byte[] bytes, int idx) {
154163
return idx;
155164
}
156165

157-
public static ObFetchPartitionMetaRequest getInstance(String tableName, String clusterName,
166+
public static ObFetchPartitionMetaRequest getInstance(int typeIdx, String tableName, String clusterName,
158167
String tenantName, String databaseName,
159168
boolean forceRenew, long timeout) {
160169
ObFetchPartitionMetaRequest request = new ObFetchPartitionMetaRequest();
170+
request.setObFetchPartitionMetaType(typeIdx);
161171
request.setTableName(tableName);
162172
if (clusterName == null) {
163173
clusterName = "";
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
package com.alipay.oceanbase.rpc.protocol.payload.impl.execute;
2+
3+
public enum ObFetchPartitionMetaType {
4+
GET_PARTITION_META("GET_PARTITION_META", 0), INVALID("INVALID", 1);
5+
6+
private final String name;
7+
private final int index;
8+
9+
ObFetchPartitionMetaType(String name, int index) {
10+
this.name = name;
11+
this.index = index;
12+
}
13+
14+
/*
15+
* Value of.
16+
*/
17+
public static ObFetchPartitionMetaType valueOf(int index) {
18+
if (GET_PARTITION_META.index == index) {
19+
return GET_PARTITION_META;
20+
} else {
21+
return INVALID;
22+
}
23+
}
24+
25+
/*
26+
* Get index.
27+
*/
28+
public int getIndex() {
29+
return index;
30+
}
31+
32+
/*
33+
* Get name.
34+
*/
35+
public String getName() {
36+
return name;
37+
}
38+
39+
}

0 commit comments

Comments
 (0)