question: private Delegate delegate ( ) throws HadoopIgfsCommunicationException { Exception errShmem = null ; Exception errTcp = null ; Delegate curDelegate = delegateRef . get ( ) ; if ( curDelegate != null ) return curDelegate ; boolean skipInProc = parameter ( conf , PARAM_IGFS_ENDPOINT_NO_EMBED , authority , false ) ; if ( ! skipInProc ) { IgfsEx igfs = getIgfsEx ( endpoint . grid ( ) , endpoint . igfs ( ) ) ; if ( igfs != null ) { HadoopIgfsEx hadoop = null ; try { hadoop = new HadoopIgfsInProc ( igfs , log , userName ) ; curDelegate = new Delegate ( hadoop , hadoop . handshake ( logDir ) ) ; } catch ( IOException | IgniteCheckedException e ) { if ( e instanceof HadoopIgfsCommunicationException ) if ( hadoop != null ) hadoop . close ( true ) ; if ( log . isDebugEnabled ( ) ) log . debug ( "Failed to connect to in-process IGFS, fallback to IPC mode." , e ) ; } } } boolean skipLocShmem = parameter ( conf , PARAM_IGFS_ENDPOINT_NO_LOCAL_SHMEM , authority , false ) ; if ( curDelegate == null && ! skipLocShmem && ! U . isWindows ( ) ) { HadoopIgfsEx hadoop = null ; try { hadoop = new HadoopIgfsOutProc ( endpoint . port ( ) , endpoint . grid ( ) , endpoint . igfs ( ) , log , userName ) ; curDelegate = new Delegate ( hadoop , hadoop . handshake ( logDir ) ) ; } catch ( IOException | IgniteCheckedException e ) { if ( e instanceof HadoopIgfsCommunicationException ) hadoop . close ( true ) ; if ( log . isDebugEnabled ( ) ) log . debug ( "Failed to connect to IGFS using shared memory [port=" + endpoint . port ( ) + ']' , e ) ; errShmem = e ; } } boolean skipLocTcp = parameter ( conf , PARAM_IGFS_ENDPOINT_NO_LOCAL_TCP , authority , false ) ; if ( curDelegate == null && ! skipLocTcp ) { HadoopIgfsEx hadoop = null ; try { hadoop = new HadoopIgfsOutProc ( LOCALHOST , endpoint . port ( ) , endpoint . grid ( ) , endpoint . igfs ( ) , log , userName ) ; curDelegate = new Delegate ( hadoop , hadoop . handshake ( logDir ) ) ; } catch ( IOException | IgniteCheckedException e ) { if ( e instanceof HadoopIgfsCommunicationException ) hadoop . close ( true ) ; if ( log . isDebugEnabled ( ) ) log . debug ( "Failed to connect to IGFS using TCP [host=" + endpoint . host ( ) + ", port=" + endpoint . port ( ) + ']' , e ) ; errTcp = e ; } } if ( curDelegate == null && ( skipLocTcp || ! F . eq ( LOCALHOST , endpoint . host ( ) ) ) ) { HadoopIgfsEx hadoop = null ; try { hadoop = new HadoopIgfsOutProc ( endpoint . host ( ) , endpoint . port ( ) , endpoint . grid ( ) , endpoint . igfs ( ) , log , userName ) ; curDelegate = new Delegate ( hadoop , hadoop . handshake ( logDir ) ) ; } catch ( IOException | IgniteCheckedException e ) { if ( e instanceof HadoopIgfsCommunicationException ) hadoop . close ( true ) ; if ( log . isDebugEnabled ( ) ) log . debug ( "Failed to connect to IGFS using TCP [host=" + endpoint . host ( ) + ", port=" + endpoint . port ( ) + ']' , e ) ; errTcp = e ; } } if ( curDelegate != null ) { if ( ! delegateRef . compareAndSet ( null , curDelegate ) ) curDelegate . doomed = true ; return curDelegate ; } else { SB errMsg = new SB ( "Failed to connect to IGFS [endpoint=igfs://" + authority + ", attempts=[" ) ; if ( errShmem != null ) errMsg . a ( "[type=SHMEM, port=" + endpoint . port ( ) + ", err=" + errShmem + "], " ) ; errMsg . a ( "[type=TCP, host=" + endpoint . host ( ) + ", port=" + endpoint . port ( ) + ", err=" + errTcp + "]] " ) ; errMsg . a ( "(ensure that IGFS is running and have IPC endpoint enabled; ensure that " + "ignite-shmem-1.0.0.jar is in Hadoop classpath if you use shared memory endpoint)." ) ; throw new HadoopIgfsCommunicationException ( errMsg . toString ( ) ) ; } }
target:  Get delegate creating it if needed.