@@ -78,6 +78,7 @@ public class ObTable extends AbstractObTable implements Lifecycle {
7878
7979 private ReentrantLock statusLock = new ReentrantLock ();
8080 private AtomicBoolean valid = new AtomicBoolean (true );
81+ private boolean isOdpMode = false ; // default as false
8182
8283 /*
8384 * Init.
@@ -413,7 +414,7 @@ public ObTableOperationResult execute(String tableName, ObTableOperationType typ
413414 public ObPayload execute (final ObPayload request ) throws RemotingException ,
414415 InterruptedException {
415416
416- if (!isValid ()) {
417+ if (!isOdpMode && ! isValid ()) {
417418 log .debug ("The server is not available, server address: " + ip + ":" + port );
418419 throw new ObTableServerConnectException ("The server is not available, server address: " + ip + ":" + port );
419420 }
@@ -424,10 +425,16 @@ public ObPayload execute(final ObPayload request) throws RemotingException,
424425 connection .checkStatus ();
425426 } catch (ConnectException ex ) {
426427 // cannot connect to ob server, need refresh table location
427- setDirty ();
428+ // do not set odp ip and port as dirty
429+ if (!isOdpMode ) {
430+ setDirty ();
431+ }
428432 throw new ObTableServerConnectException (ex );
429433 } catch (ObTableServerConnectException ex ) {
430- setDirty ();
434+ // do not set odp ip and port as dirty
435+ if (!isOdpMode ) {
436+ setDirty ();
437+ }
431438 throw ex ;
432439 } catch (Exception ex ) {
433440 throw new ObTableConnectionStatusException ("check status failed, cause: " + ex .getMessage (), ex );
@@ -478,7 +485,7 @@ public ObPayload executeWithConnection(final ObPayload request,
478485 AtomicReference <ObTableConnection > connectionRef )
479486 throws RemotingException ,
480487 InterruptedException {
481- if (!isValid ()) {
488+ if (!isOdpMode && ! isValid ()) {
482489 log .debug ("The server is not available, server address: " + ip + ":" + port );
483490 throw new ObTableServerConnectException ("The server is not available, server address: " + ip + ":" + port );
484491 }
@@ -494,10 +501,16 @@ public ObPayload executeWithConnection(final ObPayload request,
494501 connection .checkStatus ();
495502 } catch (ConnectException ex ) {
496503 // Cannot connect to ob server, need refresh table location
497- setDirty ();
504+ // do not set odp ip and port as dirty
505+ if (!isOdpMode ) {
506+ setDirty ();
507+ }
498508 throw new ObTableServerConnectException (ex );
499509 } catch (ObTableServerConnectException ex ) {
500- setDirty ();
510+ // do not set odp ip and port as dirty
511+ if (!isOdpMode ) {
512+ setDirty ();
513+ }
501514 throw ex ;
502515 } catch (Exception ex ) {
503516 throw new ObTableConnectionStatusException ("check status failed, cause: " + ex .getMessage (), ex );
@@ -621,6 +634,10 @@ public void setDatabase(String database) {
621634 this .database = database ;
622635 }
623636
637+ public void setIsOdpMode (boolean isOdpMode ) {
638+ this .isOdpMode = isOdpMode ;
639+ }
640+
624641 public void setConfigs (Map <String , Object > configs ) {
625642 this .configs = configs ;
626643 }
@@ -705,11 +722,12 @@ public static class Builder {
705722 private String userName ;
706723 private String password ;
707724 private String database ;
708- ObTableClientType clientType ;
725+ ObTableClientType clientType ;
709726
710727 private Properties properties = new Properties ();
711728
712729 private Map <String , Object > tableConfigs = new HashMap <>();
730+ private boolean isOdpMode = false ; // default as false
713731
714732 /*
715733 * Builder.
@@ -753,6 +771,11 @@ public Builder setConfigs(Map<String, Object> tableConfigs) {
753771 return this ;
754772 }
755773
774+ public Builder setIsOdpMode (boolean isOdpMode ) {
775+ this .isOdpMode = isOdpMode ;
776+ return this ;
777+ }
778+
756779 /*
757780 * Build.
758781 */
@@ -767,6 +790,7 @@ public ObTable build() throws Exception {
767790 obTable .setProperties (properties );
768791 obTable .setConfigs (tableConfigs );
769792 obTable .setClientType (clientType );
793+ obTable .setIsOdpMode (isOdpMode );
770794
771795 obTable .init ();
772796
0 commit comments