/* * To change this template, choose Tools | Templates * and open the template in the editor. */ package org.autoplot.datasource; import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeListener; import java.beans.PropertyChangeSupport; import java.io.File; import java.io.FileNotFoundException; import java.net.URI; import java.net.UnknownHostException; import java.util.Date; import java.util.HashMap; import java.util.Map; import java.util.logging.Level; import java.util.logging.Logger; import org.das2.util.LoggerManager; import org.das2.util.filesystem.FileObject; import org.das2.util.filesystem.FileSystem; import org.das2.util.filesystem.LocalFileSystem; import org.autoplot.datasource.capability.Updating; /** * * @author jbf */ public class FilePollUpdating implements Updating { private static final Logger logger= LoggerManager.getLogger("apdss.updating"); URI pollURI; FileSystem fs; // remote source of the file FileObject fo; // remote FileObject. //long pollMtime; //long pollMsize; long dirHash; long pollCyclePeriodSeconds; private final static int LIMIT_SHORT_CYCLE_PERIOD_SECONDS= 1; private final static int LIMIT_SHORT_REMOTE_CYCLE_PERIOD_SECONDS= 10; boolean dirty= false; //true indicates the hash has changed and we need to clean. //boolean polling= false; //true indicates we are polling. private static Map myThreads= new HashMap(); public FilePollUpdating( URI uri, long pollCyclePeriodSeconds ) throws FileSystem.FileSystemOfflineException, UnknownHostException, FileNotFoundException { this.pollURI= uri; URISplit split= URISplit.parse(uri); fs= FileSystem.create(split.path); fo= fs.getFileObject(split.file.substring(split.path.length())); if ( fs instanceof LocalFileSystem ) { if ( pollCyclePeriodSeconds