private void logSevereProblem(String message, Exception e) { if (commandLineArgs.isStackTraceDump()) { commandLineContext.getLogger().log(Level.SEVERE, message, e); } else { commandLineContext.getLogger().severe(message); } }
private void printHelp() { if (commandLineArgs.getOperatorName() != null) { commandLineContext.print( CommandLineUsage.getUsageTextForOperator(commandLineArgs.getOperatorName())); } else if (commandLineArgs.getGraphFilePath() != null) { commandLineContext.print( CommandLineUsage.getUsageTextForGraph( commandLineArgs.getGraphFilePath(), commandLineContext)); } else { commandLineContext.print(CommandLineUsage.getUsageText()); } }
private void runVelocityTemplates() { String velocityDirPath = commandLineArgs.getVelocityTemplateDirPath(); File velocityDir; if (velocityDirPath != null) { velocityDir = new File(velocityDirPath); } else { velocityDir = new File(CommandLineArgs.DEFAULT_VELOCITY_TEMPLATE_DIRPATH); } String[] templateNames = velocityDir.list( new FilenameFilter() { @Override public boolean accept(File dir, String name) { return name.toLowerCase().endsWith(CommandLineArgs.VELOCITY_TEMPLATE_EXTENSION); } }); Logger logger = commandLineContext.getLogger(); if (templateNames == null) { String msgPattern = "Velocity template directory '%s' does not exist or inaccessible"; logger.severe(String.format(msgPattern, velocityDir)); return; } if (templateNames.length == 0) { String msgPattern = "Velocity template directory '%s' does not contain any templates (*.vm)"; logger.warning(String.format(msgPattern, velocityDir)); return; } // It can happen that we have no target file when the operator implements the Output interface if (!commandLineContext.isFile(commandLineArgs.getTargetFilePath())) { String msgPattern = "Target file '%s' does not exist, but is required to process velocity templates"; logger.warning(String.format(msgPattern, commandLineArgs.getTargetFilePath())); return; } for (String templateName : templateNames) { try { metadataResourceEngine.writeRelatedResource( velocityDir + "/" + templateName, commandLineArgs.getTargetFilePath()); } catch (IOException e) { String msgPattern = "Can't write related resource using template file '%s': %s"; logSevereProblem(String.format(msgPattern, templateName, e.getMessage()), e); } } }
private void readMetadata(String path, boolean fail) throws Exception { try { metadataResourceEngine.readResource("metadata", path); } catch (Exception e) { if (fail) { throw e; } final String message = String.format("Failed to read metadata file '%s': %s", path, e.getMessage()); if (commandLineContext.fileExists(path)) { logSevereProblem(message, e); } else { commandLineContext.getLogger().warning(message); } } }
private void initializeJAI() { long tileCacheCapacity = commandLineArgs.getTileCacheCapacity(); int tileSchedulerParallelism = commandLineArgs.getTileSchedulerParallelism(); if (tileCacheCapacity > 0) { JAI.enableDefaultTileCache(); JAI.getDefaultInstance().getTileCache().setMemoryCapacity(tileCacheCapacity); } else { JAI.getDefaultInstance().getTileCache().setMemoryCapacity(0L); JAI.disableDefaultTileCache(); } if (tileSchedulerParallelism > 0) { JAI.getDefaultInstance().getTileScheduler().setParallelism(tileSchedulerParallelism); } final long tileCacheSize = JAI.getDefaultInstance().getTileCache().getMemoryCapacity() / (1024L * 1024L); commandLineContext .getLogger() .info(MessageFormat.format("JAI tile cache size is {0} MB", tileCacheSize)); final int schedulerParallelism = JAI.getDefaultInstance().getTileScheduler().getParallelism(); commandLineContext .getLogger() .info(MessageFormat.format("JAI tile scheduler parallelism is {0}", schedulerParallelism)); }
private Product createOpProduct( String opName, Map<String, Object> parameters, Map<String, Product> sourceProducts) throws OperatorException { return commandLineContext.createOpProduct(opName, parameters, sourceProducts); }
void executeGraph(Graph graph) throws GraphException { commandLineContext.executeGraph(graph, this); }
Graph readGraph(String filePath, Map<String, String> templateVariables) throws IOException, GraphException { return commandLineContext.readGraph(filePath, templateVariables); }
void writeProduct( Product targetProduct, String filePath, String formatName, boolean clearCacheAfterRowWrite) throws IOException { commandLineContext.writeProduct(targetProduct, filePath, formatName, clearCacheAfterRowWrite); }
Product readProduct(String filePath) throws IOException { return commandLineContext.readProduct(filePath); }