Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
import org.apache.hadoop.ozone.om.helpers.OmDirectoryInfo;
import org.apache.hadoop.ozone.om.helpers.OmKeyInfo;
import org.apache.hadoop.ozone.om.helpers.OmMultipartKeyInfo;
import org.apache.hadoop.ozone.om.helpers.OmOpenKeyInfo;
import org.apache.hadoop.ozone.om.helpers.OmVolumeArgs;
import org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.PartKeyInfo;
import picocli.CommandLine;
Expand Down Expand Up @@ -97,8 +98,8 @@ public class ContainerToKeyMapping extends AbstractSubcommand implements Callabl
private Table<String, OmDirectoryInfo> directoryTable;
private Table<String, OmKeyInfo> fileTable;
private Table<String, OmKeyInfo> keyTable;
private Table<String, OmKeyInfo> openFileTable;
private Table<String, OmKeyInfo> openKeyTable;
private Table<String, OmOpenKeyInfo> openFileTable;
private Table<String, OmOpenKeyInfo> openKeyTable;
private Table<String, OmMultipartKeyInfo> multipartInfoTable;
private DBStore dirTreeDbStore;
private Table<Long, String> dirTreeTable;
Expand Down Expand Up @@ -273,23 +274,23 @@ private void processOBSKeys(Set<Long> containerIds, Map<Long, List<String>> cont
}

