use of org.apache.storm.generated.ListBlobsResult in project storm by apache.
the class LocalCluster method listBlobs.
@Override
public ListBlobsResult listBlobs(String session) throws TException {
// Blobs are not supported in local mode. Return nothing
ListBlobsResult ret = new ListBlobsResult();
ret.set_keys(new ArrayList<>());
return ret;
}
use of org.apache.storm.generated.ListBlobsResult in project storm by apache.
the class Nimbus method listBlobs.
@SuppressWarnings("deprecation")
@Override
public ListBlobsResult listBlobs(String session) throws TException {
try {
Iterator<String> keyIt;
// starting from the beginning.
if (session == null || session.isEmpty()) {
keyIt = blobStore.listKeys();
session = Utils.uuid();
} else {
keyIt = blobListers.get(session);
}
if (keyIt == null) {
throw new RuntimeException("Blob list for session " + session + " does not exist (or timed out)");
}
if (!keyIt.hasNext()) {
blobListers.remove(session);
LOG.info("No more blobs to list for session {}", session);
// A blank result communicates that there are no more blobs.
return new ListBlobsResult(Collections.emptyList(), session);
}
ArrayList<String> listChunk = new ArrayList<>();
for (int i = 0; i < 100 && keyIt.hasNext(); i++) {
listChunk.add(keyIt.next());
}
blobListers.put(session, keyIt);
LOG.info("Downloading {} entries", listChunk.size());
return new ListBlobsResult(listChunk, session);
} catch (Exception e) {
LOG.warn("list blobs exception.", e);
if (e instanceof TException) {
throw (TException) e;
}
throw new RuntimeException(e);
}
}
Aggregations