public void createAndWatchRequestNode ( final long clientHandle , final Connection c , SnapshotInitiationInfo snapInfo , boolean notifyChanges ) throws ForwardClientException { boolean requestExists = false ; final String requestId = createRequestNode ( snapInfo ) ; if ( requestId == null ) { requestExists = true ; } else { if ( ! snapInfo . isTruncationRequest ( ) ) { try { registerUserSnapshotResponseWatch ( requestId , clientHandle , c , notifyChanges ) ; } catch ( Exception e ) { VoltDB . crashLocalVoltDB ( "Failed to register ZK watch on snapshot response" , true , e ) ; } } else { // need to construct a success response of some sort here to indicate the truncation attempt // was successfully attempted VoltTable result = SnapshotUtil . constructNodeResultsTable ( ) ; result . addRow ( - 1 , CoreUtils . getHostnameOrAddress ( ) , "" , "SUCCESS" , "SNAPSHOT REQUEST QUEUED" ) ; final ClientResponseImpl resp = new ClientResponseImpl ( ClientResponseImpl . SUCCESS , new VoltTable [ ] { result } , "User-requested truncation snapshot successfully queued for execution." , clientHandle ) ; ByteBuffer buf = ByteBuffer . allocate ( resp . getSerializedSize ( ) + 4 ) ; buf . putInt ( buf . capacity ( ) - 4 ) ; resp . flattenToBuffer ( buf ) . flip ( ) ; c . writeStream ( ) . enqueue ( buf ) ; } } if ( requestExists ) { VoltTable result = SnapshotUtil . constructNodeResultsTable ( ) ; result . addRow ( - 1 , CoreUtils . getHostnameOrAddress ( ) , "" , "FAILURE" , "SNAPSHOT IN PROGRESS" ) ; throw new ForwardClientException ( "A request to perform a user snapshot already exists" , result ) ; } }
Try to create the ZK request node and watch it if created successfully .