public static ZKUtil . StringCallback createSnapshotCompletionNode ( String path , String pathType , String nonce , long txnId , boolean isTruncation , String truncReqId ) { if ( ! ( txnId > 0 ) ) { VoltDB . crashGlobalVoltDB ( "Txnid must be greather than 0" , true , null ) ; } byte nodeBytes [ ] = null ; try { JSONStringer stringer = new JSONStringer ( ) ; stringer . object ( ) ; stringer . keySymbolValuePair ( "txnId" , txnId ) ; stringer . keySymbolValuePair ( "isTruncation" , isTruncation ) ; stringer . keySymbolValuePair ( "didSucceed" , true ) ; stringer . keySymbolValuePair ( "hostCount" , - 1 ) ; stringer . keySymbolValuePair ( SnapshotUtil . JSON_PATH , path ) ; stringer . keySymbolValuePair ( SnapshotUtil . JSON_PATH_TYPE , pathType ) ; stringer . keySymbolValuePair ( SnapshotUtil . JSON_NONCE , nonce ) ; stringer . keySymbolValuePair ( "truncReqId" , truncReqId ) ; stringer . key ( "exportSequenceNumbers" ) . object ( ) . endObject ( ) ; stringer . endObject ( ) ; JSONObject jsonObj = new JSONObject ( stringer . toString ( ) ) ; nodeBytes = jsonObj . toString ( 4 ) . getBytes ( Charsets . UTF_8 ) ; } catch ( Exception e ) { VoltDB . crashLocalVoltDB ( "Error serializing snapshot completion node JSON" , true , e ) ; } ZKUtil . StringCallback cb = new ZKUtil . StringCallback ( ) ; final String snapshotPath = VoltZK . completed_snapshots + "/" + txnId ; VoltDB . instance ( ) . getHostMessenger ( ) . getZK ( ) . create ( snapshotPath , nodeBytes , Ids . OPEN_ACL_UNSAFE , CreateMode . PERSISTENT , cb , null ) ; return cb ; }
Create the completion node for the snapshot identified by the txnId . It assumes that all hosts will race to call this so it doesn t fail if the node already exists .