Search in sources :

Example 1 with ListBlobsResult

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;
}
Also used : ListBlobsResult(org.apache.storm.generated.ListBlobsResult)

Example 2 with ListBlobsResult

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);
    }
}
Also used : TException(org.apache.storm.thrift.TException) ListBlobsResult(org.apache.storm.generated.ListBlobsResult) ArrayList(java.util.ArrayList) WorkerMetricPoint(org.apache.storm.generated.WorkerMetricPoint) DataPoint(org.apache.storm.metric.api.DataPoint) WrappedAuthorizationException(org.apache.storm.utils.WrappedAuthorizationException) IOException(java.io.IOException) IllegalStateException(org.apache.storm.generated.IllegalStateException) AlreadyAliveException(org.apache.storm.generated.AlreadyAliveException) WrappedNotAliveException(org.apache.storm.utils.WrappedNotAliveException) WrappedInvalidTopologyException(org.apache.storm.utils.WrappedInvalidTopologyException) AuthorizationException(org.apache.storm.generated.AuthorizationException) NotAliveException(org.apache.storm.generated.NotAliveException) WrappedAlreadyAliveException(org.apache.storm.utils.WrappedAlreadyAliveException) InterruptedIOException(java.io.InterruptedIOException) KeyAlreadyExistsException(org.apache.storm.generated.KeyAlreadyExistsException) TException(org.apache.storm.thrift.TException) WrappedIllegalStateException(org.apache.storm.utils.WrappedIllegalStateException) KeyNotFoundException(org.apache.storm.generated.KeyNotFoundException) InvalidTopologyException(org.apache.storm.generated.InvalidTopologyException) BindException(java.net.BindException)

Aggregations

ListBlobsResult (org.apache.storm.generated.ListBlobsResult)2 IOException (java.io.IOException)1 InterruptedIOException (java.io.InterruptedIOException)1 BindException (java.net.BindException)1 ArrayList (java.util.ArrayList)1 AlreadyAliveException (org.apache.storm.generated.AlreadyAliveException)1 AuthorizationException (org.apache.storm.generated.AuthorizationException)1 IllegalStateException (org.apache.storm.generated.IllegalStateException)1 InvalidTopologyException (org.apache.storm.generated.InvalidTopologyException)1 KeyAlreadyExistsException (org.apache.storm.generated.KeyAlreadyExistsException)1 KeyNotFoundException (org.apache.storm.generated.KeyNotFoundException)1 NotAliveException (org.apache.storm.generated.NotAliveException)1 WorkerMetricPoint (org.apache.storm.generated.WorkerMetricPoint)1 DataPoint (org.apache.storm.metric.api.DataPoint)1 TException (org.apache.storm.thrift.TException)1 WrappedAlreadyAliveException (org.apache.storm.utils.WrappedAlreadyAliveException)1 WrappedAuthorizationException (org.apache.storm.utils.WrappedAuthorizationException)1 WrappedIllegalStateException (org.apache.storm.utils.WrappedIllegalStateException)1 WrappedInvalidTopologyException (org.apache.storm.utils.WrappedInvalidTopologyException)1 WrappedNotAliveException (org.apache.storm.utils.WrappedNotAliveException)1