use of org.apache.samza.storage.blobstore.metrics.BlobStoreBackupManagerMetrics in project samza by apache.
the class TestBlobStoreBackupManager method setup.
@Before
public void setup() throws Exception {
when(clock.currentTimeMillis()).thenReturn(1234567L);
// setup test local and remote snapshots
indexBlobIdAndLocalRemoteSnapshotsPair = setupRemoteAndLocalSnapshots(true);
// setup test store name and SCMs map
testStoreNameAndSCMMap = setupTestStoreSCMMapAndStoreBackedFactoryConfig(indexBlobIdAndLocalRemoteSnapshotsPair);
// setup: setup task backup manager with expected storeName->storageEngine map
testStoreNameAndSCMMap.forEach((storeName, scm) -> storeStorageEngineMap.put(storeName, null));
mapConfig.putAll(new MapConfig(ImmutableMap.of("job.name", jobName, "job.id", jobId)));
Config config = new MapConfig(mapConfig);
// Mock - return snapshot index for blob id from test blob store map
ArgumentCaptor<String> captor = ArgumentCaptor.forClass(String.class);
when(blobStoreUtil.getSnapshotIndex(captor.capture(), any(Metadata.class))).then((Answer<CompletableFuture<SnapshotIndex>>) invocation -> {
String blobId = invocation.getArgumentAt(0, String.class);
return CompletableFuture.completedFuture(testBlobStore.get(blobId));
});
// doNothing().when(blobStoreManager).init();
when(taskModel.getTaskName().getTaskName()).thenReturn(taskName);
when(taskModel.getTaskMode()).thenReturn(TaskMode.Active);
when(metricsRegistry.newCounter(anyString(), anyString())).thenReturn(counter);
when(metricsRegistry.newGauge(anyString(), anyString(), anyLong())).thenReturn(longGauge);
when(metricsRegistry.newGauge(anyString(), anyString(), any(AtomicLong.class))).thenReturn(atomicLongGauge);
when(atomicLongGauge.getValue()).thenReturn(new AtomicLong());
when(metricsRegistry.newTimer(anyString(), anyString())).thenReturn(timer);
blobStoreTaskBackupMetrics = new BlobStoreBackupManagerMetrics(metricsRegistry);
blobStoreBackupManager = new MockBlobStoreBackupManager(jobModel, containerModel, taskModel, mockExecutor, blobStoreTaskBackupMetrics, config, Files.createTempDirectory("logged-store-").toFile(), storageManagerUtil, blobStoreManager);
}
use of org.apache.samza.storage.blobstore.metrics.BlobStoreBackupManagerMetrics in project samza by apache.
the class BlobStoreStateBackendFactory method getBackupManager.
@Override
public TaskBackupManager getBackupManager(JobContext jobContext, ContainerModel containerModel, TaskModel taskModel, ExecutorService backupExecutor, MetricsRegistry metricsRegistry, Config config, Clock clock, File loggedStoreBaseDir, File nonLoggedStoreBaseDir) {
BlobStoreConfig blobStoreConfig = new BlobStoreConfig(config);
String blobStoreManagerFactory = blobStoreConfig.getBlobStoreManagerFactory();
Preconditions.checkState(StringUtils.isNotBlank(blobStoreManagerFactory));
BlobStoreManagerFactory factory = ReflectionUtil.getObj(blobStoreManagerFactory, BlobStoreManagerFactory.class);
BlobStoreManager blobStoreManager = factory.getBackupBlobStoreManager(config, backupExecutor);
BlobStoreBackupManagerMetrics metrics = new BlobStoreBackupManagerMetrics(metricsRegistry);
return new BlobStoreBackupManager(jobContext.getJobModel(), containerModel, taskModel, backupExecutor, metrics, config, clock, loggedStoreBaseDir, new StorageManagerUtil(), blobStoreManager);
}
Aggregations