Search in sources :

Example 6 with ErrorInfo

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

the class StormClusterStateImpl method errors.

@Override
public List<ErrorInfo> errors(String stormId, String componentId) {
    List<ErrorInfo> errorInfos = new ArrayList<>();
    String path = ClusterUtils.errorPath(stormId, componentId);
    if (stateStorage.node_exists(path, false)) {
        List<String> childrens = stateStorage.get_children(path, false);
        for (String child : childrens) {
            String childPath = path + ClusterUtils.ZK_SEPERATOR + child;
            ErrorInfo errorInfo = ClusterUtils.maybeDeserialize(stateStorage.get_data(childPath, false), ErrorInfo.class);
            if (errorInfo != null) {
                errorInfos.add(errorInfo);
            }
        }
    }
    Collections.sort(errorInfos, new Comparator<ErrorInfo>() {

        public int compare(ErrorInfo arg0, ErrorInfo arg1) {
            return Integer.compare(arg1.get_error_time_secs(), arg0.get_error_time_secs());
        }
    });
    return errorInfos;
}
Also used : ErrorInfo(org.apache.storm.generated.ErrorInfo) ArrayList(java.util.ArrayList)

Example 7 with ErrorInfo

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

the class Nimbus method getTopologyInfoWithOptsImpl.

private TopologyInfo getTopologyInfoWithOptsImpl(String topoId, GetInfoOptions options) throws NotAliveException, AuthorizationException, InvalidTopologyException, Exception {
    CommonTopoInfo common = getCommonTopoInfo(topoId, "getTopologyInfo");
    if (common.base == null) {
        throw new WrappedNotAliveException(topoId);
    }
    IStormClusterState state = stormClusterState;
    NumErrorsChoice numErrChoice = Utils.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());
            Map<String, String> nodeToHost = common.assignment.get_node_host();
            Map<String, Object> heartbeat = common.beats.get(ClientStatsUtil.convertExecutor(entry.getKey()));
            if (heartbeat == null) {
                heartbeat = Collections.emptyMap();
            }
            ExecutorSummary summ = new ExecutorSummary(execInfo, common.taskToComponent.get(execInfo.get_task_start()), nodeToHost.get(ni.get_node()), ni.get_port_iterator().next().intValue(), (Integer) heartbeat.getOrDefault("uptime", 0));
            // heartbeats "stats"
            Map ex = (Map) heartbeat.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.topology.is_set_storm_version()) {
        topoInfo.set_storm_version(common.topology.get_storm_version());
    }
    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 && underlyingScheduler instanceof ResourceAwareScheduler) {
        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;
}
Also used : HashMap(java.util.HashMap) ExecutorStats(org.apache.storm.generated.ExecutorStats) ErrorInfo(org.apache.storm.generated.ErrorInfo) ArrayList(java.util.ArrayList) WrappedNotAliveException(org.apache.storm.utils.WrappedNotAliveException) ExecutorSummary(org.apache.storm.generated.ExecutorSummary) ResourceAwareScheduler(org.apache.storm.scheduler.resource.ResourceAwareScheduler) ExecutorInfo(org.apache.storm.generated.ExecutorInfo) NodeInfo(org.apache.storm.generated.NodeInfo) ArrayList(java.util.ArrayList) List(java.util.List) IStormClusterState(org.apache.storm.cluster.IStormClusterState) NumErrorsChoice(org.apache.storm.generated.NumErrorsChoice) 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) TopologyInfo(org.apache.storm.generated.TopologyInfo)

Example 8 with ErrorInfo

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

the class ThriftBridgeSerializationDelegateTest method testThriftInstance.

@Test
public void testThriftInstance() throws Exception {
    ErrorInfo errorInfo = new ErrorInfo();
    errorInfo.set_error("error");
    errorInfo.set_error_time_secs(1);
    errorInfo.set_host("host");
    errorInfo.set_port(1);
    byte[] serialized = new ThriftSerializationDelegate().serialize(errorInfo);
    ErrorInfo errorInfo2 = testDelegate.deserialize(serialized, ErrorInfo.class);
    assertEquals(errorInfo, errorInfo2);
    serialized = testDelegate.serialize(errorInfo);
    errorInfo2 = new ThriftSerializationDelegate().deserialize(serialized, ErrorInfo.class);
    assertEquals(errorInfo, errorInfo2);
}
Also used : ErrorInfo(org.apache.storm.generated.ErrorInfo) Test(org.junit.Test)

Example 9 with ErrorInfo

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

