Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
86 commits
Select commit Hold shift + click to select a range
c692b0b
git reset to no test util commit
JackShi148 Aug 27, 2024
f78d0d3
add ObFetchPartitionMetaType in request, pass re-fetch meta
JackShi148 Aug 27, 2024
4bf91e3
pass all situations to get ODP partition meta
JackShi148 Aug 27, 2024
325e25a
fix LSBatch in HBase mode, pass getPartition self-testing
JackShi148 Aug 28, 2024
379a534
correct format
JackShi148 Aug 28, 2024
47e46a3
revert LSBatch negateHbaseTimestamp
JackShi148 Aug 28, 2024
56dab83
revert batch atomic change
JackShi148 Aug 28, 2024
7ba0c39
correct substr test
JackShi148 Aug 28, 2024
29f1623
Merge branch 'master' into get_partition_meta
JackShi148 Aug 29, 2024
23993f2
compatible with table master branch
JackShi148 Aug 29, 2024
9682063
update addScanRange test with partition
JackShi148 Aug 29, 2024
f71f0ff
update odp rpc lock timeout, add odp range query
JackShi148 Aug 29, 2024
3cfeaae
add odp refresh lock timeout into initProperties
JackShi148 Aug 30, 2024
ef65f99
remove getPartition with only row key values
JackShi148 Aug 30, 2024
d59d565
delete useless getStart and getEnd interface in Partition
JackShi148 Sep 9, 2024
d6b23cc
format code
JackShi148 Sep 13, 2024
babeabd
remove testing output
JackShi148 Sep 13, 2024
c946600
bugfix hbase mode using odp mode does not add row key; format code
JackShi148 Sep 18, 2024
c6ec777
add exception dealing in fetching odp partition meta
JackShi148 Sep 18, 2024
4d364e5
correct test case
JackShi148 Oct 14, 2024
b3bd4d8
do not calculate partition_id in ODP mode when using index
JackShi148 Oct 15, 2024
330d79c
do not calculate partition_id in ODP mode when using index query
JackShi148 Oct 15, 2024
38ee5c3
Merge remote-tracking branch 'myfork/get_partition_meta' into get_par…
JackShi148 Oct 15, 2024
db4038a
merge get_partition_meta into master
JackShi148 Oct 16, 2024
d8a831a
Merge remote-tracking branch 'refs/remotes/myfork/get_partition_meta'…
JackShi148 Oct 16, 2024
d40573e
fetch the latest partition information in ocp mode everytime using ge…
JackShi148 Oct 16, 2024
7ec185c
add refresh flag in getPartition to get latest table and partition in…
JackShi148 Oct 17, 2024
ecf8cc6
Optimize SQL for refreshing table location information
maochongxin Sep 19, 2024
a82d5d0
partical refresh
maochongxin Sep 24, 2024
6874323
Fix infinite loop caused by removed reference
maochongxin Oct 10, 2024
1d46a86
fix lsop retry fail
maochongxin Oct 14, 2024
8d60c55
Remove unnecessary comments and format code
maochongxin Oct 15, 2024
22eeb36
Fix frequent refresh lock failures due to short refresh interval
maochongxin Oct 18, 2024
73ef9aa
Fix frequent refresh lock failures due to short refresh interval
maochongxin Oct 18, 2024
a46e2b0
add result code -4723
maochongxin Oct 18, 2024
c487f6d
correct test; getPartition with rowKey do not need to add rowKey before
JackShi148 Oct 21, 2024
7134d32
correct test cases
JackShi148 Oct 21, 2024
4d277c9
fix batch in odp mode after merge
JackShi148 Oct 22, 2024
f7b3d01
bugfix query with part_id
JackShi148 Oct 23, 2024
fb03d26
fix review
maochongxin Oct 23, 2024
e5762f4
add -4138
maochongxin Oct 23, 2024
4c630ee
fix review: add ut for byteutil
maochongxin Oct 25, 2024
64926a4
fix lsop refresh location
maochongxin Oct 25, 2024
e5e8687
Merge pull request #204 from oceanbase/retry_batchops_merge_master
maochongxin Oct 25, 2024
c8e655a
fix: correct reverse-scan results affected by retry logic
maochongxin Oct 28, 2024
bec5329
Merge pull request #208 from oceanbase/fix-rescan-result-error
maochongxin Oct 28, 2024
43b39eb
set ODP mode retry number to 3
JackShi148 Oct 29, 2024
e184f61
revert retry time
JackShi148 Oct 30, 2024
a53ba60
feature: Optimize partial refresh and add retry for executeMutation/q…
maochongxin Nov 4, 2024
f56010d
opt for errorMsg when execute batch in the scene of table not exist
GroundWu Nov 5, 2024
6d00f65
fix ls batch errMsg
GroundWu Nov 5, 2024
af579af
update pom.xml
WeiXinChan Nov 5, 2024
9f96bbf
remove some unused dependencies in pom.xml
WeiXinChan Nov 5, 2024
07c37aa
fix 3.x null exception (#214)
miyuan-ljr Nov 5, 2024
e053056
Merge pull request #216 from WeiXinChan/pom
GroundWu Nov 5, 2024
6afeb69
[fix] add threshold for refresh table entry with location (#220)
maochongxin Nov 7, 2024
31027b7
Fix the issue where the tablet_id is incorrect when the partition tab…
stuBirdFly Nov 11, 2024
2bac7bb
[fix] 3.x compatible (#223)
miyuan-ljr Nov 11, 2024
142249c
[fix] test case stuck in await (#227)
miyuan-ljr Nov 12, 2024
5691945
partition=1 error fix
JackShi148 Nov 12, 2024
9a71482
merge master into get_partition_meta
JackShi148 Nov 12, 2024
cbaa84a
merge master
JackShi148 Nov 12, 2024
2f250d9
fix after merge and correct some test cases
JackShi148 Nov 12, 2024
ff955e0
fix getPartition after merge
JackShi148 Nov 12, 2024
678a618
add logic id into partition
JackShi148 Nov 12, 2024
dc0be4b
fix global index route refresh wrong when route need refresh (#228)
GroundWu Nov 12, 2024
684a44e
Fix global route refresh wrong (#231)
GroundWu Nov 14, 2024
8365ecd
revert ls batch, do not fetch odp partition meta in ls batch
JackShi148 Nov 19, 2024
121b970
[Chore] remove the use of sofa common log
shenyunlong Nov 20, 2024
d524ae3
modify version control for direct-load partition (#236)
medcll Nov 20, 2024
d0701b6
param (#221)
miyuan-ljr Nov 21, 2024
a13481f
Merge pull request #235 from oceanbase/remove_sofa_log
stuBirdFly Nov 21, 2024
cd42200
[fix] multi-cf retry table not exist (#229)
maochongxin Nov 21, 2024
14677e5
fix global index route wrong when need partial route refresh (#232)
GroundWu Nov 25, 2024
3171e0d
feature: hbase compatible 2.x (#242)
miyuan-ljr Nov 25, 2024
d82c7fb
everytime force new if flag is true
JackShi148 Nov 25, 2024
fe5f280
add comments
JackShi148 Nov 25, 2024
c77ac53
fix -5150 error and try to refresh route after relogin
GroundWu Nov 27, 2024
12a4582
merge obkv master
JackShi148 Nov 27, 2024
cba681a
fix getAllPartitionInternal
JackShi148 Nov 27, 2024
70ca8e1
Merge pull request #243 from GroundWu/fix_5150_unit_transfer
GroundWu Nov 27, 2024
c1b23e7
Merge remote-tracking branch 'obkv/master' into get_partition_meta
JackShi148 Nov 27, 2024
5a3bbe0
fix -5150 tenent not exists
JackShi148 Nov 27, 2024
8c1e9b8
merge master into get_partition_meta
JackShi148 Dec 5, 2024
0bd35bc
remove useless import
JackShi148 Dec 5, 2024
1d49ce5
revert global index test case
JackShi148 Dec 6, 2024
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
24 changes: 24 additions & 0 deletions src/main/java/com/alipay/oceanbase/rpc/ObClusterTableQuery.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@

package com.alipay.oceanbase.rpc;

import com.alipay.oceanbase.rpc.location.model.partition.Partition;
import com.alipay.oceanbase.rpc.mutation.Row;
import com.alipay.oceanbase.rpc.protocol.payload.impl.ObObj;
import com.alipay.oceanbase.rpc.protocol.payload.impl.execute.ObTableEntityType;
import com.alipay.oceanbase.rpc.protocol.payload.impl.execute.aggregation.ObTableAggregationType;
import com.alipay.oceanbase.rpc.protocol.payload.impl.execute.query.ObHTableFilter;
Expand Down Expand Up @@ -152,6 +154,28 @@ public TableQuery addScanRange(Object[] start, boolean startEquals, Object[] end
return this;
}

@Override
public TableQuery addScanRange(Object start, Object end) {
if (start instanceof Partition) {
Long startPartitionId = ((Partition) start).getPartitionId();
Long endPartitionId = ((Partition) end).getPartitionId();
if (!startPartitionId.equals(endPartitionId)) {
throw new IllegalArgumentException(
"The partition id must be the same for start and end partition in scan range");
}
Long startPartId = ((Partition) start).getPartId();
Long endPartId = ((Partition) end).getPartId();
if (!startPartId.equals(endPartId)) {
throw new IllegalArgumentException(
"The logic part id must be the same for start and end partition in scan range");
}
tableClientQuery.setPartId(startPartId);
start = ObObj.getMin();
end = ObObj.getMax();
}
return addScanRange(new Object[] { start }, true, new Object[] { end }, true);
}

/**
* Add scan range starts with.
*/
Expand Down
448 changes: 443 additions & 5 deletions src/main/java/com/alipay/oceanbase/rpc/ObTableClient.java

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import com.alipay.oceanbase.rpc.protocol.payload.Pcodes;
import com.alipay.oceanbase.rpc.protocol.payload.impl.direct_load.ObTableDirectLoadResult;
import com.alipay.oceanbase.rpc.protocol.payload.impl.execute.ObTableApiMove;
import com.alipay.oceanbase.rpc.protocol.payload.impl.execute.ObFetchPartitionMetaResult;
import com.alipay.oceanbase.rpc.protocol.payload.impl.execute.ObTableBatchOperationResult;
import com.alipay.oceanbase.rpc.protocol.payload.impl.execute.ObTableLSOpResult;
import com.alipay.oceanbase.rpc.protocol.payload.impl.execute.ObTableOperationResult;
Expand Down Expand Up @@ -106,6 +107,15 @@ public ObPayload newPayload(ObRpcPacketHeader header) {
return new ObTableLSOpResult();
}
}, //
OB_TABLE_API_PART_META_QUERY(Pcodes.OB_TABLE_API_PART_META_QUERY) {
/**
* New payload.
*/
@Override
public ObPayload newPayload(ObRpcPacketHeader header) {
return new ObFetchPartitionMetaResult();
}
}, //
OB_TABLE_API_MOVE(Pcodes.OB_TABLE_API_MOVE) {
/**
* New payload.
Expand Down Expand Up @@ -159,6 +169,8 @@ public static ObTablePacketCode valueOf(short value) {
return OB_TABLE_API_DIRECT_LOAD;
case Pcodes.OB_TABLE_API_LS_EXECUTE:
return OB_TABLE_API_LS_EXECUTE;
case Pcodes.OB_TABLE_API_PART_META_QUERY:
return OB_TABLE_API_PART_META_QUERY;
case Pcodes.OB_TABLE_API_MOVE:
return OB_TABLE_API_MOVE;
case Pcodes.OB_ERROR_PACKET:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ public ObPayload invokeSync(final ObTableConnection conn, final ObPayload reques
ObRpcResultCode resultCode = new ObRpcResultCode();
resultCode.decode(buf);
// If response indicates the request is routed to wrong server, we should refresh the routing meta.
if (!conn.getObTable().getReRouting() &&response.getHeader().isRoutingWrong()) {
if (!conn.getObTable().isEnableRerouting() && response.getHeader().isRoutingWrong()) {
String errMessage = TraceUtil.formatTraceMessage(conn, request,
"routed to the wrong server: " + response.getMessage());
logger.warn(errMessage);
Expand All @@ -139,7 +139,8 @@ public ObPayload invokeSync(final ObTableConnection conn, final ObPayload reques
throw new ObTableNeedFetchAllException(errMessage, resultCode.getRcode());
}
}
if (resultCode.getRcode() != 0 && response.getHeader().getPcode() != Pcodes.OB_TABLE_API_MOVE) {
if (resultCode.getRcode() != 0
&& response.getHeader().getPcode() != Pcodes.OB_TABLE_API_MOVE) {
String errMessage = TraceUtil.formatTraceMessage(conn, request,
"routed to the wrong server: " + response.getMessage());
logger.warn(errMessage);
Expand Down Expand Up @@ -193,23 +194,25 @@ private boolean needFetchAll(int errorCode, int pcode) {
|| errorCode == ResultCodes.OB_TABLE_NOT_EXIST.errorCode
|| errorCode == ResultCodes.OB_TABLET_NOT_EXIST.errorCode
|| errorCode == ResultCodes.OB_LS_NOT_EXIST.errorCode
|| errorCode == ResultCodes.OB_MAPPING_BETWEEN_TABLET_AND_LS_NOT_EXIST.errorCode
|| errorCode == ResultCodes.OB_SNAPSHOT_DISCARDED.errorCode
|| (pcode == Pcodes.OB_TABLE_API_LS_EXECUTE && errorCode == ResultCodes.OB_NOT_MASTER.errorCode);
}

private boolean needFetchPartial(int errorCode) {
return errorCode == ResultCodes.OB_LOCATION_LEADER_NOT_EXIST.errorCode
|| errorCode == ResultCodes.OB_NOT_MASTER.errorCode
|| errorCode == ResultCodes.OB_RS_NOT_MASTER.errorCode
|| errorCode == ResultCodes.OB_RS_SHUTDOWN.errorCode
|| errorCode == ResultCodes.OB_RPC_SEND_ERROR.errorCode
|| errorCode == ResultCodes.OB_RPC_POST_ERROR.errorCode
|| errorCode == ResultCodes.OB_PARTITION_NOT_EXIST.errorCode
|| errorCode == ResultCodes.OB_LOCATION_NOT_EXIST.errorCode
|| errorCode == ResultCodes.OB_PARTITION_IS_STOPPED.errorCode
|| errorCode == ResultCodes.OB_PARTITION_IS_BLOCKED.errorCode
|| errorCode == ResultCodes.OB_SERVER_IS_INIT.errorCode
|| errorCode == ResultCodes.OB_SERVER_IS_STOPPING.errorCode
|| errorCode == ResultCodes.OB_TRANS_RPC_TIMEOUT.errorCode
|| errorCode == ResultCodes.OB_NO_READABLE_REPLICA.errorCode;
|| errorCode == ResultCodes.OB_NOT_MASTER.errorCode
|| errorCode == ResultCodes.OB_RS_NOT_MASTER.errorCode
|| errorCode == ResultCodes.OB_RS_SHUTDOWN.errorCode
|| errorCode == ResultCodes.OB_RPC_SEND_ERROR.errorCode
|| errorCode == ResultCodes.OB_RPC_POST_ERROR.errorCode
|| errorCode == ResultCodes.OB_PARTITION_NOT_EXIST.errorCode
|| errorCode == ResultCodes.OB_LOCATION_NOT_EXIST.errorCode
|| errorCode == ResultCodes.OB_PARTITION_IS_STOPPED.errorCode
|| errorCode == ResultCodes.OB_PARTITION_IS_BLOCKED.errorCode
|| errorCode == ResultCodes.OB_SERVER_IS_INIT.errorCode
|| errorCode == ResultCodes.OB_SERVER_IS_STOPPING.errorCode
|| errorCode == ResultCodes.OB_TRANS_RPC_TIMEOUT.errorCode
|| errorCode == ResultCodes.OB_NO_READABLE_REPLICA.errorCode;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,11 @@ public static ObTableException convertToObTableException(String host, int port,
+ "]" + "[" + resultCodes.name() + "]"
+ "[" + errMsg + "]" + "[" + server + "]"
+ "[" + trace + "]", resultCodes.errorCode);
} else if (resultCodes.errorCode == OB_ERR_KV_ROUTE_ENTRY_EXPIRE.errorCode) {
return new ObTablePartitionChangeException("[" + String.valueOf(resultCodes.errorCode)
+ "]" + "[" + resultCodes.name() + "]" + "["
+ errMsg + "]" + "[" + server + "]" + "["
+ trace + "]", resultCodes.errorCode);
} else {
// [errCode][errCodeName][errMsg][server][trace]
return new ObTableException("[" + String.valueOf(resultCodes.errorCode) + "]" + "["
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
import com.alibaba.fastjson.JSONException;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.parser.ParserConfig;
import com.alipay.oceanbase.rpc.ObClusterTableBatchOps;
import com.alipay.oceanbase.rpc.ObGlobal;
import com.alipay.oceanbase.rpc.constant.Constants;
import com.alipay.oceanbase.rpc.exception.*;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,10 @@
import com.alipay.oceanbase.rpc.location.model.partition.ObPartitionLevel;
import com.alipay.oceanbase.rpc.protocol.payload.Constants;

import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.locks.Lock;

import static com.google.common.base.Preconditions.checkArgument;

Expand All @@ -46,14 +47,17 @@ public class TableEntry {
private ObPartitionInfo partitionInfo = null;
private volatile long refreshTimeMills;
private volatile long refreshAllTimeMills;
private volatile long odpRefreshTimeMills;
private Map<String, Integer> rowKeyElement = null;

// table location
private TableLocation tableLocation = null;
// partition location
private TableEntryKey tableEntryKey = null;
private volatile ObPartitionEntry partitionEntry = null;


public ConcurrentHashMap<Long, Lock> refreshLockMap = new ConcurrentHashMap<>();

/*
* Is valid.
*/
Expand Down Expand Up @@ -156,6 +160,10 @@ public long getRefreshAllTimeMills() {
return refreshAllTimeMills;
}

public long getOdpRefreshTimeMills() {
return odpRefreshTimeMills;
}

/*
* Set refresh time mills.
*/
Expand All @@ -170,6 +178,10 @@ public void setRefreshAllTimeMills(long refreshAllTimeMills) {
this.refreshAllTimeMills = refreshAllTimeMills;
}

public void setOdpRefreshTimeMills(long odpRefreshTimeMills) {
this.odpRefreshTimeMills = odpRefreshTimeMills;
}

public Map<String, Integer> getRowKeyElement() {
return rowKeyElement;
}
Expand Down Expand Up @@ -220,8 +232,6 @@ public void prepare() throws IllegalArgumentException {
checkArgument(partitionInfo != null, "partition table partition info is not ready. key"
+ tableEntryKey);
partitionInfo.prepare();
checkArgument(partitionEntry != null,
"partition table partition entry is not ready. key" + tableEntryKey);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import com.alipay.oceanbase.rpc.protocol.payload.impl.ObObj;
import com.alipay.oceanbase.rpc.protocol.payload.impl.ObObjType;
import com.alipay.oceanbase.rpc.util.RandomUtil;
import com.alipay.oceanbase.rpc.util.Serialization;
import com.alipay.oceanbase.rpc.util.TableClientLoggerFactory;
import com.alipay.oceanbase.rpc.mutation.Row;
import org.apache.commons.lang.builder.ToStringBuilder;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import com.alipay.oceanbase.rpc.protocol.payload.impl.ObColumn;
import com.alipay.oceanbase.rpc.protocol.payload.impl.ObObj;
import com.alipay.oceanbase.rpc.util.ObHashUtils;
import com.alipay.oceanbase.rpc.util.Serialization;
import com.alipay.oceanbase.rpc.util.TableClientLoggerFactory;
import org.apache.commons.lang.builder.ToStringBuilder;
import org.slf4j.Logger;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,23 @@

import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;


public class ObPartitionEntry {
private Map<Long, ObPartitionLocation> partitionLocation = new HashMap<Long, ObPartitionLocation>();

// mapping from tablet id to ls id, and the part id to tablet id mapping is in ObPartitionInfo
private Map<Long, Long> tabletLsIdMap = new HashMap<>();

// tabelt id -> (PartitionLocation, LsId)
private ConcurrentHashMap<Long, ObPartitionLocationInfo> partitionInfos = new ConcurrentHashMap<>();


public ObPartitionLocationInfo getPartitionInfo(long tabletId) {
return partitionInfos.computeIfAbsent(tabletId, id -> new ObPartitionLocationInfo());
}

public Map<Long, ObPartitionLocation> getPartitionLocation() {
return partitionLocation;
}
Expand All @@ -39,6 +49,16 @@ public void setPartitionLocation(Map<Long, ObPartitionLocation> partitionLocatio
this.partitionLocation = partitionLocation;
}

public Map<Long, Long> getTabletLsIdMap() {
return tabletLsIdMap;
}

public void setTabletLsIdMap(Map<Long, Long> tabletLsIdMap) {
this.tabletLsIdMap = tabletLsIdMap;
}

public long getLsId(long tabletId) { return tabletLsIdMap.get(tabletId); }

/*
* Get partition location with part id.
*/
Expand Down Expand Up @@ -86,14 +106,4 @@ public void prepareForWeakRead(ObServerLdcLocation ldcLocation) {
public String toString() {
return "ObPartitionEntry{" + "partitionLocation=" + partitionLocation + '}';
}

public Map<Long, Long> getTabletLsIdMap() {
return tabletLsIdMap;
}

public void setTabletLsIdMap(Map<Long, Long> tabletLsIdMap) {
this.tabletLsIdMap = tabletLsIdMap;
}

public long getLsId(long tabletId) { return tabletLsIdMap.get(tabletId); }
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
package com.alipay.oceanbase.rpc.location.model.partition;

import com.alipay.oceanbase.rpc.protocol.payload.impl.ObColumn;
import com.alipay.oceanbase.rpc.util.Serialization;

import java.util.ArrayList;
import java.util.List;
Expand All @@ -30,7 +31,7 @@ public class ObPartitionInfo {
private ObPartDesc firstPartDesc = null;
private ObPartDesc subPartDesc = null;
private List<ObColumn> partColumns = new ArrayList<ObColumn>(1);
// mapping from part id to tablet id, and the tablet id to ls id mapping is in ObPartitionInfo
// mapping from part id to tablet id, and the tablet id to ls id mapping is in ObPartitionEntry
private Map<Long, Long> partTabletIdMap = null;
private Map<String, Long> partNameIdMap = null;
private Map<String, Integer> rowKeyElement = null;
Expand Down Expand Up @@ -163,4 +164,5 @@ public Map<Long, Long> getPartTabletIdMap() {
public void setPartTabletIdMap(Map<Long, Long> partTabletIdMap) {
this.partTabletIdMap = partTabletIdMap;
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
/*-
* #%L
* com.oceanbase:obkv-table-client
* %%
* Copyright (C) 2021 - 2024 OceanBase
* %%
* OBKV Table Client Framework is licensed under Mulan PSL v2.
* You can use this software according to the terms and conditions of the Mulan PSL v2.
* You may obtain a copy of Mulan PSL v2 at:
* http://license.coscl.org.cn/MulanPSL2
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
* See the Mulan PSL v2 for more details.
* #L%
*/

package com.alipay.oceanbase.rpc.location.model.partition;

import java.util.concurrent.CountDownLatch;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.locks.ReentrantReadWriteLock;

import static com.alipay.oceanbase.rpc.protocol.payload.Constants.OB_INVALID_ID;

public class ObPartitionLocationInfo {
private ObPartitionLocation partitionLocation = null;
private Long tabletLsId = OB_INVALID_ID;
private Long lastUpdateTime = 0L;
public ReentrantReadWriteLock rwLock = new ReentrantReadWriteLock();
public AtomicBoolean initialized = new AtomicBoolean(false);
public final CountDownLatch initializationLatch = new CountDownLatch(1);

public ObPartitionLocation getPartitionLocation() {
rwLock.readLock().lock();
try {
return partitionLocation;
} finally {
rwLock.readLock().unlock();
}
}

public void updateLocation(ObPartitionLocation newLocation, Long tabletLsId) {
rwLock.writeLock().lock();
try {
this.partitionLocation = newLocation;
this.tabletLsId = tabletLsId;
this.lastUpdateTime = System.currentTimeMillis();
} finally {
rwLock.writeLock().unlock();
}
}

public Long getTabletLsId() {
rwLock.readLock().lock();
try {
return tabletLsId;
} finally {
rwLock.readLock().unlock();
}
}

public Long getLastUpdateTime() {
rwLock.readLock().lock();
try {
return lastUpdateTime;
} finally {
rwLock.readLock().unlock();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import com.alipay.oceanbase.rpc.protocol.payload.impl.column.ObGeneratedColumn;
import com.alipay.oceanbase.rpc.protocol.payload.impl.column.ObSimpleColumn;
import com.alipay.oceanbase.rpc.util.RandomUtil;
import com.alipay.oceanbase.rpc.util.Serialization;
import com.alipay.oceanbase.rpc.util.TableClientLoggerFactory;
import org.apache.commons.lang.builder.ToStringBuilder;
import org.slf4j.Logger;
Expand Down
Loading
Loading