HDFS-12366. Ozone: Refactor KSM metadata class names to avoid confusion. Contributed by Weiwei Yang.
This commit is contained in:
parent
7b3e7eb565
commit
ca72c2342c
|
@ -39,15 +39,15 @@ public class BucketManagerImpl implements BucketManager {
|
||||||
LoggerFactory.getLogger(BucketManagerImpl.class);
|
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.
|
* Constructs BucketManager.
|
||||||
* @param metadataManager
|
* @param metadataManager
|
||||||
*/
|
*/
|
||||||
public BucketManagerImpl(MetadataManager metadataManager){
|
public BucketManagerImpl(KSMMetadataManager metadataManager){
|
||||||
this.metadataManager = metadataManager;
|
this.metadataManager = metadataManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -30,7 +30,7 @@ import java.util.concurrent.locks.Lock;
|
||||||
/**
|
/**
|
||||||
* KSM metadata manager interface.
|
* KSM metadata manager interface.
|
||||||
*/
|
*/
|
||||||
public interface MetadataManager {
|
public interface KSMMetadataManager {
|
||||||
/**
|
/**
|
||||||
* Start metadata manager.
|
* Start metadata manager.
|
||||||
*/
|
*/
|
|
@ -58,13 +58,13 @@ import static org.apache.hadoop.ozone.ksm.KSMConfigKeys
|
||||||
/**
|
/**
|
||||||
* KSM metadata manager interface.
|
* KSM metadata manager interface.
|
||||||
*/
|
*/
|
||||||
public class MetadataManagerImpl implements MetadataManager {
|
public class KSMMetadataManagerImpl implements KSMMetadataManager {
|
||||||
|
|
||||||
private final MetadataStore store;
|
private final MetadataStore store;
|
||||||
private final ReadWriteLock lock;
|
private final ReadWriteLock lock;
|
||||||
|
|
||||||
|
|
||||||
public MetadataManagerImpl(OzoneConfiguration conf) throws IOException {
|
public KSMMetadataManagerImpl(OzoneConfiguration conf) throws IOException {
|
||||||
File metaDir = OzoneUtils.getScmMetadirPath(conf);
|
File metaDir = OzoneUtils.getScmMetadirPath(conf);
|
||||||
final int cacheSize = conf.getInt(OZONE_KSM_DB_CACHE_SIZE_MB,
|
final int cacheSize = conf.getInt(OZONE_KSM_DB_CACHE_SIZE_MB,
|
||||||
OZONE_KSM_DB_CACHE_SIZE_DEFAULT);
|
OZONE_KSM_DB_CACHE_SIZE_DEFAULT);
|
|
@ -50,11 +50,11 @@ public class KeyManagerImpl implements KeyManager {
|
||||||
* A SCM block client, used to talk to SCM to allocate block during putKey.
|
* A SCM block client, used to talk to SCM to allocate block during putKey.
|
||||||
*/
|
*/
|
||||||
private final ScmBlockLocationProtocol scmBlockClient;
|
private final ScmBlockLocationProtocol scmBlockClient;
|
||||||
private final MetadataManager metadataManager;
|
private final KSMMetadataManager metadataManager;
|
||||||
private final long scmBlockSize;
|
private final long scmBlockSize;
|
||||||
|
|
||||||
public KeyManagerImpl(ScmBlockLocationProtocol scmBlockClient,
|
public KeyManagerImpl(ScmBlockLocationProtocol scmBlockClient,
|
||||||
MetadataManager metadataManager, OzoneConfiguration conf) {
|
KSMMetadataManager metadataManager, OzoneConfiguration conf) {
|
||||||
this.scmBlockClient = scmBlockClient;
|
this.scmBlockClient = scmBlockClient;
|
||||||
this.metadataManager = metadataManager;
|
this.metadataManager = metadataManager;
|
||||||
this.scmBlockSize = conf.getLong(OZONE_SCM_BLOCK_SIZE_KEY,
|
this.scmBlockSize = conf.getLong(OZONE_SCM_BLOCK_SIZE_KEY,
|
||||||
|
|
|
@ -78,7 +78,7 @@ public class KeySpaceManager extends ServiceRuntimeInfoImpl
|
||||||
|
|
||||||
private final RPC.Server ksmRpcServer;
|
private final RPC.Server ksmRpcServer;
|
||||||
private final InetSocketAddress ksmRpcAddress;
|
private final InetSocketAddress ksmRpcAddress;
|
||||||
private final MetadataManager metadataManager;
|
private final KSMMetadataManager metadataManager;
|
||||||
private final VolumeManager volumeManager;
|
private final VolumeManager volumeManager;
|
||||||
private final BucketManager bucketManager;
|
private final BucketManager bucketManager;
|
||||||
private final KeyManager keyManager;
|
private final KeyManager keyManager;
|
||||||
|
@ -102,7 +102,7 @@ public class KeySpaceManager extends ServiceRuntimeInfoImpl
|
||||||
handlerCount);
|
handlerCount);
|
||||||
ksmRpcAddress = OzoneClientUtils.updateRPCListenAddress(conf,
|
ksmRpcAddress = OzoneClientUtils.updateRPCListenAddress(conf,
|
||||||
OZONE_KSM_ADDRESS_KEY, ksmNodeRpcAddr, ksmRpcServer);
|
OZONE_KSM_ADDRESS_KEY, ksmNodeRpcAddr, ksmRpcServer);
|
||||||
metadataManager = new MetadataManagerImpl(conf);
|
metadataManager = new KSMMetadataManagerImpl(conf);
|
||||||
volumeManager = new VolumeManagerImpl(metadataManager, conf);
|
volumeManager = new VolumeManagerImpl(metadataManager, conf);
|
||||||
bucketManager = new BucketManagerImpl(metadataManager);
|
bucketManager = new BucketManagerImpl(metadataManager);
|
||||||
metrics = KSMMetrics.create();
|
metrics = KSMMetrics.create();
|
||||||
|
@ -168,7 +168,7 @@ public class KeySpaceManager extends ServiceRuntimeInfoImpl
|
||||||
* Get metadata manager.
|
* Get metadata manager.
|
||||||
* @return metadata manager.
|
* @return metadata manager.
|
||||||
*/
|
*/
|
||||||
public MetadataManager getMetadataManager() {
|
public KSMMetadataManager getMetadataManager() {
|
||||||
return metadataManager;
|
return metadataManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -46,7 +46,7 @@ public class VolumeManagerImpl implements VolumeManager {
|
||||||
private static final Logger LOG =
|
private static final Logger LOG =
|
||||||
LoggerFactory.getLogger(VolumeManagerImpl.class);
|
LoggerFactory.getLogger(VolumeManagerImpl.class);
|
||||||
|
|
||||||
private final MetadataManager metadataManager;
|
private final KSMMetadataManager metadataManager;
|
||||||
private final int maxUserVolumeCount;
|
private final int maxUserVolumeCount;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -54,7 +54,7 @@ public class VolumeManagerImpl implements VolumeManager {
|
||||||
* @param conf - Ozone configuration.
|
* @param conf - Ozone configuration.
|
||||||
* @throws IOException
|
* @throws IOException
|
||||||
*/
|
*/
|
||||||
public VolumeManagerImpl(MetadataManager metadataManager,
|
public VolumeManagerImpl(KSMMetadataManager metadataManager,
|
||||||
OzoneConfiguration conf) throws IOException {
|
OzoneConfiguration conf) throws IOException {
|
||||||
this.metadataManager = metadataManager;
|
this.metadataManager = metadataManager;
|
||||||
this.maxUserVolumeCount = conf.getInt(OZONE_KSM_USER_MAX_VOLUME,
|
this.maxUserVolumeCount = conf.getInt(OZONE_KSM_USER_MAX_VOLUME,
|
||||||
|
|
|
@ -47,16 +47,16 @@ import java.util.concurrent.locks.ReentrantReadWriteLock;
|
||||||
import static org.mockito.Mockito.any;
|
import static org.mockito.Mockito.any;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests BucketManagerImpl, mocks MetadataManager for testing.
|
* Tests BucketManagerImpl, mocks KSMMetadataManager for testing.
|
||||||
*/
|
*/
|
||||||
@RunWith(MockitoJUnitRunner.class)
|
@RunWith(MockitoJUnitRunner.class)
|
||||||
public class TestBucketManagerImpl {
|
public class TestBucketManagerImpl {
|
||||||
@Rule
|
@Rule
|
||||||
public ExpectedException thrown = ExpectedException.none();
|
public ExpectedException thrown = ExpectedException.none();
|
||||||
|
|
||||||
private MetadataManager getMetadataManagerMock(String... volumesToCreate)
|
private KSMMetadataManager getMetadataManagerMock(String... volumesToCreate)
|
||||||
throws IOException {
|
throws IOException {
|
||||||
MetadataManager metadataManager = Mockito.mock(MetadataManager.class);
|
KSMMetadataManager metadataManager = Mockito.mock(KSMMetadataManager.class);
|
||||||
Map<String, byte[]> metadataDB = new HashMap<>();
|
Map<String, byte[]> metadataDB = new HashMap<>();
|
||||||
ReadWriteLock lock = new ReentrantReadWriteLock();
|
ReadWriteLock lock = new ReentrantReadWriteLock();
|
||||||
|
|
||||||
|
@ -133,7 +133,7 @@ public class TestBucketManagerImpl {
|
||||||
@Test
|
@Test
|
||||||
public void testCreateBucketWithoutVolume() throws IOException {
|
public void testCreateBucketWithoutVolume() throws IOException {
|
||||||
thrown.expectMessage("Volume doesn't exist");
|
thrown.expectMessage("Volume doesn't exist");
|
||||||
MetadataManager metaMgr = getMetadataManagerMock();
|
KSMMetadataManager metaMgr = getMetadataManagerMock();
|
||||||
try {
|
try {
|
||||||
BucketManager bucketManager = new BucketManagerImpl(metaMgr);
|
BucketManager bucketManager = new BucketManagerImpl(metaMgr);
|
||||||
KsmBucketInfo bucketInfo = KsmBucketInfo.newBuilder()
|
KsmBucketInfo bucketInfo = KsmBucketInfo.newBuilder()
|
||||||
|
@ -150,7 +150,7 @@ public class TestBucketManagerImpl {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testCreateBucket() throws IOException {
|
public void testCreateBucket() throws IOException {
|
||||||
MetadataManager metaMgr = getMetadataManagerMock("sampleVol");
|
KSMMetadataManager metaMgr = getMetadataManagerMock("sampleVol");
|
||||||
BucketManager bucketManager = new BucketManagerImpl(metaMgr);
|
BucketManager bucketManager = new BucketManagerImpl(metaMgr);
|
||||||
KsmBucketInfo bucketInfo = KsmBucketInfo.newBuilder()
|
KsmBucketInfo bucketInfo = KsmBucketInfo.newBuilder()
|
||||||
.setVolumeName("sampleVol")
|
.setVolumeName("sampleVol")
|
||||||
|
@ -163,7 +163,7 @@ public class TestBucketManagerImpl {
|
||||||
@Test
|
@Test
|
||||||
public void testCreateAlreadyExistingBucket() throws IOException {
|
public void testCreateAlreadyExistingBucket() throws IOException {
|
||||||
thrown.expectMessage("Bucket already exist");
|
thrown.expectMessage("Bucket already exist");
|
||||||
MetadataManager metaMgr = getMetadataManagerMock("sampleVol");
|
KSMMetadataManager metaMgr = getMetadataManagerMock("sampleVol");
|
||||||
try {
|
try {
|
||||||
BucketManager bucketManager = new BucketManagerImpl(metaMgr);
|
BucketManager bucketManager = new BucketManagerImpl(metaMgr);
|
||||||
KsmBucketInfo bucketInfo = KsmBucketInfo.newBuilder()
|
KsmBucketInfo bucketInfo = KsmBucketInfo.newBuilder()
|
||||||
|
@ -183,7 +183,7 @@ public class TestBucketManagerImpl {
|
||||||
public void testGetBucketInfoForInvalidBucket() throws IOException {
|
public void testGetBucketInfoForInvalidBucket() throws IOException {
|
||||||
thrown.expectMessage("Bucket not found");
|
thrown.expectMessage("Bucket not found");
|
||||||
try {
|
try {
|
||||||
MetadataManager metaMgr = getMetadataManagerMock("sampleVol");
|
KSMMetadataManager metaMgr = getMetadataManagerMock("sampleVol");
|
||||||
BucketManager bucketManager = new BucketManagerImpl(metaMgr);
|
BucketManager bucketManager = new BucketManagerImpl(metaMgr);
|
||||||
bucketManager.getBucketInfo("sampleVol", "bucketOne");
|
bucketManager.getBucketInfo("sampleVol", "bucketOne");
|
||||||
} catch(KSMException ksmEx) {
|
} catch(KSMException ksmEx) {
|
||||||
|
@ -195,7 +195,7 @@ public class TestBucketManagerImpl {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testGetBucketInfo() throws IOException {
|
public void testGetBucketInfo() throws IOException {
|
||||||
MetadataManager metaMgr = getMetadataManagerMock("sampleVol");
|
KSMMetadataManager metaMgr = getMetadataManagerMock("sampleVol");
|
||||||
BucketManager bucketManager = new BucketManagerImpl(metaMgr);
|
BucketManager bucketManager = new BucketManagerImpl(metaMgr);
|
||||||
KsmBucketInfo bucketInfo = KsmBucketInfo.newBuilder()
|
KsmBucketInfo bucketInfo = KsmBucketInfo.newBuilder()
|
||||||
.setVolumeName("sampleVol")
|
.setVolumeName("sampleVol")
|
||||||
|
@ -215,7 +215,7 @@ public class TestBucketManagerImpl {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSetBucketPropertyAddACL() throws IOException {
|
public void testSetBucketPropertyAddACL() throws IOException {
|
||||||
MetadataManager metaMgr = getMetadataManagerMock("sampleVol");
|
KSMMetadataManager metaMgr = getMetadataManagerMock("sampleVol");
|
||||||
List<OzoneAcl> acls = new LinkedList<>();
|
List<OzoneAcl> acls = new LinkedList<>();
|
||||||
OzoneAcl ozoneAcl = new OzoneAcl(OzoneAcl.OzoneACLType.USER,
|
OzoneAcl ozoneAcl = new OzoneAcl(OzoneAcl.OzoneACLType.USER,
|
||||||
"root", OzoneAcl.OzoneACLRights.READ);
|
"root", OzoneAcl.OzoneACLRights.READ);
|
||||||
|
@ -252,7 +252,7 @@ public class TestBucketManagerImpl {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSetBucketPropertyRemoveACL() throws IOException {
|
public void testSetBucketPropertyRemoveACL() throws IOException {
|
||||||
MetadataManager metaMgr = getMetadataManagerMock("sampleVol");
|
KSMMetadataManager metaMgr = getMetadataManagerMock("sampleVol");
|
||||||
List<OzoneAcl> acls = new LinkedList<>();
|
List<OzoneAcl> acls = new LinkedList<>();
|
||||||
OzoneAcl aclOne = new OzoneAcl(OzoneAcl.OzoneACLType.USER,
|
OzoneAcl aclOne = new OzoneAcl(OzoneAcl.OzoneACLType.USER,
|
||||||
"root", OzoneAcl.OzoneACLRights.READ);
|
"root", OzoneAcl.OzoneACLRights.READ);
|
||||||
|
@ -288,7 +288,7 @@ public class TestBucketManagerImpl {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSetBucketPropertyChangeStorageType() throws IOException {
|
public void testSetBucketPropertyChangeStorageType() throws IOException {
|
||||||
MetadataManager metaMgr = getMetadataManagerMock("sampleVol");
|
KSMMetadataManager metaMgr = getMetadataManagerMock("sampleVol");
|
||||||
BucketManager bucketManager = new BucketManagerImpl(metaMgr);
|
BucketManager bucketManager = new BucketManagerImpl(metaMgr);
|
||||||
KsmBucketInfo bucketInfo = KsmBucketInfo.newBuilder()
|
KsmBucketInfo bucketInfo = KsmBucketInfo.newBuilder()
|
||||||
.setVolumeName("sampleVol")
|
.setVolumeName("sampleVol")
|
||||||
|
@ -314,7 +314,7 @@ public class TestBucketManagerImpl {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSetBucketPropertyChangeVersioning() throws IOException {
|
public void testSetBucketPropertyChangeVersioning() throws IOException {
|
||||||
MetadataManager metaMgr = getMetadataManagerMock("sampleVol");
|
KSMMetadataManager metaMgr = getMetadataManagerMock("sampleVol");
|
||||||
BucketManager bucketManager = new BucketManagerImpl(metaMgr);
|
BucketManager bucketManager = new BucketManagerImpl(metaMgr);
|
||||||
KsmBucketInfo bucketInfo = KsmBucketInfo.newBuilder()
|
KsmBucketInfo bucketInfo = KsmBucketInfo.newBuilder()
|
||||||
.setVolumeName("sampleVol")
|
.setVolumeName("sampleVol")
|
||||||
|
@ -339,7 +339,7 @@ public class TestBucketManagerImpl {
|
||||||
@Test
|
@Test
|
||||||
public void testDeleteBucket() throws IOException {
|
public void testDeleteBucket() throws IOException {
|
||||||
thrown.expectMessage("Bucket not found");
|
thrown.expectMessage("Bucket not found");
|
||||||
MetadataManager metaMgr = getMetadataManagerMock("sampleVol");
|
KSMMetadataManager metaMgr = getMetadataManagerMock("sampleVol");
|
||||||
BucketManager bucketManager = new BucketManagerImpl(metaMgr);
|
BucketManager bucketManager = new BucketManagerImpl(metaMgr);
|
||||||
for(int i = 0; i < 5; i++) {
|
for(int i = 0; i < 5; i++) {
|
||||||
KsmBucketInfo bucketInfo = KsmBucketInfo.newBuilder()
|
KsmBucketInfo bucketInfo = KsmBucketInfo.newBuilder()
|
||||||
|
@ -372,7 +372,7 @@ public class TestBucketManagerImpl {
|
||||||
@Test
|
@Test
|
||||||
public void testDeleteNonEmptyBucket() throws IOException {
|
public void testDeleteNonEmptyBucket() throws IOException {
|
||||||
thrown.expectMessage("Bucket is not empty");
|
thrown.expectMessage("Bucket is not empty");
|
||||||
MetadataManager metaMgr = getMetadataManagerMock("sampleVol");
|
KSMMetadataManager metaMgr = getMetadataManagerMock("sampleVol");
|
||||||
BucketManager bucketManager = new BucketManagerImpl(metaMgr);
|
BucketManager bucketManager = new BucketManagerImpl(metaMgr);
|
||||||
KsmBucketInfo bucketInfo = KsmBucketInfo.newBuilder()
|
KsmBucketInfo bucketInfo = KsmBucketInfo.newBuilder()
|
||||||
.setVolumeName("sampleVol")
|
.setVolumeName("sampleVol")
|
||||||
|
|
Loading…
Reference in New Issue