GH-109: Refactor Hadoop Accessor to do command pattern
------------------------------------------------------

                 Key: OOZIE-135
                 URL: https://issues.apache.org/jira/browse/OOZIE-135
             Project: Oozie
          Issue Type: Bug
            Reporter: Hadoop QA


All Hadoop JobClient?/FileSystem access should be done using the following:

    public interface HadoopFSCommand {
        public void call(FileSystem fs) throws HadoopCommandException;
    }

    public interface HadoopJobCommand {
        public void call(JobClient jobClient, FileSystem fs) throws 
HadoopCommandException;
    }

    //This replaces current StoreService
    public class HadoopAccessorService implements Service {
        ...

        public void execute(final HadoopFSCommand fsCommand) throws 
HadoopCommandException {
            //all instrumentation is missing here
            UGI.doAs(
                    FileSystem fs = GET FS
                    try {
                        fsCommand.call(fs);                    
                    }
                    finally {
                      fs.close();        
                    }
            );
        }

        public void execute(final HadoopJobCommand fsCommand) throws 
HadoopCommandException {
            //all instrumentation is missing here
            UGI.doAs(
                    FileSystem fs = GET FS
                    JobClient jc = GET_JC
                    try {
                        fsCommand.call(jc, fs);                    
                    }
                    finally {
                      try {
                          jc.close();
                      }
                      catch () {                          
                      }
                      try {
                          fs.close();        
                      }
                      catch () {                          
                      }
                    }
            );
        }
    }

The accessor should have the USER-UGI second level cache and a a config value 
should specify if the cache is to be used
or not (if OFF do fs.close() on every call, if ON, do nothing, and cache should 
do eviction on no use timeout)

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

Reply via email to