package com.collective.celos;

import java.net.URI;
import java.util.HashMap;
import java.util.Map;

import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;

/**
 * Check in HDFS for a data dependency.
 */
public class HDFSCheckTrigger implements Trigger {

    private final ScheduledTimeFormatter formatter = new ScheduledTimeFormatter();
    private final FileSystem fs;
    private final String rawPathString;
    private final String fsString;

    private static final Map<String, FileSystem> cachedFSs = new HashMap<>();

    public HDFSCheckTrigger(String rawPathString, String fsString) throws Exception {
        this.rawPathString = Util.requireNonNull(rawPathString);
        this.fsString = Util.requireNonNull(fsString);

        synchronized (cachedFSs) {
            if (cachedFSs.containsKey(fsString)) {
                this.fs = cachedFSs.get(fsString);
            } else {
                this.fs = FileSystem.get(new URI(fsString), new Configuration());
                cachedFSs.put(fsString, this.fs);
            }
        }
    }

    @Override
    public boolean isDataAvailable(ScheduledTime now, ScheduledTime t) throws Exception {
        Path path = new Path(formatter.replaceTimeTokens(rawPathString, t));
        return fs.exists(path);
    }

    public String getFsString() {
        return fsString;
    }

    public String getRawPathString() {
        return rawPathString;
    }

}

@@ -796,47 +796,8 @@
 );%0A%0A
-        synchronized (cachedFSs) %7B%0A    
     
@@ -843,36 +843,32 @@
 ) %7B%0A            
-    
 this.fs = cached
@@ -894,20 +894,16 @@
         
- 
-   
 %7D else %7B
@@ -903,20 +903,16 @@
  else %7B%0A
-    
         
@@ -993,20 +993,16 @@
         
- 
-   
 cachedFS
@@ -1031,22 +1031,8 @@
 s);%0A
-            %7D%0A
     

Remove unneeded synchronized block.