From ca72c2342c1182a913f6361bb2f499ec694f5915 Mon Sep 17 00:00:00 2001 From: Anu Engineer Date: Tue, 29 Aug 2017 13:57:51 -0700 Subject: [PATCH] HDFS-12366. Ozone: Refactor KSM metadata class names to avoid confusion. Contributed by Weiwei Yang. --- .../hadoop/ozone/ksm/BucketManagerImpl.java | 6 ++-- ...taManager.java => KSMMetadataManager.java} | 2 +- ...rImpl.java => KSMMetadataManagerImpl.java} | 4 +-- .../hadoop/ozone/ksm/KeyManagerImpl.java | 4 +-- .../hadoop/ozone/ksm/KeySpaceManager.java | 6 ++-- .../hadoop/ozone/ksm/VolumeManagerImpl.java | 4 +-- .../ozone/ksm/TestBucketManagerImpl.java | 28 +++++++++---------- 7 files changed, 27 insertions(+), 27 deletions(-) rename hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/ozone/ksm/{MetadataManager.java => KSMMetadataManager.java} (99%) rename hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/ozone/ksm/{MetadataManagerImpl.java => KSMMetadataManagerImpl.java} (99%) diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/ozone/ksm/BucketManagerImpl.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/ozone/ksm/BucketManagerImpl.java index 95f76dd2879..d0e81495493 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/ozone/ksm/BucketManagerImpl.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/ozone/ksm/BucketManagerImpl.java @@ -39,15 +39,15 @@ public class BucketManagerImpl implements BucketManager { LoggerFactory.getLogger(BucketManagerImpl.class); /** - * MetadataManager is used for accessing KSM MetadataDB and ReadWriteLock. + * KSMMetadataManager is used for accessing KSM MetadataDB and ReadWriteLock. */ - private final MetadataManager metadataManager; + private final KSMMetadataManager metadataManager; /** * Constructs BucketManager. * @param metadataManager */ - public BucketManagerImpl(MetadataManager metadataManager){ + public BucketManagerImpl(KSMMetadataManager metadataManager){ this.metadataManager = metadataManager; } diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/ozone/ksm/MetadataManager.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/ozone/ksm/KSMMetadataManager.java similarity index 99% rename from hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/ozone/ksm/MetadataManager.java rename to hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/ozone/ksm/KSMMetadataManager.java index a08898f39cc..fe93718292b 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/ozone/ksm/MetadataManager.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/ozone/ksm/KSMMetadataManager.java @@ -30,7 +30,7 @@ import java.util.concurrent.locks.Lock; /** * KSM metadata manager interface. */ -public interface MetadataManager { +public interface KSMMetadataManager { /** * Start metadata manager. */ diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/ozone/ksm/MetadataManagerImpl.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/ozone/ksm/KSMMetadataManagerImpl.java similarity index 99% rename from hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/ozone/ksm/MetadataManagerImpl.java rename to hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/ozone/ksm/KSMMetadataManagerImpl.java index 6be4675fcb4..b954685efa3 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/ozone/ksm/MetadataManagerImpl.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/ozone/ksm/KSMMetadataManagerImpl.java @@ -58,13 +58,13 @@ import static org.apache.hadoop.ozone.ksm.KSMConfigKeys /** * KSM metadata manager interface. */ -public class MetadataManagerImpl implements MetadataManager { +public class KSMMetadataManagerImpl implements KSMMetadataManager { private final MetadataStore store; private final ReadWriteLock lock; - public MetadataManagerImpl(OzoneConfiguration conf) throws IOException { + public KSMMetadataManagerImpl(OzoneConfiguration conf) throws IOException { File metaDir = OzoneUtils.getScmMetadirPath(conf); final int cacheSize = conf.getInt(OZONE_KSM_DB_CACHE_SIZE_MB, OZONE_KSM_DB_CACHE_SIZE_DEFAULT); diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/ozone/ksm/KeyManagerImpl.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/ozone/ksm/KeyManagerImpl.java index f259d85eb4f..aea7b3199e8 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/ozone/ksm/KeyManagerImpl.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/ozone/ksm/KeyManagerImpl.java @@ -50,11 +50,11 @@ public class KeyManagerImpl implements KeyManager { * A SCM block client, used to talk to SCM to allocate block during putKey. */ private final ScmBlockLocationProtocol scmBlockClient; - private final MetadataManager metadataManager; + private final KSMMetadataManager metadataManager; private final long scmBlockSize; public KeyManagerImpl(ScmBlockLocationProtocol scmBlockClient, - MetadataManager metadataManager, OzoneConfiguration conf) { + KSMMetadataManager metadataManager, OzoneConfiguration conf) { this.scmBlockClient = scmBlockClient; this.metadataManager = metadataManager; this.scmBlockSize = conf.getLong(OZONE_SCM_BLOCK_SIZE_KEY, diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/ozone/ksm/KeySpaceManager.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/ozone/ksm/KeySpaceManager.java index 96493fd9692..3b76e5cea83 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/ozone/ksm/KeySpaceManager.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/ozone/ksm/KeySpaceManager.java @@ -78,7 +78,7 @@ public class KeySpaceManager extends ServiceRuntimeInfoImpl private final RPC.Server ksmRpcServer; private final InetSocketAddress ksmRpcAddress; - private final MetadataManager metadataManager; + private final KSMMetadataManager metadataManager; private final VolumeManager volumeManager; private final BucketManager bucketManager; private final KeyManager keyManager; @@ -102,7 +102,7 @@ public class KeySpaceManager extends ServiceRuntimeInfoImpl handlerCount); ksmRpcAddress = OzoneClientUtils.updateRPCListenAddress(conf, OZONE_KSM_ADDRESS_KEY, ksmNodeRpcAddr, ksmRpcServer); - metadataManager = new MetadataManagerImpl(conf); + metadataManager = new KSMMetadataManagerImpl(conf); volumeManager = new VolumeManagerImpl(metadataManager, conf); bucketManager = new BucketManagerImpl(metadataManager); metrics = KSMMetrics.create(); @@ -168,7 +168,7 @@ public class KeySpaceManager extends ServiceRuntimeInfoImpl * Get metadata manager. * @return metadata manager. */ - public MetadataManager getMetadataManager() { + public KSMMetadataManager getMetadataManager() { return metadataManager; } diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/ozone/ksm/VolumeManagerImpl.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/ozone/ksm/VolumeManagerImpl.java index 1dab4aa75fd..8ab5d6890f6 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/ozone/ksm/VolumeManagerImpl.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/ozone/ksm/VolumeManagerImpl.java @@ -46,7 +46,7 @@ public class VolumeManagerImpl implements VolumeManager { private static final Logger LOG = LoggerFactory.getLogger(VolumeManagerImpl.class); - private final MetadataManager metadataManager; + private final KSMMetadataManager metadataManager; private final int maxUserVolumeCount; /** @@ -54,7 +54,7 @@ public class VolumeManagerImpl implements VolumeManager { * @param conf - Ozone configuration. * @throws IOException */ - public VolumeManagerImpl(MetadataManager metadataManager, + public VolumeManagerImpl(KSMMetadataManager metadataManager, OzoneConfiguration conf) throws IOException { this.metadataManager = metadataManager; this.maxUserVolumeCount = conf.getInt(OZONE_KSM_USER_MAX_VOLUME, diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/ozone/ksm/TestBucketManagerImpl.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/ozone/ksm/TestBucketManagerImpl.java index 852c1ffa155..b1a1606e08f 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/ozone/ksm/TestBucketManagerImpl.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/ozone/ksm/TestBucketManagerImpl.java @@ -47,16 +47,16 @@ import java.util.concurrent.locks.ReentrantReadWriteLock; import static org.mockito.Mockito.any; /** - * Tests BucketManagerImpl, mocks MetadataManager for testing. + * Tests BucketManagerImpl, mocks KSMMetadataManager for testing. */ @RunWith(MockitoJUnitRunner.class) public class TestBucketManagerImpl { @Rule public ExpectedException thrown = ExpectedException.none(); - private MetadataManager getMetadataManagerMock(String... volumesToCreate) + private KSMMetadataManager getMetadataManagerMock(String... volumesToCreate) throws IOException { - MetadataManager metadataManager = Mockito.mock(MetadataManager.class); + KSMMetadataManager metadataManager = Mockito.mock(KSMMetadataManager.class); Map metadataDB = new HashMap<>(); ReadWriteLock lock = new ReentrantReadWriteLock(); @@ -133,7 +133,7 @@ public class TestBucketManagerImpl { @Test public void testCreateBucketWithoutVolume() throws IOException { thrown.expectMessage("Volume doesn't exist"); - MetadataManager metaMgr = getMetadataManagerMock(); + KSMMetadataManager metaMgr = getMetadataManagerMock(); try { BucketManager bucketManager = new BucketManagerImpl(metaMgr); KsmBucketInfo bucketInfo = KsmBucketInfo.newBuilder() @@ -150,7 +150,7 @@ public class TestBucketManagerImpl { @Test public void testCreateBucket() throws IOException { - MetadataManager metaMgr = getMetadataManagerMock("sampleVol"); + KSMMetadataManager metaMgr = getMetadataManagerMock("sampleVol"); BucketManager bucketManager = new BucketManagerImpl(metaMgr); KsmBucketInfo bucketInfo = KsmBucketInfo.newBuilder() .setVolumeName("sampleVol") @@ -163,7 +163,7 @@ public class TestBucketManagerImpl { @Test public void testCreateAlreadyExistingBucket() throws IOException { thrown.expectMessage("Bucket already exist"); - MetadataManager metaMgr = getMetadataManagerMock("sampleVol"); + KSMMetadataManager metaMgr = getMetadataManagerMock("sampleVol"); try { BucketManager bucketManager = new BucketManagerImpl(metaMgr); KsmBucketInfo bucketInfo = KsmBucketInfo.newBuilder() @@ -183,7 +183,7 @@ public class TestBucketManagerImpl { public void testGetBucketInfoForInvalidBucket() throws IOException { thrown.expectMessage("Bucket not found"); try { - MetadataManager metaMgr = getMetadataManagerMock("sampleVol"); + KSMMetadataManager metaMgr = getMetadataManagerMock("sampleVol"); BucketManager bucketManager = new BucketManagerImpl(metaMgr); bucketManager.getBucketInfo("sampleVol", "bucketOne"); } catch(KSMException ksmEx) { @@ -195,7 +195,7 @@ public class TestBucketManagerImpl { @Test public void testGetBucketInfo() throws IOException { - MetadataManager metaMgr = getMetadataManagerMock("sampleVol"); + KSMMetadataManager metaMgr = getMetadataManagerMock("sampleVol"); BucketManager bucketManager = new BucketManagerImpl(metaMgr); KsmBucketInfo bucketInfo = KsmBucketInfo.newBuilder() .setVolumeName("sampleVol") @@ -215,7 +215,7 @@ public class TestBucketManagerImpl { @Test public void testSetBucketPropertyAddACL() throws IOException { - MetadataManager metaMgr = getMetadataManagerMock("sampleVol"); + KSMMetadataManager metaMgr = getMetadataManagerMock("sampleVol"); List acls = new LinkedList<>(); OzoneAcl ozoneAcl = new OzoneAcl(OzoneAcl.OzoneACLType.USER, "root", OzoneAcl.OzoneACLRights.READ); @@ -252,7 +252,7 @@ public class TestBucketManagerImpl { @Test public void testSetBucketPropertyRemoveACL() throws IOException { - MetadataManager metaMgr = getMetadataManagerMock("sampleVol"); + KSMMetadataManager metaMgr = getMetadataManagerMock("sampleVol"); List acls = new LinkedList<>(); OzoneAcl aclOne = new OzoneAcl(OzoneAcl.OzoneACLType.USER, "root", OzoneAcl.OzoneACLRights.READ); @@ -288,7 +288,7 @@ public class TestBucketManagerImpl { @Test public void testSetBucketPropertyChangeStorageType() throws IOException { - MetadataManager metaMgr = getMetadataManagerMock("sampleVol"); + KSMMetadataManager metaMgr = getMetadataManagerMock("sampleVol"); BucketManager bucketManager = new BucketManagerImpl(metaMgr); KsmBucketInfo bucketInfo = KsmBucketInfo.newBuilder() .setVolumeName("sampleVol") @@ -314,7 +314,7 @@ public class TestBucketManagerImpl { @Test public void testSetBucketPropertyChangeVersioning() throws IOException { - MetadataManager metaMgr = getMetadataManagerMock("sampleVol"); + KSMMetadataManager metaMgr = getMetadataManagerMock("sampleVol"); BucketManager bucketManager = new BucketManagerImpl(metaMgr); KsmBucketInfo bucketInfo = KsmBucketInfo.newBuilder() .setVolumeName("sampleVol") @@ -339,7 +339,7 @@ public class TestBucketManagerImpl { @Test public void testDeleteBucket() throws IOException { thrown.expectMessage("Bucket not found"); - MetadataManager metaMgr = getMetadataManagerMock("sampleVol"); + KSMMetadataManager metaMgr = getMetadataManagerMock("sampleVol"); BucketManager bucketManager = new BucketManagerImpl(metaMgr); for(int i = 0; i < 5; i++) { KsmBucketInfo bucketInfo = KsmBucketInfo.newBuilder() @@ -372,7 +372,7 @@ public class TestBucketManagerImpl { @Test public void testDeleteNonEmptyBucket() throws IOException { thrown.expectMessage("Bucket is not empty"); - MetadataManager metaMgr = getMetadataManagerMock("sampleVol"); + KSMMetadataManager metaMgr = getMetadataManagerMock("sampleVol"); BucketManager bucketManager = new BucketManagerImpl(metaMgr); KsmBucketInfo bucketInfo = KsmBucketInfo.newBuilder() .setVolumeName("sampleVol")