@Test public void resolve() throws Exception { HadoopScript script = new HadoopScript( "testing", set(), "com.example.Client", map("home", ExecutionScript.PLACEHOLDER_HOME, "exec", ExecutionScript.PLACEHOLDER_EXECUTION_ID, "args", ExecutionScript.PLACEHOLDER_ARGUMENTS), map("ASAKUSA_HOME", ExecutionScript.PLACEHOLDER_HOME)); ExecutionContext context = new ExecutionContext("b", "f", "e", ExecutionPhase.MAIN, map("arg", "ARG")); HadoopScript resolved = script.resolve(context, handler(ExecutionScriptHandler.KEY_ENV_PREFIX + "ASAKUSA_HOME", "ah")); assertThat(resolved.isResolved(), is(true)); assertThat(resolved.getHadoopProperties().size(), is(3)); assertThat(resolved.getHadoopProperties().get("home"), is("ah")); assertThat(resolved.getHadoopProperties().get("exec"), is("e")); assertThat(resolved.getHadoopProperties().get("args"), is(context.getArgumentsAsString())); assertThat(resolved.getEnvironmentVariables().size(), is(1)); assertThat(resolved.getEnvironmentVariables().get("ASAKUSA_HOME"), is("ah")); }
@Override public HadoopScript resolve( ExecutionContext context, ExecutionScriptHandler<?> handler) throws InterruptedException, IOException { if (context == null) { throw new IllegalArgumentException("context must not be null"); } if (handler == null) { throw new IllegalArgumentException("handler must not be null"); } if (isResolved()) { return this; } LOG.debug("Resolving {}", this); PlaceholderResolver resolver = new PlaceholderResolver(this, context, handler); Map<String, String> resolvedProperties = new LinkedHashMap<>(); for (Map.Entry<String, String> entry : getHadoopProperties().entrySet()) { resolvedProperties.put(entry.getKey(), resolver.resolve(entry.getValue())); } LOG.debug("Resolved Hadoop properties: {}", resolvedProperties); Map<String, String> resolvedEnvironments = new LinkedHashMap<>(); for (Map.Entry<String, String> entry : getEnvironmentVariables().entrySet()) { resolvedEnvironments.put(entry.getKey(), resolver.resolve(entry.getValue())); } LOG.debug("Resolved environment variables: {}", resolvedEnvironments); return new HadoopScript( getId(), getBlockerIds(), className, resolvedProperties, resolvedEnvironments, supportedExtensions, true); }
HadoopScript implements ExecutionScript { @Override public HadoopScript resolve( ExecutionContext context, ExecutionScriptHandler<?> handler) throws InterruptedException, IOException { if (context == null) { throw new IllegalArgumentException("context must not be null"); } if (handler == null) { throw new IllegalArgumentException("handler must not be null"); } if (isResolved()) { return this; } LOG.debug("Resolving {}", this); PlaceholderResolver resolver = new PlaceholderResolver(this, context, handler); Map<String, String> resolvedProperties = new LinkedHashMap<>(); for (Map.Entry<String, String> entry : getHadoopProperties().entrySet()) { resolvedProperties.put(entry.getKey(), resolver.resolve(entry.getValue())); } LOG.debug("Resolved Hadoop properties: {}", resolvedProperties); Map<String, String> resolvedEnvironments = new LinkedHashMap<>(); for (Map.Entry<String, String> entry : getEnvironmentVariables().entrySet()) { resolvedEnvironments.put(entry.getKey(), resolver.resolve(entry.getValue())); } LOG.debug("Resolved environment variables: {}", resolvedEnvironments); return new HadoopScript( getId(), getBlockerIds(), className, resolvedProperties, resolvedEnvironments, supportedExtensions, true); } }
HadoopScript implements ExecutionScript { @Override public HadoopScript resolve( ExecutionContext context, ExecutionScriptHandler<?> handler) throws InterruptedException, IOException { if (context == null) { throw new IllegalArgumentException("context must not be null"); } if (handler == null) { throw new IllegalArgumentException("handler must not be null"); } if (isResolved()) { return this; } LOG.debug("Resolving {}", this); PlaceholderResolver resolver = new PlaceholderResolver(this, context, handler); Map<String, String> resolvedProperties = new LinkedHashMap<>(); for (Map.Entry<String, String> entry : getHadoopProperties().entrySet()) { resolvedProperties.put(entry.getKey(), resolver.resolve(entry.getValue())); } LOG.debug("Resolved Hadoop properties: {}", resolvedProperties); Map<String, String> resolvedEnvironments = new LinkedHashMap<>(); for (Map.Entry<String, String> entry : getEnvironmentVariables().entrySet()) { resolvedEnvironments.put(entry.getKey(), resolver.resolve(entry.getValue())); } LOG.debug("Resolved environment variables: {}", resolvedEnvironments); return new HadoopScript( getId(), getBlockerIds(), className, resolvedProperties, resolvedEnvironments, supportedExtensions, true); } HadoopScript(
            String id, Set<String> blockerIds,
            String className,
            Map<String, String> hadoopProperties,
            Map<String, String> environmentVariables);  HadoopScript(
            String id, Set<String> blockerIds,
            String className, Map<String, String> hadoopProperties, Map<String, String> environmentVariables,
            Collection<String> supportedExtensions); private  HadoopScript(
            String id, Set<String> blockerIds,
            String className, Map<String, String> hadoopProperties, Map<String, String> environmentVariables,
            Collection<String> supportedExtensions,
            boolean resolved); }