the class StormClusterStateImpl method reportError.

@Override
public void reportError(String stormId, String componentId, String node, Long port, Throwable error) {
    String path = ClusterUtils.errorPath(stormId, componentId);
    ErrorInfo errorInfo = new ErrorInfo(ClusterUtils.stringifyError(error), Time.currentTimeSecs());
    errorInfo.set_host(node);
    errorInfo.set_port(port.intValue());
    byte[] serData = Utils.serialize(errorInfo);
    stateStorage.mkdirs(path, defaultAcls);
    stateStorage.create_sequential(path + ClusterUtils.ZK_SEPERATOR + "e", serData, defaultAcls);
    String lastErrorPath = ClusterUtils.lastErrorPath(stormId, componentId);
    stateStorage.set_data(lastErrorPath, serData, defaultAcls);
    List<String> childrens = stateStorage.get_children(path, false);
    Collections.sort(childrens, new Comparator<String>() {

        public int compare(String arg0, String arg1) {
            return Long.compare(Long.parseLong(arg0.substring(1)), Long.parseLong(arg1.substring(1)));
        }
    });
    while (childrens.size() > 10) {
        String znodePath = path + ClusterUtils.ZK_SEPERATOR + childrens.remove(0);
        try {
            stateStorage.delete_node(znodePath);
        } catch (Exception e) {
            if (Utils.exceptionCauseIsInstanceOf(KeeperException.NoNodeException.class, e)) {
                // if the node is already deleted, do nothing
                LOG.warn("Could not find the znode: {}", znodePath);
            } else {
                throw e;
            }
        }
    }
}
Also used : ErrorInfo(org.apache.storm.generated.ErrorInfo) KeeperException(org.apache.storm.shade.org.apache.zookeeper.KeeperException)

Example 10 with ErrorInfo

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

the class UIHelpers method getSpoutAggStatsMap.

/**
 * getSpoutAggStatsMap.
 * @param componentAggregateStats componentAggregateStats
 * @param window window
 * @return getSpoutAggStatsMap
 */
private static Map<String, Object> getSpoutAggStatsMap(ComponentAggregateStats componentAggregateStats, String window) {
    Map<String, Object> result = new HashMap();
    SpoutAggregateStats spoutAggregateStats = componentAggregateStats.get_specific_stats().get_spout();
    CommonAggregateStats commonStats = componentAggregateStats.get_common_stats();
    result.put("window", window);
    result.put("windowPretty", getWindowHint(window));
    result.put("emitted", commonStats.get_emitted());
    result.put("transferred", commonStats.get_transferred());
    result.put("acked", commonStats.get_acked());
    result.put("failed", commonStats.get_failed());
    result.put("completeLatency", spoutAggregateStats.get_complete_latency_ms());
    ErrorInfo lastError = componentAggregateStats.get_last_error();
    result.put("lastError", Objects.isNull(lastError) ? "" : getTruncatedErrorString(lastError.get_error()));
    return result;
}
Also used : HashMap(java.util.HashMap) ErrorInfo(org.apache.storm.generated.ErrorInfo) SpoutAggregateStats(org.apache.storm.generated.SpoutAggregateStats) CommonAggregateStats(org.apache.storm.generated.CommonAggregateStats)

Aggregations

ErrorInfo (org.apache.storm.generated.ErrorInfo)10 HashMap (java.util.HashMap)4 ArrayList (java.util.ArrayList)3 List (java.util.List)3 Map (java.util.Map)3 IStormClusterState (org.apache.storm.cluster.IStormClusterState)3 ComponentAggregateStats (org.apache.storm.generated.ComponentAggregateStats)3 TopologyInfo (org.apache.storm.generated.TopologyInfo)3 ExecutorInfo (org.apache.storm.generated.ExecutorInfo)2 ExecutorStats (org.apache.storm.generated.ExecutorStats)2 ExecutorSummary (org.apache.storm.generated.ExecutorSummary)2 NodeInfo (org.apache.storm.generated.NodeInfo)2 NotAliveException (org.apache.storm.generated.NotAliveException)2 NumErrorsChoice (org.apache.storm.generated.NumErrorsChoice)2 TimeCacheMap (org.apache.storm.utils.TimeCacheMap)2 Test (org.junit.Test)2 Test (org.junit.jupiter.api.Test)2 ImmutableMap (com.google.common.collect.ImmutableMap)1 IOException (java.io.IOException)1 InterruptedIOException (java.io.InterruptedIOException)1