Skip to content
Draft
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 @@ -155,7 +155,7 @@ public class TestKeyManagerImpl {
@TempDir
private static File dir;
private static PrefixManager prefixManager;
private static KeyManagerImpl keyManager;
private static KeyManager keyManager;
private static StorageContainerManager scm;
private static ScmBlockLocationProtocol mockScmBlockLocationProtocol;
private static StorageContainerLocationInternalInterface mockScmContainerClient;
Expand Down Expand Up @@ -215,7 +215,7 @@ public static void setUp() throws Exception {
mockScmContainerClient);
om = omTestManagers.getOzoneManager();
metadataManager = omTestManagers.getMetadataManager();
keyManager = (KeyManagerImpl)omTestManagers.getKeyManager();
keyManager = omTestManagers.getKeyManager();
prefixManager = omTestManagers.getPrefixManager();
writeClient = omTestManagers.getWriteClient();
rpcClient = omTestManagers.getRpcClient();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@
import org.apache.hadoop.ozone.client.io.OzoneInputStream;
import org.apache.hadoop.ozone.client.io.OzoneOutputStream;
import org.apache.hadoop.ozone.om.IOmMetadataReader;
import org.apache.hadoop.ozone.om.KeyManagerImpl;
import org.apache.hadoop.ozone.om.KeyManager;
import org.apache.hadoop.ozone.om.OMConfigKeys;
import org.apache.hadoop.ozone.om.OMStorage;
import org.apache.hadoop.ozone.om.OMUpgradeTestUtils;
Expand Down Expand Up @@ -293,13 +293,13 @@ private void createBucket(OzoneVolume volume, String bucketVal) throws IOExcepti
}

private void stopKeyManager() throws IOException {
KeyManagerImpl keyManager = (KeyManagerImpl) HddsWhiteboxTestUtils
KeyManager keyManager = (KeyManager) HddsWhiteboxTestUtils
.getInternalState(ozoneManager, "keyManager");
keyManager.stop();
}

