Github user revans2 commented on a diff in the pull request: https://github.com/apache/storm/pull/2347#discussion_r141184831 --- Diff: external/storm-blobstore-migration/src/main/java/org/apache/storm/blobstore/MigrateBlobs.java --- @@ -0,0 +1,125 @@ +package org.apache.storm.blobstore; + +import java.io.IOException; +import java.io.InputStream; +import java.util.Map; + +import javax.security.auth.Subject; +import javax.security.auth.login.LoginContext; + +import org.apache.storm.Config; +import org.apache.storm.blobstore.BlobStore; +import org.apache.storm.hdfs.blobstore.HdfsBlobStore; +import org.apache.storm.nimbus.NimbusInfo; +import org.apache.storm.utils.Utils; +import org.apache.storm.blobstore.LocalFsBlobStore; +import org.apache.storm.generated.AuthorizationException; +import org.apache.storm.generated.KeyAlreadyExistsException; +import org.apache.storm.generated.KeyNotFoundException; +import org.apache.storm.generated.ReadableBlobMeta; +import org.apache.storm.generated.SettableBlobMeta; + +public class MigrateBlobs { + + protected static void deleteAllBlobStoreKeys(BlobStore bs, Subject who) throws AuthorizationException, KeyNotFoundException { + Iterable<String> hdfsKeys = () -> bs.listKeys(); + for(String key : hdfsKeys) { + System.out.println(key); + bs.deleteBlob(key, who); + } + } + + protected static void copyBlobStoreKeys(BlobStore bsFrom, Subject whoFrom, BlobStore bsTo, Subject whoTo) throws AuthorizationException, KeyAlreadyExistsException, IOException, KeyNotFoundException { + Iterable<String> lfsKeys = () -> bsFrom.listKeys(); + for(String key : lfsKeys) { + ReadableBlobMeta readable_meta = bsFrom.getBlobMeta(key, whoFrom); + SettableBlobMeta meta = readable_meta.get_settable(); + InputStream in = bsFrom.getBlob(key, whoFrom); + System.out.println("COPYING BLOB " + key + " FROM " + bsFrom + " TO " + bsTo); + bsTo.createBlob(key, in, meta, whoTo); + System.out.println("DONE CREATING BLOB " + key); + } + } + + + public static void main(String[] args) throws Exception { + // TODO Auto-generated method stub --- End diff -- Please remove this comment.
---