Search in sources :

Example 1 with CustomModelsInfo

use of org.alfresco.repo.dictionary.CustomModelsInfo in project alfresco-repository by Alfresco.

the class ModelUsageDataCollectorTest method setUp.

@Before
public void setUp() {
    mockDescriptorDAO = mock(DescriptorDAO.class);
    mockCollectorService = mock(HBDataCollectorService.class);
    mockScheduler = mock(HeartBeatJobScheduler.class);
    Descriptor mockDescriptor = mock(Descriptor.class);
    when(mockDescriptor.getId()).thenReturn("mock_id");
    when(mockDescriptorDAO.getDescriptor()).thenReturn(mockDescriptor);
    CustomModelsInfo mockCustomModelsInfo = mock(CustomModelsInfo.class);
    CustomModelService customModelService = mock(CustomModelService.class);
    when(customModelService.getCustomModelsInfo()).thenReturn(mockCustomModelsInfo);
    TransactionService mockTransactionService = mock(TransactionService.class);
    RetryingTransactionHelper mockRetryingTransactionHelper = mock(RetryingTransactionHelper.class);
    when(mockRetryingTransactionHelper.doInTransaction(any(RetryingTransactionHelper.RetryingTransactionCallback.class), anyBoolean())).thenReturn(mockCustomModelsInfo);
    when(mockTransactionService.getRetryingTransactionHelper()).thenReturn(mockRetryingTransactionHelper);
    usageModelCollector = new ModelUsageDataCollector("acs.repository.usage.model", "1.0", "0 0 0 ? * *", mockScheduler);
    usageModelCollector.setHbDataCollectorService(mockCollectorService);
    usageModelCollector.setCurrentRepoDescriptorDAO(mockDescriptorDAO);
    usageModelCollector.setCustomModelService(customModelService);
    usageModelCollector.setTransactionService(mockTransactionService);
    collectedData = usageModelCollector.collectData();
}
Also used : TransactionService(org.alfresco.service.transaction.TransactionService) HeartBeatJobScheduler(org.alfresco.heartbeat.jobs.HeartBeatJobScheduler) CustomModelsInfo(org.alfresco.repo.dictionary.CustomModelsInfo) RetryingTransactionHelper(org.alfresco.repo.transaction.RetryingTransactionHelper) CustomModelService(org.alfresco.service.cmr.dictionary.CustomModelService) HBDataCollectorService(org.alfresco.service.cmr.repository.HBDataCollectorService) Descriptor(org.alfresco.service.descriptor.Descriptor) DescriptorDAO(org.alfresco.repo.descriptor.DescriptorDAO) Before(org.junit.Before)

Example 2 with CustomModelsInfo

use of org.alfresco.repo.dictionary.CustomModelsInfo in project alfresco-repository by Alfresco.

the class ModelUsageDataCollector method collectData.

@Override
public List<HBData> collectData() {
    logger.debug("Preparing repository usage (model) data...");
    final CustomModelsInfo customModelsInfo = transactionService.getRetryingTransactionHelper().doInTransaction(() -> customModelService.getCustomModelsInfo(), true);
    Map<String, Object> modelUsageValues = new HashMap<>();
    modelUsageValues.put("numOfActiveModels", new Integer(customModelsInfo.getNumberOfActiveModels()));
    modelUsageValues.put("numOfActiveTypes", new Integer(customModelsInfo.getNumberOfActiveTypes()));
    modelUsageValues.put("numOfActiveAspects", new Integer(customModelsInfo.getNumberOfActiveAspects()));
    HBData modelUsageData = new HBData(this.currentRepoDescriptorDAO.getDescriptor().getId(), this.getCollectorId(), this.getCollectorVersion(), new Date(), modelUsageValues);
    return Arrays.asList(modelUsageData);
}
Also used : CustomModelsInfo(org.alfresco.repo.dictionary.CustomModelsInfo) HBData(org.alfresco.heartbeat.datasender.HBData)

Aggregations

CustomModelsInfo (org.alfresco.repo.dictionary.CustomModelsInfo)2 HBData (org.alfresco.heartbeat.datasender.HBData)1 HeartBeatJobScheduler (org.alfresco.heartbeat.jobs.HeartBeatJobScheduler)1 DescriptorDAO (org.alfresco.repo.descriptor.DescriptorDAO)1 RetryingTransactionHelper (org.alfresco.repo.transaction.RetryingTransactionHelper)1 CustomModelService (org.alfresco.service.cmr.dictionary.CustomModelService)1 HBDataCollectorService (org.alfresco.service.cmr.repository.HBDataCollectorService)1 Descriptor (org.alfresco.service.descriptor.Descriptor)1 TransactionService (org.alfresco.service.transaction.TransactionService)1 Before (org.junit.Before)1