/** * Deploys an application with an application configuration object. * * @param namespace namespace to which the application should be deployed * @param jarFile JAR file of the application to deploy * @param appConfig application configuration object * @throws IOException if a network error occurred * @throws UnauthenticatedException if the request is not authorized successfully in the gateway server */ public void deploy(NamespaceId namespace, File jarFile, Config appConfig) throws IOException, UnauthenticatedException { deploy(namespace, jarFile, GSON.toJson(appConfig)); }
/** * Deploys an application with a serialized application configuration string. * * @param namespace namespace to which the application should be deployed * @param jarFile JAR file of the application to deploy * @param appConfig serialized application configuration * @throws IOException if a network error occurred * @throws UnauthenticatedException if the request is not authorized successfully in the gateway server */ public void deploy(NamespaceId namespace, File jarFile, @Nullable String appConfig) throws IOException, UnauthenticatedException { deploy(namespace, jarFile, appConfig, null); }
@Override public ApplicationManager deployApplication(ApplicationId appId, AppRequest appRequest) throws Exception { applicationClient.deploy(appId, appRequest); return new RemoteApplicationManager(appId, clientConfig, restClient); }
@Override public void perform(Arguments arguments, PrintStream output) throws Exception { File file = resolver.resolvePathToFile(arguments.get(ArgumentName.APP_JAR_FILE.toString())); Preconditions.checkArgument(file.exists(), "File " + file.getAbsolutePath() + " does not exist"); Preconditions.checkArgument(file.canRead(), "File " + file.getAbsolutePath() + " is not readable"); String configPath = arguments.getOptional(ArgumentName.APP_CONFIG_FILE.toString()); StringBuilder configString = new StringBuilder(); File configFile = resolver.resolvePathToFile(configPath); List<String> lines = Files.readAllLines(configFile.getAbsoluteFile().toPath(), StandardCharsets.UTF_8); for (String line: lines) { configString.append(line); } applicationClient.deploy(cliConfig.getCurrentNamespace(), file, configString.toString()); output.println("Successfully deployed application"); }
@Override public void perform(Arguments arguments, PrintStream output) throws Exception { File file = resolver.resolvePathToFile(arguments.get(ArgumentName.APP_JAR_FILE.toString())); Preconditions.checkArgument(file.exists(), "File " + file.getAbsolutePath() + " does not exist"); Preconditions.checkArgument(file.canRead(), "File " + file.getAbsolutePath() + " is not readable"); String appConfig = arguments.getOptional(ArgumentName.APP_CONFIG.toString(), ""); applicationClient.deploy(cliConfig.getCurrentNamespace(), file, appConfig); output.println("Successfully deployed application"); }
@Override public void perform(Arguments arguments, PrintStream output) throws Exception { File file = resolver.resolvePathToFile(arguments.get(ArgumentName.APP_JAR_FILE.toString())); Preconditions.checkArgument(file.exists(), "File " + file.getAbsolutePath() + " does not exist"); Preconditions.checkArgument(file.canRead(), "File " + file.getAbsolutePath() + " is not readable"); String appConfig = arguments.getOptional(ArgumentName.APP_CONFIG.toString(), ""); applicationClient.deploy(cliConfig.getCurrentNamespace(), file, appConfig); output.println("Successfully deployed application"); }
@Override public void perform(Arguments arguments, PrintStream output) throws Exception { File file = resolver.resolvePathToFile(arguments.get(ArgumentName.APP_JAR_FILE.toString())); Preconditions.checkArgument(file.exists(), "File " + file.getAbsolutePath() + " does not exist"); Preconditions.checkArgument(file.canRead(), "File " + file.getAbsolutePath() + " is not readable"); String configPath = arguments.getOptional(ArgumentName.APP_CONFIG_FILE.toString()); StringBuilder configString = new StringBuilder(); File configFile = resolver.resolvePathToFile(configPath); List<String> lines = Files.readAllLines(configFile.getAbsoluteFile().toPath(), StandardCharsets.UTF_8); for (String line: lines) { configString.append(line); } applicationClient.deploy(cliConfig.getCurrentNamespace(), file, configString.toString()); output.println("Successfully deployed application"); }
applicationClient.deploy(namespace, appJarFile, appConfig); } finally { if (!appJarFile.delete()) {
public void applicationClient() throws Exception { // Construct the client used to interact with CDAP ApplicationClient appClient = new ApplicationClient(clientConfig); // Fetch the list of applications List<ApplicationRecord> apps = appClient.list(NamespaceId.DEFAULT); // Deploy an application File appJarFile = new File("your-app.jar"); appClient.deploy(NamespaceId.DEFAULT, appJarFile); // Delete an application appClient.delete(NamespaceId.DEFAULT.app("Purchase")); // List programs belonging to an application appClient.listPrograms(NamespaceId.DEFAULT.app("Purchase")); }
@Override public void perform(Arguments arguments, PrintStream output) throws Exception { ApplicationId appId = parseApplicationId(arguments); String artifactName = arguments.get(ArgumentName.ARTIFACT_NAME.toString()); String artifactVersion = arguments.get(ArgumentName.ARTIFACT_VERSION.toString()); ArtifactScope artifactScope = ArtifactScope.valueOf(arguments.get(ArgumentName.SCOPE.toString()).toUpperCase()); ArtifactSummary artifact = new ArtifactSummary(artifactName, artifactVersion, artifactScope); JsonObject config = new JsonObject(); String ownerPrincipal = null; Boolean updateSchedules = null; PreviewConfig previewConfig = null; String configPath = arguments.getOptional(ArgumentName.APP_CONFIG_FILE.toString()); if (configPath != null) { File configFile = resolver.resolvePathToFile(configPath); try (FileReader reader = new FileReader(configFile)) { AppRequest<JsonObject> appRequest = GSON.fromJson(reader, configType); config = appRequest.getConfig(); ownerPrincipal = appRequest.getOwnerPrincipal(); previewConfig = appRequest.getPreview(); updateSchedules = appRequest.canUpdateSchedules(); } } AppRequest<JsonObject> appRequest = new AppRequest<>(artifact, config, previewConfig, ownerPrincipal, updateSchedules); applicationClient.deploy(appId, appRequest); output.println("Successfully created application"); }
@Override public void perform(Arguments arguments, PrintStream output) throws Exception { ApplicationId appId = parseApplicationId(arguments); String artifactName = arguments.get(ArgumentName.ARTIFACT_NAME.toString()); String artifactVersion = arguments.get(ArgumentName.ARTIFACT_VERSION.toString()); ArtifactScope artifactScope = ArtifactScope.valueOf(arguments.get(ArgumentName.SCOPE.toString()).toUpperCase()); ArtifactSummary artifact = new ArtifactSummary(artifactName, artifactVersion, artifactScope); JsonObject config = new JsonObject(); String ownerPrincipal = null; Boolean updateSchedules = null; PreviewConfig previewConfig = null; String configPath = arguments.getOptional(ArgumentName.APP_CONFIG_FILE.toString()); if (configPath != null) { File configFile = resolver.resolvePathToFile(configPath); try (FileReader reader = new FileReader(configFile)) { AppRequest<JsonObject> appRequest = GSON.fromJson(reader, configType); config = appRequest.getConfig(); ownerPrincipal = appRequest.getOwnerPrincipal(); previewConfig = appRequest.getPreview(); updateSchedules = appRequest.canUpdateSchedules(); } } AppRequest<JsonObject> appRequest = new AppRequest<>(artifact, config, previewConfig, ownerPrincipal, updateSchedules); applicationClient.deploy(appId, appRequest); output.println("Successfully created application"); }