| /** |
| * Licensed to the Apache Software Foundation (ASF) under one |
| * or more contributor license agreements. See the NOTICE file |
| * distributed with this work for additional information |
| * regarding copyright ownership. The ASF licenses this file |
| * to you under the Apache License, Version 2.0 (the |
| * "License"); you may not use this file except in compliance |
| * with the License. You may obtain a copy of the License at |
| * |
| * http://www.apache.org/licenses/LICENSE-2.0 |
| * |
| * Unless required by applicable law or agreed to in writing, software |
| * distributed under the License is distributed on an "AS IS" BASIS, |
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| * See the License for the specific language governing permissions and |
| * limitations under the License. |
| */ |
| package backtype.storm.scheduler; |
| |
| import java.util.Collection; |
| import java.util.HashMap; |
| import java.util.Map; |
| |
| import backtype.storm.Config; |
| import backtype.storm.generated.StormTopology; |
| |
| |
| public class TopologyDetails { |
| String topologyId; |
| Map topologyConf; |
| StormTopology topology; |
| Map<ExecutorDetails, String> executorToComponent; |
| int numWorkers; |
| |
| public TopologyDetails(String topologyId, Map topologyConf, StormTopology topology, int numWorkers) { |
| this.topologyId = topologyId; |
| this.topologyConf = topologyConf; |
| this.topology = topology; |
| this.numWorkers = numWorkers; |
| } |
| |
| public TopologyDetails(String topologyId, Map topologyConf, StormTopology topology, int numWorkers, Map<ExecutorDetails, String> executorToComponents) { |
| this(topologyId, topologyConf, topology, numWorkers); |
| this.executorToComponent = new HashMap<ExecutorDetails, String>(0); |
| if (executorToComponents != null) { |
| this.executorToComponent.putAll(executorToComponents); |
| } |
| } |
| |
| public String getId() { |
| return topologyId; |
| } |
| |
| public String getName() { |
| return (String)this.topologyConf.get(Config.TOPOLOGY_NAME); |
| } |
| |
| public Map getConf() { |
| return topologyConf; |
| } |
| |
| public int getNumWorkers() { |
| return numWorkers; |
| } |
| |
| public StormTopology getTopology() { |
| return topology; |
| } |
| |
| public Map<ExecutorDetails, String> getExecutorToComponent() { |
| return this.executorToComponent; |
| } |
| |
| public Map<ExecutorDetails, String> selectExecutorToComponent(Collection<ExecutorDetails> executors) { |
| Map<ExecutorDetails, String> ret = new HashMap<ExecutorDetails, String>(executors.size()); |
| for (ExecutorDetails executor : executors) { |
| String compId = this.executorToComponent.get(executor); |
| if (compId != null) { |
| ret.put(executor, compId); |
| } |
| } |
| |
| return ret; |
| } |
| |
| public Collection<ExecutorDetails> getExecutors() { |
| return this.executorToComponent.keySet(); |
| } |
| } |