@Test
  public void testProcessDeleteAndSchedule() throws Exception {
    // Submit process with invalid property so that coord submit fails and bundle goes to failed
    // state
    Map<String, String> overlay = getUniqueOverlay();
    String tmpFileName = overlayParametersOverTemplate(PROCESS_TEMPLATE, overlay);
    Process process =
        (Process) EntityType.PROCESS.getUnmarshaller().unmarshal(new File(tmpFileName));
    Property prop = new Property();
    prop.setName("newProp");
    prop.setValue("${formatTim()}");
    process.getProperties().getProperties().add(prop);
    File tmpFile = getTempFile();
    EntityType.PROCESS.getMarshaller().marshal(process, tmpFile);
    scheduleProcess(tmpFile.getAbsolutePath(), overlay);
    waitForBundleStart(Status.FAILED);

    // Delete and re-submit the process with correct workflow
    ClientResponse clientRepsonse =
        this.service
            .path("api/entities/delete/process/" + processName)
            .header("Remote-User", REMOTE_USER)
            .accept(MediaType.TEXT_XML)
            .delete(ClientResponse.class);
    assertSuccessful(clientRepsonse);
    process.getWorkflow().setPath("/falcon/test/workflow");
    tmpFile = getTempFile();
    EntityType.PROCESS.getMarshaller().marshal(process, tmpFile);
    clientRepsonse =
        this.service
            .path("api/entities/submitAndSchedule/process")
            .header("Remote-User", REMOTE_USER)
            .accept(MediaType.TEXT_XML)
            .type(MediaType.TEXT_XML)
            .post(ClientResponse.class, getServletInputStream(tmpFile.getAbsolutePath()));
    assertSuccessful(clientRepsonse);

    // Assert that new schedule creates new bundle
    List<BundleJob> bundles = getBundles();
    Assert.assertEquals(bundles.size(), 2);
  }
Пример #2
0
  protected Properties getEntityProperties(Entity myEntity) {
    Properties properties = new Properties();
    switch (myEntity.getEntityType()) {
      case CLUSTER:
        org.apache.falcon.entity.v0.cluster.Properties clusterProps =
            ((Cluster) myEntity).getProperties();
        if (clusterProps != null) {
          for (Property prop : clusterProps.getProperties()) {
            properties.put(prop.getName(), prop.getValue());
          }
        }
        break;

      case FEED:
        org.apache.falcon.entity.v0.feed.Properties feedProps = ((Feed) myEntity).getProperties();
        if (feedProps != null) {
          for (org.apache.falcon.entity.v0.feed.Property prop : feedProps.getProperties()) {
            properties.put(prop.getName(), prop.getValue());
          }
        }
        break;

      case PROCESS:
        org.apache.falcon.entity.v0.process.Properties processProps =
            ((Process) myEntity).getProperties();
        if (processProps != null) {
          for (org.apache.falcon.entity.v0.process.Property prop : processProps.getProperties()) {
            properties.put(prop.getName(), prop.getValue());
          }
        }
        break;

      default:
        throw new IllegalArgumentException("Unhandled entity type " + myEntity.getEntityType());
    }
    return properties;
  }
 private static void addProperty(List<Property> propertyList, String name, String value) {
   Property prop = new Property();
   prop.setName(name);
   prop.setValue(value);
   propertyList.add(prop);
 }