-
Notifications
You must be signed in to change notification settings - Fork 2.9k
/
URIStatus.java
251 lines (216 loc) · 6.25 KB
/
URIStatus.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
/*
* The Alluxio Open Foundation licenses this work under the Apache License, version 2.0
* (the "License"). You may not use this work except in compliance with the License, which is
* available at www.apache.org/licenses/LICENSE-2.0
*
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
* either express or implied, as more fully set forth in the License.
*
* See the NOTICE file distributed with this work for information regarding copyright ownership.
*/
package alluxio.client.file;
import alluxio.annotation.PublicApi;
import alluxio.wire.FileBlockInfo;
import alluxio.wire.FileInfo;
import alluxio.wire.TtlAction;
import com.google.common.base.Preconditions;
import java.util.List;
import javax.annotation.concurrent.ThreadSafe;
/**
* Wrapper around {@link FileInfo}. Represents the metadata about a file or directory in Alluxio.
* This is a snapshot of information about the file or directory and not all attributes are
* guaranteed to be up to date. Attributes documented as immutable will always be accurate, and
* attributes documented as mutable may be out of date.
*/
@PublicApi
@ThreadSafe
public class URIStatus {
private final FileInfo mInfo;
/**
* Constructs an instance of this class from a {@link FileInfo}.
*
* @param info an object containing the information about a particular uri
*/
public URIStatus(FileInfo info) {
mInfo = Preconditions.checkNotNull(info, "Cannot create a URIStatus from a null FileInfo");
}
/**
* @return a list of block ids belonging to the file, empty for directories, immutable
*/
public List<Long> getBlockIds() {
return mInfo.getBlockIds();
}
/**
* @return the default block size for this file, 0 for directories, immutable
*/
public long getBlockSizeBytes() {
return mInfo.getBlockSizeBytes();
}
/**
* @return the epoch time the entity referenced by this uri was created, immutable
*/
public long getCreationTimeMs() {
return mInfo.getCreationTimeMs();
}
/**
* @return the unique identifier of the entity referenced by this uri used by Alluxio servers,
* immutable
*/
public long getFileId() {
return mInfo.getFileId();
}
/**
* @return the group that owns the entity referenced by this uri, mutable
*/
public String getGroup() {
return mInfo.getGroup();
}
/**
* @return the percentage of blocks in Alluxio memory tier storage, mutable
*/
public int getInMemoryPercentage() {
return mInfo.getInMemoryPercentage();
}
/**
* @return the epoch time the entity referenced by this uri was last modified, mutable
*/
public long getLastModificationTimeMs() {
return mInfo.getLastModificationTimeMs();
}
/**
* @return the length in bytes of the file, 0 for directories, mutable
*/
public long getLength() {
return mInfo.getLength();
}
/**
* For example for the uri: alluxio://host:1000/foo/bar/baz, baz is the name.
*
* @return the last path component of the entity referenced by this uri, mutable
*/
public String getName() {
return mInfo.getName();
}
/**
* For example, for the uri: alluxio://host:1000/foo/bar/baz, the path is /foo/bar/baz.
*
* @return the entire path component of the entity referenced by this uri, mutable
*/
public String getPath() {
return mInfo.getPath();
}
/**
* @return the int representation of the ACL mode bits of the entity referenced by this uri,
* mutable
*/
public int getMode() {
return mInfo.getMode();
}
/**
* @return the string representation of the persistence status, mutable
*/
// TODO(calvin): Consider returning the enum if it is moved to common
public String getPersistenceState() {
return mInfo.getPersistenceState();
}
/**
* @return the time-to-live in milliseconds since the creation time of the entity referenced by
* this uri, mutable
*/
public long getTtl() {
return mInfo.getTtl();
}
/**
* @return the action to perform on ttl expiry
*/
public TtlAction getTtlAction() {
return mInfo.getTtlAction();
}
/**
* @return the uri of the under storage location of the entity referenced by this uri, mutable
*/
public String getUfsPath() {
return mInfo.getUfsPath();
}
/**
* @return the owner of the entity referenced by this uri, mutable
*/
public String getOwner() {
return mInfo.getOwner();
}
/**
* @return whether the entity referenced by this uri can be stored in Alluxio space, mutable
*/
public boolean isCacheable() {
return mInfo.isCacheable();
}
/**
* @return whether the entity referenced by this uri has been marked as completed, immutable
*/
public boolean isCompleted() {
return mInfo.isCompleted();
}
/**
* @return whether the entity referenced by this uri is a directory, immutable
*/
// TODO(calvin): Consider consolidating the terms directory and folder
public boolean isFolder() {
return mInfo.isFolder();
}
/**
* @return whether the entity referenced by this uri is persisted to an underlying storage,
* mutable
*/
public boolean isPersisted() {
return mInfo.isPersisted();
}
/**
* @return whether the entity referenced by this uri is pinned, mutable
*/
public boolean isPinned() {
return mInfo.isPinned();
}
/**
* @return whether the entity referenced by this uri is a mount point
*/
public boolean isMountPoint() {
return mInfo.isMountPoint();
}
/**
* @return the mount point path in Alluxio for this file
*/
public String getAlluxioMountPoint() {
return mInfo.getAlluxioMountPoint();
}
/**
* @return the mount table version
*/
public long getMountTableVersion() {
return mInfo.getMountTableVersion();
}
/**
* @return the list of file block descriptors
*/
public List<FileBlockInfo> getFileBlockInfos() {
return mInfo.getFileBlockInfos();
}
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (!(o instanceof URIStatus)) {
return false;
}
URIStatus that = (URIStatus) o;
return mInfo.equals(that.mInfo);
}
@Override
public int hashCode() {
return mInfo.hashCode();
}
@Override
public String toString() {
return mInfo.toString();
}
}