Search in sources :

Example 1 with NodeInfo

use of org.apache.storm.generated.NodeInfo in project storm by apache.

the class Nimbus method getTopologyInfoWithOpts.

@Override
public TopologyInfo getTopologyInfoWithOpts(String topoId, GetInfoOptions options) throws NotAliveException, AuthorizationException, TException {
    try {
        getTopologyInfoWithOptsCalls.mark();
        CommonTopoInfo common = getCommonTopoInfo(topoId, "getTopologyInfo");
        if (common.base == null) {
            throw new NotAliveException(topoId);
        }
        IStormClusterState state = stormClusterState;
        NumErrorsChoice numErrChoice = OR(options.get_num_err_choice(), NumErrorsChoice.ALL);
        Map<String, List<ErrorInfo>> errors = new HashMap<>();
        for (String component : common.allComponents) {
            switch(numErrChoice) {
                case NONE:
                    errors.put(component, Collections.emptyList());
                    break;
                case ONE:
                    List<ErrorInfo> errList = new ArrayList<>();
                    ErrorInfo info = state.lastError(topoId, component);
                    if (info != null) {
                        errList.add(info);
                    }
                    errors.put(component, errList);
                    break;
                case ALL:
                    errors.put(component, state.errors(topoId, component));
                    break;
                default:
                    LOG.warn("Got invalid NumErrorsChoice '{}'", numErrChoice);
                    errors.put(component, state.errors(topoId, component));
                    break;
            }
        }
        List<ExecutorSummary> summaries = new ArrayList<>();
        if (common.assignment != null) {
            for (Entry<List<Long>, NodeInfo> entry : common.assignment.get_executor_node_port().entrySet()) {
                NodeInfo ni = entry.getValue();
                ExecutorInfo execInfo = toExecInfo(entry.getKey());
                String host = entry.getValue().get_node();
                Map<String, Object> heartbeat = common.beats.get(StatsUtil.convertExecutor(entry.getKey()));
                if (heartbeat == null) {
                    heartbeat = Collections.emptyMap();
                }
                ExecutorSummary summ = new ExecutorSummary(execInfo, common.taskToComponent.get(execInfo.get_task_start()), ni.get_node(), ni.get_port_iterator().next().intValue(), (Integer) heartbeat.getOrDefault("uptime", 0));
                //heartbeats "stats"
                Map<String, Object> hb = (Map<String, Object>) heartbeat.get("heartbeat");
                if (hb != null) {
                    Map ex = (Map) hb.get("stats");
                    if (ex != null) {
                        ExecutorStats stats = StatsUtil.thriftifyExecutorStats(ex);
                        summ.set_stats(stats);
                    }
                }
                summaries.add(summ);
            }
        }
        TopologyInfo topoInfo = new TopologyInfo(topoId, common.topoName, Time.deltaSecs(common.launchTimeSecs), summaries, extractStatusStr(common.base), errors);
        if (common.base.is_set_owner()) {
            topoInfo.set_owner(common.base.get_owner());
        }
        String schedStatus = idToSchedStatus.get().get(topoId);
        if (schedStatus != null) {
            topoInfo.set_sched_status(schedStatus);
        }
        TopologyResources resources = getResourcesForTopology(topoId, common.base);
        if (resources != null) {
            topoInfo.set_requested_memonheap(resources.getRequestedMemOnHeap());
            topoInfo.set_requested_memoffheap(resources.getRequestedMemOffHeap());
            topoInfo.set_requested_cpu(resources.getRequestedCpu());
            topoInfo.set_assigned_memonheap(resources.getAssignedMemOnHeap());
            topoInfo.set_assigned_memoffheap(resources.getAssignedMemOffHeap());
            topoInfo.set_assigned_cpu(resources.getAssignedCpu());
        }
        if (common.base.is_set_component_debug()) {
            topoInfo.set_component_debug(common.base.get_component_debug());
        }
        topoInfo.set_replication_count(getBlobReplicationCount(ConfigUtils.masterStormCodeKey(topoId)));
        return topoInfo;
    } catch (Exception e) {
        LOG.warn("Get topo info exception. (topology id='{}')", topoId, e);
        if (e instanceof TException) {
            throw (TException) e;
        }
        throw new RuntimeException(e);
    }
}
Also used : TException(org.apache.thrift.TException) HashMap(java.util.HashMap) ExecutorStats(org.apache.storm.generated.ExecutorStats) ArrayList(java.util.ArrayList) ExecutorSummary(org.apache.storm.generated.ExecutorSummary) NotAliveException(org.apache.storm.generated.NotAliveException) ExecutorInfo(org.apache.storm.generated.ExecutorInfo) ArrayList(java.util.ArrayList) List(java.util.List) IStormClusterState(org.apache.storm.cluster.IStormClusterState) ErrorInfo(org.apache.storm.generated.ErrorInfo) 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) NodeInfo(org.apache.storm.generated.NodeInfo) NumErrorsChoice(org.apache.storm.generated.NumErrorsChoice) Map(java.util.Map) TimeCacheMap(org.apache.storm.utils.TimeCacheMap) ImmutableMap(com.google.common.collect.ImmutableMap) HashMap(java.util.HashMap) TopologyInfo(org.apache.storm.generated.TopologyInfo)