HadoopScript implements ExecutionScript { @Override public HadoopScript resolve( ExecutionContext context, ExecutionScriptHandler<?> handler) throws InterruptedException, IOException { if (context == null) { throw new IllegalArgumentException("context must not be null"); } if (handler == null) { throw new IllegalArgumentException("handler must not be null"); } if (isResolved()) { return this; } LOG.debug("Resolving {}", this); PlaceholderResolver resolver = new PlaceholderResolver(this, context, handler); Map<String, String> resolvedProperties = new LinkedHashMap<>(); for (Map.Entry<String, String> entry : getHadoopProperties().entrySet()) { resolvedProperties.put(entry.getKey(), resolver.resolve(entry.getValue())); } LOG.debug("Resolved Hadoop properties: {}", resolvedProperties); Map<String, String> resolvedEnvironments = new LinkedHashMap<>(); for (Map.Entry<String, String> entry : getEnvironmentVariables().entrySet()) { resolvedEnvironments.put(entry.getKey(), resolver.resolve(entry.getValue())); } LOG.debug("Resolved environment variables: {}", resolvedEnvironments); return new HadoopScript( getId(), getBlockerIds(), className, resolvedProperties, resolvedEnvironments, supportedExtensions, true); } HadoopScript(
            String id, Set<String> blockerIds,
            String className,
            Map<String, String> hadoopProperties,
            Map<String, String> environmentVariables);  HadoopScript(
            String id, Set<String> blockerIds,
            String className, Map<String, String> hadoopProperties, Map<String, String> environmentVariables,
            Collection<String> supportedExtensions); private  HadoopScript(
            String id, Set<String> blockerIds,
            String className, Map<String, String> hadoopProperties, Map<String, String> environmentVariables,
            Collection<String> supportedExtensions,
            boolean resolved); @Override Kind getKind(); @Override String getId(); @Override Set<String> getBlockerIds(); String getClassName(); Map<String, String> getHadoopProperties(); @Override Map<String, String> getEnvironmentVariables(); @Override Set<String> getSupportedExtensions(); @Override boolean isResolved(); @Override HadoopScript resolve(
            ExecutionContext context,
            ExecutionScriptHandler<?> handler); @Override String toString(); @Override int hashCode(); @Override boolean equals(Object obj); }
HadoopScript implements ExecutionScript { @Override public HadoopScript resolve( ExecutionContext context, ExecutionScriptHandler<?> handler) throws InterruptedException, IOException { if (context == null) { throw new IllegalArgumentException("context must not be null"); } if (handler == null) { throw new IllegalArgumentException("handler must not be null"); } if (isResolved()) { return this; } LOG.debug("Resolving {}", this); PlaceholderResolver resolver = new PlaceholderResolver(this, context, handler); Map<String, String> resolvedProperties = new LinkedHashMap<>(); for (Map.Entry<String, String> entry : getHadoopProperties().entrySet()) { resolvedProperties.put(entry.getKey(), resolver.resolve(entry.getValue())); } LOG.debug("Resolved Hadoop properties: {}", resolvedProperties); Map<String, String> resolvedEnvironments = new LinkedHashMap<>(); for (Map.Entry<String, String> entry : getEnvironmentVariables().entrySet()) { resolvedEnvironments.put(entry.getKey(), resolver.resolve(entry.getValue())); } LOG.debug("Resolved environment variables: {}", resolvedEnvironments); return new HadoopScript( getId(), getBlockerIds(), className, resolvedProperties, resolvedEnvironments, supportedExtensions, true); } HadoopScript(
            String id, Set<String> blockerIds,
            String className,
            Map<String, String> hadoopProperties,
            Map<String, String> environmentVariables);  HadoopScript(
            String id, Set<String> blockerIds,
            String className, Map<String, String> hadoopProperties, Map<String, String> environmentVariables,
            Collection<String> supportedExtensions); private  HadoopScript(
            String id, Set<String> blockerIds,
            String className, Map<String, String> hadoopProperties, Map<String, String> environmentVariables,
            Collection<String> supportedExtensions,
            boolean resolved); @Override Kind getKind(); @Override String getId(); @Override Set<String> getBlockerIds(); String getClassName(); Map<String, String> getHadoopProperties(); @Override Map<String, String> getEnvironmentVariables(); @Override Set<String> getSupportedExtensions(); @Override boolean isResolved(); @Override HadoopScript resolve(
            ExecutionContext context,
            ExecutionScriptHandler<?> handler); @Override String toString(); @Override int hashCode(); @Override boolean equals(Object obj);  }