• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2021 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 package android.car.watchdog;
18 
19 import static com.android.car.internal.ExcludeFromCodeCoverageGeneratedReport.BOILERPLATE_CODE;
20 
21 import android.annotation.NonNull;
22 import android.os.Parcelable;
23 
24 import com.android.car.internal.ExcludeFromCodeCoverageGeneratedReport;
25 import com.android.car.internal.util.AnnotationValidations;
26 import com.android.car.internal.util.DataClass;
27 
28 /**
29  * Disk I/O overuse stats for a package.
30  */
31 @DataClass(genToString = true, genHiddenBuilder = true)
32 public final class IoOveruseStats implements Parcelable {
33     /**
34      * Start time of the time period, in epoch seconds.
35      */
36     private long mStartTime;
37 
38     /**
39      * Duration of the time period, in seconds.
40      */
41     private long mDurationInSeconds;
42 
43     /**
44      * Total times the package has written to disk beyond the allowed write bytes during the given
45      * period.
46      */
47     private long mTotalOveruses = 0;
48 
49     /**
50      * Total times the package was killed during the given period due to disk I/O overuse.
51      */
52     private long mTotalTimesKilled = 0;
53 
54     /**
55      * Aggregated number of bytes written to disk by the package during the given period.
56      */
57     private long mTotalBytesWritten = 0;
58 
59     /**
60      * Package may be killed on disk I/O overuse.
61      *
62      * <p>Disk I/O overuse is triggered on exceeding {@link #mRemainingWriteBytes}.
63      */
64     private boolean mKillableOnOveruse = false;
65 
66     /**
67      * Number of write bytes remaining in each application or system state.
68      *
69      * <p>On exceeding these limit in at least one system or application state, the package may be
70      * killed if {@link #mKillableOnOveruse} is {@code true}.
71      *
72      * <p>The {@link #mDurationInSeconds} does not apply to this field.
73      */
74     private @NonNull PerStateBytes mRemainingWriteBytes = new PerStateBytes(0L, 0L, 0L);
75 
76 
77 
78     // Code below generated by codegen v1.0.23.
79     //
80     // DO NOT MODIFY!
81     // CHECKSTYLE:OFF Generated code
82     //
83     // To regenerate run:
84     // $ codegen $ANDROID_BUILD_TOP/packages/services/Car/car-lib/src/android/car/watchdog/IoOveruseStats.java
85     //
86     // To exclude the generated code from IntelliJ auto-formatting enable (one-time):
87     //   Settings > Editor > Code Style > Formatter Control
88     //@formatter:off
89 
90 
91     @DataClass.Generated.Member
IoOveruseStats( long startTime, long durationInSeconds, long totalOveruses, long totalTimesKilled, long totalBytesWritten, boolean killableOnOveruse, @NonNull PerStateBytes remainingWriteBytes)92     /* package-private */ IoOveruseStats(
93             long startTime,
94             long durationInSeconds,
95             long totalOveruses,
96             long totalTimesKilled,
97             long totalBytesWritten,
98             boolean killableOnOveruse,
99             @NonNull PerStateBytes remainingWriteBytes) {
100         this.mStartTime = startTime;
101         this.mDurationInSeconds = durationInSeconds;
102         this.mTotalOveruses = totalOveruses;
103         this.mTotalTimesKilled = totalTimesKilled;
104         this.mTotalBytesWritten = totalBytesWritten;
105         this.mKillableOnOveruse = killableOnOveruse;
106         this.mRemainingWriteBytes = remainingWriteBytes;
107         AnnotationValidations.validate(
108                 NonNull.class, null, mRemainingWriteBytes);
109 
110         // onConstructed(); // You can define this method to get a callback
111     }
112 
113     /**
114      * Start time of the time period, in epoch seconds.
115      */
116     @DataClass.Generated.Member
getStartTime()117     public long getStartTime() {
118         return mStartTime;
119     }
120 
121     /**
122      * Duration of the time period, in seconds.
123      */
124     @DataClass.Generated.Member
getDurationInSeconds()125     public long getDurationInSeconds() {
126         return mDurationInSeconds;
127     }
128 
129     /**
130      * Total times the package has written to disk beyond the allowed write bytes during the given
131      * period.
132      */
133     @DataClass.Generated.Member
getTotalOveruses()134     public long getTotalOveruses() {
135         return mTotalOveruses;
136     }
137 
138     /**
139      * Total times the package was killed during the given period due to disk I/O overuse.
140      */
141     @DataClass.Generated.Member
getTotalTimesKilled()142     public long getTotalTimesKilled() {
143         return mTotalTimesKilled;
144     }
145 
146     /**
147      * Aggregated number of bytes written to disk by the package during the given period.
148      */
149     @DataClass.Generated.Member
getTotalBytesWritten()150     public long getTotalBytesWritten() {
151         return mTotalBytesWritten;
152     }
153 
154     /**
155      * Package may be killed on disk I/O overuse.
156      *
157      * <p>Disk I/O overuse is triggered on exceeding {@link #mRemainingWriteBytes}.
158      */
159     @DataClass.Generated.Member
isKillableOnOveruse()160     public boolean isKillableOnOveruse() {
161         return mKillableOnOveruse;
162     }
163 
164     /**
165      * Number of write bytes remaining in each application or system state.
166      *
167      * <p>On exceeding these limit in at least one system or application state, the package may be
168      * killed if {@link #mKillableOnOveruse} is {@code true}.
169      *
170      * <p>The {@link #mDurationInSeconds} does not apply to this field.
171      */
172     @DataClass.Generated.Member
getRemainingWriteBytes()173     public @NonNull PerStateBytes getRemainingWriteBytes() {
174         return mRemainingWriteBytes;
175     }
176 
177     @Override
178     @DataClass.Generated.Member
toString()179     public String toString() {
180         // You can override field toString logic by defining methods like:
181         // String fieldNameToString() { ... }
182 
183         return "IoOveruseStats { " +
184                 "startTime = " + mStartTime + ", " +
185                 "durationInSeconds = " + mDurationInSeconds + ", " +
186                 "totalOveruses = " + mTotalOveruses + ", " +
187                 "totalTimesKilled = " + mTotalTimesKilled + ", " +
188                 "totalBytesWritten = " + mTotalBytesWritten + ", " +
189                 "killableOnOveruse = " + mKillableOnOveruse + ", " +
190                 "remainingWriteBytes = " + mRemainingWriteBytes +
191         " }";
192     }
193 
194     @Override
195     @DataClass.Generated.Member
writeToParcel(@onNull android.os.Parcel dest, int flags)196     public void writeToParcel(@NonNull android.os.Parcel dest, int flags) {
197         // You can override field parcelling by defining methods like:
198         // void parcelFieldName(Parcel dest, int flags) { ... }
199 
200         byte flg = 0;
201         if (mKillableOnOveruse) flg |= 0x20;
202         dest.writeByte(flg);
203         dest.writeLong(mStartTime);
204         dest.writeLong(mDurationInSeconds);
205         dest.writeLong(mTotalOveruses);
206         dest.writeLong(mTotalTimesKilled);
207         dest.writeLong(mTotalBytesWritten);
208         dest.writeTypedObject(mRemainingWriteBytes, flags);
209     }
210 
211     @Override
212     @DataClass.Generated.Member
213     @ExcludeFromCodeCoverageGeneratedReport(reason = BOILERPLATE_CODE)
describeContents()214     public int describeContents() { return 0; }
215 
216     /** @hide */
217     @SuppressWarnings({"unchecked", "RedundantCast"})
218     @DataClass.Generated.Member
IoOveruseStats(@onNull android.os.Parcel in)219     /* package-private */ IoOveruseStats(@NonNull android.os.Parcel in) {
220         // You can override field unparcelling by defining methods like:
221         // static FieldType unparcelFieldName(Parcel in) { ... }
222 
223         byte flg = in.readByte();
224         boolean killableOnOveruse = (flg & 0x20) != 0;
225         long startTime = in.readLong();
226         long durationInSeconds = in.readLong();
227         long totalOveruses = in.readLong();
228         long totalTimesKilled = in.readLong();
229         long totalBytesWritten = in.readLong();
230         PerStateBytes remainingWriteBytes = (PerStateBytes) in.readTypedObject(PerStateBytes.CREATOR);
231 
232         this.mStartTime = startTime;
233         this.mDurationInSeconds = durationInSeconds;
234         this.mTotalOveruses = totalOveruses;
235         this.mTotalTimesKilled = totalTimesKilled;
236         this.mTotalBytesWritten = totalBytesWritten;
237         this.mKillableOnOveruse = killableOnOveruse;
238         this.mRemainingWriteBytes = remainingWriteBytes;
239         AnnotationValidations.validate(
240                 NonNull.class, null, mRemainingWriteBytes);
241 
242         // onConstructed(); // You can define this method to get a callback
243     }
244 
245     @DataClass.Generated.Member
246     public static final @NonNull Parcelable.Creator<IoOveruseStats> CREATOR
247             = new Parcelable.Creator<IoOveruseStats>() {
248         @Override
249         public IoOveruseStats[] newArray(int size) {
250             return new IoOveruseStats[size];
251         }
252 
253         @Override
254         public IoOveruseStats createFromParcel(@NonNull android.os.Parcel in) {
255             return new IoOveruseStats(in);
256         }
257     };
258 
259     /**
260      * A builder for {@link IoOveruseStats}
261      * @hide
262      */
263     @SuppressWarnings("WeakerAccess")
264     @DataClass.Generated.Member
265     public static final class Builder {
266 
267         private long mStartTime;
268         private long mDurationInSeconds;
269         private long mTotalOveruses;
270         private long mTotalTimesKilled;
271         private long mTotalBytesWritten;
272         private boolean mKillableOnOveruse;
273         private @NonNull PerStateBytes mRemainingWriteBytes;
274 
275         private long mBuilderFieldsSet = 0L;
276 
277         /**
278          * Creates a new Builder.
279          *
280          * @param startTime
281          *   Start time of the time period, in epoch seconds.
282          * @param durationInSeconds
283          *   Duration of the time period, in seconds.
284          */
Builder( long startTime, long durationInSeconds)285         public Builder(
286                 long startTime,
287                 long durationInSeconds) {
288             mStartTime = startTime;
289             mDurationInSeconds = durationInSeconds;
290         }
291 
292         /**
293          * Start time of the time period, in epoch seconds.
294          */
295         @DataClass.Generated.Member
setStartTime(long value)296         public @NonNull Builder setStartTime(long value) {
297             checkNotUsed();
298             mBuilderFieldsSet |= 0x1;
299             mStartTime = value;
300             return this;
301         }
302 
303         /**
304          * Duration of the time period, in seconds.
305          */
306         @DataClass.Generated.Member
setDurationInSeconds(long value)307         public @NonNull Builder setDurationInSeconds(long value) {
308             checkNotUsed();
309             mBuilderFieldsSet |= 0x2;
310             mDurationInSeconds = value;
311             return this;
312         }
313 
314         /**
315          * Total times the package has written to disk beyond the allowed write bytes during the given
316          * period.
317          */
318         @DataClass.Generated.Member
setTotalOveruses(long value)319         public @NonNull Builder setTotalOveruses(long value) {
320             checkNotUsed();
321             mBuilderFieldsSet |= 0x4;
322             mTotalOveruses = value;
323             return this;
324         }
325 
326         /**
327          * Total times the package was killed during the given period due to disk I/O overuse.
328          */
329         @DataClass.Generated.Member
setTotalTimesKilled(long value)330         public @NonNull Builder setTotalTimesKilled(long value) {
331             checkNotUsed();
332             mBuilderFieldsSet |= 0x8;
333             mTotalTimesKilled = value;
334             return this;
335         }
336 
337         /**
338          * Aggregated number of bytes written to disk by the package during the given period.
339          */
340         @DataClass.Generated.Member
setTotalBytesWritten(long value)341         public @NonNull Builder setTotalBytesWritten(long value) {
342             checkNotUsed();
343             mBuilderFieldsSet |= 0x10;
344             mTotalBytesWritten = value;
345             return this;
346         }
347 
348         /**
349          * Package may be killed on disk I/O overuse.
350          *
351          * <p>Disk I/O overuse is triggered on exceeding {@link #mRemainingWriteBytes}.
352          */
353         @DataClass.Generated.Member
setKillableOnOveruse(boolean value)354         public @NonNull Builder setKillableOnOveruse(boolean value) {
355             checkNotUsed();
356             mBuilderFieldsSet |= 0x20;
357             mKillableOnOveruse = value;
358             return this;
359         }
360 
361         /**
362          * Number of write bytes remaining in each application or system state.
363          *
364          * <p>On exceeding these limit in at least one system or application state, the package may be
365          * killed if {@link #mKillableOnOveruse} is {@code true}.
366          *
367          * <p>The {@link #mDurationInSeconds} does not apply to this field.
368          */
369         @DataClass.Generated.Member
setRemainingWriteBytes(@onNull PerStateBytes value)370         public @NonNull Builder setRemainingWriteBytes(@NonNull PerStateBytes value) {
371             checkNotUsed();
372             mBuilderFieldsSet |= 0x40;
373             mRemainingWriteBytes = value;
374             return this;
375         }
376 
377         /** Builds the instance. This builder should not be touched after calling this! */
build()378         public @NonNull IoOveruseStats build() {
379             checkNotUsed();
380             mBuilderFieldsSet |= 0x80; // Mark builder used
381 
382             if ((mBuilderFieldsSet & 0x4) == 0) {
383                 mTotalOveruses = 0;
384             }
385             if ((mBuilderFieldsSet & 0x8) == 0) {
386                 mTotalTimesKilled = 0;
387             }
388             if ((mBuilderFieldsSet & 0x10) == 0) {
389                 mTotalBytesWritten = 0;
390             }
391             if ((mBuilderFieldsSet & 0x20) == 0) {
392                 mKillableOnOveruse = false;
393             }
394             if ((mBuilderFieldsSet & 0x40) == 0) {
395                 mRemainingWriteBytes = new PerStateBytes(0L, 0L, 0L);
396             }
397             IoOveruseStats o = new IoOveruseStats(
398                     mStartTime,
399                     mDurationInSeconds,
400                     mTotalOveruses,
401                     mTotalTimesKilled,
402                     mTotalBytesWritten,
403                     mKillableOnOveruse,
404                     mRemainingWriteBytes);
405             return o;
406         }
407 
checkNotUsed()408         private void checkNotUsed() {
409             if ((mBuilderFieldsSet & 0x80) != 0) {
410                 throw new IllegalStateException(
411                         "This Builder should not be reused. Use a new Builder instance instead");
412             }
413         }
414     }
415 
416     @DataClass.Generated(
417             time = 1721770855487L,
418             codegenVersion = "1.0.23",
419             sourceFile = "packages/services/Car/car-lib/src/android/car/watchdog/IoOveruseStats.java",
420             inputSignatures = "private  long mStartTime\nprivate  long mDurationInSeconds\nprivate  long mTotalOveruses\nprivate  long mTotalTimesKilled\nprivate  long mTotalBytesWritten\nprivate  boolean mKillableOnOveruse\nprivate @android.annotation.NonNull android.car.watchdog.PerStateBytes mRemainingWriteBytes\nclass IoOveruseStats extends java.lang.Object implements [android.os.Parcelable]\n@com.android.car.internal.util.DataClass(genToString=true, genHiddenBuilder=true)")
421     @Deprecated
422     @ExcludeFromCodeCoverageGeneratedReport(reason = BOILERPLATE_CODE)
__metadata()423     private void __metadata() {}
424 
425 
426     //@formatter:on
427     // End of generated code
428 
429 }
430