Search in sources :

Example 1 with BlobStore

use of org.apache.storm.blobstore.BlobStore in project storm by apache.

the class Nimbus method computeExecutorToComponent.

private Map<List<Integer>, String> computeExecutorToComponent(String topoId, StormBase base) throws KeyNotFoundException, AuthorizationException, InvalidTopologyException, IOException {
    BlobStore store = blobStore;
    List<List<Integer>> executors = computeExecutors(topoId, base);
    StormTopology topology = readStormTopologyAsNimbus(topoId, store);
    Map<String, Object> topoConf = readTopoConfAsNimbus(topoId, store);
    Map<Integer, String> taskToComponent = StormCommon.stormTaskInfo(topology, topoConf);
    Map<List<Integer>, String> ret = new HashMap<>();
    for (List<Integer> executor : executors) {
        ret.put(executor, taskToComponent.get(executor.get(0)));
    }
    return ret;
}
Also used : HashMap(java.util.HashMap) StormTopology(org.apache.storm.generated.StormTopology) ArrayList(java.util.ArrayList) List(java.util.List) BlobStore(org.apache.storm.blobstore.BlobStore) LocalFsBlobStore(org.apache.storm.blobstore.LocalFsBlobStore)

Example 2 with BlobStore

use of org.apache.storm.blobstore.BlobStore in project storm by apache.

the class Nimbus method setupBlobstore.

/**
     * Sets up blobstore state for all current keys.
     * @throws KeyNotFoundException 
     * @throws AuthorizationException 
     */
private void setupBlobstore() throws AuthorizationException, KeyNotFoundException {
    IStormClusterState state = stormClusterState;
    BlobStore store = blobStore;
    Set<String> localKeys = new HashSet<>();
    for (Iterator<String> it = store.listKeys(); it.hasNext(); ) {
        localKeys.add(it.next());
    }
    Set<String> activeKeys = new HashSet<>(state.activeKeys());
    Set<String> activeLocalKeys = new HashSet<>(localKeys);
    activeLocalKeys.retainAll(activeKeys);
    Set<String> keysToDelete = new HashSet<>(localKeys);
    keysToDelete.removeAll(activeKeys);
    NimbusInfo nimbusInfo = nimbusHostPortInfo;
    LOG.debug("Deleting keys not on the zookeeper {}", keysToDelete);
    for (String toDelete : keysToDelete) {
        store.deleteBlob(toDelete, NIMBUS_SUBJECT);
    }
    LOG.debug("Creating list of key entries for blobstore inside zookeeper {} local {}", activeKeys, activeLocalKeys);
    for (String key : activeLocalKeys) {
        try {
            state.setupBlobstore(key, nimbusInfo, getVersionForKey(key, nimbusInfo, conf));
        } catch (KeyNotFoundException e) {
            // invalid key, remove it from blobstore
            store.deleteBlob(key, NIMBUS_SUBJECT);
        }
    }
}
Also used : IStormClusterState(org.apache.storm.cluster.IStormClusterState) BlobStore(org.apache.storm.blobstore.BlobStore) LocalFsBlobStore(org.apache.storm.blobstore.LocalFsBlobStore) KeyNotFoundException(org.apache.storm.generated.KeyNotFoundException) HashSet(java.util.HashSet) NimbusInfo(org.apache.storm.nimbus.NimbusInfo)

Example 3 with BlobStore

use of org.apache.storm.blobstore.BlobStore in project storm by apache.

the class Nimbus method blobSync.

private void blobSync() throws Exception {
    if ("distributed".equals(conf.get(Config.STORM_CLUSTER_MODE))) {
        if (!isLeader()) {
            IStormClusterState state = stormClusterState;
            NimbusInfo nimbusInfo = nimbusHostPortInfo;
            BlobStore store = blobStore;
            Set<String> allKeys = new HashSet<>();
            for (Iterator<String> it = store.listKeys(); it.hasNext(); ) {
                allKeys.add(it.next());
            }
            Set<String> zkKeys = new HashSet<>(state.blobstore(() -> {
                try {
                    this.blobSync();
                } catch (Exception e) {
                    throw new RuntimeException(e);
                }
            }));
            LOG.debug("blob-sync blob-store-keys {} zookeeper-keys {}", allKeys, zkKeys);
            BlobSynchronizer sync = new BlobSynchronizer(store, conf);
            sync.setNimbusInfo(nimbusInfo);
            sync.setBlobStoreKeySet(allKeys);
            sync.setZookeeperKeySet(zkKeys);
            sync.syncBlobs();
        }
    //else not leader (NOOP)
    }
//else local (NOOP)
}
Also used : BlobSynchronizer(org.apache.storm.blobstore.BlobSynchronizer) IStormClusterState(org.apache.storm.cluster.IStormClusterState) BlobStore(org.apache.storm.blobstore.BlobStore) LocalFsBlobStore(org.apache.storm.blobstore.LocalFsBlobStore) AuthorizationException(org.apache.storm.generated.AuthorizationException) NotAliveException(org.apache.storm.generated.NotAliveException) InterruptedIOException(java.io.InterruptedIOException) TException(org.apache.thrift.TException) IOException(java.io.IOException) AlreadyAliveException(org.apache.storm.generated.AlreadyAliveException) KeyAlreadyExistsException(org.apache.storm.generated.KeyAlreadyExistsException) KeyNotFoundException(org.apache.storm.generated.KeyNotFoundException) InvalidTopologyException(org.apache.storm.generated.InvalidTopologyException) BindException(java.net.BindException) NimbusInfo(org.apache.storm.nimbus.NimbusInfo) HashSet(java.util.HashSet)

