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 http://www.apache.org/licenses/LICENSE-2.0 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 org.kitesdk.maven.plugins;
 
 import java.io.File;
 import java.net.URI;
 import java.net.URL;
 import java.util.List;
 
 abstract class AbstractDatasetMojo extends AbstractHadoopMojo {

  
A Kite dataset URI.
 
   @Parameter(property = "kite.uri")
   protected String uri;

  
The root directory of the dataset repository. Optional if using HCatalog for metadata storage.
 
   @Parameter(property = "kite.rootDirectory")
   protected String rootDirectory;

  
If true, store dataset metadata in HCatalog, otherwise store it on the filesystem.
 
   @Parameter(property = "kite.hcatalog")
   protected boolean hcatalog = true;

  
The URI specifying the dataset repository, e.g. repo:hdfs://host:8020/data. Optional, but if specified then kite.rootDirectory and kite.hcatalog are ignored.
 
   @Parameter(property = "kite.repositoryUri")
   protected String repositoryUri;

  
Hadoop configuration properties.
 
   @Parameter(property = "kite.hadoopConfiguration")
 
   private static void addToConfiguration(Properties hadoopConfiguration) {
     // base the new Configuration on the current defaults
     Configuration conf = new Configuration(DefaultConfiguration.get());
 
     // add all of the properties as config settings
     for (String key : hadoopConfiguration.stringPropertyNames()) {
       String value = hadoopConfiguration.getProperty(key);
       conf.set(keyvalue);
     }
 
     // replace the original Configuration
     DefaultConfiguration.set(conf);
 
      = true;
   }
 
   static boolean addedConf = false;
 
   protected Configuration getConf() {
     if (!) {
     }
     // use the default
     return DefaultConfiguration.get();
   }
 
    getConf(); // ensure properties are added to DefaultConfig
    if ( != null) {
      return DatasetRepositories.repositoryFor();
    }
    if ( != null) {
      URI uri = URI.create();
      if () {
        return DatasetRepositories.repositoryFor("repo:hive:" + uri.getPath());
      } else if (uri.getScheme() != null) {
        return DatasetRepositories.repositoryFor("repo:" + uri.toString());
      } else if (getConf().get("fs.defaultFS") != null) {
        URI defaultFS = URI.create(getConf().get("fs.defaultFS"));
        return DatasetRepositories.repositoryFor(
            "repo:" + defaultFS.getScheme() + ":" + uri.getPath());
      } else if (getConf().get("fs.default.name") != null) {
        URI defaultFS = URI.create(getConf().get("fs.default.name"));
        return DatasetRepositories.repositoryFor(
            "repo:" + defaultFS.getScheme() + ":" + uri.getPath());
      } else {
        return DatasetRepositories.repositoryFor("repo:file:" + uri.getPath());
      }
    } else if () {
      return DatasetRepositories.repositoryFor("repo:hive");
    }
    throw new IllegalArgumentException(
        "Root directory must be specified if not using Hive.");
  }
  void configureSchema(DatasetDescriptor.Builder descriptorBuilderString
      avroSchemaFileString avroSchemaReflectClassthrows MojoExecutionException {
    if (avroSchemaFile != null) {
      File avroSchema = new File(avroSchemaFile);
      try {
        if (avroSchema.exists()) {
          descriptorBuilder.schema(avroSchema);
        } else {
          descriptorBuilder.schema(Resources.getResource(avroSchemaFile).openStream());
        }
      } catch (IOException e) {
        throw new MojoExecutionException("Problem while reading file " + avroSchemaFilee);
      }
    } else if (avroSchemaReflectClass != null) {
      try {
        List<URLclasspath = new ArrayList<URL>();
        for (Object element : .getCompileClasspathElements()) {
          String path = (Stringelement;
          classpath.add(new File(path).toURI().toURL());
        }
        ClassLoader parentClassLoader = getClass().getClassLoader(); // use Maven's classloader, not the system one
        ClassLoader classLoader = new URLClassLoader(
            classpath.toArray(new URL[classpath.size()]), parentClassLoader);
        descriptorBuilder.schema(Class.forName(avroSchemaReflectClasstrueclassLoader));
      } catch (ClassNotFoundException e) {
        throw new MojoExecutionException("Problem finding class " +
            avroSchemaReflectClasse);
      } catch (MalformedURLException e) {
        throw new MojoExecutionException("Problem finding class " +
            avroSchemaReflectClasse);
      } catch (DependencyResolutionRequiredException e) {
        throw new MojoExecutionException("Problem finding class " +
            avroSchemaReflectClasse);
      }
    }
  }
New to GrepCode? Check out our FAQ X