Example 2 with NodeInfo

use of org.apache.storm.generated.NodeInfo in project storm by apache.

the class WorkerState method refreshConnections.

public void refreshConnections() {
    Assignment assignment = null;
    try {
        assignment = getLocalAssignment(stormClusterState, topologyId);
    } catch (Exception e) {
        LOG.warn("Failed to read assignment. This should only happen when topology is shutting down.", e);
    }
    suicideIfLocalAssignmentsChanged(assignment);
    Set<NodeInfo> neededConnections = new HashSet<>();
    Map<Integer, NodeInfo> newTaskToNodePort = new HashMap<>();
    if (null != assignment) {
        Map<Integer, NodeInfo> taskToNodePort = StormCommon.taskToNodeport(assignment.get_executor_node_port());
        for (Map.Entry<Integer, NodeInfo> taskToNodePortEntry : taskToNodePort.entrySet()) {
            Integer task = taskToNodePortEntry.getKey();
            if (outboundTasks.contains(task)) {
                newTaskToNodePort.put(task, taskToNodePortEntry.getValue());
                if (!localTaskIds.contains(task)) {
                    neededConnections.add(taskToNodePortEntry.getValue());
                }
            }
        }
    }
    final Set<NodeInfo> currentConnections = cachedNodeToPortSocket.get().keySet();
    final Set<NodeInfo> newConnections = Sets.difference(neededConnections, currentConnections);
    final Set<NodeInfo> removeConnections = Sets.difference(currentConnections, neededConnections);
    Map<String, String> nodeHost = assignment != null ? assignment.get_node_host() : null;
    // Add new connections atomically
    cachedNodeToPortSocket.getAndUpdate(prev -> {
        Map<NodeInfo, IConnection> next = new HashMap<>(prev);
        for (NodeInfo nodeInfo : newConnections) {
            next.put(nodeInfo, mqContext.connect(topologyId, // Host
            nodeHost.get(nodeInfo.get_node()), // Port
            nodeInfo.get_port().iterator().next().intValue(), workerTransfer.getRemoteBackPressureStatus()));
        }
        return next;
    });
    try {
        endpointSocketLock.writeLock().lock();
        cachedTaskToNodePort.set(newTaskToNodePort);
    } finally {
        endpointSocketLock.writeLock().unlock();
    }
    // It is okay that cachedNodeToHost can be temporarily out of sync with cachedTaskToNodePort
    if (nodeHost != null) {
        cachedNodeToHost.set(nodeHost);
    } else {
        cachedNodeToHost.set(new HashMap<>());
    }
    for (NodeInfo nodeInfo : removeConnections) {
        cachedNodeToPortSocket.get().get(nodeInfo).close();
    }
    // Remove old connections atomically
    cachedNodeToPortSocket.getAndUpdate(prev -> {
        Map<NodeInfo, IConnection> next = new HashMap<>(prev);
        removeConnections.forEach(next::remove);
        return next;
    });
}
Also used : ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) HashMap(java.util.HashMap) IConnection(org.apache.storm.messaging.IConnection) InvalidTopologyException(org.apache.storm.generated.InvalidTopologyException) IOException(java.io.IOException) Assignment(org.apache.storm.generated.Assignment) NodeInfo(org.apache.storm.generated.NodeInfo) Map(java.util.Map) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) ImmutableMap(org.apache.storm.shade.com.google.common.collect.ImmutableMap) HashMap(java.util.HashMap) ConcurrentMap(java.util.concurrent.ConcurrentMap) HashSet(java.util.HashSet)