private void startKeyManager() throws IOException {
KeyManagerImpl keyManager = (KeyManagerImpl) HddsWhiteboxTestUtils
KeyManager keyManager = (KeyManager) HddsWhiteboxTestUtils
.getInternalState(ozoneManager, "keyManager");
keyManager.start(conf);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
import org.apache.hadoop.ozone.client.OzoneVolume;
import org.apache.hadoop.ozone.client.VolumeArgs;
import org.apache.hadoop.ozone.client.io.OzoneOutputStream;
import org.apache.hadoop.ozone.om.KeyManagerImpl;
import org.apache.hadoop.ozone.om.KeyManager;
import org.apache.hadoop.ozone.om.OMConfigKeys;
import org.apache.hadoop.ozone.om.OMStorage;
import org.apache.hadoop.ozone.om.OmSnapshotManager;
Expand Down Expand Up @@ -138,7 +138,7 @@ public static void init() throws Exception {
objectStore = client.getObjectStore();

ozoneManager = cluster.getOzoneManager();
final KeyManagerImpl keyManager = (KeyManagerImpl) HddsWhiteboxTestUtils
final KeyManager keyManager = (KeyManager) HddsWhiteboxTestUtils
.getInternalState(ozoneManager, "keyManager");

// stop the deletion services so that keys can still be read
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
import org.apache.hadoop.ozone.client.OzoneKey;
import org.apache.hadoop.ozone.client.OzoneVolume;
import org.apache.hadoop.ozone.client.io.OzoneOutputStream;
import org.apache.hadoop.ozone.om.KeyManagerImpl;
import org.apache.hadoop.ozone.om.KeyManager;
import org.apache.hadoop.ozone.om.OMConfigKeys;
import org.apache.hadoop.ozone.om.OMStorage;
import org.apache.hadoop.ozone.om.OmSnapshotManager;
Expand Down Expand Up @@ -116,7 +116,7 @@ public void init() throws Exception {
client = cluster.newClient();
store = client.getObjectStore();

KeyManagerImpl keyManager = (KeyManagerImpl) HddsWhiteboxTestUtils
KeyManager keyManager = (KeyManager) HddsWhiteboxTestUtils
.getInternalState(leaderOzoneManager, "keyManager");
// stop the deletion services so that keys can still be read
keyManager.stop();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
import org.apache.hadoop.conf.ReconfigurationException;
import org.apache.hadoop.hdds.conf.ReconfigurationHandler;
import org.apache.hadoop.hdds.tracing.TracingConfig;
import org.apache.hadoop.ozone.om.KeyManagerImpl;
import org.apache.hadoop.ozone.om.KeyManager;
import org.apache.hadoop.ozone.om.OmConfig;
import org.apache.hadoop.ozone.om.OzoneManager;
import org.apache.hadoop.ozone.om.service.KeyLifecycleService;
Expand Down Expand Up @@ -222,7 +222,7 @@ void unsetAllowListAllVolumes(String newValue) throws ReconfigurationException {
void sstFilteringServiceInterval() throws ReconfigurationException {
// Tests reconfiguration of SST filtering service interval
final OzoneManager om = cluster().getOzoneManager();
final KeyManagerImpl keyManagerImpl = (KeyManagerImpl) om.getKeyManager();
final KeyManager keyManagerImpl = om.getKeyManager();

// Get the original interval value
String originalValue = om.getConfiguration().get(OZONE_SNAPSHOT_SST_FILTERING_SERVICE_INTERVAL);
Expand All @@ -239,8 +239,6 @@ void sstFilteringServiceInterval() throws ReconfigurationException {
assertEquals(newIntervalValue, om.getConfiguration()
.get(OZONE_SNAPSHOT_SST_FILTERING_SERVICE_INTERVAL));
// Verify the service is still enabled with the new interval
assertTrue(keyManagerImpl.isSstFilteringSvcEnabled(),
"SstFilteringService should remain enabled with new interval");
assertNotNull(keyManagerImpl.getSnapshotSstFilteringService(),
"SstFilteringService should not be null with new interval");
// Verify the new interval is applied (30 seconds = 30000 milliseconds)
Expand All @@ -254,8 +252,6 @@ void sstFilteringServiceInterval() throws ReconfigurationException {
getSubject().reconfigureProperty(OZONE_SNAPSHOT_SST_FILTERING_SERVICE_INTERVAL, disableValue);
assertEquals(disableValue, om.getConfiguration().get(OZONE_SNAPSHOT_SST_FILTERING_SERVICE_INTERVAL));
// Verify that the SstFilteringService is stopped
assertFalse(keyManagerImpl.isSstFilteringSvcEnabled(),
"SstFilteringService should be disabled when interval is -1");
assertNull(keyManagerImpl.getSnapshotSstFilteringService(),
"SstFilteringService should be null when disabled");

Expand All @@ -264,8 +260,6 @@ void sstFilteringServiceInterval() throws ReconfigurationException {
getSubject().reconfigureProperty(OZONE_SNAPSHOT_SST_FILTERING_SERVICE_INTERVAL, originalValue);
assertEquals(originalValue, om.getConfiguration().get(OZONE_SNAPSHOT_SST_FILTERING_SERVICE_INTERVAL));
// Verify that the SstFilteringService is running again
assertTrue(keyManagerImpl.isSstFilteringSvcEnabled(),
"SstFilteringService should be enabled after restoring original interval");
assertNotNull(keyManagerImpl.getSnapshotSstFilteringService(),
"SstFilteringService should not be null when enabled");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -377,6 +377,11 @@ DeleteKeysResult getPendingDeletionSubFiles(long volumeId, long bucketId, OmKeyI
*/
SstFilteringService getSnapshotSstFilteringService();

/**
* Restart the snapshot SST filtering service with the interval in {@code conf}; it stays stopped if disabled.
*/
void restartSnapshotSstFilteringService(OzoneConfiguration conf);

/**
* Returns the instance of Snapshot Defrag service.
* @return Background service.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -433,6 +433,12 @@ public void stopSnapshotSstFilteringService() {
}
}

@Override
public void restartSnapshotSstFilteringService(OzoneConfiguration conf) {
stopSnapshotSstFilteringService();
startSnapshotSstFilteringService(conf);
}

/**
* Start the snapshot defrag service if interval is not set to disabled value.
* @param conf
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6297,18 +6297,10 @@ private void reconfKeyLifecycleService(Map<String, Boolean> changedKeys, Configu
}

private String reconfOzoneSnapshotSSTFilteringServiceInterval(String newVal) {
boolean wasSstFilteringSvcEnabled = ((KeyManagerImpl) keyManager).isSstFilteringSvcEnabled();
getConfiguration().set(OZONE_SNAPSHOT_SST_FILTERING_SERVICE_INTERVAL, newVal);

if (this.isFilesystemSnapshotEnabled()) {
if (wasSstFilteringSvcEnabled) {
// Sanity check
Objects.requireNonNull(keyManager.getSnapshotSstFilteringService(),
"sstFilteringService should not be null when SST filtering service is enabled.");
((KeyManagerImpl) keyManager).stopSnapshotSstFilteringService();
}
// Note startSnapshotSstFilteringService checks whether the config is set to a value that enables the service
((KeyManagerImpl) keyManager).startSnapshotSstFilteringService(getConfiguration());
keyManager.restartSnapshotSstFilteringService(getConfiguration());
} else {
LOG.warn("Ozone filesystem snapshot is not enabled. {} is reconfigured but will not make any difference.",
OZONE_SNAPSHOT_SST_FILTERING_SERVICE_INTERVAL);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,9 +138,9 @@ public OmTestManagers(OzoneConfiguration conf,
.getObjectStore().getClientProxy().getOzoneManagerClient();
metadataManager = (OmMetadataManagerImpl) HddsWhiteboxTestUtils
.getInternalState(om, "metadataManager");
volumeManager = (VolumeManagerImpl)HddsWhiteboxTestUtils
volumeManager = (VolumeManager)HddsWhiteboxTestUtils
.getInternalState(om, "volumeManager");
bucketManager = (BucketManagerImpl)HddsWhiteboxTestUtils
bucketManager = (BucketManager)HddsWhiteboxTestUtils
.getInternalState(om, "bucketManager");
prefixManager = (PrefixManagerImpl)HddsWhiteboxTestUtils
.getInternalState(om, "prefixManager");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ class TestKeyManagerUnit extends OzoneTestBase {

private OMMetadataManager metadataManager;
private StorageContainerLocationInternalInterface containerClient;
private KeyManagerImpl keyManager;
private KeyManager keyManager;

private Instant startDate;
private ScmBlockLocationProtocol blockClient;
Expand All @@ -127,7 +127,7 @@ void setup(@TempDir Path testDir) throws Exception {
= new OmTestManagers(configuration, blockClient, containerClient);
om = omTestManagers.getOzoneManager();
metadataManager = omTestManagers.getMetadataManager();
keyManager = (KeyManagerImpl)omTestManagers.getKeyManager();
keyManager = omTestManagers.getKeyManager();
writeClient = omTestManagers.getWriteClient();
}

Expand Down