analysis.io: Introduce the input/output linux analysis
[deliverable/tracecompass.git] / analysis / org.eclipse.tracecompass.analysis.os.linux.core / src / org / eclipse / tracecompass / internal / analysis / os / linux / core / inputoutput / handlers / BlockRqComplete.java
1 /*******************************************************************************
2 * Copyright (c) 2016 École Polytechnique de Montréal
3 *
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
8 *******************************************************************************/
9
10 package org.eclipse.tracecompass.internal.analysis.os.linux.core.inputoutput.handlers;
11
12 import org.eclipse.jdt.annotation.NonNull;
13 import org.eclipse.tracecompass.analysis.os.linux.core.trace.IKernelAnalysisEventLayout;
14 import org.eclipse.tracecompass.common.core.NonNullUtils;
15 import org.eclipse.tracecompass.internal.analysis.os.linux.core.inputoutput.DiskWriteModel;
16 import org.eclipse.tracecompass.internal.analysis.os.linux.core.inputoutput.InputOutputStateProvider;
17 import org.eclipse.tracecompass.internal.analysis.os.linux.core.inputoutput.Request;
18 import org.eclipse.tracecompass.internal.analysis.os.linux.core.kernel.handlers.KernelEventHandler;
19 import org.eclipse.tracecompass.statesystem.core.ITmfStateSystemBuilder;
20 import org.eclipse.tracecompass.statesystem.core.exceptions.AttributeNotFoundException;
21 import org.eclipse.tracecompass.tmf.core.event.ITmfEvent;
22 import org.eclipse.tracecompass.tmf.core.event.ITmfEventField;
23
24 /**
25 * Request completed event handler
26 *
27 * @author Houssem Daoud
28 */
29 public class BlockRqComplete extends KernelEventHandler {
30
31 private final InputOutputStateProvider fStateProvider;
32
33 /**
34 * Constructor
35 *
36 * @param layout
37 * event layout
38 * @param sp
39 * The state provider calling this handler
40 */
41 public BlockRqComplete(IKernelAnalysisEventLayout layout, InputOutputStateProvider sp) {
42 super(layout);
43 fStateProvider = sp;
44 }
45
46 @Override
47 public void handleEvent(@NonNull ITmfStateSystemBuilder ss, @NonNull ITmfEvent event) throws AttributeNotFoundException {
48 ITmfEventField content = event.getContent();
49 long ts = event.getTimestamp().getValue();
50
51 Long sector = NonNullUtils.checkNotNull((Long) content.getField(getLayout().fieldBlockSector()).getValue());
52 int nrSector = ((Long) content.getField(getLayout().fieldBlockNrSector()).getValue()).intValue();
53 int phydisk = ((Long) content.getField(getLayout().fieldBlockDeviceId()).getValue()).intValue();
54 int rwbs = ((Long) content.getField(getLayout().fieldBlockRwbs()).getValue()).intValue();
55 DiskWriteModel disk = fStateProvider.getDisk(phydisk);
56
57 Request request = disk.getDriverRequest(sector);
58 if (request == null) {
59 request = new Request(disk, sector, rwbs);
60 }
61 request.setNrSector(nrSector);
62 request.setType(rwbs);
63 disk.completeRequest(ts, request);
64 }
65
66 }
This page took 0.032617 seconds and 5 git commands to generate.