Example 3 with NodeInfo

use of org.apache.storm.generated.NodeInfo in project storm by apache.

the class WorkerState method readWorkerExecutors.

private List<List<Long>> readWorkerExecutors(String assignmentId, int port, Assignment assignment) {
    List<List<Long>> executorsAssignedToThisWorker = new ArrayList<>();
    executorsAssignedToThisWorker.add(Constants.SYSTEM_EXECUTOR_ID);
    Map<List<Long>, NodeInfo> executorToNodePort = assignment.get_executor_node_port();
    for (Map.Entry<List<Long>, NodeInfo> entry : executorToNodePort.entrySet()) {
        NodeInfo nodeInfo = entry.getValue();
        if (nodeInfo.get_node().equals(assignmentId) && nodeInfo.get_port().iterator().next() == port) {
            executorsAssignedToThisWorker.add(entry.getKey());
        }
    }
    return executorsAssignedToThisWorker;
}
Also used : NodeInfo(org.apache.storm.generated.NodeInfo) ArrayList(java.util.ArrayList) List(java.util.List) ArrayList(java.util.ArrayList) Map(java.util.Map) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) ImmutableMap(org.apache.storm.shade.com.google.common.collect.ImmutableMap) HashMap(java.util.HashMap) ConcurrentMap(java.util.concurrent.ConcurrentMap)

Example 4 with NodeInfo

use of org.apache.storm.generated.NodeInfo in project storm by apache.

the class Nimbus method changedExecutors.

