Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
public interface ApplicationContext<T extends Config> {
  T getConfig();
}

public interface Application<T extends Config> {
  void configure(ApplicationConfigurer configurer, ApplicationContext<T> context);
}
 
public abstract class AbstractApplication<T> implements Application<T extends Config> {
  ...
  protected final ApplicationContext<T> getContext() { return context; }
}
 
public class MyApp extends AbstractApplication<MyApp.MyConfig> {
 
  public static class MyConfig {
    private String stream;
    private String table;
    private MyFlowConfig flowOptions;
  }
 
  public void configure() {
    // ApplicationContext now has a method to get a custom config object whose fields will
    // be injected using the values given in the RESTful API
    MyConfig config = getContext().getConfig();
    addStream(new Stream(config.stream));
    createDataset(config.table, Table.class);
    addFlow(config.stream, config.table, config.flowOptions);
  }
}

 

Story Details

 

Users will still be able to deploy an app in one call. Suppose a user wants to deploy their application contained in myapp-1.0.0.jar.  They make the same RESTful call they would today:

Code Block
PUT /namespaces/default/apps/myapp -H "X-Archive-Name: myapp-1.0.0.jar" -H "Content-Type: application/octet-stream" --data-binary @myapp-1.0.0.

...

jar

 

Internally, CDAP will add the jar to its ArtifactRepository (new in CDAP 3.1), and then create the an application from that artifact. In this example, the application creates stream A and Table X by default.

After the app is deployed, a user can now create Application myapp2 by referencing the artifact and config in their request without actually including the jar contents in the request.

Image Removed

 

Users will also be able to This lets users create applications using only config.

Code Block
PUT /namespaces/default/apps/myapp2 -H "X-Archive-Name: myapp-1.0.0.jar" -H "Content-Type: application/json" -d '{ "stream": "B", "table": "X" }'

 

Image Added

Users can also deploy an artifact without creating an application.

Code Block
PUT /namespaces/default/artifacts/myapp -H "X-Artifact-Name: myapp-1.0.1.jar" --data-binary @myapp-1.0.1.jar

 

An application can then be created from that artifact in a separate call.

Code Block
PUT /namespaces/default/apps/myapp3 -H "X-Archive-Name: myapp-1.0.1.jar" -H "Content-Type: application/json" -d '{ "stream": "C", "table": "X" }'

 

 

Users will also be able to update their applications to use a different version of an artifact.

Code Block
PUT /namespaces/default/apps/myapp/properties -H "X-Archive-Name: myapp-1.0.1.jar" -H "Content-Type: application/json" -d '{ "stream": "A", "table": "X" }'

 

RESTful API changes