Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,11 @@ public void buildOdpTable(String tenantName, String fullUserName, String passwor

this.obTable = new ObTable.Builder(addr, port) //
.setLoginInfo(tenantName, fullUserName, password, database, ObTableClientType.JAVA_TABLE_CLIENT) //
.setProperties(properties).setConfigs(tableConfigs).build();
.setProperties(properties).setConfigs(tableConfigs).setIsOdpMode(true).build();
if (ObGlobal.isDistributedExecSupport() && runningMode == ObTableClient.RunningMode.HBASE) { // support distributed execute, login again
this.obTable = new ObTable.Builder(addr, port)
.setLoginInfo(tenantName, fullUserName, password, database, ObTableClientType.JAVA_HBASE_CLIENT)
.setProperties(properties).setConfigs(tableConfigs).build();
.setProperties(properties).setConfigs(tableConfigs).setIsOdpMode(true).build();
}
}

Expand Down
38 changes: 31 additions & 7 deletions src/main/java/com/alipay/oceanbase/rpc/table/ObTable.java
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ public class ObTable extends AbstractObTable implements Lifecycle {

private ReentrantLock statusLock = new ReentrantLock();
private AtomicBoolean valid = new AtomicBoolean(true);
private boolean isOdpMode = false; // default as false

/*
* Init.
Expand Down Expand Up @@ -413,7 +414,7 @@ public ObTableOperationResult execute(String tableName, ObTableOperationType typ
public ObPayload execute(final ObPayload request) throws RemotingException,
InterruptedException {

if (!isValid()) {
if (!isOdpMode && !isValid()) {
log.debug("The server is not available, server address: " + ip + ":" + port);
throw new ObTableServerConnectException("The server is not available, server address: " + ip + ":" + port);
}
Expand All @@ -424,10 +425,16 @@ public ObPayload execute(final ObPayload request) throws RemotingException,
connection.checkStatus();
} catch (ConnectException ex) {
// cannot connect to ob server, need refresh table location
setDirty();
// do not set odp ip and port as dirty
if (!isOdpMode) {
setDirty();
}
throw new ObTableServerConnectException(ex);
} catch (ObTableServerConnectException ex) {
setDirty();
// do not set odp ip and port as dirty
if (!isOdpMode) {
setDirty();
}
throw ex;
} catch (Exception ex) {
throw new ObTableConnectionStatusException("check status failed, cause: " + ex.getMessage(), ex);
Expand Down Expand Up @@ -478,7 +485,7 @@ public ObPayload executeWithConnection(final ObPayload request,
AtomicReference<ObTableConnection> connectionRef)
throws RemotingException,
InterruptedException {
if (!isValid()) {
if (!isOdpMode && !isValid()) {
log.debug("The server is not available, server address: " + ip + ":" + port);
throw new ObTableServerConnectException("The server is not available, server address: " + ip + ":" + port);
}
Expand All @@ -494,10 +501,16 @@ public ObPayload executeWithConnection(final ObPayload request,
connection.checkStatus();
} catch (ConnectException ex) {
// Cannot connect to ob server, need refresh table location
setDirty();
// do not set odp ip and port as dirty
if (!isOdpMode) {
setDirty();
}
throw new ObTableServerConnectException(ex);
} catch (ObTableServerConnectException ex) {
setDirty();
// do not set odp ip and port as dirty
if (!isOdpMode) {
setDirty();
}
throw ex;
} catch (Exception ex) {
throw new ObTableConnectionStatusException("check status failed, cause: " + ex.getMessage(), ex);
Expand Down Expand Up @@ -621,6 +634,10 @@ public void setDatabase(String database) {
this.database = database;
}

public void setIsOdpMode(boolean isOdpMode) {
this.isOdpMode = isOdpMode;
}

public void setConfigs(Map<String, Object> configs) {
this.configs = configs;
}
Expand Down Expand Up @@ -705,11 +722,12 @@ public static class Builder {
private String userName;
private String password;
private String database;
ObTableClientType clientType;
ObTableClientType clientType;

private Properties properties = new Properties();

private Map<String, Object> tableConfigs = new HashMap<>();
private boolean isOdpMode = false; // default as false

/*
* Builder.
Expand Down Expand Up @@ -753,6 +771,11 @@ public Builder setConfigs(Map<String, Object> tableConfigs) {
return this;
}

public Builder setIsOdpMode(boolean isOdpMode) {
this.isOdpMode = isOdpMode;
return this;
}

/*
* Build.
*/
Expand All @@ -767,6 +790,7 @@ public ObTable build() throws Exception {
obTable.setProperties(properties);
obTable.setConfigs(tableConfigs);
obTable.setClientType(clientType);
obTable.setIsOdpMode(isOdpMode);

obTable.init();

Expand Down