@Test(expected=RuntimeException.class) public void testReadCurrentIdWithoutDir() throws Exception { process.run(portBindings, conf, setParams(CacheMetadataManagingProcess.MODE_READ_CURRENT_ID, null)); }
@Override public void run(PortBindings portBindings, Configuration conf, Map<String, String> parameters) throws Exception { String mode = parameters.get(PARAM_MODE); Properties props = new Properties(); String cacheDirParamValue = parameters.get(PARAM_CACHE_DIR); Preconditions.checkNotNull(cacheDirParamValue, "cache directory location not provided! " + "'" + PARAM_CACHE_DIR + "' parameter is missing!"); Path cacheDir = new Path(cacheDirParamValue); switch(mode) { case MODE_READ_CURRENT_ID: { props.setProperty(OUTPUT_PROPERTY_CACHE_ID, getExistingCacheId(conf, cacheDir)); break; } case MODE_GENERATE_NEW_ID: { props.setProperty(OUTPUT_PROPERTY_CACHE_ID, generateNewCacheId(conf, cacheDir)); break; } case MODE_WRITE_ID: { writeCacheId(conf, cacheDir, parameters.get(PARAM_ID)); break; } case MODE_READ_META: { readMeta(conf, cacheDir, props); break; } case MODE_WRITE_META: { writeMeta(conf, cacheDir, parameters.get(PARAM_ID), parameters.get(PARAM_NEXT_RECORD_INDEX)); break; } default: { throw new RuntimeException("unsupported mode: " + mode); } } File file = new File(System.getProperty(OOZIE_ACTION_OUTPUT_FILENAME)); OutputStream os = new FileOutputStream(file); try { props.store(os, ""); } finally { os.close(); } }
CacheMetadataManagingProcess implements eu.dnetlib.iis.common.java.Process { @Override public void run(PortBindings portBindings, Configuration conf, Map<String, String> parameters) throws Exception { String mode = parameters.get(PARAM_MODE); Properties props = new Properties(); String cacheDirParamValue = parameters.get(PARAM_CACHE_DIR); Preconditions.checkNotNull(cacheDirParamValue, "cache directory location not provided! " + "'" + PARAM_CACHE_DIR + "' parameter is missing!"); Path cacheDir = new Path(cacheDirParamValue); switch(mode) { case MODE_READ_CURRENT_ID: { props.setProperty(OUTPUT_PROPERTY_CACHE_ID, getExistingCacheId(conf, cacheDir)); break; } case MODE_GENERATE_NEW_ID: { props.setProperty(OUTPUT_PROPERTY_CACHE_ID, generateNewCacheId(conf, cacheDir)); break; } case MODE_WRITE_ID: { writeCacheId(conf, cacheDir, parameters.get(PARAM_ID)); break; } case MODE_READ_META: { readMeta(conf, cacheDir, props); break; } case MODE_WRITE_META: { writeMeta(conf, cacheDir, parameters.get(PARAM_ID), parameters.get(PARAM_NEXT_RECORD_INDEX)); break; } default: { throw new RuntimeException("unsupported mode: " + mode); } } File file = new File(System.getProperty(OOZIE_ACTION_OUTPUT_FILENAME)); OutputStream os = new FileOutputStream(file); try { props.store(os, ""); } finally { os.close(); } } }
CacheMetadataManagingProcess implements eu.dnetlib.iis.common.java.Process { @Override public void run(PortBindings portBindings, Configuration conf, Map<String, String> parameters) throws Exception { String mode = parameters.get(PARAM_MODE); Properties props = new Properties(); String cacheDirParamValue = parameters.get(PARAM_CACHE_DIR); Preconditions.checkNotNull(cacheDirParamValue, "cache directory location not provided! " + "'" + PARAM_CACHE_DIR + "' parameter is missing!"); Path cacheDir = new Path(cacheDirParamValue); switch(mode) { case MODE_READ_CURRENT_ID: { props.setProperty(OUTPUT_PROPERTY_CACHE_ID, getExistingCacheId(conf, cacheDir)); break; } case MODE_GENERATE_NEW_ID: { props.setProperty(OUTPUT_PROPERTY_CACHE_ID, generateNewCacheId(conf, cacheDir)); break; } case MODE_WRITE_ID: { writeCacheId(conf, cacheDir, parameters.get(PARAM_ID)); break; } case MODE_READ_META: { readMeta(conf, cacheDir, props); break; } case MODE_WRITE_META: { writeMeta(conf, cacheDir, parameters.get(PARAM_ID), parameters.get(PARAM_NEXT_RECORD_INDEX)); break; } default: { throw new RuntimeException("unsupported mode: " + mode); } } File file = new File(System.getProperty(OOZIE_ACTION_OUTPUT_FILENAME)); OutputStream os = new FileOutputStream(file); try { props.store(os, ""); } finally { os.close(); } } CacheMetadataManagingProcess();  CacheMetadataManagingProcess(FileSystemFacadeFactory fsFacadeFactory); }
CacheMetadataManagingProcess implements eu.dnetlib.iis.common.java.Process { @Override public void run(PortBindings portBindings, Configuration conf, Map<String, String> parameters) throws Exception { String mode = parameters.get(PARAM_MODE); Properties props = new Properties(); String cacheDirParamValue = parameters.get(PARAM_CACHE_DIR); Preconditions.checkNotNull(cacheDirParamValue, "cache directory location not provided! " + "'" + PARAM_CACHE_DIR + "' parameter is missing!"); Path cacheDir = new Path(cacheDirParamValue); switch(mode) { case MODE_READ_CURRENT_ID: { props.setProperty(OUTPUT_PROPERTY_CACHE_ID, getExistingCacheId(conf, cacheDir)); break; } case MODE_GENERATE_NEW_ID: { props.setProperty(OUTPUT_PROPERTY_CACHE_ID, generateNewCacheId(conf, cacheDir)); break; } case MODE_WRITE_ID: { writeCacheId(conf, cacheDir, parameters.get(PARAM_ID)); break; } case MODE_READ_META: { readMeta(conf, cacheDir, props); break; } case MODE_WRITE_META: { writeMeta(conf, cacheDir, parameters.get(PARAM_ID), parameters.get(PARAM_NEXT_RECORD_INDEX)); break; } default: { throw new RuntimeException("unsupported mode: " + mode); } } File file = new File(System.getProperty(OOZIE_ACTION_OUTPUT_FILENAME)); OutputStream os = new FileOutputStream(file); try { props.store(os, ""); } finally { os.close(); } } CacheMetadataManagingProcess();  CacheMetadataManagingProcess(FileSystemFacadeFactory fsFacadeFactory); @Override Map<String, PortType> getInputPorts(); @Override Map<String, PortType> getOutputPorts(); @Override void run(PortBindings portBindings, Configuration conf,
            Map<String, String> parameters); String getExistingCacheId(Configuration conf, Path cacheDir); Properties readMeta(Configuration conf, Path cacheDir, Properties props); String generateNewCacheId(Configuration conf, Path cacheDir); void writeCacheId(Configuration conf, Path cacheDir, String cacheId); void writeMeta(Configuration conf, Path cacheDir, String cacheId, String nextRecordIndex); }
