public String createClusterHadoop(
      String name, int nodes, String instance, Map<String, Boolean> apps) {
    RunJobFlowResult result;
    StepFactory stepFactory = new StepFactory();
    StepConfig enabledebugging =
        new StepConfig()
            .withName("Enable debugging")
            .withActionOnFailure("TERMINATE_JOB_FLOW")
            .withHadoopJarStep(stepFactory.newEnableDebuggingStep());

    List<Application> applications = new ArrayList<Application>();

    if (apps.get("hive")) {
      Application hive = new Application().withName("Hive");
      applications.add(hive);
    }
    if (apps.get("hue")) {
      Application hue = new Application().withName("Hue");
      applications.add(hue);
    }
    if (apps.get("spark")) {
      Application spark = new Application().withName("Spark");
      applications.add(spark);
    }
    RunJobFlowRequest request =
        new RunJobFlowRequest()
            .withName(name)
            .withReleaseLabel("emr-4.1.0")
            .withSteps(enabledebugging)
            .withApplications(applications)
            .withServiceRole("EMR_DefaultRole")
            .withJobFlowRole("EMR_EC2_DefaultRole")
            .withInstances(
                new JobFlowInstancesConfig()
                    .withInstanceCount(nodes)
                    .withKeepJobFlowAliveWhenNoSteps(true)
                    .withMasterInstanceType(instance)
                    .withSlaveInstanceType(instance));

    result = emr.runJobFlow(request);
    return result.getJobFlowId();
  }