@Override public Location call() throws Exception { return namespacedLocationFactory.get(namespaceId); } });
/** * Returns the location for the given namespace that contains all streams belong to that namespace. */ private Location getStreamBaseLocation(NamespaceId namespace) throws IOException { return namespacedLocationFactory.get(namespace).append(streamBaseDirPath); }
@Override public Location call() throws Exception { return namespacedLocationFactory.get(namespaceId).append(streamBaseDirPath); } });
private void deleteLocation(NamespaceId namespaceId) throws IOException { // TODO: CDAP-1581: Implement soft delete Location namespaceHome = namespacedLocationFactory.get(namespaceId); try { if (hasCustomLocation(namespaceQueryAdmin.get(namespaceId))) { LOG.debug("Custom location mapping {} was found while deleting namespace {}. Deleting all data inside it but" + "skipping namespace home directory delete.", namespaceHome, namespaceId); // delete everything inside the namespace home but not the namespace home as its user owned directory Locations.deleteContent(namespaceHome); } else { // a custom location was not provided for this namespace so cdap is responsible for managing the lifecycle of // the location hence delete it. if (namespaceHome.exists() && !namespaceHome.delete(true)) { throw new IOException(String.format("Error while deleting home directory '%s' for namespace '%s'", namespaceHome, namespaceId)); } } } catch (Exception e) { throw new IOException(String.format("Error while deleting home directory %s for namespace %s ", namespaceHome, namespaceId), e); } }
private Location validateCustomLocation(NamespaceMeta namespaceMeta) throws IOException { Location customNamespacedLocation = namespacedLocationFactory.get(namespaceMeta); if (!customNamespacedLocation.exists()) { throw new IOException(String.format(
Location namespaceHomeLocation = namespacedLocationFactory.get(namespace); if (!namespaceHomeLocation.exists()) { String msg = String.format("Home directory %s for namespace %s not found",
/** * Creates a temporary directory through the {@link LocationFactory} provided to this class. */ private Location createTempLocationDirectory() throws IOException { ProgramId programId = context.getProgram().getId(); String tempLocationName = String.format("%s/%s.%s.%s.%s.%s", cConf.get(Constants.AppFabric.TEMP_DIR), programId.getType().name().toLowerCase(), programId.getNamespace(), programId.getApplication(), programId.getProgram(), context.getRunId().getId()); Location location = locationFactory.get(programId.getNamespaceId()).append(tempLocationName); location.mkdirs(); return location; }
return namespacedLocationFactory.get(namespaceId).append(dataDir).append(basePath);
private Location copyFile(Id.Artifact artifactId, InputSupplier<? extends InputStream> artifactContentSupplier) throws IOException { Location fileDirectory = namespacedLocationFactory.get(artifactId.getNamespace().toEntityId()) .append(ARTIFACTS_PATH).append(artifactId.getName()); Location destination = fileDirectory.append(artifactId.getVersion().getVersion()).getTempFile(".jar"); Locations.mkdirsIfNotExists(fileDirectory); // write the file contents try (InputStream artifactContents = artifactContentSupplier.getInput(); OutputStream destinationStream = destination.getOutputStream()) { ByteStreams.copy(artifactContents, destinationStream); } return destination; }
void clear(final NamespaceId namespace) throws IOException { final Id.Namespace namespaceId = Id.Namespace.fromEntityId(namespace); namespacedLocationFactory.get(namespace).append(ARTIFACTS_PATH).delete(true);
} else { namespaceHome = namespacedLocationFactory.get(namespaceMeta); if (namespaceHome.exists()) { throw new FileAlreadyExistsException(null, null,