Package com.cloudera.cdk.data

Examples of com.cloudera.cdk.data.MetadataProviderException


    this.conf = conf;
    try {
      this.rootFileSystem = rootDirectory.getFileSystem(conf);
      this.rootDirectory = rootFileSystem.makeQualified(rootDirectory);
    } catch (IOException ex) {
      throw new MetadataProviderException(
          "Cannot get FileSystem for root path", ex);
    }
  }
View Full Code Here


    try {
      inputStream = rootFileSystem.open(descriptorPath);
      properties.load(inputStream);
      threw = false;
    } catch (IOException e) {
      throw new MetadataProviderException(
          "Unable to load descriptor file:" + descriptorPath + " for dataset:" + name, e);
    } finally {
      try {
        Closeables.close(inputStream, threw);
      } catch (IOException e) {
        throw new MetadataProviderException(e);
      }
    }

    if (properties.containsKey(FORMAT_FIELD_NAME)) {
      builder.format(Accessor.getDefault().newFormat(
          properties.getProperty(FORMAT_FIELD_NAME)));
    }
    if (properties.containsKey(PARTITION_EXPRESSION_FIELD_NAME)) {
      builder.partitionStrategy(Accessor.getDefault().fromExpression(properties
          .getProperty(PARTITION_EXPRESSION_FIELD_NAME)));
    }
    Path schemaPath = new Path(metadataPath, SCHEMA_FILE_NAME);
    try {
      builder.schemaUri(rootFileSystem.makeQualified(schemaPath).toUri());
    } catch (IOException e) {
      throw new MetadataProviderException(
        "Unable to load schema file:" + schemaPath + " for dataset:" + name, e);
    }

    final Path location;
    if (properties.containsKey(LOCATION_FIELD_NAME)) {
View Full Code Here

            "Descriptor directory:" + metadataLocation + " already exists");
      }
      // create the directory so that update can do the rest of the work
      rootFileSystem.mkdirs(metadataLocation);
    } catch (IOException e) {
      throw new MetadataProviderException(
          "Unable to create metadata directory:" + metadataLocation +
          " for dataset:" + name, e);
    }

    writeDescriptor(rootFileSystem, metadataLocation, name, newDescriptor);
View Full Code Here

        }
      } else {
        return false;
      }
    } catch (IOException e) {
      throw new MetadataProviderException(
          "Unable to find or delete metadata directory:" + metadataDirectory +
          " for dataset:" + name, e);
    }
  }
View Full Code Here

    final Path potentialPath = pathForMetadata(name);
    try {
      return rootFileSystem.exists(potentialPath);
    } catch (IOException ex) {
      throw new MetadataProviderException(
          "Could not check metadata path:" + potentialPath, ex);
    }
  }
View Full Code Here

      }
    } catch (FileNotFoundException ex) {
      // the repo hasn't created any files yet
      return datasets;
    } catch (IOException ex) {
      throw new MetadataProviderException("Could not list data sets", ex);
    }
    return datasets;
  }
View Full Code Here

      outputStream.write(descriptor.getSchema().toString(true)
          .getBytes(Charsets.UTF_8));
      outputStream.flush();
      threw = false;
    } catch (IOException e) {
      throw new MetadataProviderException(
          "Unable to save schema file:" + schemaPath + " for dataset:" + name, e);
    } finally {
      try {
        Closeables.close(outputStream, threw);
      } catch (IOException e) {
        throw new MetadataProviderException(e);
      }
    }

    Properties properties = new Properties();
    properties.setProperty(VERSION_FIELD_NAME, METADATA_VERSION);
    properties.setProperty(FORMAT_FIELD_NAME, descriptor.getFormat().getName());

    final URI dataLocation = descriptor.getLocation();
    if (dataLocation != null) {
      properties.setProperty(LOCATION_FIELD_NAME, dataLocation.toString());
    }

    if (descriptor.isPartitioned()) {
      properties.setProperty(PARTITION_EXPRESSION_FIELD_NAME,
          Accessor.getDefault().toExpression(descriptor.getPartitionStrategy()));
    }

    // copy custom properties to the table
    for (String property : descriptor.listProperties()) {
      // no need to check the reserved list, those are not set on descriptors
      properties.setProperty(property, descriptor.getProperty(property));
    }

    final Path descriptorPath = new Path(metadataLocation, DESCRIPTOR_FILE_NAME);
    threw = true;
    try {
      outputStream = fs.create(descriptorPath, true /* overwrite */ );
      properties.store(outputStream, "Dataset descriptor for " + name);
      outputStream.flush();
      threw = false;
    } catch (IOException e) {
      throw new MetadataProviderException(
          "Unable to save descriptor file:" + descriptorPath + " for dataset:" + name, e);
    } finally {
      try {
        Closeables.close(outputStream, threw);
      } catch (IOException e) {
        throw new MetadataProviderException(e);
      }
    }
  }
View Full Code Here

      if (!fs.exists(location)) {
        throw new com.cloudera.cdk.data.NoSuchDatasetException("Descriptor location is missing: " +
            location);
      }
    } catch (IOException ex) {
      throw new MetadataProviderException("Cannot access descriptor location", ex);
    }
  }
View Full Code Here

    try {
      this.rootFileSystem = rootDirectory.getFileSystem(conf);
      this.rootDirectory = rootFileSystem.makeQualified(rootDirectory);
    } catch (IOException ex) {
      throw new MetadataProviderException(
          "Could not get FileSystem for root path", ex);
    }
  }
View Full Code Here

    Preconditions.checkArgument(name != null, "Name cannot be null");

    final Table table = hcat.getTable(HiveUtils.DEFAULT_DB, name);

    if (!TableType.EXTERNAL_TABLE.equals(table.getTableType())) {
      throw new MetadataProviderException(
          "Table is not external, type:" + table.getTableType());
    }

    return HiveUtils.descriptorForTable(conf, table);
  }
View Full Code Here

TOP

Related Classes of com.cloudera.cdk.data.MetadataProviderException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.