1 /*******************************************************************************
2 * Copyright (c) 2016 École Polytechnique de Montréal
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 *******************************************************************************/
10 package org
.eclipse
.tracecompass
.internal
.analysis
.os
.linux
.core
.inputoutput
.handlers
;
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
;
25 * Request completed event handler
27 * @author Houssem Daoud
29 public class BlockRqComplete
extends KernelEventHandler
{
31 private final InputOutputStateProvider fStateProvider
;
39 * The state provider calling this handler
41 public BlockRqComplete(IKernelAnalysisEventLayout layout
, InputOutputStateProvider sp
) {
47 public void handleEvent(@NonNull ITmfStateSystemBuilder ss
, @NonNull ITmfEvent event
) throws AttributeNotFoundException
{
48 ITmfEventField content
= event
.getContent();
49 long ts
= event
.getTimestamp().getValue();
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
);
57 Request request
= disk
.getDriverRequest(sector
);
58 if (request
== null) {
59 request
= new Request(disk
, sector
, rwbs
);
61 request
.setNrSector(nrSector
);
62 request
.setType(rwbs
);
63 disk
.completeRequest(ts
, request
);