use of io.cdap.cdap.internal.app.runtime.BasicArguments in project cdap by caskdata.
the class MapReduceWithMultipleInputsTest method testMapperOutputTypeChecking.
@Test
public void testMapperOutputTypeChecking() throws Exception {
final ApplicationWithPrograms app = deployApp(AppWithMapReduceUsingInconsistentMappers.class);
// the mapreduce with consistent mapper types will succeed
Assert.assertTrue(runProgram(app, AppWithMapReduceUsingInconsistentMappers.MapReduceWithConsistentMapperTypes.class, new BasicArguments()));
// the mapreduce with mapper classes of inconsistent output types will fail, whether the mappers are set through
// CDAP APIs or also directly on the job
Assert.assertFalse(runProgram(app, AppWithMapReduceUsingInconsistentMappers.MapReduceWithInconsistentMapperTypes.class, new BasicArguments()));
Assert.assertFalse(runProgram(app, AppWithMapReduceUsingInconsistentMappers.MapReduceWithInconsistentMapperTypes2.class, new BasicArguments()));
}
use of io.cdap.cdap.internal.app.runtime.BasicArguments in project cdap by caskdata.
the class MapReduceWithMultipleInputsTest method testAddingMultipleInputsWithSameAlias.
@Test
public void testAddingMultipleInputsWithSameAlias() throws Exception {
final ApplicationWithPrograms app = deployApp(AppWithMapReduceUsingMultipleInputs.class);
// will fail because it configured two inputs with the same alias
Assert.assertFalse(runProgram(app, AppWithMapReduceUsingMultipleInputs.InvalidMapReduce.class, new BasicArguments()));
}
use of io.cdap.cdap.internal.app.runtime.BasicArguments in project cdap by caskdata.
the class MapReduceConfigTest method testConfigIsolation.
@Test
public void testConfigIsolation() throws Exception {
ApplicationWithPrograms app = deployApp(AppWithSingleInputOutput.class);
Assert.assertTrue(runProgram(app, AppWithSingleInputOutput.SimpleMapReduce.class, new BasicArguments()));
}
use of io.cdap.cdap.internal.app.runtime.BasicArguments in project cdap by caskdata.
the class AbstractProgramRuntimeService method updateProgramOptions.
/**
* Updates the given {@link ProgramOptions} and return a new instance.
* It copies the {@link ProgramOptions}. Then it adds all entries returned by {@link #getExtraProgramOptions()}
* followed by adding the {@link RunId} to the system arguments.
*
* Also scope resolution will be performed on the user arguments on the application and program.
*
* @param programId the program id
* @param options The {@link ProgramOptions} in which the RunId to be included
* @param runId The RunId to be included
* @param clusterMode clustermode for the program run
* @param applicationClass application class for the program
* @return the copy of the program options with RunId included in them
*/
private ProgramOptions updateProgramOptions(ArtifactId artifactId, ProgramId programId, ProgramOptions options, RunId runId, ClusterMode clusterMode, ApplicationClass applicationClass) {
// Build the system arguments
Map<String, String> systemArguments = new HashMap<>(options.getArguments().asMap());
// this can happen if this is a program within a workflow, and the workflow already added these arguments
for (Map.Entry<String, String> extraOption : getExtraProgramOptions().entrySet()) {
systemArguments.putIfAbsent(extraOption.getKey(), extraOption.getValue());
}
systemArguments.putIfAbsent(ProgramOptionConstants.RUN_ID, runId.getId());
systemArguments.putIfAbsent(ProgramOptionConstants.ARTIFACT_ID, Joiner.on(':').join(artifactId.toIdParts()));
if (clusterMode == ClusterMode.ISOLATED) {
systemArguments.putIfAbsent(ProgramOptionConstants.APPLICATION_CLASS, applicationClass.getClassName());
}
// Resolves the user arguments
// First resolves at the cluster scope if the cluster.name is not empty
String clusterName = options.getArguments().getOption(Constants.CLUSTER_NAME);
Map<String, String> userArguments = options.getUserArguments().asMap();
if (!Strings.isNullOrEmpty(clusterName)) {
userArguments = RuntimeArguments.extractScope(CLUSTER_SCOPE, clusterName, userArguments);
}
// Then resolves at the application scope
userArguments = RuntimeArguments.extractScope(APPLICATION_SCOPE, programId.getApplication(), userArguments);
// Then resolves at the program level
userArguments = RuntimeArguments.extractScope(programId.getType().getScope(), programId.getProgram(), userArguments);
return new SimpleProgramOptions(options.getProgramId(), new BasicArguments(systemArguments), new BasicArguments(userArguments), options.isDebug());
}
use of io.cdap.cdap.internal.app.runtime.BasicArguments in project cdap by caskdata.
the class ProgramOptions method fromNotification.
/**
* Decodes {@link ProgramOptions} from a {@link Notification} object, based on the
* {@link Notification.Type#PROGRAM_STATUS} type.
*/
static ProgramOptions fromNotification(Notification notification, Gson gson) {
Map<String, String> properties = notification.getProperties();
ProgramId programId = gson.fromJson(properties.get(ProgramOptionConstants.PROGRAM_RUN_ID), ProgramRunId.class).getParent();
String userArgumentsString = properties.get(ProgramOptionConstants.USER_OVERRIDES);
String systemArgumentsString = properties.get(ProgramOptionConstants.SYSTEM_OVERRIDES);
String debugString = properties.get(ProgramOptionConstants.DEBUG_ENABLED);
Type stringStringMap = new TypeToken<Map<String, String>>() {
}.getType();
boolean debug = Boolean.parseBoolean(debugString);
Map<String, String> userArguments = userArgumentsString == null ? Collections.emptyMap() : gson.fromJson(userArgumentsString, stringStringMap);
Map<String, String> systemArguments = systemArgumentsString == null ? Collections.emptyMap() : gson.fromJson(systemArgumentsString, stringStringMap);
return new SimpleProgramOptions(programId, new BasicArguments(systemArguments), new BasicArguments(userArguments), debug);
}
Aggregations