Package com.asakusafw.runtime.util

Examples of com.asakusafw.runtime.util.VariableTable


    }

    static VariableTable getVariableTable(JobContext context) {
        assert context != null;
        String arguments = context.getConfiguration().get(StageConstants.PROP_ASAKUSA_BATCH_ARGS, "");
        VariableTable variables = new VariableTable(VariableTable.RedefineStrategy.IGNORE);
        variables.defineVariables(arguments);
        return variables;
    }
View Full Code Here


    public static class Initializer implements RuntimeResource {

        @Override
        public void setup(ResourceConfiguration configuration) throws IOException, InterruptedException {
            String arguments = configuration.get(StageConstants.PROP_ASAKUSA_BATCH_ARGS, "");
            VariableTable variables = new VariableTable(VariableTable.RedefineStrategy.IGNORE);
            variables.defineVariables(arguments);
            BatchContext context = new BatchContext(variables.getVariables());
            CONTEXTS.set(context);
        }
View Full Code Here

     * @throws Exception
     */
    @Test
    public void loadImportParamTest02() throws Exception {
        // 環境変数を設定
        VariableTable table = new VariableTable();
        table.defineVariable("user_name", "asakusa");
        table.defineVariable("user_pass", "hadoop");
        Map<String, String> env = new HashMap<String, String>();
        env.put(Constants.THUNDER_GATE_HOME, System.getenv(Constants.THUNDER_GATE_HOME));
        env.put(Constants.ENV_ARGS, table.toSerialString());
        ConfigurationLoader.setEnv(env);

        JobFlowParamLoader loder = new JobFlowParamLoader(){
            @Override
            protected Properties getImportProp(File dslFile, String targetName) throws IOException {
View Full Code Here

     * @throws Exception
     */
    @Test
    public void loadImportParamTest05() throws Exception {
        // 環境変数を設定
        VariableTable table = new VariableTable();
        table.defineVariable("user_pass", "hadoop");
        Map<String, String> env = new HashMap<String, String>();
        env.put(Constants.THUNDER_GATE_HOME, System.getenv(Constants.THUNDER_GATE_HOME));
        env.put(Constants.ENV_ARGS, table.toSerialString());
        ConfigurationLoader.setEnv(env);

        JobFlowParamLoader loder = new JobFlowParamLoader(){
            @Override
            protected Properties getImportProp(File dslFile, String targetName) throws IOException {
View Full Code Here

    /**
     * 現在の環境で利用する変数表を新しく作成して返す。
     * @return 現在の環境で利用する変数表
     */
    public static VariableTable createVariableTable() {
        VariableTable variables = new VariableTable(RedefineStrategy.OVERWRITE);
        variables.defineVariable("__caller__", String.valueOf(ConfigurationLoader.getEnvProperty("USER")));
        String args = ConfigurationLoader.getEnvProperty(ENV_ARGS);
        if (args != null) {
            variables.defineVariables(args);
        }
        return variables;
    }
View Full Code Here

        if (basePathString == null || basePathString.isEmpty()) {
            basePath = null;
        } else {
            basePath = new Path(basePathString);
        }
        VariableTable variables = Constants.createVariableTable();
        variables.defineVariable(Constants.HDFS_PATH_VARIABLE_USER, user);
        variables.defineVariable(Constants.HDFS_PATH_VARIABLE_EXECUTION_ID, executionId);
        FileSystem fs;
        try {
            if (basePath == null) {
                fs = FileSystem.get(conf);
            } else {
                fs = FileSystem.get(basePath.toUri(), conf);
                basePath = fs.makeQualified(basePath);
            }
        } catch (IOException e) {
            throw new BulkLoaderSystemException(e, CLASS, "TG-COMMON-00019", rawPaths);
        }
        List<Path> results = new ArrayList<Path>();
        for (String rawPath : rawPaths) {
            String resolved = variables.parse(rawPath, false);
            Path fullPath;
            if (basePath == null) {
                fullPath = fs.makeQualified(new Path(resolved));
            } else {
                fullPath = new Path(basePath, resolved);
View Full Code Here

    }

    private void dumpCleaner(Context context, JobflowModel model) {
        assert context != null;
        assert model != null;
        VariableTable variables = new VariableTable();
        variables.defineVariable(StageConstants.VAR_USER, "$USER");
        variables.defineVariable(StageConstants.VAR_BATCH_ID, "$" + VAR_BATCH_ID);
        variables.defineVariable(StageConstants.VAR_FLOW_ID, "$" + VAR_FLOW_ID);
        variables.defineVariable(StageConstants.VAR_EXECUTION_ID, EXPR_EXECUTION_ID);
        String path = getEnvironment().getConfiguration().getRootLocation().toPath('/');
        try {
            String parsed = variables.parse(path, true);
            context.put("# Cleaner");
            context.put("echo \"cleaning job temporary resources\"");
            context.put("{0} {1} {2} {3} {4} {5}",
                    quote(PREFIX_APP_HOME + CMD_CLEANER),
                    quote(parsed),
View Full Code Here

     * @throws IOException ファイルの読み込みに失敗した場合
     */
    private static void loadProperties(List<String> propertyPaths) throws IOException {
        assert propertyPaths != null;
        Properties properties = loadRawProperties(propertyPaths);
        VariableTable variables = new VariableTable(RedefineStrategy.IGNORE);
        putAll(variables, sysProp);
        putAll(variables, env);
        prop.putAll(resolveProperties(variables, properties));
    }
View Full Code Here

    private String createSearchCondition(
            String serchCondition,
            String targetName,
            String jobflowId,
            String fileName) {
        VariableTable variables = Constants.createVariableTable();
        try {
            return variables.parse(serchCondition, true);
        } catch (IllegalArgumentException e) {
            LOG.error("TG-COMMON-00002",
                    "検索条件の置換文字に対応する変数が存在しない。検索条件:" + serchCondition,
                    targetName, jobflowId, fileName);
            return null;
View Full Code Here

                        targetName, jobflowId, tableName, fileName);
                return false;
            } else {
                try {
                    // 有効なパスかチェック
                    VariableTable variables = Constants.createVariableTable();
                    variables.defineVariable(Constants.HDFS_PATH_VARIABLE_USER, "dummyuser");
                    variables.defineVariable(Constants.HDFS_PATH_VARIABLE_EXECUTION_ID, "dummyid");
                    String dummyPath = variables.parse(path, false);
                    new URI(dummyPath).normalize();
                } catch (URISyntaxException e) {
                    LOG.error(e, "TG-COMMON-00004",
                            "HDFS上に書き出す際のファイルパスが有効でない",
                            targetName, jobflowId, tableName, fileName);
View Full Code Here

TOP

Related Classes of com.asakusafw.runtime.util.VariableTable

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.