Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
d10ba4b
HDDS-7740. [Snapshot] Implement SnapshotDeletingService
aswinshakil Feb 2, 2023
81cad24
Merge master and fix findbugs.
aswinshakil Feb 2, 2023
bbd106b
HDDS-7740: Fix tests.
aswinshakil Feb 2, 2023
d2e5750
Merge remote-tracking branch 'asf/master' into HDDS-7740
smengcl Feb 7, 2023
fb7b7ae
HDDS-7740: Address review comments.
aswinshakil Feb 27, 2023
31de5bc
Merge apache/master to HDDS-7740
aswinshakil Feb 27, 2023
a31bd8c
HDDS-7740. Fix Unit test.
aswinshakil Feb 27, 2023
2470c11
HDDS-7740. Add Unit test.
aswinshakil Mar 2, 2023
a0f58d3
HDDS-7740. Add suggestion.
aswinshakil Mar 2, 2023
c36f0fd
HDDS-7740. Change put to putWithBatch.
aswinshakil Mar 3, 2023
e79b931
Trigger Build
aswinshakil Mar 3, 2023
e79910e
Merge branch 'master' of https://github.com/apache/ozone into HDDS-7740
aswinshakil Mar 3, 2023
b37e860
HDDS-7740. Fix UT.
aswinshakil Mar 3, 2023
0bc1e14
HDDS-7740. Address review comments.
aswinshakil Mar 5, 2023
9ab9373
HDDS-7740. Update current snapshot deletedTable.
aswinshakil Mar 10, 2023
ff78d47
HDDS-7740. Disable test.
aswinshakil Mar 11, 2023
54c88d5
Merge branch 'master' of https://github.com/apache/ozone into HDDS-7740
aswinshakil Mar 11, 2023
2144e16
HDDS-7740. Change variable name and adjust condition.
aswinshakil Mar 14, 2023
0d9f773
HDDS-7740. Add comment and update variable name.
aswinshakil Mar 14, 2023
5f17166
HDDS-7883. [Snapshot] Accommodate FSO, Key renames and implement OMSn…
aswinshakil Mar 16, 2023
8dfc27e
HDDS-7883. Fix findbugs.
aswinshakil Mar 16, 2023
090f428
Merge master
aswinshakil Mar 16, 2023
006b3cc
Merge master
aswinshakil Mar 16, 2023
f8180d6
HDDS-7883. Remove unused declaration.
aswinshakil Mar 16, 2023
fa1118d
HDDS-7883. Add test and address comments.
aswinshakil Mar 17, 2023
eeaa9f7
Fix Findbugs
aswinshakil Mar 21, 2023
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
9 changes: 9 additions & 0 deletions hadoop-hdds/common/src/main/resources/ozone-default.xml
Original file line number Diff line number Diff line change
Expand Up @@ -491,6 +491,15 @@
and DataNode.
</description>
</property>
<property>
<name>ozone.snapshot.key.deleting.limit.per.task</name>
<value>20000</value>
<tag>OM, PERFORMANCE</tag>
<description>
The maximum number of deleted keys to be scanned by Snapshot
Deleting Service per snapshot run.
</description>
</property>
<property>
<name>ozone.om.service.ids</name>
<value/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,7 @@ public static boolean isReadOnly(
case CreateSnapshot:
case DeleteSnapshot:
case SnapshotMoveDeletedKeys:
case SnapshotPurge:
return false;
default:
LOG.error("CmdType {} is not categorized as readOnly or not.", cmdType);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,10 @@ private OMConfigKeys() {
public static final String OZONE_KEY_DELETING_LIMIT_PER_TASK =
"ozone.key.deleting.limit.per.task";
public static final int OZONE_KEY_DELETING_LIMIT_PER_TASK_DEFAULT = 20000;
public static final String OZONE_SNAPSHOT_KEY_DELETING_LIMIT_PER_TASK =
"ozone.snapshot.key.deleting.limit.per.task";
public static final int OZONE_SNAPSHOT_KEY_DELETING_LIMIT_PER_TASK_DEFAULT
= 20000;

public static final String OZONE_OM_OPEN_KEY_CLEANUP_SERVICE_INTERVAL =
"ozone.om.open.key.cleanup.service.interval";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ enum Type {
SnapshotMoveDeletedKeys = 116;

TransferLeadership = 117;
SnapshotPurge = 118;
}

message OMRequest {
Expand Down Expand Up @@ -248,6 +249,7 @@ message OMRequest {
optional SnapshotMoveDeletedKeysRequest SnapshotMoveDeletedKeysRequest = 116;

optional hdds.TransferLeadershipRequestProto TransferOmLeadershipRequest = 117;
optional SnapshotPurgeRequest SnapshotPurgeRequest = 118;

}

Expand Down Expand Up @@ -357,6 +359,7 @@ message OMResponse {
optional SnapshotMoveDeletedKeysResponse SnapshotMoveDeletedKeysResponse = 116;

optional hdds.TransferLeadershipResponseProto TransferOmLeadershipResponse = 117;
optional SnapshotPurgeResponse SnapshotPurgeResponse = 118;
}

enum Status {
Expand Down Expand Up @@ -1717,6 +1720,10 @@ message SnapshotMoveKeyInfos {
repeated KeyInfo keyInfos = 2;
}

message SnapshotPurgeRequest {
repeated string snapshotDBKeys = 1;
}

message DeleteTenantRequest {
optional string tenantId = 1;
}
Expand Down Expand Up @@ -1783,6 +1790,10 @@ message SnapshotMoveDeletedKeysResponse {

}

message SnapshotPurgeResponse {

}

message SnapshotDiffReportProto {
optional string volumeName = 1;
optional string bucketName = 2;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,7 @@ public class OmMetadataManagerImpl implements OMMetadataManager,

private Map<String, Table> tableMap = new HashMap<>();
private List<TableCacheMetrics> tableCacheMetrics = new LinkedList<>();
private SnapshotChainManager snapshotChainManager;

public OmMetadataManagerImpl(OzoneConfiguration conf) throws IOException {
this.lock = new OzoneManagerLock(conf);
Expand Down Expand Up @@ -464,6 +465,8 @@ public void start(OzoneConfiguration configuration) throws IOException {

initializeOmTables(true);
}

snapshotChainManager = new SnapshotChainManager(this);
}

public static DBStore loadDB(OzoneConfiguration configuration, File metaDir)
Expand Down Expand Up @@ -1632,6 +1635,15 @@ public Table<String, OmKeyRenameInfo> getRenamedKeyTable() {
return renamedKeyTable;
}

/**
* Get Snapshot Chain Manager.
*
* @return SnapshotChainManager.
*/
public SnapshotChainManager getSnapshotChainManager() {
return snapshotChainManager;
}

/**
* Update store used by subclass.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -452,7 +452,6 @@ private enum State {
// This metadata reader points to the active filesystem
private OmMetadataReader omMetadataReader;
private OmSnapshotManager omSnapshotManager;
private SnapshotChainManager snapshotChainManager;

/** A list of property that are reconfigurable at runtime. */
private final SortedSet<String> reconfigurableProperties =
Expand Down Expand Up @@ -770,7 +769,6 @@ private void instantiateServices(boolean withNewSnapshot) throws IOException {
omMetadataReader = new OmMetadataReader(keyManager, prefixManager,
this, LOG, AUDIT, metrics);
omSnapshotManager = new OmSnapshotManager(this);
snapshotChainManager = new SnapshotChainManager(metadataManager);

// Snapshot metrics
updateActiveSnapshotMetrics();
Expand Down Expand Up @@ -1510,15 +1508,6 @@ public OmSnapshotManager getOmSnapshotManager() {
return omSnapshotManager;
}

/**
* Get Snapshot Chain Manager.
*
* @return SnapshotChainManager.
*/
public SnapshotChainManager getSnapshotChainManager() {
return snapshotChainManager;
}

/**
* Get metadata manager.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public class SnapshotChainManager {
snapshotChainPath;
private Map<String, String> latestPathSnapshotID;
private String latestGlobalSnapshotID;
private Map<String, String> snapshotPathToTableKey;
private Map<String, String> snapshotIdToTableKey;
private static final Logger LOG =
LoggerFactory.getLogger(SnapshotChainManager.class);

Expand All @@ -58,7 +58,7 @@ public SnapshotChainManager(OMMetadataManager metadataManager)
snapshotChainGlobal = new LinkedHashMap<>();
snapshotChainPath = new HashMap<>();
latestPathSnapshotID = new HashMap<>();
snapshotPathToTableKey = new HashMap<>();
snapshotIdToTableKey = new HashMap<>();
latestGlobalSnapshotID = null;
loadFromSnapshotInfoTable(metadataManager);
}
Expand Down Expand Up @@ -100,8 +100,7 @@ private void addSnapshotGlobal(String snapshotID,
*/
private void addSnapshotPath(String snapshotPath,
String snapshotID,
String prevPathID,
String snapTableKey) throws IOException {
String prevPathID) throws IOException {
// set previous snapshotID to null if it is "" for
// internal in-mem structure
if (prevPathID != null && prevPathID.isEmpty()) {
Expand Down Expand Up @@ -139,8 +138,6 @@ private void addSnapshotPath(String snapshotPath,
.put(snapshotID,
new SnapshotChainInfo(snapshotID, prevPathID, null));

// store snapshot ID to snapshot DB table key in the map
snapshotPathToTableKey.put(snapshotID, snapTableKey);
// set state variable latestPath snapshot entry to this snapshotID
latestPathSnapshotID.put(snapshotPath, snapshotID);
};
Expand Down Expand Up @@ -272,7 +269,7 @@ private void loadFromSnapshotInfoTable(OMMetadataManager metadataManager)
snapshotChainGlobal.clear();
snapshotChainPath.clear();
latestPathSnapshotID.clear();
snapshotPathToTableKey.clear();
snapshotIdToTableKey.clear();

while (keyIter.hasNext()) {
kv = keyIter.next();
Expand All @@ -292,8 +289,9 @@ public void addSnapshot(SnapshotInfo sinfo) throws IOException {
sinfo.getGlobalPreviousSnapshotID());
addSnapshotPath(sinfo.getSnapshotPath(),
sinfo.getSnapshotID(),
sinfo.getPathPreviousSnapshotID(),
sinfo.getTableKey());
sinfo.getPathPreviousSnapshotID());
// store snapshot ID to snapshot DB table key in the map
snapshotIdToTableKey.put(sinfo.getSnapshotID(), sinfo.getTableKey());
}

/**
Expand All @@ -304,9 +302,12 @@ public void addSnapshot(SnapshotInfo sinfo) throws IOException {
public boolean deleteSnapshot(SnapshotInfo sinfo) throws IOException {
boolean status;

status = deleteSnapshotGlobal(sinfo.getSnapshotID());
return status && deleteSnapshotPath(sinfo.getSnapshotPath(),
sinfo.getSnapshotID());
status = deleteSnapshotGlobal(sinfo.getSnapshotID()) &&
deleteSnapshotPath(sinfo.getSnapshotPath(), sinfo.getSnapshotID());
if (status) {
snapshotIdToTableKey.remove(sinfo.getSnapshotID());
}
return status;
}

/**
Expand Down Expand Up @@ -521,8 +522,8 @@ public String previousPathSnapshot(String snapshotPath, String snapshotID)
.getPreviousSnapshotID();
}

public String getTableKey(String snapshotPath) {
return snapshotPathToTableKey.get(snapshotPath);
public String getTableKey(String snapshotId) {
return snapshotIdToTableKey.get(snapshotId);
}

@VisibleForTesting
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@
import org.apache.hadoop.ozone.om.request.snapshot.OMSnapshotCreateRequest;
import org.apache.hadoop.ozone.om.request.snapshot.OMSnapshotDeleteRequest;
import org.apache.hadoop.ozone.om.request.snapshot.OMSnapshotMoveDeletedKeysRequest;
import org.apache.hadoop.ozone.om.request.snapshot.OMSnapshotPurgeRequest;
import org.apache.hadoop.ozone.om.request.upgrade.OMCancelPrepareRequest;
import org.apache.hadoop.ozone.om.request.upgrade.OMFinalizeUpgradeRequest;
import org.apache.hadoop.ozone.om.request.upgrade.OMPrepareRequest;
Expand Down Expand Up @@ -218,6 +219,8 @@ public static OMClientRequest createClientRequest(OMRequest omRequest,
return new OMSnapshotDeleteRequest(omRequest);
case SnapshotMoveDeletedKeys:
return new OMSnapshotMoveDeletedKeysRequest(omRequest);
case SnapshotPurge:
return new OMSnapshotPurgeRequest(omRequest);
case DeleteOpenKeys:
BucketLayout bktLayout = BucketLayout.DEFAULT;
if (omRequest.getDeleteOpenKeysRequest().hasBucketLayout()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@
import org.apache.hadoop.ozone.OmUtils;
import org.apache.hadoop.ozone.audit.AuditLogger;
import org.apache.hadoop.ozone.audit.OMAction;
import org.apache.hadoop.ozone.om.OMMetadataManager;
import org.apache.hadoop.ozone.om.OMMetrics;
import org.apache.hadoop.ozone.om.OmMetadataManagerImpl;
import org.apache.hadoop.ozone.om.OzoneManager;
import org.apache.hadoop.ozone.om.SnapshotChainManager;
import org.apache.hadoop.ozone.om.exceptions.OMException;
Expand Down Expand Up @@ -115,9 +115,10 @@ public OMClientResponse validateAndUpdateCache(OzoneManager ozoneManager,

boolean acquiredBucketLock = false, acquiredSnapshotLock = false;
IOException exception = null;
OMMetadataManager omMetadataManager = ozoneManager.getMetadataManager();
OmMetadataManagerImpl omMetadataManager = (OmMetadataManagerImpl)
ozoneManager.getMetadataManager();
SnapshotChainManager snapshotChainManager =
ozoneManager.getSnapshotChainManager();
omMetadataManager.getSnapshotChainManager();

OMResponse.Builder omResponse = OmResponseUtil.getOMResponseBuilder(
getOmRequest());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

package org.apache.hadoop.ozone.om.request.snapshot;

import org.apache.hadoop.ozone.om.OmMetadataManagerImpl;
import org.apache.hadoop.ozone.om.OmSnapshot;
import org.apache.hadoop.ozone.om.OmSnapshotManager;
import org.apache.hadoop.ozone.om.OzoneManager;
Expand Down Expand Up @@ -57,8 +58,10 @@ public OMSnapshotMoveDeletedKeysRequest(OMRequest omRequest) {
public OMClientResponse validateAndUpdateCache(OzoneManager ozoneManager,
long trxnLogIndex, OzoneManagerDoubleBufferHelper omDoubleBufferHelper) {
OmSnapshotManager omSnapshotManager = ozoneManager.getOmSnapshotManager();
OmMetadataManagerImpl omMetadataManager = (OmMetadataManagerImpl)
ozoneManager.getMetadataManager();
SnapshotChainManager snapshotChainManager =
ozoneManager.getSnapshotChainManager();
omMetadataManager.getSnapshotChainManager();

SnapshotMoveDeletedKeysRequest moveDeletedKeysRequest =
getOmRequest().getSnapshotMoveDeletedKeysRequest();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/

package org.apache.hadoop.ozone.om.request.snapshot;

import org.apache.hadoop.ozone.om.OzoneManager;
import org.apache.hadoop.ozone.om.ratis.utils.OzoneManagerDoubleBufferHelper;
import org.apache.hadoop.ozone.om.request.OMClientRequest;
import org.apache.hadoop.ozone.om.request.util.OmResponseUtil;
import org.apache.hadoop.ozone.om.response.OMClientResponse;
import org.apache.hadoop.ozone.om.response.snapshot.OMSnapshotPurgeResponse;
import org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos;
import org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.OMRequest;
import org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.SnapshotPurgeRequest;

import java.util.List;

/**
* Handles OMSnapshotPurge Request.
*/
public class OMSnapshotPurgeRequest extends OMClientRequest {

public OMSnapshotPurgeRequest(OMRequest omRequest) {
super(omRequest);
}

@Override
public OMClientResponse validateAndUpdateCache(OzoneManager ozoneManager,
long trxnLogIndex, OzoneManagerDoubleBufferHelper omDoubleBufferHelper) {

OMClientResponse omClientResponse = null;

OzoneManagerProtocolProtos.OMResponse.Builder omResponse =
OmResponseUtil.getOMResponseBuilder(getOmRequest());
SnapshotPurgeRequest snapshotPurgeRequest = getOmRequest()
.getSnapshotPurgeRequest();

List<String> snapshotDbKeys = snapshotPurgeRequest
.getSnapshotDBKeysList();

omClientResponse = new OMSnapshotPurgeResponse(omResponse.build(),
snapshotDbKeys);
addResponseToDoubleBuffer(trxnLogIndex, omClientResponse,
omDoubleBufferHelper);

return omClientResponse;
}
}
Loading