private static List<List<Long>> changedExecutors(Map<List<Long>, NodeInfo> map, Map<List<Long>, List<Object>> newExecToNodePort) {
    HashMap<NodeInfo, List<List<Long>>> tmpSlotAssigned = map == null ? new HashMap<>() : Utils.reverseMap(map);
    HashMap<List<Object>, List<List<Long>>> slotAssigned = new HashMap<>();
    for (Entry<NodeInfo, List<List<Long>>> entry : tmpSlotAssigned.entrySet()) {
        NodeInfo ni = entry.getKey();
        List<Object> key = new ArrayList<>(2);
        key.add(ni.get_node());
        key.add(ni.get_port_iterator().next());
        List<List<Long>> value = new ArrayList<>(entry.getValue());
        value.sort(Comparator.comparing(a -> a.get(0)));
        slotAssigned.put(key, value);
    }
    HashMap<List<Object>, List<List<Long>>> tmpNewSlotAssigned = newExecToNodePort == null ? new HashMap<>() : Utils.reverseMap(newExecToNodePort);
    HashMap<List<Object>, List<List<Long>>> newSlotAssigned = new HashMap<>();
    for (Entry<List<Object>, List<List<Long>>> entry : tmpNewSlotAssigned.entrySet()) {
        List<List<Long>> value = new ArrayList<>(entry.getValue());
        value.sort(Comparator.comparing(a -> a.get(0)));
        newSlotAssigned.put(entry.getKey(), value);
    }
    Map<List<Object>, List<List<Long>>> diff = mapDiff(slotAssigned, newSlotAssigned);
    List<List<Long>> ret = new ArrayList<>();
    for (List<List<Long>> val : diff.values()) {
        ret.addAll(val);
    }
    return ret;
}
Also used : ZooDefs(org.apache.storm.shade.org.apache.zookeeper.ZooDefs) MetricSet(com.codahale.metrics.MetricSet) AssignmentDistributionService(org.apache.storm.nimbus.AssignmentDistributionService) DerivativeGauge(com.codahale.metrics.DerivativeGauge) INimbus(org.apache.storm.scheduler.INimbus) Assignment(org.apache.storm.generated.Assignment) ServerSocket(java.net.ServerSocket) DaemonConfig(org.apache.storm.DaemonConfig) DaemonType(org.apache.storm.cluster.DaemonType) IAuthorizer(org.apache.storm.security.auth.IAuthorizer) Map(java.util.Map) SchedulerAssignmentImpl(org.apache.storm.scheduler.SchedulerAssignmentImpl) TupleUtils(org.apache.storm.utils.TupleUtils) ComponentPageInfo(org.apache.storm.generated.ComponentPageInfo) SupervisorAssignments(org.apache.storm.generated.SupervisorAssignments) SpecificAggregateStats(org.apache.storm.generated.SpecificAggregateStats) IPrincipalToLocal(org.apache.storm.security.auth.IPrincipalToLocal) TopologyInfo(org.apache.storm.generated.TopologyInfo) WorkerTokenManager(org.apache.storm.security.auth.workertoken.WorkerTokenManager) SupervisorWorkerHeartbeat(org.apache.storm.generated.SupervisorWorkerHeartbeat) SimpleVersion(org.apache.storm.utils.SimpleVersion) Time(org.apache.storm.utils.Time) DefaultScheduler(org.apache.storm.scheduler.DefaultScheduler) INimbusCredentialPlugin(org.apache.storm.security.INimbusCredentialPlugin) Shutdownable(org.apache.storm.daemon.Shutdownable) StormCommon(org.apache.storm.daemon.StormCommon) SettableBlobMeta(org.apache.storm.generated.SettableBlobMeta) ErrorInfo(org.apache.storm.generated.ErrorInfo) ProfileAction(org.apache.storm.generated.ProfileAction) AggLevel(org.apache.storm.metricstore.AggLevel) MetricStore(org.apache.storm.metricstore.MetricStore) TopologyPageInfo(org.apache.storm.generated.TopologyPageInfo) Topologies(org.apache.storm.scheduler.Topologies) SupervisorSummary(org.apache.storm.generated.SupervisorSummary) ServerUtils(org.apache.storm.utils.ServerUtils) ConfigValidation(org.apache.storm.validation.ConfigValidation) SupervisorPageInfo(org.apache.storm.generated.SupervisorPageInfo) LocalState(org.apache.storm.utils.LocalState) WrappedAuthorizationException(org.apache.storm.utils.WrappedAuthorizationException) TopologyInitialStatus(org.apache.storm.generated.TopologyInitialStatus) ServerConfigUtils(org.apache.storm.utils.ServerConfigUtils) IOException(java.io.IOException) Utils(org.apache.storm.utils.Utils) ReqContext(org.apache.storm.security.auth.ReqContext) AtomicLong(java.util.concurrent.atomic.AtomicLong) Constants(org.apache.storm.Constants) WritableByteChannel(java.nio.channels.WritableByteChannel) TopologySummary(org.apache.storm.generated.TopologySummary) ComponentType(org.apache.storm.generated.ComponentType) ClusterSummary(org.apache.storm.generated.ClusterSummary) StatsUtil(org.apache.storm.stats.StatsUtil) IllegalStateException(org.apache.storm.generated.IllegalStateException) AlreadyAliveException(org.apache.storm.generated.AlreadyAliveException) IWorkerHeartbeatsRecoveryStrategy(org.apache.storm.nimbus.IWorkerHeartbeatsRecoveryStrategy) MultitenantScheduler(org.apache.storm.scheduler.multitenant.MultitenantScheduler) WorkerSlot(org.apache.storm.scheduler.WorkerSlot) GetInfoOptions(org.apache.storm.generated.GetInfoOptions) WorkerMetricPoint(org.apache.storm.generated.WorkerMetricPoint) KillOptions(org.apache.storm.generated.KillOptions) UptimeComputer(org.apache.storm.utils.Utils.UptimeComputer) LSTopoHistory(org.apache.storm.generated.LSTopoHistory) SchedulerAssignment(org.apache.storm.scheduler.SchedulerAssignment) Metric(org.apache.storm.metricstore.Metric) ThriftServer(org.apache.storm.security.auth.ThriftServer) Collection(java.util.Collection) ClientStatsUtil(org.apache.storm.stats.ClientStatsUtil) NavigableMap(java.util.NavigableMap) Collectors(java.util.stream.Collectors) ReadableBlobMeta(org.apache.storm.generated.ReadableBlobMeta) BlacklistScheduler(org.apache.storm.scheduler.blacklist.BlacklistScheduler) ProfileRequest(org.apache.storm.generated.ProfileRequest) Entry(java.util.Map.Entry) OciUtils(org.apache.storm.container.oci.OciUtils) WorkerHeartbeatsRecoveryStrategyFactory(org.apache.storm.nimbus.WorkerHeartbeatsRecoveryStrategyFactory) ExecutorDetails(org.apache.storm.scheduler.ExecutorDetails) RebalanceOptions(org.apache.storm.generated.RebalanceOptions) Iface(org.apache.storm.generated.Nimbus.Iface) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) Function(java.util.function.Function) HashSet(java.util.HashSet) Meter(com.codahale.metrics.Meter) TopologyStatus(org.apache.storm.generated.TopologyStatus) IGroupMappingServiceProvider(org.apache.storm.security.auth.IGroupMappingServiceProvider) VisibleForTesting(org.apache.storm.shade.com.google.common.annotations.VisibleForTesting) JSONValue(org.json.simple.JSONValue) OwnerResourceSummary(org.apache.storm.generated.OwnerResourceSummary) DefaultTopologyValidator(org.apache.storm.nimbus.DefaultTopologyValidator) DaemonCommon(org.apache.storm.daemon.DaemonCommon) Logger(org.slf4j.Logger) KeySequenceNumber(org.apache.storm.blobstore.KeySequenceNumber) Channels(java.nio.channels.Channels) NimbusInfo(org.apache.storm.nimbus.NimbusInfo) FileInputStream(java.io.FileInputStream) ResourceUtils(org.apache.storm.scheduler.resource.ResourceUtils) WrappedNotAliveException(org.apache.storm.utils.WrappedNotAliveException) Subject(javax.security.auth.Subject) TopologyActionOptions(org.apache.storm.generated.TopologyActionOptions) WrappedInvalidTopologyException(org.apache.storm.utils.WrappedInvalidTopologyException) Comparator(java.util.Comparator) SpoutAggregateStats(org.apache.storm.generated.SpoutAggregateStats) ClusterMetricsConsumerExecutor(org.apache.storm.metric.ClusterMetricsConsumerExecutor) ClientAuthUtils(org.apache.storm.security.auth.ClientAuthUtils) ComponentAggregateStats(org.apache.storm.generated.ComponentAggregateStats) Arrays(java.util.Arrays) UnaryOperator(java.util.function.UnaryOperator) CachedGauge(com.codahale.metrics.CachedGauge) RotatingMap(org.apache.storm.utils.RotatingMap) BlobStore(org.apache.storm.blobstore.BlobStore) ResourceMetrics(org.apache.storm.scheduler.resource.normalization.ResourceMetrics) CommonAggregateStats(org.apache.storm.generated.CommonAggregateStats) ListBlobsResult(org.apache.storm.generated.ListBlobsResult) BoltAggregateStats(org.apache.storm.generated.BoltAggregateStats) Set(java.util.Set) Credentials(org.apache.storm.generated.Credentials) AuthorizationException(org.apache.storm.generated.AuthorizationException) ConfigUtils(org.apache.storm.utils.ConfigUtils) InputStreamWithMeta(org.apache.storm.blobstore.InputStreamWithMeta) NotAliveException(org.apache.storm.generated.NotAliveException) Timer(com.codahale.metrics.Timer) Config(org.apache.storm.Config) MapDifference(org.apache.storm.shade.com.google.common.collect.MapDifference) ImmutableMap(org.apache.storm.shade.com.google.common.collect.ImmutableMap) ITopologyActionNotifierPlugin(org.apache.storm.nimbus.ITopologyActionNotifierPlugin) ITopologyValidator(org.apache.storm.nimbus.ITopologyValidator) AclEnforcement(org.apache.storm.zookeeper.AclEnforcement) WrappedAlreadyAliveException(org.apache.storm.utils.WrappedAlreadyAliveException) InterruptedIOException(java.io.InterruptedIOException) TreeSet(java.util.TreeSet) ArrayList(java.util.ArrayList) ILeaderElector(org.apache.storm.nimbus.ILeaderElector) NumErrorsChoice(org.apache.storm.generated.NumErrorsChoice) Zookeeper(org.apache.storm.zookeeper.Zookeeper) ReflectionUtils(org.apache.storm.utils.ReflectionUtils) ExecutorInfo(org.apache.storm.generated.ExecutorInfo) Maps(org.apache.storm.shade.com.google.common.collect.Maps) NodeInfo(org.apache.storm.generated.NodeInfo) ClusterStateContext(org.apache.storm.cluster.ClusterStateContext) DefaultWatcherCallBack(org.apache.storm.callback.DefaultWatcherCallBack) MetricRegistry(com.codahale.metrics.MetricRegistry) NimbusPrincipal(org.apache.storm.security.auth.NimbusPrincipal) ExecutorStats(org.apache.storm.generated.ExecutorStats) WorkerSummary(org.apache.storm.generated.WorkerSummary) Strings(org.apache.storm.shade.com.google.common.base.Strings) FileOutputStream(java.io.FileOutputStream) IStormClusterState(org.apache.storm.cluster.IStormClusterState) ACL(org.apache.storm.shade.org.apache.zookeeper.data.ACL) File(java.io.File) LocalFsBlobStore(org.apache.storm.blobstore.LocalFsBlobStore) Cluster(org.apache.storm.scheduler.Cluster) TimeCacheMap(org.apache.storm.utils.TimeCacheMap) StormTimer(org.apache.storm.StormTimer) SupervisorWorkerHeartbeats(org.apache.storm.generated.SupervisorWorkerHeartbeats) ObjectReader(org.apache.storm.utils.ObjectReader) CuratorFramework(org.apache.storm.shade.org.apache.curator.framework.CuratorFramework) ClusterInfo(org.apache.storm.metric.api.IClusterMetricsConsumer.ClusterInfo) IClusterMetricsConsumer(org.apache.storm.metric.api.IClusterMetricsConsumer) LogLevel(org.apache.storm.generated.LogLevel) NormalizedResourceRequest(org.apache.storm.scheduler.resource.normalization.NormalizedResourceRequest) TopologyHistoryInfo(org.apache.storm.generated.TopologyHistoryInfo) LoggerFactory(org.slf4j.LoggerFactory) ByteBuffer(java.nio.ByteBuffer) SubmitOptions(org.apache.storm.generated.SubmitOptions) SupervisorResources(org.apache.storm.scheduler.SupervisorResources) DebugOptions(org.apache.storm.generated.DebugOptions) VersionInfo(org.apache.storm.utils.VersionInfo) BlobStoreAclHandler(org.apache.storm.blobstore.BlobStoreAclHandler) ThriftConnectionType(org.apache.storm.security.auth.ThriftConnectionType) KeyAlreadyExistsException(org.apache.storm.generated.KeyAlreadyExistsException) TopologyDetails(org.apache.storm.scheduler.TopologyDetails) LogConfig(org.apache.storm.generated.LogConfig) TException(org.apache.storm.thrift.TException) WrappedIllegalStateException(org.apache.storm.utils.WrappedIllegalStateException) WorkerMetrics(org.apache.storm.generated.WorkerMetrics) WorkerResources(org.apache.storm.generated.WorkerResources) List(java.util.List) KeyNotFoundException(org.apache.storm.generated.KeyNotFoundException) Principal(java.security.Principal) ICredentialsRenewer(org.apache.storm.security.auth.ICredentialsRenewer) SupervisorInfo(org.apache.storm.generated.SupervisorInfo) BufferInputStream(org.apache.storm.utils.BufferInputStream) SpoutSpec(org.apache.storm.generated.SpoutSpec) AtomicOutputStream(org.apache.storm.blobstore.AtomicOutputStream) InvalidTopologyException(org.apache.storm.generated.InvalidTopologyException) ClusterUtils(org.apache.storm.cluster.ClusterUtils) SlidingTimeWindowReservoir(com.codahale.metrics.SlidingTimeWindowReservoir) MetricStoreConfig(org.apache.storm.metricstore.MetricStoreConfig) Histogram(com.codahale.metrics.Histogram) IScheduler(org.apache.storm.scheduler.IScheduler) HashMap(java.util.HashMap) BindException(java.net.BindException) ClientZookeeper(org.apache.storm.zookeeper.ClientZookeeper) BeginDownloadResult(org.apache.storm.generated.BeginDownloadResult) AtomicReference(java.util.concurrent.atomic.AtomicReference) Bolt(org.apache.storm.generated.Bolt) StormTopology(org.apache.storm.generated.StormTopology) DataPoint(org.apache.storm.metric.api.DataPoint) ThriftAccessLogger(org.apache.storm.logging.ThriftAccessLogger) StormMetricsRegistry(org.apache.storm.metric.StormMetricsRegistry) OutputStream(java.io.OutputStream) StormBase(org.apache.storm.generated.StormBase) NimbusSummary(org.apache.storm.generated.NimbusSummary) Iterator(java.util.Iterator) SupervisorDetails(org.apache.storm.scheduler.SupervisorDetails) ExecutorSummary(org.apache.storm.generated.ExecutorSummary) TimeUnit(java.util.concurrent.TimeUnit) ResourceAwareScheduler(org.apache.storm.scheduler.resource.ResourceAwareScheduler) LogLevelAction(org.apache.storm.generated.LogLevelAction) Processor(org.apache.storm.generated.Nimbus.Processor) Collections(java.util.Collections) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) NodeInfo(org.apache.storm.generated.NodeInfo) AtomicLong(java.util.concurrent.atomic.AtomicLong) ArrayList(java.util.ArrayList) List(java.util.List)

