2 * Copyright (C) 2017 EfficiOS Inc., Alexandre Montplaisir <alexmonthy@efficios.com>
4 * All rights reserved. This program and the accompanying materials are
5 * made available under the terms of the Eclipse Public License v1.0 which
6 * accompanies this distribution, and is available at
7 * http://www.eclipse.org/legal/epl-v10.html
10 package org
.lttng
.scope
.lttng
.kernel
.core
.views
.timegraph
.resources
;
12 import static java
.util
.Objects
.requireNonNull
;
14 import java
.util
.Collections
;
15 import java
.util
.LinkedList
;
16 import java
.util
.List
;
17 import java
.util
.function
.Function
;
19 import org
.lttng
.scope
.lttng
.kernel
.core
.analysis
.os
.Attributes
;
20 import org
.lttng
.scope
.lttng
.kernel
.core
.views
.timegraph
.resources
.elements
.ResourcesIrqTreeElement
;
21 import org
.lttng
.scope
.lttng
.kernel
.core
.views
.timegraph
.resources
.elements
.ResourcesIrqTreeElement
.IrqType
;
22 import org
.lttng
.scope
.tmf2
.views
.core
.timegraph
.model
.render
.tree
.TimeGraphTreeElement
;
23 import org
.lttng
.scope
.tmf2
.views
.core
.timegraph
.model
.render
.tree
.TimeGraphTreeRender
;
25 import com
.google
.common
.annotations
.VisibleForTesting
;
26 import com
.google
.common
.primitives
.Ints
;
28 import ca
.polymtl
.dorsal
.libdelorean
.ITmfStateSystem
;
31 * View model for a Resources view showing IRQs and SoftIRQs.
33 * @author Alexandre Montplaisir
35 public class ResourcesIrqModelProvider
extends ResourcesBaseModelProvider
{
37 private static final String
[] IRQS_QUARK_PATTERN
= { Attributes
.IRQS
, "*" }; //$NON-NLS-1$
38 private static final String
[] SOFT_IRQS_QUARK_PATTERN
= { Attributes
.SOFT_IRQS
, "*" }; //$NON-NLS-1$
41 * Get the tree element name for every cpu.
44 public static final Function
<TreeRenderContext
, TimeGraphTreeRender
> SS_TO_TREE_RENDER_FUNCTION
= (treeContext
) -> {
45 ITmfStateSystem ss
= treeContext
.ss
;
47 List
<ResourcesIrqTreeElement
> treeElems
= new LinkedList
<>();
48 /* Create "IRQ *" children */
49 ss
.getQuarks(IRQS_QUARK_PATTERN
).forEach(irqQuark
-> {
50 String name
= ss
.getAttributeName(irqQuark
);
51 Integer irqNumber
= Ints
.tryParse(name
);
52 if (irqNumber
!= null) {
53 treeElems
.add(new ResourcesIrqTreeElement(IrqType
.IRQ
, irqNumber
, irqQuark
));
57 /* Create "SoftIRQ *" children */
58 ss
.getQuarks(SOFT_IRQS_QUARK_PATTERN
).forEach(irqQuark
-> {
59 String name
= ss
.getAttributeName(irqQuark
);
60 Integer irqNumber
= Ints
.tryParse(name
);
61 if (irqNumber
!= null) {
62 treeElems
.add(new ResourcesIrqTreeElement(IrqType
.SOFTIRQ
, irqNumber
, irqQuark
));
66 Collections
.sort(treeElems
, IRQ_SORTER
);
67 @SuppressWarnings("rawtypes")
68 List treeElems2
= treeElems
;
69 TimeGraphTreeElement rootElement
= new TimeGraphTreeElement(treeContext
.traceName
, treeElems2
);
70 return new TimeGraphTreeRender(rootElement
);
76 public ResourcesIrqModelProvider() {
77 super(requireNonNull(Messages
.resourcesIrqProviderName
), SS_TO_TREE_RENDER_FUNCTION
);