private void processOpenFiles(Set<Long> containerIds, Map<Long, List<String>> containerToOpenKeysMap) {
try (TableIterator<String, ? extends Table.KeyValue<String, OmKeyInfo>> fileIterator =
try (TableIterator<String, ? extends Table.KeyValue<String, OmOpenKeyInfo>> fileIterator =
openFileTable.iterator()) {
while (fileIterator.hasNext()) {
Table.KeyValue<String, OmKeyInfo> entry = fileIterator.next();
addOpenKeyToContainerMap(entry.getKey(), entry.getValue(), containerIds, containerToOpenKeysMap);
Table.KeyValue<String, OmOpenKeyInfo> entry = fileIterator.next();
addOpenKeyToContainerMap(entry.getKey(), entry.getValue().getKeyInfo(), containerIds, containerToOpenKeysMap);
}
} catch (Exception e) {
err().println("Exception occurred reading openFileTable (FSO keys), " + e);
}
}

private void processOpenKeys(Set<Long> containerIds, Map<Long, List<String>> containerToOpenKeysMap) {
try (TableIterator<String, ? extends Table.KeyValue<String, OmKeyInfo>> keyIterator =
try (TableIterator<String, ? extends Table.KeyValue<String, OmOpenKeyInfo>> keyIterator =
openKeyTable.iterator()) {
while (keyIterator.hasNext()) {
Table.KeyValue<String, OmKeyInfo> entry = keyIterator.next();
addOpenKeyToContainerMap(entry.getKey(), entry.getValue(), containerIds, containerToOpenKeysMap);
Table.KeyValue<String, OmOpenKeyInfo> entry = keyIterator.next();
addOpenKeyToContainerMap(entry.getKey(), entry.getValue().getKeyInfo(), containerIds, containerToOpenKeysMap);
}
} catch (Exception e) {
err().println("Exception occurred reading openKeyTable (OBS keys), " + e);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
import org.apache.hadoop.ozone.om.helpers.OmKeyLocationInfo;
import org.apache.hadoop.ozone.om.helpers.OmKeyLocationInfoGroup;
import org.apache.hadoop.ozone.om.helpers.OmMultipartKeyInfo;
import org.apache.hadoop.ozone.om.helpers.OmOpenKeyInfo;
import org.apache.hadoop.ozone.om.helpers.OmVolumeArgs;
import org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.KeyInfo;
import org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.PartKeyInfo;
Expand Down Expand Up @@ -281,14 +282,16 @@ private void createTestData() throws Exception {
"openFile", OPEN_FILE_ID, DIR_ID, CONTAINER_ID_1);
String openFileKey = omMetadataManager.getOpenFileName(
VOLUME_ID, FSO_BUCKET_ID, DIR_ID, "openFile", 1L);
omMetadataManager.getOpenKeyTable(BucketLayout.FILE_SYSTEM_OPTIMIZED).put(openFileKey, openFileInfo);
omMetadataManager.getOpenKeyTable(BucketLayout.FILE_SYSTEM_OPTIMIZED).put(openFileKey,
new OmOpenKeyInfo.Builder().setKeyInfo(openFileInfo).build());

// Create open OBS key with a block in container 2
OmKeyInfo openKeyInfo = createOBSKeyInfo(
"openKey", OPEN_KEY_ID, CONTAINER_ID_2);
String openKey = omMetadataManager.getOzoneKey(
VOLUME_NAME, OBS_BUCKET_NAME, "openKey");
omMetadataManager.getOpenKeyTable(BucketLayout.OBJECT_STORE).put(openKey, openKeyInfo);
omMetadataManager.getOpenKeyTable(BucketLayout.OBJECT_STORE).put(openKey,
new OmOpenKeyInfo.Builder().setKeyInfo(openKeyInfo).build());

// Create MPU (multipart upload) for OBS bucket with parts in container 5
createMultipartUpload();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,15 +103,6 @@ public final class OmKeyInfo extends WithParentObjectId
*/
private final ImmutableMap<String, String> tags;

// expectedDataGeneration, when used in key creation indicates that a
// key with the same keyName should exist with the given generation.
// For a key commit to succeed, the original key should still be present with the
// generation unchanged.
// This allows a key to be created an committed atomically if the original has not
// been modified.
private Long expectedDataGeneration = null;
private String expectedETag;

private OmKeyInfo(Builder b) {
super(b);
this.volumeName = b.volumeName;
Expand All @@ -129,8 +120,6 @@ private OmKeyInfo(Builder b) {
this.isFile = b.isFile;
this.ownerName = b.ownerName;
this.tags = b.tags.build();
this.expectedDataGeneration = b.expectedDataGeneration;
this.expectedETag = b.expectedETag;
}

private static Codec<OmKeyInfo> newCodec(boolean ignorePipeline) {
Expand Down Expand Up @@ -183,22 +172,6 @@ public String getFileName() {
return fileName;
}

public void setExpectedDataGeneration(Long generation) {
this.expectedDataGeneration = generation;
}

public Long getExpectedDataGeneration() {
return expectedDataGeneration;
}

public void setExpectedETag(String eTag) {
this.expectedETag = eTag;
}

public String getExpectedETag() {
return expectedETag;
}

public String getOwnerName() {
return ownerName;
}
Expand Down Expand Up @@ -501,8 +474,6 @@ public static class Builder extends WithParentObjectId.Builder<OmKeyInfo> {

private boolean isFile;
private final MapBuilder<String, String> tags;
private Long expectedDataGeneration = null;
private String expectedETag;

public Builder() {
this.acls = AclListBuilder.empty();
Expand All @@ -524,8 +495,6 @@ public Builder(OmKeyInfo obj) {
this.fileName = obj.fileName;
this.fileChecksum = obj.fileChecksum;
this.isFile = obj.isFile;
this.expectedDataGeneration = obj.expectedDataGeneration;
this.expectedETag = obj.expectedETag;
this.tags = MapBuilder.of(obj.tags);
obj.keyLocationVersions.forEach(keyLocationVersion ->
this.omKeyLocationInfoGroups.add(
Expand Down Expand Up @@ -692,16 +661,6 @@ public Builder addAllTags(Map<String, String> keyTags) {
return this;
}

public Builder setExpectedDataGeneration(Long existingGeneration) {
this.expectedDataGeneration = existingGeneration;
return this;
}

public Builder setExpectedETag(String eTag) {
this.expectedETag = eTag;
return this;
}

@Override
protected void validate() {
super.validate();
Expand Down Expand Up @@ -818,12 +777,6 @@ private KeyInfo getProtobuf(boolean ignorePipeline, String fullKeyName,
kb.setFileEncryptionInfo(OMPBHelper.convert(encInfo));
}
kb.setIsFile(isFile);
if (expectedDataGeneration != null) {
kb.setExpectedDataGeneration(expectedDataGeneration);
}
if (expectedETag != null) {
kb.setExpectedETag(expectedETag);
}
if (ownerName != null) {
kb.setOwnerName(ownerName);
}
Expand Down Expand Up @@ -874,12 +827,6 @@ public static Builder builderFromProtobuf(KeyInfo keyInfo) {
if (keyInfo.hasIsFile()) {
builder.setFile(keyInfo.getIsFile());
}
if (keyInfo.hasExpectedDataGeneration()) {
builder.setExpectedDataGeneration(keyInfo.getExpectedDataGeneration());
}
if (keyInfo.hasExpectedETag()) {
builder.setExpectedETag(keyInfo.getExpectedETag());
}

if (keyInfo.hasOwnerName()) {
builder.setOwnerName(keyInfo.getOwnerName());
Expand Down
Loading