Exemplo n.º 1
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 bindCustomProperties(
      final org.apache.falcon.entity.v0.process.Properties customProperties,
      final Properties extensionProperties) {
    List<Property> propertyList = new ArrayList<>();

    for (Map.Entry<Object, Object> extensionProperty : extensionProperties.entrySet()) {
      if (ExtensionProperties.getOptionsMap().get(extensionProperty.getKey().toString()) == null) {
        addProperty(
            propertyList,
            (String) extensionProperty.getKey(),
            (String) extensionProperty.getValue());
      }
    }

    customProperties.getProperties().addAll(propertyList);
  }