Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
Copyright 2013 Cloudera Inc. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
package com.cloudera.cdk.maven.plugins;
import  org.apache.hadoop.conf.Configuration;
import  org.apache.hadoop.fs.FileSystem;
import  org.apache.hadoop.fs.FileUtil;
import  org.apache.hadoop.fs.Path;
Deploy a packaged application to a Hadoop filesystem, such as HDFS.
@Mojo(name = "deploy-app")
public class DeployAppMojo extends AbstractAppMojo {

The local directory of the application to deploy.
  @Parameter(property = "cdk.localApplicationFile",
      defaultValue = "${}/${}-app")
  private File localApplicationFile;

The Hadoop fileystem used to deploy the application. The filesystem must be accessible by the client deploying the application.
  @Parameter(property = "cdk.deployFileSystem", required = true)
  private String deployFileSystem;

Whether to automatically undeploy applications that already exist when deploying. If false, and this application has already been deployed, then an error will be reported.
  @Parameter(property = "cdk.updateApplication", defaultValue = "false")
  private boolean updateApplication;
  public void execute() throws MojoExecutionExceptionMojoFailureException {
    try {
      Configuration conf = new Configuration();
      Path appPath = getAppPath();
      getLog().info("Deploying " +  +  " to " +  appPath);
      FileSystem destFileSystem = FileSystem.get(new URI(), conf);
      if (destFileSystem.exists(appPath)) {
        if (!) {
          throw new MojoExecutionException("Application already exists at " +
              appPath + ". Use 'updateApplication' option to force deployment.");
        boolean success = destFileSystem.delete(appPathtrue);
        if (!success) {
          throw new MojoExecutionException("Error deleting existing application at " +
      boolean success = FileUtil.copy(destFileSystemappPathfalseconf);
      if (!success) {
        throw new MojoExecutionException("Error creating parent directories " +
            "for deploying Oozie application");
    } catch (URISyntaxException e) {
      throw new MojoExecutionException("Syntax error in 'deployFileSystem': "
          + e);
    } catch (IOException e) {
      throw new MojoExecutionException("Error deploying application"e);
New to GrepCode? Check out our FAQ X