-
Notifications
You must be signed in to change notification settings - Fork 2.9k
/
LockBlockOptions.java
190 lines (167 loc) · 4.9 KB
/
LockBlockOptions.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
/*
* 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.block.options;
import alluxio.thrift.LockBlockTOptions;
import com.google.common.base.Objects;
import javax.annotation.concurrent.NotThreadSafe;
/**
* Method options for locking blocks.
*/
@NotThreadSafe
public final class LockBlockOptions {
private String mUfsPath;
private long mOffset;
private long mBlockSize;
private int mMaxUfsReadConcurrency;
private String mAlluxioMountPoint;
private long mMountTableVersion;
/**
* @return the default {@link LockBlockOptions}
*/
public static LockBlockOptions defaults() {
return new LockBlockOptions();
}
/**
* Creates a {@link LockBlockOptions} instance.
*/
private LockBlockOptions() {}
/**
* @return the UFS path
*/
public String getUfsPath() {
return mUfsPath;
}
/**
* @return the block offset in the UFS file
*/
public long getOffset() {
return mOffset;
}
/**
* @return the UFS block size
*/
public long getBlockSize() {
return mBlockSize;
}
/**
* @return the maximum UFS read concurrency
*/
public int getMaxUfsReadConcurrency() {
return mMaxUfsReadConcurrency;
}
/**
* @return the mount point path in Alluxio for the file this block belonging to
*/
public String getAlluxioMountPoint() {
return mAlluxioMountPoint;
}
/**
* @return the mount table version
*/
public long getMountTableVersion() {
return mMountTableVersion;
}
/**
* @param ufsPath the UFS path to set
* @return the updated options object
*/
public LockBlockOptions setUfsPath(String ufsPath) {
mUfsPath = ufsPath;
return this;
}
/**
* @param offset the UFS block offset to set
* @return the updated options object
*/
public LockBlockOptions setOffset(long offset) {
mOffset = offset;
return this;
}
/**
* @param blockSize the UFS block size to set
* @return the updated options object
*/
public LockBlockOptions setBlockSize(long blockSize) {
mBlockSize = blockSize;
return this;
}
/**
* @param maxUfsReadConcurrency the maximum UFS read concurrency
* @return the updated options object
*/
public LockBlockOptions setMaxUfsReadConcurrency(int maxUfsReadConcurrency) {
mMaxUfsReadConcurrency = maxUfsReadConcurrency;
return this;
}
/**
* @param alluxioMountPoint the mount point path in Alluxio for this file
* @return the updated options object
*/
public LockBlockOptions setAlluxioMountPoint(String alluxioMountPoint) {
mAlluxioMountPoint = alluxioMountPoint;
return this;
}
/**
* @param mountTableVersion the mount table version
* @return the updated options object
*/
public LockBlockOptions setMountTableVersion(long mountTableVersion) {
mMountTableVersion = mountTableVersion;
return this;
}
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (!(o instanceof LockBlockOptions)) {
return false;
}
LockBlockOptions that = (LockBlockOptions) o;
return Objects.equal(mAlluxioMountPoint, that.mAlluxioMountPoint)
&& Objects.equal(mUfsPath, that.mUfsPath)
&& Objects.equal(mOffset, that.mOffset)
&& Objects.equal(mBlockSize, that.mBlockSize)
&& Objects.equal(mMaxUfsReadConcurrency, that.mMaxUfsReadConcurrency)
&& Objects.equal(mMountTableVersion, that.mMountTableVersion);
}
@Override
public int hashCode() {
return Objects.hashCode(mAlluxioMountPoint, mBlockSize, mMaxUfsReadConcurrency,
mMountTableVersion, mOffset, mUfsPath);
}
@Override
public String toString() {
return Objects.toStringHelper(this)
.add("alluxioMountPoint", mAlluxioMountPoint)
.add("blockSize", mBlockSize)
.add("maxUfsReadConcurrency", mMaxUfsReadConcurrency)
.add("mountTableVersion", mMountTableVersion)
.add("offset", mOffset)
.add("ufsPath", mUfsPath)
.toString();
}
/**
* Converts the object to a {@link LockBlockTOptions} object.
*
* @return the thrift lock block options
*/
public LockBlockTOptions toThrift() {
LockBlockTOptions options = new LockBlockTOptions();
options.setAlluxioMountPoint(mAlluxioMountPoint);
options.setBlockSize(mBlockSize);
options.setMaxUfsReadConcurrency(mMaxUfsReadConcurrency);
options.setMountTableVersion(mMountTableVersion);
options.setOffset(mOffset);
options.setUfsPath(mUfsPath);
return options;
}
}