use of com.github.ambry.clustermap.MockReplicaId in project ambry by linkedin.
the class AmbryServerRequestsTest method changePartitionState.
/**
* Changes the write state of the partition
* @param id the {@link MockPartitionId} whose status needs to change
* @param seal if {@code true}, partition will become
* {@link com.github.ambry.clustermap.PartitionState#READ_ONLY}. Otherwise
* {@link com.github.ambry.clustermap.PartitionState#READ_WRITE}
*/
private void changePartitionState(PartitionId id, boolean seal) {
MockReplicaId replicaId = (MockReplicaId) findReplica(id);
replicaId.setSealedState(seal);
((MockPartitionId) id).resolvePartitionStatus();
}
use of com.github.ambry.clustermap.MockReplicaId in project ambry by linkedin.
the class UndeleteOperationTrackerTest method populateReplicaList.
/**
* Populate replicas for a partition.
* @param replicaCount The number of replicas to populate.
* @param replicaState The {@link ReplicaState} associated with these replicas.
*/
private void populateReplicaList(int replicaCount, ReplicaState replicaState) {
for (int i = 0; i < replicaCount; i++) {
ReplicaId replicaId = new MockReplicaId(PORT, mockPartition, datanodes.get(i % datanodes.size()), 0);
mockPartition.replicaIds.add(replicaId);
mockPartition.replicaAndState.put(replicaId, replicaState);
}
}
use of com.github.ambry.clustermap.MockReplicaId in project ambry by linkedin.
the class BlobStoreCompactorTest method generateLocalAndPeerReplicas.
// helpers
// general
/**
* Generate local replica and two peer replicas.
* @return a list of replicas (first one is local replica, others are remote peer replicas)
*/
private List<MockReplicaId> generateLocalAndPeerReplicas() {
Port port = new Port(6667, PortType.PLAINTEXT);
List<String> mountPaths = Arrays.asList("/mnt/u001", "/mnt/u002", "/mnt/u003");
// generate two peer replicas
MockDataNodeId peerNode1 = new MockDataNodeId("node1_host", Collections.singletonList(port), mountPaths, null);
MockDataNodeId peerNode2 = new MockDataNodeId("node2_host", Collections.singletonList(port), mountPaths, null);
MockDataNodeId localNode = new MockDataNodeId("local_host", Collections.singletonList(port), mountPaths, null);
MockPartitionId mockPartitionId = new MockPartitionId(101L, MockClusterMap.DEFAULT_PARTITION_CLASS);
MockReplicaId peerReplica1 = new MockReplicaId(port.getPort(), mockPartitionId, peerNode1, 0);
MockReplicaId peerReplica2 = new MockReplicaId(port.getPort(), mockPartitionId, peerNode2, 1);
MockReplicaId localReplica = new MockReplicaId(port.getPort(), mockPartitionId, localNode, 2);
localReplica.setPeerReplicas(Arrays.asList(peerReplica1, peerReplica2));
return Arrays.asList(localReplica, peerReplica1, peerReplica2);
}
use of com.github.ambry.clustermap.MockReplicaId in project ambry by linkedin.
the class CloudStorageManagerTest method shutdownBlobStoreTest.
/**
* Test {@code CloudStorageManager#shutdownBlobStore}
* @throws IOException
*/
@Test
public void shutdownBlobStoreTest() throws IOException {
CloudStorageManager cloudStorageManager = createNewCloudStorageManager();
ReplicaId mockReplicaId = clusterMap.getReplicaIds(clusterMap.getDataNodeIds().get(0)).get(0);
PartitionId partitionId = mockReplicaId.getPartitionId();
// try shutdown for a store of partition that was never added
Assert.assertFalse(cloudStorageManager.shutdownBlobStore(partitionId));
// add and start a replica to the store
Assert.assertTrue(cloudStorageManager.addBlobStore(mockReplicaId));
// try shutdown for a store of partition that was added
Assert.assertTrue(cloudStorageManager.shutdownBlobStore(partitionId));
// try shutdown for a removed partition
Assert.assertTrue(cloudStorageManager.removeBlobStore(partitionId));
Assert.assertFalse(cloudStorageManager.shutdownBlobStore(partitionId));
}
use of com.github.ambry.clustermap.MockReplicaId in project ambry by linkedin.
the class CloudStorageManagerTest method checkLocalPartitionStatusTest.
/**
* Test {@code CloudStorageManager#checkLocalPartitionStatus}
* @throws IOException
*/
@Test
public void checkLocalPartitionStatusTest() throws IOException {
CloudStorageManager cloudStorageManager = createNewCloudStorageManager();
ReplicaId mockReplicaId = clusterMap.getReplicaIds(clusterMap.getDataNodeIds().get(0)).get(0);
PartitionId partitionId = mockReplicaId.getPartitionId();
// try checkLocalPartitionStatus for a partition that doesn't exist
Assert.assertEquals(cloudStorageManager.checkLocalPartitionStatus(partitionId, new MockReplicaId(ReplicaType.DISK_BACKED)), ServerErrorCode.No_Error);
// add and start a replica to the store
Assert.assertTrue(cloudStorageManager.addBlobStore(mockReplicaId));
// try checkLocalPartitionStatus for an added replica
Assert.assertEquals(cloudStorageManager.checkLocalPartitionStatus(partitionId, new MockReplicaId(ReplicaType.DISK_BACKED)), ServerErrorCode.No_Error);
// stop a replica on the store
Assert.assertTrue("Failed in stopping replica", cloudStorageManager.shutdownBlobStore(partitionId));
// try checkLocalPartitionStatus for a stopped replica (stopped blob store)
Assert.assertEquals(cloudStorageManager.checkLocalPartitionStatus(partitionId, mockReplicaId), ServerErrorCode.No_Error);
// try checkLocalPartitionStatus for a removed replica
Assert.assertTrue(cloudStorageManager.removeBlobStore(partitionId));
Assert.assertEquals(cloudStorageManager.checkLocalPartitionStatus(partitionId, new MockReplicaId(ReplicaType.DISK_BACKED)), ServerErrorCode.No_Error);
}
Aggregations