Skip to content

Commit e45a10b

Browse files
bharatviswa504ahussein
authored andcommitted
HDDS-1638. Implement Key Write Requests to use Cache and DoubleBuffer. (apache#956)
1 parent 028f643 commit e45a10b

File tree

52 files changed

+4279
-466
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+4279
-466
lines changed

hadoop-hdds/common/src/main/java/org/apache/hadoop/utils/db/Table.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,14 @@ default void addCacheEntry(CacheKey<KEY> cacheKey,
123123
throw new NotImplementedException("addCacheEntry is not implemented");
124124
}
125125

126+
/**
127+
* Get the cache value from table cache.
128+
* @param cacheKey
129+
*/
130+
default CacheValue<VALUE> getCacheValue(CacheKey<KEY> cacheKey) {
131+
throw new NotImplementedException("getCacheValue is not implemented");
132+
}
133+
126134
/**
127135
* Removes all the entries from the table cache which are having epoch value
128136
* less

hadoop-hdds/common/src/main/java/org/apache/hadoop/utils/db/TypedTable.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,11 @@ public void addCacheEntry(CacheKey<KEY> cacheKey,
158158
cache.put(cacheKey, cacheValue);
159159
}
160160

161+
@Override
162+
public CacheValue<VALUE> getCacheValue(CacheKey<KEY> cacheKey) {
163+
return cache.get(cacheKey);
164+
}
165+
161166
public Iterator<Map.Entry<CacheKey<KEY>, CacheValue<VALUE>>> cacheIterator() {
162167
return cache.iterator();
163168
}

hadoop-hdds/common/src/test/java/org/apache/hadoop/ozone/audit/DummyAction.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ public enum DummyAction implements AuditAction {
2424

2525
CREATE_VOLUME,
2626
CREATE_BUCKET,
27-
CREATE_KEY,
2827
READ_VOLUME,
2928
READ_BUCKET,
3029
READ_KEY,

hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/audit/OMAction.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ public enum OMAction implements AuditAction {
3030
COMMIT_KEY,
3131
CREATE_VOLUME,
3232
CREATE_BUCKET,
33-
CREATE_KEY,
3433
DELETE_VOLUME,
3534
DELETE_BUCKET,
3635
DELETE_KEY,

hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/om/helpers/OmKeyInfo.java

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -165,28 +165,34 @@ public void updateLocationInfoList(List<OmKeyLocationInfo> locationInfoList) {
165165
* part of the latest version, not a new version.
166166
*
167167
* @param newLocationList the list of new blocks to be added.
168+
* @param updateTime if true, will update modification time.
168169
* @throws IOException
169170
*/
170171
public synchronized void appendNewBlocks(
171-
List<OmKeyLocationInfo> newLocationList) throws IOException {
172+
List<OmKeyLocationInfo> newLocationList, boolean updateTime)
173+
throws IOException {
172174
if (keyLocationVersions.size() == 0) {
173175
throw new IOException("Appending new block, but no version exist");
174176
}
175177
OmKeyLocationInfoGroup currentLatestVersion =
176178
keyLocationVersions.get(keyLocationVersions.size() - 1);
177179
currentLatestVersion.appendNewBlocks(newLocationList);
178-
setModificationTime(Time.now());
180+
if (updateTime) {
181+
setModificationTime(Time.now());
182+
}
179183
}
180184

181185
/**
182186
* Add a new set of blocks. The new blocks will be added as appending a new
183187
* version to the all version list.
184188
*
185189
* @param newLocationList the list of new blocks to be added.
190+
* @param updateTime - if true, updates modification time.
186191
* @throws IOException
187192
*/
188193
public synchronized long addNewVersion(
189-
List<OmKeyLocationInfo> newLocationList) throws IOException {
194+
List<OmKeyLocationInfo> newLocationList, boolean updateTime)
195+
throws IOException {
190196
long latestVersionNum;
191197
if (keyLocationVersions.size() == 0) {
192198
// no version exist, these blocks are the very first version.
@@ -202,7 +208,10 @@ public synchronized long addNewVersion(
202208
keyLocationVersions.add(newVersion);
203209
latestVersionNum = newVersion.getVersion();
204210
}
205-
setModificationTime(Time.now());
211+
212+
if (updateTime) {
213+
setModificationTime(Time.now());
214+
}
206215
return latestVersionNum;
207216
}
208217

hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/om/helpers/OmKeyLocationInfo.java

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@
2323
import org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.KeyLocation;
2424
import org.apache.hadoop.security.token.Token;
2525

26+
import java.util.Objects;
27+
2628
/**
2729
* One key can be too huge to fit in one container. In which case it gets split
2830
* into a number of subkeys. This class represents one such subkey instance.
@@ -202,4 +204,27 @@ public String toString() {
202204
", pipeline=" + pipeline +
203205
", createVersion=" + createVersion + '}';
204206
}
207+
208+
@Override
209+
public boolean equals(Object o) {
210+
if (this == o) {
211+
return true;
212+
}
213+
if (o == null || getClass() != o.getClass()) {
214+
return false;
215+
}
216+
OmKeyLocationInfo that = (OmKeyLocationInfo) o;
217+
return length == that.length &&
218+
offset == that.offset &&
219+
createVersion == that.createVersion &&
220+
Objects.equals(blockID, that.blockID) &&
221+
Objects.equals(token, that.token) &&
222+
Objects.equals(pipeline, that.pipeline);
223+
}
224+
225+
@Override
226+
public int hashCode() {
227+
return Objects.hash(blockID, length, offset, token, createVersion,
228+
pipeline);
229+
}
205230
}

hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/om/protocolPB/OzoneManagerProtocolClientSideTranslatorPB.java

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -726,11 +726,20 @@ private OMResponse handleError(OMResponse resp) throws OMException {
726726
public OmKeyLocationInfo allocateBlock(OmKeyArgs args, long clientId,
727727
ExcludeList excludeList) throws IOException {
728728
AllocateBlockRequest.Builder req = AllocateBlockRequest.newBuilder();
729-
KeyArgs keyArgs = KeyArgs.newBuilder()
729+
KeyArgs.Builder keyArgs = KeyArgs.newBuilder()
730730
.setVolumeName(args.getVolumeName())
731731
.setBucketName(args.getBucketName())
732732
.setKeyName(args.getKeyName())
733-
.setDataSize(args.getDataSize()).build();
733+
.setDataSize(args.getDataSize());
734+
735+
if (args.getFactor() != null) {
736+
keyArgs.setFactor(args.getFactor());
737+
}
738+
739+
if (args.getType() != null) {
740+
keyArgs.setType(args.getType());
741+
}
742+
734743
req.setKeyArgs(keyArgs);
735744
req.setClientID(clientId);
736745
req.setExcludeList(excludeList.getProtoBuf());

hadoop-ozone/common/src/main/proto/OzoneManagerProtocol.proto

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -617,6 +617,10 @@ message KeyArgs {
617617
optional uint32 multipartNumber = 10;
618618
repeated hadoop.hdds.KeyValue metadata = 11;
619619
repeated OzoneAclInfo acls = 12;
620+
// This will be set when the request is received in pre-Execute. This
621+
// value is used in setting creation/modification time depending on the
622+
// request type.
623+
optional uint64 modificationTime = 13;
620624
}
621625

622626
message KeyLocation {
@@ -712,6 +716,9 @@ message ListStatusResponse {
712716

713717
message CreateKeyRequest {
714718
required KeyArgs keyArgs = 1;
719+
// Set in OM HA during preExecute step. This way all OM's use same ID in
720+
// OM HA.
721+
optional uint64 clientID = 2;
715722
}
716723

717724
message CreateKeyResponse {

hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/MiniOzoneHAClusterImpl.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ public void restartOzoneManager() throws IOException {
103103
public void stop() {
104104
for (OzoneManager ozoneManager : ozoneManagers) {
105105
if (ozoneManager != null) {
106-
LOG.info("Stopping the OzoneManager " + ozoneManager.getOMNodId());
106+
LOG.info("Stopping the OzoneManager " + ozoneManager.getOMNodeId());
107107
ozoneManager.stop();
108108
ozoneManager.join();
109109
}

hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/om/TestOzoneManagerHA.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -479,7 +479,7 @@ public void testOMProxyProviderInitialization() throws Exception {
479479
}
480480
}
481481
Assert.assertTrue("There is no OM Client Proxy corresponding to OM " +
482-
"node" + cluster.getOzoneManager(i).getOMNodId(),
482+
"node" + cluster.getOzoneManager(i).getOMNodeId(),
483483
omClientProxyExists);
484484
}
485485
}
@@ -604,7 +604,7 @@ public void testReadRequest() throws Exception {
604604

605605
// Failover to the OM node that the objectStore points to
606606
omFailoverProxyProvider.performFailoverIfRequired(
607-
ozoneManager.getOMNodId());
607+
ozoneManager.getOMNodeId());
608608

609609
// A read request should result in the proxyProvider failing over to
610610
// leader node.

0 commit comments

Comments
 (0)