Example 5 with NodeInfo

use of org.apache.storm.generated.NodeInfo in project storm by apache.

the class Nimbus method getTopologyPageInfo.

@Override
public TopologyPageInfo getTopologyPageInfo(String topoId, String window, boolean includeSys) throws NotAliveException, AuthorizationException, TException {
    try {
        getTopologyPageInfoCalls.mark();
        CommonTopoInfo common = getCommonTopoInfo(topoId, "getTopologyPageInfo");
        String topoName = common.topoName;
        IStormClusterState state = stormClusterState;
        Assignment assignment = common.assignment;
        Map<List<Integer>, Map<String, Object>> beats = common.beats;
        Map<Integer, String> taskToComp = common.taskToComponent;
        StormTopology topology = common.topology;
        StormBase base = common.base;
        if (base == null) {
            throw new WrappedNotAliveException(topoId);
        }
        String owner = base.get_owner();
        Map<WorkerSlot, WorkerResources> workerToResources = getWorkerResourcesForTopology(topoId);
        List<WorkerSummary> workerSummaries = null;
        Map<List<Long>, List<Object>> exec2NodePort = new HashMap<>();
        if (assignment != null) {
            Map<List<Long>, NodeInfo> execToNodeInfo = assignment.get_executor_node_port();
            Map<String, String> nodeToHost = assignment.get_node_host();
            for (Entry<List<Long>, NodeInfo> entry : execToNodeInfo.entrySet()) {
                NodeInfo ni = entry.getValue();
                List<Object> nodePort = Arrays.asList(ni.get_node(), ni.get_port_iterator().next());
                exec2NodePort.put(entry.getKey(), nodePort);
            }
            workerSummaries = StatsUtil.aggWorkerStats(topoId, topoName, taskToComp, beats, exec2NodePort, nodeToHost, workerToResources, includeSys, // this is the topology page, so we know the user is authorized
            true, null, owner);
        }
        TopologyPageInfo topoPageInfo = StatsUtil.aggTopoExecsStats(topoId, exec2NodePort, taskToComp, beats, topology, window, includeSys, state);
        if (topology.is_set_storm_version()) {
            topoPageInfo.set_storm_version(topology.get_storm_version());
        }
        Map<String, Object> topoConf = Utils.merge(conf, common.topoConf);
        addSpoutAggStats(topoPageInfo, topology, topoConf);
        addBoltAggStats(topoPageInfo, topology, topoConf, includeSys);
        if (workerSummaries != null) {
            topoPageInfo.set_workers(workerSummaries);
        }
        if (base.is_set_owner()) {
            topoPageInfo.set_owner(base.get_owner());
        }
        if (base.is_set_topology_version()) {
            topoPageInfo.set_topology_version(base.get_topology_version());
        }
        String schedStatus = idToSchedStatus.get().get(topoId);
        if (schedStatus != null) {
            topoPageInfo.set_sched_status(schedStatus);
        }
        TopologyResources resources = getResourcesForTopology(topoId, base);
        if (resources != null && underlyingScheduler instanceof ResourceAwareScheduler) {
            topoPageInfo.set_requested_memonheap(resources.getRequestedMemOnHeap());
            topoPageInfo.set_requested_memoffheap(resources.getRequestedMemOffHeap());
            topoPageInfo.set_requested_cpu(resources.getRequestedCpu());
            topoPageInfo.set_assigned_memonheap(resources.getAssignedMemOnHeap());
            topoPageInfo.set_assigned_memoffheap(resources.getAssignedMemOffHeap());
            topoPageInfo.set_assigned_cpu(resources.getAssignedCpu());
            topoPageInfo.set_requested_shared_off_heap_memory(resources.getRequestedSharedMemOffHeap());
            topoPageInfo.set_requested_regular_off_heap_memory(resources.getRequestedNonSharedMemOffHeap());
            topoPageInfo.set_requested_shared_on_heap_memory(resources.getRequestedSharedMemOnHeap());
            topoPageInfo.set_requested_regular_on_heap_memory(resources.getRequestedNonSharedMemOnHeap());
            topoPageInfo.set_assigned_shared_off_heap_memory(resources.getAssignedSharedMemOffHeap());
            topoPageInfo.set_assigned_regular_off_heap_memory(resources.getAssignedNonSharedMemOffHeap());
            topoPageInfo.set_assigned_shared_on_heap_memory(resources.getAssignedSharedMemOnHeap());
            topoPageInfo.set_assigned_regular_on_heap_memory(resources.getAssignedNonSharedMemOnHeap());
            topoPageInfo.set_assigned_generic_resources(resources.getAssignedGenericResources());
            topoPageInfo.set_requested_generic_resources(resources.getRequestedGenericResources());
        }
        int launchTimeSecs = common.launchTimeSecs;
        topoPageInfo.set_name(topoName);
        topoPageInfo.set_status(extractStatusStr(base));
        topoPageInfo.set_uptime_secs(Time.deltaSecs(launchTimeSecs));
        topoPageInfo.set_topology_conf(JSONValue.toJSONString(topoConf));
        topoPageInfo.set_replication_count(getBlobReplicationCount(ConfigUtils.masterStormCodeKey(topoId)));
        if (base.is_set_component_debug()) {
            DebugOptions debug = base.get_component_debug().get(topoId);
            if (debug != null) {
                topoPageInfo.set_debug_options(debug);
            }
        }
        return topoPageInfo;
    } catch (Exception e) {
        LOG.warn("Get topo page info exception. (topology id='{}')", topoId, e);
        if (e instanceof TException) {
            throw (TException) e;
        }
        throw new RuntimeException(e);
    }
}
Also used : TException(org.apache.storm.thrift.TException) HashMap(java.util.HashMap) StormTopology(org.apache.storm.generated.StormTopology) StormBase(org.apache.storm.generated.StormBase) DebugOptions(org.apache.storm.generated.DebugOptions) ResourceAwareScheduler(org.apache.storm.scheduler.resource.ResourceAwareScheduler) Assignment(org.apache.storm.generated.Assignment) SchedulerAssignment(org.apache.storm.scheduler.SchedulerAssignment) WorkerSlot(org.apache.storm.scheduler.WorkerSlot) ArrayList(java.util.ArrayList) List(java.util.List) IStormClusterState(org.apache.storm.cluster.IStormClusterState) WorkerResources(org.apache.storm.generated.WorkerResources) TopologyPageInfo(org.apache.storm.generated.TopologyPageInfo) WrappedNotAliveException(org.apache.storm.utils.WrappedNotAliveException) 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) WorkerSummary(org.apache.storm.generated.WorkerSummary) NodeInfo(org.apache.storm.generated.NodeInfo) Map(java.util.Map) NavigableMap(java.util.NavigableMap) RotatingMap(org.apache.storm.utils.RotatingMap) ImmutableMap(org.apache.storm.shade.com.google.common.collect.ImmutableMap) TimeCacheMap(org.apache.storm.utils.TimeCacheMap) HashMap(java.util.HashMap)

Aggregations

NodeInfo (org.apache.storm.generated.NodeInfo)30 HashMap (java.util.HashMap)21 ArrayList (java.util.ArrayList)18 List (java.util.List)18 Map (java.util.Map)15 Assignment (org.apache.storm.generated.Assignment)13 HashSet (java.util.HashSet)10 SchedulerAssignment (org.apache.storm.scheduler.SchedulerAssignment)9 ImmutableMap (org.apache.storm.shade.com.google.common.collect.ImmutableMap)9 TimeCacheMap (org.apache.storm.utils.TimeCacheMap)9 IOException (java.io.IOException)7 NavigableMap (java.util.NavigableMap)7 InvalidTopologyException (org.apache.storm.generated.InvalidTopologyException)7 WorkerResources (org.apache.storm.generated.WorkerResources)7 WorkerSlot (org.apache.storm.scheduler.WorkerSlot)7 RotatingMap (org.apache.storm.utils.RotatingMap)7 InterruptedIOException (java.io.InterruptedIOException)6 BindException (java.net.BindException)6 IStormClusterState (org.apache.storm.cluster.IStormClusterState)6 AlreadyAliveException (org.apache.storm.generated.AlreadyAliveException)6