use of org.javaswift.joss.model.Container in project alluxio by Alluxio.
the class SwiftUnderFileSystem method getObjectListingChunk.
@Override
protected ObjectListingChunk getObjectListingChunk(String key, boolean recursive) throws IOException {
Container container = mAccount.getContainer(mContainerName);
String prefix = PathUtils.normalizePath(key, PATH_SEPARATOR);
// In case key is root (empty string) do not normalize prefix
prefix = prefix.equals(PATH_SEPARATOR) ? "" : prefix;
PaginationMap paginationMap = container.getPaginationMap(prefix, getListingChunkLength());
if (paginationMap != null && paginationMap.getNumberOfPages() > 0) {
return new SwiftObjectListingChunk(paginationMap, 0, recursive);
}
return null;
}
use of org.javaswift.joss.model.Container in project alluxio by Alluxio.
the class SwiftUnderFileSystem method getObjectStatus.
@Override
protected ObjectStatus getObjectStatus(String key) {
Container container = mAccount.getContainer(mContainerName);
StoredObject meta = container.getObject(key);
if (meta != null && meta.exists()) {
return new ObjectStatus(meta.getContentLength(), meta.getLastModifiedAsDate().getTime());
}
return null;
}
use of org.javaswift.joss.model.Container in project alluxio by Alluxio.
the class SwiftUnderFileSystem method copyObject.
@Override
protected boolean copyObject(String source, String destination) {
LOG.debug("copy from {} to {}", source, destination);
// Retry copy for a few times, in case some Swift internal errors happened during copy.
for (int i = 0; i < NUM_RETRIES; i++) {
try {
Container container = mAccount.getContainer(mContainerName);
container.getObject(source).copyObject(container, container.getObject(destination));
return true;
} catch (CommandException e) {
LOG.error("Source path {} does not exist", source);
return false;
} catch (Exception e) {
LOG.error("Failed to copy file {} to {}", source, destination, e.getMessage());
if (i != NUM_RETRIES - 1) {
LOG.error("Retrying copying file {} to {}", source, destination);
}
}
}
LOG.error("Failed to copy file {} to {}, after {} retries", source, destination, NUM_RETRIES);
return false;
}
use of org.javaswift.joss.model.Container in project alluxio by Alluxio.
the class SwiftUnderFileSystem method createEmptyObject.
@Override
protected boolean createEmptyObject(String key) {
try {
Container container = mAccount.getContainer(mContainerName);
StoredObject object = container.getObject(key);
object.uploadObject(new byte[0]);
return true;
} catch (CommandException e) {
LOG.error("Failed to create object: {}", key, e);
return false;
}
}
use of org.javaswift.joss.model.Container in project alluxio by Alluxio.
the class SwiftUnderFileSystem method deleteObject.
@Override
protected boolean deleteObject(String path) throws IOException {
try {
Container container = mAccount.getContainer(mContainerName);
StoredObject object = container.getObject(path);
if (object != null) {
object.delete();
return true;
}
} catch (CommandException e) {
LOG.debug("Object {} not found", path);
}
return false;
}
Aggregations