public void createAllDevNullTargets ( Exception lastWriteException ) { Map < Integer , SnapshotDataTarget > targets = Maps . newHashMap ( ) ; final AtomicInteger numTargets = new AtomicInteger ( ) ; for ( Deque < SnapshotTableTask > tasksForSite : m_taskListsForHSIds . values ( ) ) { for ( SnapshotTableTask task : tasksForSite ) { // Close any created targets and replace them with DevNull, go web-scale if ( task . getTarget ( true ) != null ) { try { task . getTarget ( ) . close ( ) ; } catch ( Exception e ) { SNAP_LOG . error ( "Failed closing data target after error" , e ) ; } } SnapshotDataTarget target = targets . get ( task . m_table . getRelativeIndex ( ) ) ; if ( target == null ) { target = new DevNullSnapshotTarget ( lastWriteException ) ; final Runnable onClose = new TargetStatsClosure ( target , task . m_table . getTypeName ( ) , numTargets , m_snapshotRecord ) ; target . setOnCloseHandler ( onClose ) ; targets . put ( task . m_table . getRelativeIndex ( ) , target ) ; m_targets . add ( target ) ; numTargets . incrementAndGet ( ) ; } task . setTarget ( target ) ; } } }
In case the deferred setup phase fails some data targets may have not been created yet . This method will close all existing data targets and replace all with DevNullDataTargets so that snapshot can be drained .