@ Override public Object executeOnLocalNode ( final ODistributedRequestId reqId , final ORemoteTask task , final ODatabaseDocumentInternal database ) { if ( database != null && ! ( database . getStorage ( ) instanceof ODistributedStorage ) ) throw new ODistributedException ( "Distributed storage was not installed for database '" + database . getName ( ) + "'. Implementation found: " + database . getStorage ( ) . getClass ( ) . getName ( ) ) ; final ODistributedAbstractPlugin manager = this ; return OScenarioThreadLocal . executeAsDistributed ( new Callable < Object > ( ) { @ Override public Object call ( ) throws Exception { try { final Object result = task . execute ( reqId , serverInstance , manager , database ) ; if ( result instanceof Throwable && ! ( result instanceof OException ) ) // EXCEPTION ODistributedServerLog . debug ( this , nodeName , getNodeNameById ( reqId . getNodeId ( ) ) , DIRECTION . IN , "Error on executing request %d (%s) on local node: " , ( Throwable ) result , reqId , task ) ; else { // OK final String sourceNodeName = task . getNodeSource ( ) ; if ( database != null ) { final ODistributedDatabaseImpl ddb = getMessageService ( ) . getDatabase ( database . getName ( ) ) ; if ( ddb != null && ! ( result instanceof Throwable ) && task instanceof OAbstractReplicatedTask && ! task . isIdempotent ( ) ) { // UPDATE LSN WITH LAST OPERATION ddb . setLSN ( sourceNodeName , ( ( OAbstractReplicatedTask ) task ) . getLastLSN ( ) , true ) ; // UPDATE LSN WITH LAST LOCAL OPERATION ddb . setLSN ( getLocalNodeName ( ) , ( ( OAbstractPaginatedStorage ) database . getStorage ( ) . getUnderlying ( ) ) . getLSN ( ) , true ) ; } } } return result ; } catch ( InterruptedException e ) { // IGNORE IT ODistributedServerLog . debug ( this , nodeName , getNodeNameById ( reqId . getNodeId ( ) ) , DIRECTION . IN , "Interrupted execution on executing distributed request %s on local node: %s" , e , reqId , task ) ; return e ; } catch ( Exception e ) { if ( ! ( e instanceof OException ) ) ODistributedServerLog . error ( this , nodeName , getNodeNameById ( reqId . getNodeId ( ) ) , DIRECTION . IN , "Error on executing distributed request %s on local node: %s" , e , reqId , task ) ; return e ; } } } ) ; }
Executes the request on local node . In case of error returns the Exception itself