/** * Returns the path where this MetadataProvider will store metadata. * * Note that this is not dependent on the actual storage location for the * dataset, although they are usually co-located. This provider must be able * to read metadata without a location for the Dataset when loading. * * @param name The {@link Dataset} name * @return The directory {@link Path} where metadata files will be located */ private Path pathForMetadata(String namespace, String name) { return pathForMetadata(rootDirectory, namespace, name); }
Path expectedPath = pathForMetadata(namespace, name); if (DEFAULT_NAMESPACE.equals(namespace)) {
@Override public DatasetDescriptor create(String namespace, String name, DatasetDescriptor descriptor) { Preconditions.checkNotNull(namespace, "Namespace cannot be null"); Preconditions.checkNotNull(name, "Dataset name cannot be null"); Preconditions.checkNotNull(descriptor, "Descriptor cannot be null"); Compatibility.check(namespace, name, descriptor); LOG.debug("Saving dataset metadata name:{} descriptor:{}", name, descriptor); // no need to check backward-compatibility when creating new datasets Path metadataLocation = pathForMetadata(namespace, name); try { if (rootFileSystem.exists(metadataLocation)) { throw new DatasetExistsException( "Descriptor directory already exists: " + metadataLocation); } // create the directory so that update can do the rest of the work rootFileSystem.mkdirs(metadataLocation); } catch (IOException e) { throw new DatasetIOException( "Unable to create metadata directory: " + metadataLocation + " for dataset: " + name, e); } writeDescriptor(rootFileSystem, metadataLocation, name, descriptor); return descriptor; }