Skip to content

Commit 9bad991

Browse files
committed
rebase secondary_part master
1 parent de08160 commit 9bad991

File tree

11 files changed

+44
-34
lines changed

11 files changed

+44
-34
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -364,7 +364,7 @@ private void initMetadata() throws Exception {
364364
// build tableRoster and ServerRoster
365365
TableEntryKey rootServerKey = new TableEntryKey(clusterName, tenantName,
366366
OCEANBASE_DATABASE, ALL_DUMMY_TABLE);
367-
tableRoute.initRoster(rootServerKey, initialized);
367+
tableRoute.initRoster(rootServerKey, initialized, runningMode);
368368
// create background refresh-checker task
369369
tableRoute.launchRouteRefresher();
370370
}
@@ -2705,7 +2705,7 @@ public enum RunningMode {
27052705
NORMAL, HBASE;
27062706
}
27072707

2708-
private ObTableClientType getClientType(RunningMode runningMode) {
2708+
public ObTableClientType getClientType(RunningMode runningMode) {
27092709
if (ObGlobal.isDistributedExecSupport()) {
27102710
return runningMode == RunningMode.HBASE ? ObTableClientType.JAVA_HBASE_CLIENT : ObTableClientType.JAVA_TABLE_CLIENT;
27112711
} else {

src/main/java/com/alipay/oceanbase/rpc/location/model/OdpInfo.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,11 @@ public void setPort(int port) {
4141
}
4242

4343
public void buildOdpTable(String tenantName, String fullUserName, String password,
44-
String database, Properties properties,
44+
String database, ObTableClientType clientType, Properties properties,
4545
Map<String, Object> tableConfigs) throws Exception {
4646
this.obTable = new ObTable.Builder(addr, port)
47-
.setLoginInfo(tenantName, fullUserName, password, database).setProperties(properties)
48-
.setConfigs(tableConfigs).build();
47+
.setLoginInfo(tenantName, fullUserName, password, database, clientType)
48+
.setProperties(properties).setConfigs(tableConfigs).build();
4949
}
5050

5151
public ObTable getObTable() {

src/main/java/com/alipay/oceanbase/rpc/location/model/TableRoster.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ public class TableRoster {
3535
private String database;
3636
private Properties properties = new Properties();
3737
private Map<String, Object> tableConfigs = new HashMap<>();
38+
private ObTableClientType clientType;
3839
/*
3940
* ServerAddr(all) -> ObTableConnection
4041
*/
@@ -55,6 +56,9 @@ public void setDatabase(String database) {
5556
public void setTables(ConcurrentHashMap<ObServerAddr, ObTable> tables) {
5657
this.tables = tables;
5758
}
59+
public void setClientType(ObTableClientType clientType) {
60+
this.clientType = clientType;
61+
}
5862
public void setProperties(Properties properties) {
5963
this.properties = properties;
6064
}
@@ -90,7 +94,7 @@ public List<ObServerAddr> refreshTablesAndGetNewServers(List<ReplicaLocation> ne
9094
}
9195

9296
ObTable obTable = new ObTable.Builder(addr.getIp(), addr.getSvrPort()) //
93-
.setLoginInfo(tenantName, userName, password, database) //
97+
.setLoginInfo(tenantName, userName, password, database, clientType) //
9498
.setProperties(properties).setConfigs(tableConfigs).build();
9599
ObTable oldObTable = tables.putIfAbsent(addr, obTable);
96100
logger.warn("add new table addr, {}", addr.toString());
@@ -141,12 +145,13 @@ public void closeRoster() throws ObTableCloseException {
141145
}
142146

143147
public static TableRoster getInstanceOf(String tenantName, String userName, String password, String database,
144-
Properties properties, Map<String, Object> tableConfigs) {
148+
ObTableClientType clientType, Properties properties, Map<String, Object> tableConfigs) {
145149
TableRoster tableRoster = new TableRoster();
146150
tableRoster.setTenantName(tenantName);
147151
tableRoster.setUserName(userName);
148152
tableRoster.setPassword(password);
149153
tableRoster.setDatabase(database);
154+
tableRoster.setClientType(clientType);
150155
tableRoster.setProperties(properties);
151156
tableRoster.setTableConfigs(tableConfigs);
152157
return tableRoster;

src/main/java/com/alipay/oceanbase/rpc/location/model/TableRoute.java

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
import com.alipay.oceanbase.rpc.protocol.payload.impl.execute.query.ObNewRange;
3030
import com.alipay.oceanbase.rpc.protocol.payload.impl.execute.query.ObTableQuery;
3131
import com.alipay.oceanbase.rpc.table.ObTable;
32+
import com.alipay.oceanbase.rpc.table.ObTableClientType;
3233
import com.alipay.oceanbase.rpc.table.ObTableParam;
3334
import com.alipay.oceanbase.rpc.table.ObTableServerCapacity;
3435
import com.alipay.oceanbase.rpc.util.StringUtil;
@@ -170,11 +171,12 @@ public ObTableServerCapacity getServerCapacity() {
170171
}
171172
}
172173

173-
public void buildOdpInfo(String odpAddr, int odpPort) throws Exception {
174+
public void buildOdpInfo(String odpAddr, int odpPort, ObTableClientType clientType)
175+
throws Exception {
174176
this.odpInfo = new OdpInfo(odpAddr, odpPort);
175177
this.odpInfo.buildOdpTable(tableClient.getTenantName(), tableClient.getFullUserName(),
176-
tableClient.getPassword(), tableClient.getDatabase(), tableClient.getProperties(),
177-
tableClient.getTableConfigs());
178+
tableClient.getPassword(), tableClient.getDatabase(), clientType,
179+
tableClient.getProperties(), tableClient.getTableConfigs());
178180
}
179181

180182
/**
@@ -193,7 +195,8 @@ public ConfigServerInfo loadConfigServerInfo() throws Exception {
193195
* tableRoster stores all observer connection belongs to the current tenant
194196
* serverRoster stores all observer address and LDC information for weak-reading
195197
* */
196-
public void initRoster(TableEntryKey rootServerKey, boolean initialized) throws Exception {
198+
public void initRoster(TableEntryKey rootServerKey, boolean initialized,
199+
ObTableClient.RunningMode runningMode) throws Exception {
197200
List<ObServerAddr> servers = new ArrayList<ObServerAddr>();
198201
ConcurrentHashMap<ObServerAddr, ObTable> addr2Table = new ConcurrentHashMap<ObServerAddr, ObTable>();
199202
List<ObServerAddr> rsList = configServerInfo.getRsList();
@@ -255,7 +258,8 @@ public void initRoster(TableEntryKey rootServerKey, boolean initialized) throws
255258
ObTable obTable = new ObTable.Builder(addr.getIp(), addr.getSvrPort())
256259
//
257260
.setLoginInfo(tableClient.getTenantName(), tableClient.getUserName(),
258-
tableClient.getPassword(), tableClient.getDatabase())
261+
tableClient.getPassword(), tableClient.getDatabase(),
262+
tableClient.getClientType(runningMode))
259263
//
260264
.setProperties(tableClient.getProperties())
261265
.setConfigs(tableClient.getTableConfigs()).build();
@@ -279,7 +283,8 @@ public void initRoster(TableEntryKey rootServerKey, boolean initialized) throws
279283
JSON.toJSON(servers));
280284
this.tableRoster = TableRoster.getInstanceOf(tableClient.getTenantName(),
281285
tableClient.getUserName(), tableClient.getPassword(), tableClient.getDatabase(),
282-
tableClient.getProperties(), tableClient.getTableConfigs());
286+
tableClient.getClientType(runningMode), tableClient.getProperties(),
287+
tableClient.getTableConfigs());
283288
this.tableRoster.setTables(addr2Table);
284289
this.serverRoster.reset(servers);
285290

src/main/java/com/alipay/oceanbase/rpc/mutation/BatchOperation.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -374,7 +374,7 @@ private void negateHbaseTimestamp(Mutation mutation) {
374374
if (rowKey == null || rowKey.size() != 3) {
375375
throw new IllegalArgumentException("hbase rowkey length must be 3");
376376
} else {
377-
long ts = (long)ObTableClient.getRowKeyValue(mutation, 2);
377+
long ts = (long) ObTableClient.getRowKeyValue(mutation, 2);
378378
ObTableClient.setRowKeyValue(mutation, 2, -ts);
379379
}
380380
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ public void setIsCheckAndExecute(boolean isCheckAndExecute) {
164164
public void setIsCheckNoExists(boolean isCheckNoExists) {
165165
queryAndMutateFlag.setIsCheckNotExists(isCheckNoExists);
166166
}
167-
167+
168168
public void setIsUserSpecifiedT(boolean isUserSpecifiedT) {
169169
queryAndMutateFlag.setIsUserSpecifiedT(isUserSpecifiedT);
170170
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
public class ObTableQueryAsyncRequest extends ObTableAbstractOperationRequest {
3939
private ObTableQueryRequest obTableQueryRequest;
4040
private long querySessionId;
41-
private ObQueryOperationType queryType = ObQueryOperationType.QUERY_START;
41+
private ObQueryOperationType queryType = ObQueryOperationType.QUERY_START;
4242

4343
private boolean allowDistributeScan = true;
4444

src/main/java/com/alipay/oceanbase/rpc/table/ObHBaseParams.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
public class ObHBaseParams extends ObKVParamsBase {
2626
int caching = -1; // limit the number of for each rpc call
2727
int callTimeout = -1; // scannerLeasePeriodTimeout in hbase, client rpc timeout
28-
boolean allowPartialResults = false; // whether allow partial row return or not
28+
boolean allowPartialResults = false; // whether allow partial row return or not
2929
boolean isCacheBlock = false; // whether enable server block cache and row cache or not
3030
boolean checkExistenceOnly = false; // check the existence only
3131
String hbaseVersion = "1.3.6";

src/main/java/com/alipay/oceanbase/rpc/table/ObTableClientLSBatchOpsImpl.java

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -233,22 +233,23 @@ public void addOperation(QueryAndMutate queryAndMutate) {
233233
ObTableQuery obTableQuery = queryAndMutate.getQuery();
234234
if (queryAndMutate.getMutation() instanceof Delete) {
235235
Delete delete = (Delete) queryAndMutate.getMutation();
236-
ObTableSingleOpQuery singleOpQuery = ObTableSingleOpQuery.getInstance(obTableQuery.getIndexName(),
237-
obTableQuery.getKeyRanges(), obTableQuery.getSelectColumns(),
238-
obTableQuery.getScanOrder(), obTableQuery.isHbaseQuery(),
239-
obTableQuery.gethTableFilter(), obTableQuery.getObKVParams(),
240-
obTableQuery.getFilterString());
236+
ObTableSingleOpQuery singleOpQuery = ObTableSingleOpQuery.getInstance(
237+
obTableQuery.getIndexName(), obTableQuery.getKeyRanges(),
238+
obTableQuery.getSelectColumns(), obTableQuery.getScanOrder(),
239+
obTableQuery.isHbaseQuery(), obTableQuery.gethTableFilter(),
240+
obTableQuery.getObKVParams(), obTableQuery.getFilterString());
241241
singleOp.setQuery(singleOpQuery);
242242
singleOp.setQuery(singleOpQuery);
243243
singleOp.setSingleOpType(ObTableOperationType.QUERY_AND_MUTATE);
244244
String[] rowKeyNames = delete.getRowKey().getColumns();
245245
Object[] rowKeyValues = delete.getRowKey().getValues();
246-
ObTableSingleOpEntity entity = ObTableSingleOpEntity.getInstance(rowKeyNames, rowKeyValues,
247-
null, null);
246+
ObTableSingleOpEntity entity = ObTableSingleOpEntity.getInstance(rowKeyNames,
247+
rowKeyValues, null, null);
248248
singleOp.addEntity(entity);
249249
addOperation(singleOp);
250250
} else {
251-
throw new ObTableException("invalid operation type " + queryAndMutate.getMutation().getOperationType());
251+
throw new ObTableException("invalid operation type "
252+
+ queryAndMutate.getMutation().getOperationType());
252253
}
253254
}
254255

@@ -400,8 +401,9 @@ private Row calculateRowKey(ObPair<Integer, ObTableSingleOp> operationPair) {
400401
List<String> rowKeyNames = operation.getRowKeyNames();
401402
int rowKeySize = rowKeyObject.size();
402403
if (rowKeySize != rowKeyNames.size()) {
403-
throw new ObTableUnexpectedException("the length of rowKey value and rowKey name of the No." +
404-
operationPair.getLeft() + " operation is not matched");
404+
throw new ObTableUnexpectedException(
405+
"the length of rowKey value and rowKey name of the No." + operationPair.getLeft()
406+
+ " operation is not matched");
405407
}
406408
for (int j = 0; j < rowKeySize; j++) {
407409
Object rowKeyObj = rowKeyObject.get(j).getValue();
@@ -820,8 +822,7 @@ private boolean shouldRetry(Throwable throwable) {
820822
}
821823

822824
private void executeWithRetries(ObTableSingleOpResult[] results,
823-
Map.Entry<Long, TabletOperationsMap> entry)
824-
throws Exception {
825+
Map.Entry<Long, TabletOperationsMap> entry) throws Exception {
825826

826827
int retryCount = 0;
827828
boolean success = false;
@@ -859,8 +860,8 @@ private void executeWithRetries(ObTableSingleOpResult[] results,
859860
}
860861
}
861862
if (!success) {
862-
errMsg = "Failed to execute operation after retrying " + retryCount + " times. Last error Msg:" +
863-
"[errCode="+ errCode +"] " + errMsg;
863+
errMsg = "Failed to execute operation after retrying " + retryCount
864+
+ " times. Last error Msg:" + "[errCode=" + errCode + "] " + errMsg;
864865
throw new ObTableUnexpectedException(errMsg);
865866
}
866867
}

src/main/java/com/alipay/oceanbase/rpc/table/ObTableClientQueryImpl.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ public class ObTableClientQueryImpl extends AbstractTableQueryImpl {
5050
private final ObTableClient obTableClient;
5151
private Map<Long, ObPair<Long, ObTableParam>> partitionObTables;
5252

53-
private Row rowKey; // only used by BatchOperation
53+
private Row rowKey; // only used by BatchOperation
5454

5555
private boolean allowDistributeScan = true;
5656

0 commit comments

Comments
 (0)