Example 4 with BlobStore

use of org.apache.storm.blobstore.BlobStore in project storm by apache.

the class BlobStoreTest method testWithAuthenticationUpdate.

@Test
void testWithAuthenticationUpdate() throws Exception {
    try (AutoCloseableBlobStoreContainer container = initHdfs("/storm/blobstore-auth-update")) {
        BlobStore store = container.blobStore;
        Subject who = getSubject("test_subject");
        assertStoreHasExactly(store);
        SettableBlobMeta metadata = new SettableBlobMeta(BlobStoreAclHandler.DEFAULT);
        try (AtomicOutputStream out = store.createBlob("test", metadata, who)) {
            out.write(1);
        }
        assertStoreHasExactly(store, "test");
        readAssertEqualsWithAuth(store, who, "test", 1);
        try (AtomicOutputStream out = store.updateBlob("test", who)) {
            out.write(2);
        }
        assertStoreHasExactly(store, "test");
        readAssertEqualsWithAuth(store, who, "test", 2);
        try (AtomicOutputStream out = store.updateBlob("test", who)) {
            out.write(3);
        }
        assertStoreHasExactly(store, "test");
        readAssertEqualsWithAuth(store, who, "test", 3);
        LOG.info("Deleting test");
        store.deleteBlob("test", who);
        assertStoreHasExactly(store);
    }
}
Also used : AtomicOutputStream(org.apache.storm.blobstore.AtomicOutputStream) SettableBlobMeta(org.apache.storm.generated.SettableBlobMeta) BlobStore(org.apache.storm.blobstore.BlobStore) Subject(javax.security.auth.Subject) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 5 with BlobStore

use of org.apache.storm.blobstore.BlobStore in project storm by apache.

the class BlobStoreTest method testWithAuthentication.

@ParameterizedTest
@EnumSource(value = AuthenticationTestSubject.class)
void testWithAuthentication(AuthenticationTestSubject testSubject) throws Exception {
    try (AutoCloseableBlobStoreContainer container = initHdfs("/storm/blobstore-auth-" + testSubject.name())) {
        BlobStore store = container.blobStore;
        assertStoreHasExactly(store);
        SettableBlobMeta metadata = new SettableBlobMeta(BlobStoreAclHandler.DEFAULT);
        try (AtomicOutputStream out = store.createBlob("test", metadata, testSubject.subject)) {
            assertStoreHasExactly(store, "test");
            out.write(1);
        }
        store.deleteBlob("test", testSubject.subject);
    }
}
Also used : AtomicOutputStream(org.apache.storm.blobstore.AtomicOutputStream) SettableBlobMeta(org.apache.storm.generated.SettableBlobMeta) BlobStore(org.apache.storm.blobstore.BlobStore) EnumSource(org.junit.jupiter.params.provider.EnumSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Aggregations

BlobStore (org.apache.storm.blobstore.BlobStore)18 LocalFsBlobStore (org.apache.storm.blobstore.LocalFsBlobStore)11 IStormClusterState (org.apache.storm.cluster.IStormClusterState)7 KeyNotFoundException (org.apache.storm.generated.KeyNotFoundException)7 HashMap (java.util.HashMap)6 Subject (javax.security.auth.Subject)6 SettableBlobMeta (org.apache.storm.generated.SettableBlobMeta)5 IOException (java.io.IOException)4 InterruptedIOException (java.io.InterruptedIOException)4 BindException (java.net.BindException)4 AtomicOutputStream (org.apache.storm.blobstore.AtomicOutputStream)4 AlreadyAliveException (org.apache.storm.generated.AlreadyAliveException)4 AuthorizationException (org.apache.storm.generated.AuthorizationException)4 InvalidTopologyException (org.apache.storm.generated.InvalidTopologyException)4 KeyAlreadyExistsException (org.apache.storm.generated.KeyAlreadyExistsException)4 NotAliveException (org.apache.storm.generated.NotAliveException)4 StormTopology (org.apache.storm.generated.StormTopology)4 ArrayList (java.util.ArrayList)3 HashSet (java.util.HashSet)3 List (java.util.List)3