@@ -117,6 +117,8 @@ public int getVersion() {
117117
118118 @ Override
119119 protected void onBeforeRequest () throws IOException {
120+ waitNodeIsOnline ();
121+
120122 connection = OClientConnectionManager .instance ().getConnection (clientTxId );
121123
122124 if (clientTxId < 0 ) {
@@ -513,7 +515,8 @@ protected ODatabaseComplex<?> openDatabase(final ODatabaseComplex<?> database, f
513515 protected void addDataSegment () throws IOException {
514516 setDataCommandInfo ("Add data segment" );
515517
516- checkDatabase ();
518+ if (!isConnectionAlive ())
519+ return ;
517520
518521 final String name = channel .readString ();
519522 final String location = channel .readString ();
@@ -532,7 +535,8 @@ protected void addDataSegment() throws IOException {
532535 protected void dropDataSegment () throws IOException {
533536 setDataCommandInfo ("Drop data segment" );
534537
535- checkDatabase ();
538+ if (!isConnectionAlive ())
539+ return ;
536540
537541 final String name = channel .readString ();
538542
@@ -550,7 +554,8 @@ protected void dropDataSegment() throws IOException {
550554 protected void removeCluster () throws IOException {
551555 setDataCommandInfo ("Remove cluster" );
552556
553- checkDatabase ();
557+ if (!isConnectionAlive ())
558+ return ;
554559
555560 final int id = channel .readShort ();
556561
@@ -573,7 +578,8 @@ protected void removeCluster() throws IOException {
573578 protected void addCluster () throws IOException {
574579 setDataCommandInfo ("Add cluster" );
575580
576- checkDatabase ();
581+ if (!isConnectionAlive ())
582+ return ;
577583
578584 final String type = channel .readString ();
579585 final String name = channel .readString ();
@@ -608,7 +614,8 @@ protected void addCluster() throws IOException {
608614 protected void rangeCluster () throws IOException {
609615 setDataCommandInfo ("Get the begin/end range of data in cluster" );
610616
611- checkDatabase ();
617+ if (!isConnectionAlive ())
618+ return ;
612619
613620 OClusterPosition [] pos = connection .database .getStorage ().getClusterDataRange (channel .readShort ());
614621
@@ -625,7 +632,8 @@ protected void rangeCluster() throws IOException {
625632 protected void isLHClustersAreUsed () throws IOException {
626633 setDataCommandInfo ("Determinate whether clusters are presented as persistent list or hash map " );
627634
628- checkDatabase ();
635+ if (!isConnectionAlive ())
636+ return ;
629637
630638 final boolean isLHClustersAreUsed = connection .database .getStorage ().isHashClustersAreUsed ();
631639
@@ -641,7 +649,8 @@ protected void isLHClustersAreUsed() throws IOException {
641649 protected void countClusters () throws IOException {
642650 setDataCommandInfo ("Count cluster elements" );
643651
644- checkDatabase ();
652+ if (!isConnectionAlive ())
653+ return ;
645654
646655 int [] clusterIds = new int [channel .readShort ()];
647656 for (int i = 0 ; i < clusterIds .length ; ++i )
@@ -665,7 +674,8 @@ protected void countClusters() throws IOException {
665674 protected void reloadDatabase () throws IOException {
666675 setDataCommandInfo ("Reload database information" );
667676
668- checkDatabase ();
677+ if (!isConnectionAlive ())
678+ return ;
669679
670680 beginResponse ();
671681 try {
@@ -866,7 +876,8 @@ protected void distributedCluster() throws IOException {
866876 protected void countDatabaseRecords () throws IOException {
867877 setDataCommandInfo ("Database count records" );
868878
869- checkDatabase ();
879+ if (!isConnectionAlive ())
880+ return ;
870881
871882 beginResponse ();
872883 try {
@@ -880,7 +891,8 @@ protected void countDatabaseRecords() throws IOException {
880891 protected void sizeDatabase () throws IOException {
881892 setDataCommandInfo ("Database size" );
882893
883- checkDatabase ();
894+ if (!isConnectionAlive ())
895+ return ;
884896
885897 beginResponse ();
886898 try {
@@ -1059,7 +1071,8 @@ protected void configGet() throws IOException {
10591071 protected void commit () throws IOException {
10601072 setDataCommandInfo ("Transaction commit" );
10611073
1062- checkDatabase ();
1074+ if (!isConnectionAlive ())
1075+ return ;
10631076
10641077 final OTransactionOptimisticProxy tx = new OTransactionOptimisticProxy ((ODatabaseRecordTx ) connection .database .getUnderlying (),
10651078 channel );
@@ -1135,6 +1148,9 @@ protected void command() throws IOException {
11351148 // FORCE THE SERVER'S TIMEOUT
11361149 command .setTimeout (serverTimeout , command .getTimeoutStrategy ());
11371150
1151+ if (!isConnectionAlive ())
1152+ return ;
1153+
11381154 // ASSIGNED THE PARSED FETCHPLAN
11391155 listener .setFetchPlan (((OCommandRequestInternal ) connection .database .command (command )).getFetchPlan ());
11401156
@@ -1194,6 +1210,15 @@ protected void command() throws IOException {
11941210 }
11951211 }
11961212
1213+ private boolean isConnectionAlive () {
1214+ if (connection == null || connection .database == null ) {
1215+ // CONNECTION/DATABASE CLOSED
1216+ OClientConnectionManager .instance ().disconnect (connection );
1217+ return false ;
1218+ }
1219+ return true ;
1220+ }
1221+
11971222 /**
11981223 * Use DATACLUSTER_COUNT
11991224 *
@@ -1203,7 +1228,8 @@ protected void command() throws IOException {
12031228 protected void countCluster () throws IOException {
12041229 setDataCommandInfo ("Count cluster records" );
12051230
1206- checkDatabase ();
1231+ if (!isConnectionAlive ())
1232+ return ;
12071233
12081234 final String clusterName = channel .readString ();
12091235 final long size = connection .database .countClusterElements (clusterName );
@@ -1220,7 +1246,8 @@ protected void countCluster() throws IOException {
12201246 protected void deleteRecord () throws IOException {
12211247 setDataCommandInfo ("Delete record" );
12221248
1223- checkDatabase ();
1249+ if (!isConnectionAlive ())
1250+ return ;
12241251
12251252 final ORID rid = channel .readRID ();
12261253 final ORecordVersion version = channel .readVersion ();
@@ -1242,7 +1269,8 @@ protected void deleteRecord() throws IOException {
12421269 protected void cleanOutRecord () throws IOException {
12431270 setDataCommandInfo ("Clean out record" );
12441271
1245- checkDatabase ();
1272+ if (!isConnectionAlive ())
1273+ return ;
12461274
12471275 final ORID rid = channel .readRID ();
12481276 final ORecordVersion version = channel .readVersion ();
@@ -1274,7 +1302,11 @@ protected void cleanOutRecord() throws IOException {
12741302 protected void updateRecord () throws IOException {
12751303 setDataCommandInfo ("Update record" );
12761304
1277- checkDatabase ();
1305+ if (!isConnectionAlive ())
1306+ return ;
1307+
1308+ if (!isConnectionAlive ())
1309+ return ;
12781310
12791311 final ORecordId rid = channel .readRID ();
12801312 final byte [] buffer = channel .readBytes ();
@@ -1298,7 +1330,8 @@ protected void updateRecord() throws IOException {
12981330 protected void createRecord () throws IOException {
12991331 setDataCommandInfo ("Create record" );
13001332
1301- checkDatabase ();
1333+ if (!isConnectionAlive ())
1334+ return ;
13021335
13031336 final int dataSegmentId = connection .data .protocolVersion >= 10 ? channel .readInt () : 0 ;
13041337 final ORecordId rid = new ORecordId (channel .readShort (), ORID .CLUSTER_POS_INVALID );
@@ -1340,6 +1373,9 @@ protected void readRecordMetadata() throws IOException {
13401373 protected void readRecord () throws IOException {
13411374 setDataCommandInfo ("Load record" );
13421375
1376+ if (!isConnectionAlive ())
1377+ return ;
1378+
13431379 final ORecordId rid = channel .readRID ();
13441380 final String fetchPlanString = channel .readString ();
13451381 boolean ignoreCache = false ;
@@ -1501,14 +1537,6 @@ private boolean loadUserFromSchema(final String iUserName, final String iUserPas
15011537 return true ;
15021538 }
15031539
1504- protected void checkDatabase () {
1505- if (connection == null )
1506- throw new OStorageException ("Connection with remote server has been lost" );
1507-
1508- if (connection .database == null )
1509- throw new OSecurityAccessException ("You need to authenticate before to execute the requested operation" );
1510- }
1511-
15121540 @ Override
15131541 protected void handleConnectionError (final OChannelBinaryServer iChannel , final Throwable e ) {
15141542 super .handleConnectionError (channel , e );
0 commit comments