use of com.github.ambry.cloud.VcrMetrics in project ambry by linkedin.
the class AzureCloudDestinationTest method setup.
@Before
public void setup() throws Exception {
long partition = 666;
PartitionId partitionId = new MockPartitionId(partition, MockClusterMap.DEFAULT_PARTITION_CLASS);
blobId = new BlobId(BLOB_ID_V6, BlobIdType.NATIVE, dataCenterId, accountId, containerId, partitionId, false, BlobDataType.DATACHUNK);
CloudBlobMetadata blobMetadata = new CloudBlobMetadata(blobId, 0, Utils.Infinite_Time, blobSize, CloudBlobMetadata.EncryptionOrigin.NONE);
mockServiceClient = mock(BlobServiceClient.class);
mockBlobBatchClient = mock(BlobBatchClient.class);
mockBlockBlobClient = AzureBlobDataAccessorTest.setupMockBlobClient(mockServiceClient);
mockBlobExistence(false);
mockumentClient = mock(AsyncDocumentClient.class);
Observable<ResourceResponse<Document>> mockResponse = getMockedObservableForSingleResource(blobMetadata);
when(mockumentClient.readDocument(anyString(), any(RequestOptions.class))).thenReturn(mockResponse);
when(mockumentClient.upsertDocument(anyString(), any(Object.class), any(RequestOptions.class), anyBoolean())).thenReturn(mockResponse);
when(mockumentClient.replaceDocument(any(Document.class), any(RequestOptions.class))).thenReturn(mockResponse);
when(mockumentClient.deleteDocument(anyString(), any(RequestOptions.class))).thenReturn(mockResponse);
configProps.setProperty(AzureCloudConfig.AZURE_STORAGE_CONNECTION_STRING, storageConnection);
configProps.setProperty(AzureCloudConfig.COSMOS_ENDPOINT, "http://ambry.beyond-the-cosmos.com:443");
configProps.setProperty(AzureCloudConfig.COSMOS_COLLECTION_LINK, "ambry/metadata");
configProps.setProperty(AzureCloudConfig.COSMOS_DELETED_CONTAINER_COLLECTION_LINK, "ambry/deletedContainer");
configProps.setProperty(AzureCloudConfig.COSMOS_KEY, "cosmos-key");
configProps.setProperty("clustermap.cluster.name", "main");
configProps.setProperty("clustermap.datacenter.name", "uswest");
configProps.setProperty("clustermap.host.name", "localhost");
configProps.setProperty(AzureCloudConfig.AZURE_STORAGE_AUTHORITY, "https://login.microsoftonline.com/test-account/");
configProps.setProperty(AzureCloudConfig.AZURE_STORAGE_CLIENTID, "client-id");
configProps.setProperty(AzureCloudConfig.AZURE_STORAGE_SECRET, "client-secret");
configProps.setProperty(AzureCloudConfig.AZURE_STORAGE_ENDPOINT, "https://azure_storage.blob.core.windows.net");
configProps.setProperty(AzureCloudConfig.AZURE_STORAGE_CLIENT_CLASS, "com.github.ambry.cloud.azure.ConnectionStringBasedStorageClient");
vcrMetrics = new VcrMetrics(new MetricRegistry());
azureMetrics = new AzureMetrics(new MetricRegistry());
clusterMap = mock(ClusterMap.class);
azureDest = new AzureCloudDestination(mockServiceClient, mockBlobBatchClient, mockumentClient, "foo", "bar", clusterName, azureMetrics, defaultAzureReplicationFeedType, clusterMap, false, configProps);
}
use of com.github.ambry.cloud.VcrMetrics in project ambry by linkedin.
the class AzureIntegrationTest method setup.
@Before
public void setup() {
testProperties = new Properties();
try (InputStream input = this.getClass().getClassLoader().getResourceAsStream(propFileName)) {
if (input == null) {
throw new IllegalStateException("Could not find resource: " + propFileName);
}
testProperties.load(input);
} catch (IOException ex) {
throw new IllegalStateException("Could not load properties from resource: " + propFileName);
}
testProperties.setProperty("clustermap.cluster.name", "Integration-Test");
testProperties.setProperty("clustermap.datacenter.name", "uswest");
testProperties.setProperty("clustermap.host.name", "localhost");
testProperties.setProperty(CloudConfig.CLOUD_DELETED_BLOB_RETENTION_DAYS, String.valueOf(retentionPeriodDays));
testProperties.setProperty(CloudConfig.CLOUD_COMPACTION_LOOKBACK_DAYS, "7");
testProperties.setProperty(AzureCloudConfig.AZURE_PURGE_BATCH_SIZE, "10");
testProperties.setProperty(AzureCloudConfig.AZURE_STORAGE_CLIENT_CLASS, azureStorageClientClass);
verifiableProperties = new VerifiableProperties(testProperties);
clusterMap = Mockito.mock(ClusterMap.class);
azureDest = getAzureDestination(verifiableProperties);
cloudRequestAgent = new CloudRequestAgent(new CloudConfig(verifiableProperties), new VcrMetrics(new MetricRegistry()));
}
use of com.github.ambry.cloud.VcrMetrics in project ambry by linkedin.
the class AzureStorageCompactorTest method buildCompactor.
private void buildCompactor(Properties configProps) throws Exception {
CloudConfig cloudConfig = new CloudConfig(new VerifiableProperties(configProps));
VcrMetrics vcrMetrics = new VcrMetrics(new MetricRegistry());
azureBlobDataAccessor = new AzureBlobDataAccessor(mockServiceClient, mockBlobBatchClient, clusterName, azureMetrics, new AzureCloudConfig(new VerifiableProperties(configProps)));
cosmosDataAccessor = new CosmosDataAccessor(mockumentClient, collectionLink, cosmosDeletedContainerCollectionLink, vcrMetrics, azureMetrics);
azureStorageCompactor = new AzureStorageCompactor(azureBlobDataAccessor, cosmosDataAccessor, cloudConfig, vcrMetrics, azureMetrics);
// Mocks for getDeadBlobs query
List<Document> docList = new ArrayList<>();
for (int j = 0; j < numBlobsPerQuery; j++) {
BlobId blobId = generateBlobId();
CloudBlobMetadata inputMetadata = new CloudBlobMetadata(blobId, testTime, Utils.Infinite_Time, blobSize, CloudBlobMetadata.EncryptionOrigin.NONE);
blobMetadataList.add(inputMetadata);
docList.add(AzureTestUtils.createDocumentFromCloudBlobMetadata(inputMetadata));
}
Observable<FeedResponse<Document>> mockResponse = mock(Observable.class);
mockObservableForQuery(docList, mockResponse);
when(mockumentClient.queryDocuments(anyString(), any(SqlQuerySpec.class), any(FeedOptions.class))).thenReturn(mockResponse);
// Mocks for purge
BlobBatch mockBatch = mock(BlobBatch.class);
when(mockBlobBatchClient.getBlobBatch()).thenReturn(mockBatch);
Response<Void> okResponse = mock(Response.class);
when(okResponse.getStatusCode()).thenReturn(202);
when(mockBatch.deleteBlob(anyString(), anyString())).thenReturn(okResponse);
Observable<StoredProcedureResponse> mockBulkDeleteResponse = getMockBulkDeleteResponse(1);
when(mockumentClient.executeStoredProcedure(anyString(), any(RequestOptions.class), any())).thenReturn(mockBulkDeleteResponse);
String checkpointJson = objectMapper.writeValueAsString(AzureStorageCompactor.emptyCheckpoints);
mockCheckpointDownload(true, checkpointJson);
}
use of com.github.ambry.cloud.VcrMetrics in project ambry by linkedin.
the class CosmosDataAccessorTest method setup.
@Before
public void setup() {
mockumentClient = mock(AsyncDocumentClient.class);
byte dataCenterId = 66;
short accountId = 101;
short containerId = 5;
PartitionId partitionId = new MockPartitionId();
blobId = new BlobId(BLOB_ID_V6, BlobIdType.NATIVE, dataCenterId, accountId, containerId, partitionId, false, BlobDataType.DATACHUNK);
blobMetadata = new CloudBlobMetadata(blobId, System.currentTimeMillis(), Utils.Infinite_Time, blobSize, CloudBlobMetadata.EncryptionOrigin.NONE);
azureMetrics = new AzureMetrics(new MetricRegistry());
VcrMetrics vcrMetrics = new VcrMetrics(new MetricRegistry());
cosmosAccessor = new CosmosDataAccessor(mockumentClient, "ambry/metadata", "ambry/deletedContainer", vcrMetrics, azureMetrics);
}
use of com.github.ambry.cloud.VcrMetrics in project ambry by linkedin.
the class CloudRouterFactory method getRequestHandlerPool.
/**
* Utility method to build a {@link RequestHandlerPool}.
* @param verifiableProperties the properties to use.
* @param clusterMap the {@link ClusterMap} to use.
* @return the constructed {@link RequestHandlerPool}.
* @throws Exception if the construction fails.
*/
public RequestHandlerPool getRequestHandlerPool(VerifiableProperties verifiableProperties, ClusterMap clusterMap, CloudDestination cloudDestination, CloudConfig cloudConfig) throws Exception {
ClusterMapConfig clusterMapConfig = new ClusterMapConfig(verifiableProperties);
MetricRegistry registry = clusterMap.getMetricRegistry();
DataNodeId nodeId = new CloudDataNode(cloudConfig, clusterMapConfig);
VcrMetrics vcrMetrics = new VcrMetrics(registry);
StoreManager cloudStorageManager = new CloudStorageManager(verifiableProperties, vcrMetrics, cloudDestination, clusterMap);
LocalRequestResponseChannel channel = new LocalRequestResponseChannel();
ServerMetrics serverMetrics = new ServerMetrics(registry, AmbryRequests.class);
StoreKeyFactory storeKeyFactory = new BlobIdFactory(clusterMap);
StoreKeyConverterFactory storeKeyConverterFactory = Utils.getObj(routerConfig.routerStoreKeyConverterFactory, verifiableProperties, registry);
// A null notification system is passed into AmbryRequests so that replication events are not emitted from a
// frontend.
AmbryRequests requests = new AmbryRequests(cloudStorageManager, channel, clusterMap, nodeId, registry, serverMetrics, null, null, null, storeKeyFactory, storeKeyConverterFactory);
return new RequestHandlerPool(routerConfig.routerRequestHandlerNumOfThreads, channel, requests);
}
Aggregations