Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
   package org.uberfire.io.impl.cluster;
   
   import java.io.InputStream;
   import java.io.OutputStream;
   import java.net.URI;
   import java.net.URLEncoder;
  import java.util.HashMap;
  import java.util.HashSet;
  import java.util.List;
  import java.util.Map;
  import java.util.Set;
  
  import org.slf4j.Logger;
  import  org.uberfire.commons.async.DescriptiveRunnable;
  import  org.uberfire.commons.async.SimpleAsyncExecutorService;
  import  org.uberfire.commons.cluster.ClusterService;
  import  org.uberfire.commons.cluster.ClusterServiceFactory;
  import  org.uberfire.commons.cluster.LockExecuteNotifySyncReleaseTemplate;
  import  org.uberfire.commons.data.Pair;
  import  org.uberfire.commons.lock.LockExecuteReleaseTemplate;
  import  org.uberfire.commons.message.AsyncCallback;
  import  org.uberfire.commons.message.MessageHandler;
  import  org.uberfire.commons.message.MessageHandlerResolver;
  import  org.uberfire.commons.message.MessageType;
  import  org.uberfire.java.nio.IOException;
  import  org.uberfire.java.nio.base.FileSystemId;
  import  org.uberfire.java.nio.base.FileSystemState;
  import  org.uberfire.java.nio.base.FileSystemStateAware;
  import  org.uberfire.java.nio.base.SeekableByteChannelWrapperImpl;
  import  org.uberfire.java.nio.channels.SeekableByteChannel;
  import  org.uberfire.java.nio.file.AtomicMoveNotSupportedException;
  import  org.uberfire.java.nio.file.CopyOption;
  import  org.uberfire.java.nio.file.DeleteOption;
  import  org.uberfire.java.nio.file.DirectoryNotEmptyException;
  import  org.uberfire.java.nio.file.DirectoryStream;
  import  org.uberfire.java.nio.file.FileAlreadyExistsException;
  import  org.uberfire.java.nio.file.FileSystem;
  import  org.uberfire.java.nio.file.FileSystemAlreadyExistsException;
  import  org.uberfire.java.nio.file.FileSystemNotFoundException;
  import  org.uberfire.java.nio.file.NoSuchFileException;
  import  org.uberfire.java.nio.file.NotDirectoryException;
  import  org.uberfire.java.nio.file.OpenOption;
  import  org.uberfire.java.nio.file.Option;
  import  org.uberfire.java.nio.file.Path;
  import  org.uberfire.java.nio.file.ProviderNotFoundException;
  import  org.uberfire.java.nio.file.attribute.FileAttribute;
  import  org.uberfire.java.nio.file.attribute.FileAttributeView;
  import  org.uberfire.java.nio.file.attribute.FileTime;
  
  import static org.uberfire.commons.validation.PortablePreconditions.checkNotNull;
  import static org.uberfire.commons.validation.Preconditions.*;
  import static org.uberfire.io.impl.cluster.ClusterMessageType.*;
  
  public class IOServiceClusterImpl implements IOClusteredService {
  
      private static final Logger logger = LoggerFactory.getLoggerIOServiceClusterImpl.class );
  
      private final IOServiceIdentifiable service;
      private final ClusterService clusterService;
      private final AtomicBoolean started = new AtomicBooleanfalse );
      private final Set<StringbatchFileSystems = Collections.newSetFromMapnew ConcurrentHashMap<StringBoolean>() );
  
      private NewFileSystemListener newFileSystemListener = null;
  
      public IOServiceClusterImplfinal IOService service,
                                   final ClusterServiceFactory clusterServiceFactory ) {
          thisserviceclusterServiceFactorytrue );
      }
  
      public IOServiceClusterImplfinal IOService service,
                                   final ClusterServiceFactory clusterServiceFactory,
                                   final boolean autoStart ) {
          checkNotNull( "clusterServiceFactory"clusterServiceFactory );
          this. = checkInstanceOf"service"serviceIOServiceIdentifiable.class );
  
          .debug"Creating instance of cluster service with auto start {}"autoStart );
          this. = clusterServiceFactory.build( new MessageHandlerResolver() {
  
              final MessageHandler newFs = new NewFileSystemMessageHandler();
              final MessageHandler syncFs = new SyncFileSystemMessageHandler();
              final MessageHandler queryFs = new QueryFileSystemMessageHandler();
  
              @Override
              public String getServiceId() {
                 return IOServiceClusterImpl.this..getId();
             }
 
             @Override
             public MessageHandler resolveHandlerfinal String serviceId,
                                                   final MessageType type ) {
 
                 if ( serviceId.equalsIOServiceClusterImpl.this..getId() ) ) {
                     if ( .equalstype ) ) {
                         return ;
                     } else if ( .equalstype ) ) {
                         return ;
                     } else if ( .equalstype ) ) {
                         return ;
                     }
                 }
 
                 return null;
             }
         } );
 
         this..onStart( new Runnable() {
             @Override
             public void run() {
                 start();
             }
         } );
     }
 
     @Override
     public void start() {
         .settrue );
         .debug"Starting cluster service {}"this );
         //New cluster members are executed within locked
         new LockExecuteReleaseTemplate<Void>().execute( new FutureTask<Void>( new Callable<Void>() {
             @Override
             public Void call() throws Exception {
 
                 // 10 seconds
                 int timeout = 10000;
                 final AtomicBoolean msgAnsweredOrTimedout = new AtomicBooleanfalse );
                 final AtomicBoolean onSync = new AtomicBooleanfalse );
 
                 final Map<IntegerFileSystemInfofileSystems = new HashMap<IntegerFileSystemInfo>();
 
                 .broadcastAndWait( .getId(), , Collections.<StringString>emptyMap(), timeoutnew AsyncCallback() {
                     @Override
                     public void onTimeOut() {
                         msgAnsweredOrTimedout.settrue );
                     }
 
                     @Override
                     public void onReplyfinal MessageType type,
                                          final Map<StringStringcontent ) {
                         if ( msgAnsweredOrTimedout.get() || onSync.get() ) {
                             return;
                         }
 
                         onSync.settrue );
 
                         SimpleAsyncExecutorService.getUnmanagedInstance().execute( new DescriptiveRunnable() {
                             @Override
                             public String getDescription() {
                                 return "Cluster Messaging Reply [" + .getId() + "/QUERY_FOR_FS]";
                             }
 
                             @Override
                             public void run() {
                                 for ( final Map.Entry<StringStringentry : content.entrySet() ) {
                                     if ( entry.getKey().startsWith"fs_" ) ) {
                                         int index = Integer.valueOfentry.getKey().substringentry.getKey().lastIndexOf"_" ) + 1 ) );
                                         if ( !fileSystems.containsKeyindex ) ) {
                                             fileSystems.putindexnew FileSystemInfo() );
                                         }
                                         final FileSystemInfo fsInfo = fileSystems.getindex );
                                         if ( entry.getKey().startsWith"fs_id_" ) ) {
                                             fsInfo.setIdentry.getValue() );
                                         } else if ( entry.getKey().startsWith"fs_scheme_" ) ) {
                                             fsInfo.setSchemeentry.getValue() );
                                         } else if ( entry.getKey().startsWith"fs_uri_" ) ) {
                                             fsInfo.setUrientry.getValue() );
                                         }
                                     }
                                 }
 
                                 for ( final FileSystemInfo fileSystemInfo : new HashSet<FileSystemInfo>( fileSystems.values() ) ) {
                                     try {
                                         final URI newFS = URI.createfileSystemInfo.getScheme() + "://" + fileSystemInfo.getId() );
                                         .newFileSystemnewFS, Collections.<StringObject>emptyMap() );
                                     } catch ( FileSystemAlreadyExistsException ex ) {
                                     }
 
                                     final URI fs = URI.createfileSystemInfo.getScheme() + "://" + fileSystemInfo.getId() + "?sync=" + fileSystemInfo.getUri().split"\n" )[ 0 ] + "&force" );
                                     .getFileSystemfs );
                                 }
 
                                 msgAnsweredOrTimedout.settrue );
                             }
                         } );
                     }
                 } );
 
                 while ( !msgAnsweredOrTimedout.get() ) {
                     try {
                         Thread.sleep( 100 );
                     } catch ( InterruptedException ignored ) {
                     }
                 }
 
                 return null;
             }
         } ) );
     }
 
     @Override
     public void dispose() {
         .dispose();
         .dispose();
     }
 
     @Override
     public void startBatch( FileSystem fs ) {
         startBatchnew FileSystem[]{ fs } );
     }
 
     @Override
     public void startBatch( FileSystem[] fs,
                             final Option... options ) {
         .lock();
         for ( final FileSystem f : fs ) {
             if ( f instanceof FileSystemId ) {
                 .add( ( (FileSystemId) f ).id() );
             }
         }
         .startBatchfsoptions );
     }
 
     @Override
     public void startBatchfinal FileSystem fs,
                             final Option... options ) {
         .lock();
         if ( fs instanceof FileSystemId ) {
             .add( ( (FileSystemId) fs ).id() );
         }
 
         .startBatchfsoptions );
     }
 
     @Override
     public void startBatchfinal FileSystem... fs ) {
         .lock();
         for ( final FileSystem f : fs ) {
             if ( f instanceof FileSystemId ) {
                 .add( ( (FileSystemId) f ).id() );
             }
         }
         .startBatchfs );
     }
 
     @Override
     public void endBatch() {
         .endBatch();
         if ( !.isInnerLocked() ) {
             final AtomicInteger process = new AtomicInteger.size() );
 
             for ( final FileSystem fs : .getFileSystems() ) {
                 if ( fs instanceof FileSystemId &&
                         .contains( ( (FileSystemId) fs ).id() ) ) {
                     try {
                         new FileSystemSyncLock<Void>( .getId(), fs ).execute( new FutureTask<Void>( new Callable<Void>() {
                             @Override
                             public Void call() throws Exception {
                                 if ( process.decrementAndGet() == 0 ) {
                                     .unlock();
                                 }
                                 return null;
                             }
                         } ) );
                     } catch ( Exception ex ) {
                         .error"End batch error"ex );
                         if ( process.decrementAndGet() == 0 ) {
                             .unlock();
                         }
                     }
                 }
             }
             .clear();
         } else {
             .unlock();
         }
     }
 
     @Override
     public FileAttribute<?>[] convertfinal Map<String, ?> attrs ) {
         return .convertattrs );
     }
 
     @Override
     public Path getfinal String first,
                      final String... more ) throws IllegalArgumentException {
         return .getfirstmore );
     }
 
     @Override
     public Path getfinal URI uri ) throws IllegalArgumentException, FileSystemNotFoundException, SecurityException {
         return .geturi );
     }
 
     @Override
     public Iterable<FileSystem> getFileSystems() {
         return .getFileSystems();
     }
 
     @Override
     public FileSystem getFileSystemfinal URI uri ) throws IllegalArgumentException, FileSystemNotFoundException, ProviderNotFoundException, SecurityException {
         return .getFileSystemuri );
     }
 
     @Override
     public FileSystem newFileSystemfinal URI uri,
                                      final Map<String, ?> env ) throws IllegalArgumentException, FileSystemAlreadyExistsException, ProviderNotFoundException, IOException, SecurityException {
         if ( env.containsKey"internal" ) ) {
             return .newFileSystemurienv );
         }
 
         return new LockExecuteNotifySyncReleaseTemplate<FileSystem>() {
 
             @Override
             public MessageType getMessageType() {
                 return ;
             }
 
             @Override
             public String getServiceId() {
                 return .getId();
             }
 
             @Override
             public Map<StringStringbuildContent() {
                 return new HashMap<StringString>() {{
                     put"uri"uri.toString() );
                     for ( final Map.Entry<String, ?> entry : env.entrySet() ) {
                         putentry.getKey(), entry.getValue().toString() );
                     }
                 }};
             }
 
             @Override
             public int timeOut() {
                 return TIMEOUT;
             }
         }.execute( new FutureTask<FileSystem>( new Callable<FileSystem>() {
             @Override
             public FileSystem call() throws Exception {
                 return .newFileSystemurinew HashMap<StringObject>( env ) {{
                     put"clusterService" );
                 }} );
             }
         } ) );
     }
 
     @Override
     public void onNewFileSystemNewFileSystemListener listener ) {
         this. = listener;
     }
 
     @Override
     public InputStream newInputStreamfinal Path path,
                                        final OpenOption... options ) throws IllegalArgumentException, NoSuchFileException, UnsupportedOperationException, IOException, SecurityException {
         return .newInputStreampathoptions );
     }
 
     @Override
     public DirectoryStream<Path> newDirectoryStreamfinal Path dir ) throws IllegalArgumentException, NotDirectoryException, IOException, SecurityException {
         return .newDirectoryStreamdir );
     }
 
     @Override
     public DirectoryStream<Path> newDirectoryStream( final Path dir,
                                                      final DirectoryStream.Filter<Path> filter ) throws IllegalArgumentException, NotDirectoryException, IOException, SecurityException {
         return .newDirectoryStreamdirfilter );
     }
 
     @Override
     public Path createFilefinal Path path,
                             final FileAttribute<?>... attrs ) throws IllegalArgumentExceptionUnsupportedOperationException, FileAlreadyExistsException, IOException, SecurityException {
         if ( isBatchpath.getFileSystem() ) ) {
             return .createFilepathattrs );
         }
 
         return new FileSystemSyncLock<Path>( .getId(), path.getFileSystem() ).execute( new FutureTask<Path>( new Callable<Path>() {
             @Override
             public Path call() throws Exception {
                 return .createFilepathattrs );
             }
         } ) );
     }
 
     @Override
     public Path createDirectoryfinal Path dir,
                                  final FileAttribute<?>... attrs ) throws IllegalArgumentExceptionUnsupportedOperationException, FileAlreadyExistsException, IOException, SecurityException {
         if ( isBatchdir.getFileSystem() ) ) {
             return .createDirectorydirattrs );
         }
 
         return new FileSystemSyncLock<Path>( .getId(), dir.getFileSystem() ).execute( new FutureTask<Path>( new Callable<Path>() {
             @Override
             public Path call() throws Exception {
                 return .createDirectorydirattrs );
             }
         } ) );
     }
 
     @Override
     public Path createDirectoriesfinal Path dir,
                                    final FileAttribute<?>... attrs ) throws UnsupportedOperationException, FileAlreadyExistsException, IOException, SecurityException {
         if ( isBatchdir.getFileSystem() ) ) {
             return .createDirectoriesdirattrs );
         }
 
         return new FileSystemSyncLock<Path>( .getId(), dir.getFileSystem() ).execute( new FutureTask<Path>( new Callable<Path>() {
             @Override
             public Path call() throws Exception {
                 return .createDirectoriesdirattrs );
             }
         } ) );
     }
 
     @Override
     public Path createDirectoryfinal Path dir,
                                  final Map<String, ?> attrs ) throws IllegalArgumentExceptionUnsupportedOperationException, FileAlreadyExistsException, IOException, SecurityException {
         if ( isBatchdir.getFileSystem() ) ) {
             return .createDirectorydirattrs );
         }
 
         return new FileSystemSyncLock<Path>( .getId(), dir.getFileSystem() ).execute( new FutureTask<Path>( new Callable<Path>() {
             @Override
             public Path call() throws Exception {
                 return .createDirectorydirattrs );
             }
         } ) );
     }
 
     @Override
     public Path createDirectoriesfinal Path dir,
                                    final Map<String, ?> attrs ) throws UnsupportedOperationException, FileAlreadyExistsException, IOException, SecurityException {
         if ( isBatchdir.getFileSystem() ) ) {
             return .createDirectoriesdirattrs );
         }
 
         return new FileSystemSyncLock<Path>( .getId(), dir.getFileSystem() ).execute( new FutureTask<Path>( new Callable<Path>() {
             @Override
             public Path call() throws Exception {
                 return .createDirectoriesdirattrs );
             }
         } ) );
     }
 
     @Override
     public void deletefinal Path path,
                         final DeleteOption... options ) throws IllegalArgumentException, NoSuchFileException, DirectoryNotEmptyException, IOException, SecurityException {
         if ( isBatchpath.getFileSystem() ) ) {
             .deletepathoptions );
         } else {
             new FileSystemSyncLock<Void>( .getId(), path.getFileSystem() ).execute( new FutureTask<Void>( new Callable<Void>() {
                 @Override
                 public Void call() throws Exception {
                     .deletepathoptions );
                     return null;
                 }
             } ) );
         }
     }
 
     @Override
     public boolean deleteIfExistsfinal Path path,
                                    final DeleteOption... options ) throws IllegalArgumentException, DirectoryNotEmptyException, IOException, SecurityException {
         if ( isBatchpath.getFileSystem() ) ) {
             return .deleteIfExistspathoptions );
         }
         return new FileSystemSyncLock<Boolean>( .getId(), path.getFileSystem() ).execute( new FutureTask<Boolean>( new Callable<Boolean>() {
             @Override
             public Boolean call() throws Exception {
                 return .deleteIfExistspathoptions );
             }
         } ) );
     }
 
     @Override
     public Path createTempFilefinal String prefix,
                                 final String suffix,
                                 final FileAttribute<?>... attrs ) throws IllegalArgumentExceptionUnsupportedOperationException, IOException, SecurityException {
         return .createTempFileprefixsuffixattrs );
     }
 
     @Override
     public Path createTempFilefinal Path dir,
                                 final String prefix,
                                 final String suffix,
                                 final FileAttribute<?>... attrs ) throws IllegalArgumentExceptionUnsupportedOperationException, IOException, SecurityException {
         return .createTempFiledirprefixsuffixattrs );
     }
 
     @Override
     public Path createTempDirectoryfinal String prefix,
                                      final FileAttribute<?>... attrs ) throws IllegalArgumentExceptionUnsupportedOperationException, IOException, SecurityException {
         return .createTempDirectoryprefixattrs );
     }
 
     @Override
     public Path createTempDirectoryfinal Path dir,
                                      final String prefix,
                                      final FileAttribute<?>... attrs ) throws IllegalArgumentExceptionUnsupportedOperationException, IOException, SecurityException {
         return .createTempDirectorydirprefixattrs );
     }
 
     @Override
     public Path copyfinal Path source,
                       final Path target,
                       final CopyOption... options ) throws UnsupportedOperationException, FileAlreadyExistsException, DirectoryNotEmptyException, IOException, SecurityException {
         if ( isBatchsource.getFileSystem() ) ) {
             return .copysourcetargetoptions );
         }
 
         return new FileSystemSyncLock<Path>( .getId(), target.getFileSystem() ).execute( new FutureTask<Path>( new Callable<Path>() {
             @Override
             public Path call() throws Exception {
                 return .copysourcetargetoptions );
             }
         } ) );
     }
 
     @Override
     public long copyfinal InputStream in,
                       final Path target,
                       final CopyOption... options ) throws IOException, FileAlreadyExistsException, DirectoryNotEmptyException, UnsupportedOperationExceptionSecurityException {
         if ( isBatchtarget.getFileSystem() ) ) {
             return .copyintargetoptions );
         }
 
         return new FileSystemSyncLock<Long>( .getId(), target.getFileSystem() ).execute( new FutureTask<Long>( new Callable<Long>() {
             @Override
             public Long call() throws Exception {
                 return .copyintargetoptions );
             }
         } ) );
     }
 
     @Override
     public long copyfinal Path source,
                       final OutputStream out ) throws IOException, SecurityException {
         return .copysourceout );
     }
 
     @Override
     public Path movefinal Path source,
                       final Path target,
                       final CopyOption... options ) throws UnsupportedOperationException, FileAlreadyExistsException, DirectoryNotEmptyException, AtomicMoveNotSupportedException, IOException, SecurityException {
         if ( isBatchsource.getFileSystem() ) ) {
             return .movesourcetargetoptions );
         }
 
         return new FileSystemSyncLock<Path>( .getId(), source.getFileSystem() ).execute( new FutureTask<Path>( new Callable<Path>() {
             @Override
             public Path call() throws Exception {
                 return new FileSystemSyncLock<Path>( .getId(), target.getFileSystem() ).execute( new FutureTask<Path>( new Callable<Path>() {
                     @Override
                     public Path call() throws Exception {
                         return .movesourcetargetoptions );
                     }
                 } ) );
             }
         } ) );
     }
 
     @Override
     public <V extends FileAttributeView> V getFileAttributeViewfinal Path path,
                                                                  final Class<V> type ) throws IllegalArgumentException {
         return .getFileAttributeViewpathtype );
     }
 
     @Override
     public Map<StringObjectreadAttributesfinal Path path ) throws UnsupportedOperationException, NoSuchFileException, IllegalArgumentException, IOException, SecurityException {
         return .readAttributespath );
     }
 
     @Override
     public Map<StringObjectreadAttributesfinal Path path,
                                                final String attributes ) throws UnsupportedOperationException, NoSuchFileException, IllegalArgumentException, IOException, SecurityException {
         return .readAttributespathattributes );
     }
 
     @Override
     public Path setAttributesfinal Path path,
                                final FileAttribute<?>... attrs ) throws UnsupportedOperationExceptionIllegalArgumentExceptionClassCastException, IOException, SecurityException {
         if ( isBatchpath.getFileSystem() ) ) {
             return .setAttributespathattrs );
         }
 
         return new FileSystemSyncLock<Path>( .getId(), path.getFileSystem() ).execute( new FutureTask<Path>( new Callable<Path>() {
             @Override
             public Path call() throws Exception {
                 return .setAttributespathattrs );
             }
         } ) );
     }
 
     @Override
     public Path setAttributesfinal Path path,
                                final Map<StringObjectattrs ) throws UnsupportedOperationExceptionIllegalArgumentExceptionClassCastException, IOException, SecurityException {
         if ( isBatchpath.getFileSystem() ) ) {
             return .setAttributespathattrs );
         }
 
         return new FileSystemSyncLock<Path>( .getId(), path.getFileSystem() ).execute( new FutureTask<Path>( new Callable<Path>() {
             @Override
             public Path call() throws Exception {
                 return .setAttributespathattrs );
             }
         } ) );
     }
 
     @Override
     public Path setAttributefinal Path path,
                               final String attribute,
                               final Object value ) throws UnsupportedOperationExceptionIllegalArgumentExceptionClassCastException, IOException, SecurityException {
         if ( isBatchpath.getFileSystem() ) ) {
             return .setAttributepathattributevalue );
         }
 
         return new FileSystemSyncLock<Path>( .getId(), path.getFileSystem() ).execute( new FutureTask<Path>( new Callable<Path>() {
             @Override
             public Path call() throws Exception {
                 return .setAttributepathattributevalue );
             }
         } ) );
     }
 
     @Override
     public Object getAttributefinal Path path,
                                 final String attribute ) throws UnsupportedOperationExceptionIllegalArgumentException, IOException, SecurityException {
         return .getAttributepathattribute );
     }
 
     @Override
     public FileTime getLastModifiedTimefinal Path path ) throws IllegalArgumentException, IOException, SecurityException {
         return .getLastModifiedTimepath );
     }
 
     @Override
     public long sizefinal Path path ) throws IllegalArgumentException, IOException, SecurityException {
         return .sizepath );
     }
 
     @Override
     public boolean existsfinal Path path ) throws IllegalArgumentExceptionSecurityException {
         return .existspath );
     }
 
     @Override
     public boolean notExistsfinal Path path ) throws IllegalArgumentExceptionSecurityException {
         return .notExistspath );
     }
 
     @Override
     public boolean isSameFilefinal Path path,
                                final Path path2 ) throws IllegalArgumentException, IOException, SecurityException {
         return .isSameFilepathpath2 );
     }
 
     @Override
     public BufferedReader newBufferedReaderfinal Path path,
                                              final Charset cs ) throws IllegalArgumentException, NoSuchFileException, IOException, SecurityException {
         return .newBufferedReaderpathcs );
     }
 
     @Override
     public byte[] readAllBytesfinal Path path ) throws IOException, OutOfMemoryErrorSecurityException {
         return .readAllBytespath );
     }
 
     @Override
     public List<StringreadAllLinesfinal Path path ) throws IllegalArgumentException, NoSuchFileException, IOException, SecurityException {
         return .readAllLinespath );
     }
 
     @Override
     public List<StringreadAllLinesfinal Path path,
                                       final Charset cs ) throws IllegalArgumentException, NoSuchFileException, IOException, SecurityException {
         return .readAllLinespathcs );
     }
 
     @Override
     public String readAllStringfinal Path path,
                                  final Charset cs ) throws IllegalArgumentException, NoSuchFileException, IOException {
         return .readAllStringpathcs );
     }
 
     @Override
     public String readAllStringfinal Path path ) throws IllegalArgumentException, NoSuchFileException, IOException {
         return .readAllStringpath );
     }
 
     @Override
     public Path writefinal Path path,
                        final byte[] bytes,
                        final OpenOption... options ) throws IOException, UnsupportedOperationExceptionSecurityException {
         if ( isBatchpath.getFileSystem() ) ) {
             return .writepathbytesoptions );
         }
 
         return new FileSystemSyncLock<Path>( .getId(), path.getFileSystem() ).execute( new FutureTask<Path>( new Callable<Path>() {
             @Override
             public Path call() throws Exception {
                 return .writepathbytesoptions );
             }
         } ) );
     }
 
     @Override
     public Path writefinal Path path,
                        final byte[] bytes,
                        final Map<String, ?> attrs,
                        final OpenOption... options ) throws IOException, UnsupportedOperationExceptionSecurityException {
         if ( isBatchpath.getFileSystem() ) ) {
             return .writepathbytesattrsoptions );
         }
 
         return new FileSystemSyncLock<Path>( .getId(), path.getFileSystem() ).execute( new FutureTask<Path>( new Callable<Path>() {
             @Override
             public Path call() throws Exception {
                 return .writepathbytesattrsoptions );
             }
         } ) );
     }
 
     @Override
     public Path writefinal Path path,
                        final byte[] bytes,
                        final Set<? extends OpenOption> options,
                        final FileAttribute<?>... attrs ) throws IllegalArgumentException, IOException, UnsupportedOperationException {
         if ( isBatchpath.getFileSystem() ) ) {
             return .writepathbytesoptionsattrs );
         }
 
         return new FileSystemSyncLock<Path>( .getId(), path.getFileSystem() ).execute( new FutureTask<Path>( new Callable<Path>() {
             @Override
             public Path call() throws Exception {
                 return .writepathbytesoptionsattrs );
             }
         } ) );
     }
 
     @Override
     public Path writefinal Path path,
                        final Iterable<? extends CharSequencelines,
                        final Charset cs,
                        final OpenOption... options ) throws IllegalArgumentException, IOException, UnsupportedOperationExceptionSecurityException {
         if ( isBatchpath.getFileSystem() ) ) {
             return .writepathlinescsoptions );
         }
 
         return new FileSystemSyncLock<Path>( .getId(), path.getFileSystem() ).execute( new FutureTask<Path>( new Callable<Path>() {
             @Override
             public Path call() throws Exception {
                 return .writepathlinescsoptions );
             }
         } ) );
     }
 
     @Override
     public Path writefinal Path path,
                        final String content,
                        final OpenOption... options ) throws IllegalArgumentException, IOException, UnsupportedOperationException {
         if ( isBatchpath.getFileSystem() ) ) {
             return .writepathcontentoptions );
         }
 
         return new FileSystemSyncLock<Path>( .getId(), path.getFileSystem() ).execute( new FutureTask<Path>( new Callable<Path>() {
             @Override
             public Path call() throws Exception {
                 return .writepathcontentoptions );
             }
         } ) );
     }
 
     @Override
     public Path writefinal Path path,
                        final String content,
                        final Charset cs,
                        final OpenOption... options ) throws IllegalArgumentException, IOException, UnsupportedOperationException {
         if ( isBatchpath.getFileSystem() ) ) {
             return .writepathcontentcsoptions );
         }
 
         return new FileSystemSyncLock<Path>( .getId(), path.getFileSystem() ).execute( new FutureTask<Path>( new Callable<Path>() {
             @Override
             public Path call() throws Exception {
                 return .writepathcontentcsoptions );
             }
         } ) );
     }
 
     @Override
     public Path writefinal Path path,
                        final String content,
                        final Set<? extends OpenOption> options,
                        final FileAttribute<?>... attrs ) throws IllegalArgumentException, IOException, UnsupportedOperationException {
         if ( isBatchpath.getFileSystem() ) ) {
             return .writepathcontentoptionsattrs );
         }
 
         return new FileSystemSyncLock<Path>( .getId(), path.getFileSystem() ).execute( new FutureTask<Path>( new Callable<Path>() {
             @Override
             public Path call() throws Exception {
                 return .writepathcontentoptionsattrs );
             }
         } ) );
     }
 
     @Override
     public Path writefinal Path path,
                        final String content,
                        final Charset cs,
                        final Set<? extends OpenOption> options,
                        final FileAttribute<?>... attrs ) throws IllegalArgumentException, IOException, UnsupportedOperationException {
         if ( isBatchpath.getFileSystem() ) ) {
             return .writepathcontentcsoptionsattrs );
         }
 
         return new FileSystemSyncLock<Path>( .getId(), path.getFileSystem() ).execute( new FutureTask<Path>( new Callable<Path>() {
             @Override
             public Path call() throws Exception {
                 return .writepathcontentcsoptionsattrs );
             }
         } ) );
     }
 
     @Override
     public Path writefinal Path path,
                        final String content,
                        final Map<String, ?> attrs,
                        final OpenOption... options ) throws IllegalArgumentException, IOException, UnsupportedOperationException {
         if ( isBatchpath.getFileSystem() ) ) {
             return .writepathcontentattrsoptions );
         }
 
         return new FileSystemSyncLock<Path>( .getId(), path.getFileSystem() ).execute( new FutureTask<Path>( new Callable<Path>() {
             @Override
             public Path call() throws Exception {
                 return .writepathcontentattrsoptions );
             }
         } ) );
     }
 
     @Override
     public Path writefinal Path path,
                        final String content,
                        final Charset cs,
                        final Map<String, ?> attrs,
                        final OpenOption... options ) throws IllegalArgumentException, IOException, UnsupportedOperationException {
         if ( isBatchpath.getFileSystem() ) ) {
             return .writepathcontentcsattrsoptions );
         }
 
         return new FileSystemSyncLock<Path>( .getId(), path.getFileSystem() ).execute( new FutureTask<Path>( new Callable<Path>() {
             @Override
             public Path call() throws Exception {
                 return .writepathcontentcsattrsoptions );
             }
         } ) );
     }
 
     @Override
     public OutputStream newOutputStreamfinal Path path,
                                          final OpenOption... options ) throws IllegalArgumentExceptionUnsupportedOperationException, IOException, SecurityException {
         final OutputStream out = .newOutputStreampathoptions );
         return new OutputStream() {
             @Override
             public void writefinal int b ) throws java.io.IOException {
                 out.writeb );
             }
 
             @Override
             public void close() throws java.io.IOException {
                 if ( isBatchpath.getFileSystem() ) ) {
                     out.close();
                 } else {
                     new FileSystemSyncLock<Void>( .getId(), path.getFileSystem() ).execute( new FutureTask<Void>( new Callable<Void>() {
                         @Override
                         public Void call() throws Exception {
                             out.close();
                             return null;
                         }
                     } ) );
                 }
             }
         };
     }
 
     @Override
     public SeekableByteChannel newByteChannelfinal Path path,
                                                final OpenOption... options ) throws IllegalArgumentExceptionUnsupportedOperationException, FileAlreadyExistsException, IOException, SecurityException {
         final SeekableByteChannel sbc = .newByteChannelpathoptions );
 
         return new SeekableByteChannelWrapperImpl( sbc ) {
             @Override
             public void close() throws java.io.IOException {
                 if ( isBatchpath.getFileSystem() ) ) {
                     sbc.close();
                 } else {
                     new FileSystemSyncLock<Void>( .getId(), path.getFileSystem() ).execute( new FutureTask<Void>( new Callable<Void>() {
                         @Override
                         public Void call() throws Exception {
                             sbc.close();
                             return null;
                         }
                     } ) );
                 }
             }
         };
     }
 
     @Override
     public SeekableByteChannel newByteChannelfinal Path path,
                                                final Set<? extends OpenOption> options,
                                                final FileAttribute<?>... attrs ) throws IllegalArgumentExceptionUnsupportedOperationException, FileAlreadyExistsException, IOException, SecurityException {
         final SeekableByteChannel sbc = .newByteChannelpathoptionsattrs );
 
         return new SeekableByteChannelWrapperImpl( sbc ) {
             @Override
             public void close() throws java.io.IOException {
                 if ( isBatchpath.getFileSystem() ) ) {
                     sbc.close();
                 } else {
                     new FileSystemSyncLock<Void>( .getId(), path.getFileSystem() ).execute( new FutureTask<Void>( new Callable<Void>() {
                         @Override
                         public Void call() throws Exception {
                             sbc.close();
                             return null;
                         }
                     } ) );