Search in sources :

Example 6 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 7 with BlobStore

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

the class Nimbus method createStateInZookeeper.

@Override
public void createStateInZookeeper(String key) throws TException {
    try {
        IStormClusterState state = stormClusterState;
        BlobStore store = blobStore;
        NimbusInfo ni = nimbusHostPortInfo;
        if (store instanceof LocalFsBlobStore) {
            state.setupBlobstore(key, ni, getVersionForKey(key, ni, conf));
        }
        LOG.debug("Created state in zookeeper {} {} {}", state, store, ni);
    } catch (Exception e) {
        LOG.warn("Exception while creating state in zookeeper - key: " + key, e);
        if (e instanceof TException) {
            throw (TException) e;
        }
        throw new RuntimeException(e);
    }
}
Also used : TException(org.apache.thrift.TException) LocalFsBlobStore(org.apache.storm.blobstore.LocalFsBlobStore) 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)

Example 8 with BlobStore

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

the class BlobStoreTest method testHdfsReplication.

@Test
public void testHdfsReplication() throws Exception {
    BlobStore store = initHdfs("/storm/blobstoreReplication");
    testReplication("/storm/blobstoreReplication/test", store);
}
Also used : BlobStore(org.apache.storm.blobstore.BlobStore) Test(org.junit.Test)

Example 9 with BlobStore

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

the class Nimbus method computeExecutors.

private List<List<Integer>> computeExecutors(String topoId, StormBase base) throws KeyNotFoundException, AuthorizationException, IOException, InvalidTopologyException {
    BlobStore store = blobStore;
    assert (base != null);
    Map<String, Integer> compToExecutors = base.get_component_executors();
    Map<String, Object> topoConf = readTopoConfAsNimbus(topoId, store);
    StormTopology topology = readStormTopologyAsNimbus(topoId, store);
    List<List<Integer>> ret = new ArrayList<>();
    if (compToExecutors != null) {
        Map<Integer, String> taskInfo = StormCommon.stormTaskInfo(topology, topoConf);
        Map<String, List<Integer>> compToTaskList = Utils.reverseMap(taskInfo);
        for (Entry<String, List<Integer>> entry : compToTaskList.entrySet()) {
            List<Integer> comps = entry.getValue();
            comps.sort(null);
            Integer numExecutors = compToExecutors.get(entry.getKey());
            if (numExecutors != null) {
                List<List<Integer>> partitioned = Utils.partitionFixed(numExecutors, comps);
                for (List<Integer> partition : partitioned) {
                    ret.add(Arrays.asList(partition.get(0), partition.get(partition.size() - 1)));
                }
            }
        }
    }
    return ret;
}
Also used : StormTopology(org.apache.storm.generated.StormTopology) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) BlobStore(org.apache.storm.blobstore.BlobStore) LocalFsBlobStore(org.apache.storm.blobstore.LocalFsBlobStore)

Example 10 with BlobStore

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

the class Nimbus method startTopology.

private void startTopology(String topoName, String topoId, TopologyStatus initStatus) throws KeyNotFoundException, AuthorizationException, IOException, InvalidTopologyException {
    assert (TopologyStatus.ACTIVE == initStatus || TopologyStatus.INACTIVE == initStatus);
    IStormClusterState state = stormClusterState;
    BlobStore store = blobStore;
    Map<String, Object> topoConf = readTopoConf(topoId, store);
    StormTopology topology = StormCommon.systemTopology(topoConf, readStormTopology(topoId, store));
    Map<String, Integer> numExecutors = new HashMap<>();
    for (Entry<String, Object> entry : StormCommon.allComponents(topology).entrySet()) {
        numExecutors.put(entry.getKey(), StormCommon.numStartExecutors(entry.getValue()));
    }
    LOG.info("Activating {}: {}", topoName, topoId);
    StormBase base = new StormBase();
    base.set_name(topoName);
    base.set_launch_time_secs(Time.currentTimeSecs());
    base.set_status(initStatus);
    base.set_num_workers(Utils.getInt(topoConf.get(Config.TOPOLOGY_WORKERS), 0));
    base.set_component_executors(numExecutors);
    base.set_owner((String) topoConf.get(Config.TOPOLOGY_SUBMITTER_USER));
    base.set_component_debug(new HashMap<>());
    state.activateStorm(topoId, base);
    notifyTopologyActionListener(topoName, "activate");
}
Also used : HashMap(java.util.HashMap) StormTopology(org.apache.storm.generated.StormTopology) StormBase(org.apache.storm.generated.StormBase) IStormClusterState(org.apache.storm.cluster.IStormClusterState) BlobStore(org.apache.storm.blobstore.BlobStore) LocalFsBlobStore(org.apache.storm.blobstore.LocalFsBlobStore)

Aggregations

BlobStore (org.apache.storm.blobstore.BlobStore)16 LocalFsBlobStore (org.apache.storm.blobstore.LocalFsBlobStore)15 IStormClusterState (org.apache.storm.cluster.IStormClusterState)11 HashMap (java.util.HashMap)6 KeyNotFoundException (org.apache.storm.generated.KeyNotFoundException)6 IOException (java.io.IOException)5 InterruptedIOException (java.io.InterruptedIOException)5 BindException (java.net.BindException)5 ArrayList (java.util.ArrayList)5 List (java.util.List)5 AlreadyAliveException (org.apache.storm.generated.AlreadyAliveException)5 AuthorizationException (org.apache.storm.generated.AuthorizationException)5 InvalidTopologyException (org.apache.storm.generated.InvalidTopologyException)5 KeyAlreadyExistsException (org.apache.storm.generated.KeyAlreadyExistsException)5 NotAliveException (org.apache.storm.generated.NotAliveException)5 StormTopology (org.apache.storm.generated.StormTopology)5 NimbusInfo (org.apache.storm.nimbus.NimbusInfo)5 TException (org.apache.thrift.TException)5 VisibleForTesting (com.google.common.annotations.VisibleForTesting)3 HashSet (java.util.HashSet)3