CacheMetadataManagingProcess implements eu.dnetlib.iis.common.java.Process { @Override public void run(PortBindings portBindings, Configuration conf, Map<String, String> parameters) throws Exception { String mode = parameters.get(PARAM_MODE); Properties props = new Properties(); String cacheDirParamValue = parameters.get(PARAM_CACHE_DIR); Preconditions.checkNotNull(cacheDirParamValue, "cache directory location not provided! " + "'" + PARAM_CACHE_DIR + "' parameter is missing!"); Path cacheDir = new Path(cacheDirParamValue); switch(mode) { case MODE_READ_CURRENT_ID: { props.setProperty(OUTPUT_PROPERTY_CACHE_ID, getExistingCacheId(conf, cacheDir)); break; } case MODE_GENERATE_NEW_ID: { props.setProperty(OUTPUT_PROPERTY_CACHE_ID, generateNewCacheId(conf, cacheDir)); break; } case MODE_WRITE_ID: { writeCacheId(conf, cacheDir, parameters.get(PARAM_ID)); break; } case MODE_READ_META: { readMeta(conf, cacheDir, props); break; } case MODE_WRITE_META: { writeMeta(conf, cacheDir, parameters.get(PARAM_ID), parameters.get(PARAM_NEXT_RECORD_INDEX)); break; } default: { throw new RuntimeException("unsupported mode: " + mode); } } File file = new File(System.getProperty(OOZIE_ACTION_OUTPUT_FILENAME)); OutputStream os = new FileOutputStream(file); try { props.store(os, ""); } finally { os.close(); } } CacheMetadataManagingProcess();  CacheMetadataManagingProcess(FileSystemFacadeFactory fsFacadeFactory); @Override Map<String, PortType> getInputPorts(); @Override Map<String, PortType> getOutputPorts(); @Override void run(PortBindings portBindings, Configuration conf,
            Map<String, String> parameters); String getExistingCacheId(Configuration conf, Path cacheDir); Properties readMeta(Configuration conf, Path cacheDir, Properties props); String generateNewCacheId(Configuration conf, Path cacheDir); void writeCacheId(Configuration conf, Path cacheDir, String cacheId); void writeMeta(Configuration conf, Path cacheDir, String cacheId, String nextRecordIndex); static final String OUTPUT_PROPERTY_CACHE_ID; static final String OUTPUT_PROPERTY_NEXT_RECORD_INDEX; static final String PARAM_CACHE_DIR; static final String PARAM_MODE; static final String PARAM_ID; static final String PARAM_NEXT_RECORD_INDEX; static final String MODE_READ_CURRENT_ID; static final String MODE_GENERATE_NEW_ID; static final String MODE_WRITE_ID; static final String MODE_READ_META; static final String MODE_WRITE_META; static final String DEFAULT_METAFILE_NAME; static final int CACHE_ID_PADDING_LENGTH; static final String UNDEFINED; static final String DEFAULT_ENCODING; }