]>
Commit | Line | Data |
---|---|---|
20effc67 TL |
1 | // Copyright (c) 2011-present, Facebook, Inc. All rights reserved. |
2 | // This source code is licensed under both the GPLv2 (found in the | |
3 | // COPYING file in the root directory) and Apache 2.0 License | |
4 | // (found in the LICENSE.Apache file in the root directory). | |
5 | ||
6 | package org.rocksdb; | |
7 | ||
8 | import java.util.Objects; | |
9 | ||
10 | /** | |
11 | * Java representation of FileOperationInfo struct from include/rocksdb/listener.h | |
12 | */ | |
13 | public class FileOperationInfo { | |
14 | private final String path; | |
15 | private final long offset; | |
16 | private final long length; | |
17 | private final long startTimestamp; | |
18 | private final long duration; | |
19 | private final Status status; | |
20 | ||
21 | /** | |
22 | * Access is private as this will only be constructed from | |
23 | * C++ via JNI. | |
24 | */ | |
25 | FileOperationInfo(final String path, final long offset, final long length, | |
26 | final long startTimestamp, final long duration, final Status status) { | |
27 | this.path = path; | |
28 | this.offset = offset; | |
29 | this.length = length; | |
30 | this.startTimestamp = startTimestamp; | |
31 | this.duration = duration; | |
32 | this.status = status; | |
33 | } | |
34 | ||
35 | /** | |
36 | * Get the file path. | |
37 | * | |
38 | * @return the file path. | |
39 | */ | |
40 | public String getPath() { | |
41 | return path; | |
42 | } | |
43 | ||
44 | /** | |
45 | * Get the offset. | |
46 | * | |
47 | * @return the offset. | |
48 | */ | |
49 | public long getOffset() { | |
50 | return offset; | |
51 | } | |
52 | ||
53 | /** | |
54 | * Get the length. | |
55 | * | |
56 | * @return the length. | |
57 | */ | |
58 | public long getLength() { | |
59 | return length; | |
60 | } | |
61 | ||
62 | /** | |
63 | * Get the start timestamp (in nanoseconds). | |
64 | * | |
65 | * @return the start timestamp. | |
66 | */ | |
67 | public long getStartTimestamp() { | |
68 | return startTimestamp; | |
69 | } | |
70 | ||
71 | /** | |
72 | * Get the operation duration (in nanoseconds). | |
73 | * | |
74 | * @return the operation duration. | |
75 | */ | |
76 | public long getDuration() { | |
77 | return duration; | |
78 | } | |
79 | ||
80 | /** | |
81 | * Get the status. | |
82 | * | |
83 | * @return the status. | |
84 | */ | |
85 | public Status getStatus() { | |
86 | return status; | |
87 | } | |
88 | ||
89 | @Override | |
90 | public boolean equals(Object o) { | |
91 | if (this == o) | |
92 | return true; | |
93 | if (o == null || getClass() != o.getClass()) | |
94 | return false; | |
95 | FileOperationInfo that = (FileOperationInfo) o; | |
96 | return offset == that.offset && length == that.length && startTimestamp == that.startTimestamp | |
97 | && duration == that.duration && Objects.equals(path, that.path) | |
98 | && Objects.equals(status, that.status); | |
99 | } | |
100 | ||
101 | @Override | |
102 | public int hashCode() { | |
103 | return Objects.hash(path, offset, length, startTimestamp, duration, status); | |
104 | } | |
105 | ||
106 | @Override | |
107 | public String toString() { | |
108 | return "FileOperationInfo{" | |
109 | + "path='" + path + '\'' + ", offset=" + offset + ", length=" + length + ", startTimestamp=" | |
110 | + startTimestamp + ", duration=" + duration + ", status=" + status + '}'; | |
111 | } | |
112 | } |