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
;
12 import java
.util
.ArrayList
;
13 import java
.util
.Collections
;
14 import java
.util
.List
;
16 import org
.eclipse
.jdt
.annotation
.Nullable
;
17 import org
.eclipse
.tracecompass
.analysis
.os
.linux
.core
.inputoutput
.IoOperationType
;
20 * Represents a request to a disk of the system
22 * @author Houssem Daoud
24 public class Request
{
27 private int fNrSector
;
28 private final DiskWriteModel fDisk
;
29 private final List
<BlockIO
> fBios
= new ArrayList
<>();
30 private @Nullable Integer fIssuedFrom
= null;
31 private IoOperationType fType
;
37 * The disk for this request
39 * The base sector of this request
43 public Request(DiskWriteModel disk
, Long sector
, int rwbs
) {
47 fType
= IoOperationType
.getType(rwbs
);
51 * Constructor from a Block IO structure
54 * The BIO to start this request from
56 public Request(BlockIO bio
) {
57 fSector
= bio
.getSector();
58 fNrSector
= bio
.getNrSector();
59 fType
= bio
.getType();
61 fDisk
= bio
.getDisk();
65 * Get the base sector of this request
67 * @return The base sector
69 public Long
getSector() {
74 * Get the number of sectors of this request
76 * @return The number of sectors
78 public int getNrSector() {
83 * Updates the number of sectors for this request
86 * The new number of sectors
88 public void setNrSector(int nrSector
) {
93 * Get the disk this request is for
95 * @return The disk of this BIO
97 public DiskWriteModel
getDisk() {
102 * Get the type of request
104 * @return The type of request
106 public IoOperationType
getType() {
111 * Set the read/write mode of this request
114 * The read/write bits of the request
116 public void setType(int rwbs
) {
117 fType
= IoOperationType
.getType(rwbs
);
121 * Get the list of BIOs included in this request
123 * @return The list of BIOs
125 public List
<BlockIO
> getBios() {
126 return Collections
.unmodifiableList(fBios
);
130 * Get the request this request is based on
132 * @return The quark of the request this is issued from
134 public @Nullable Integer
getIssuedFrom() {
139 * Insert the BIO into this request
142 * The Block IO to insert in this request
144 public void insertBio(BlockIO bio
) {
146 fNrSector
+= bio
.getNrSector();
147 if (bio
.getSector() < getSector()) {
148 fSector
= bio
.getSector();
153 * Merges a request into this one
156 * The second request to merge
158 public void mergeRequest(Request request
) {
159 fBios
.addAll(request
.getBios());
160 fNrSector
= getNrSector() + request
.getNrSector();
This page took 0.035687 seconds and 5 git commands to generate.