@Test public void testQueueSizeFailure() throws Throwable { doReturn(getInsightFeed(1)).when(mockInsightClient).getObjects(anyList()); doReturn(new QueueResult<>().setSuccessful(false)).when(mockReadyAgendaQueue).size(); queueMonitor.monitor(RESOURCE_POOL_ID); }
public void monitor(String resourcePoolId) throws Throwable { DataObjectResponse<Insight> insightObjectFeed = insightClient.getObjects(Collections.singletonList(new ByResourcePoolId(resourcePoolId))); if(insightObjectFeed.isError()) { logger.error("Error getting any insights by resourcePoolId: {}", resourcePoolId); reportFailed("resourcePool"); return; } if(insightObjectFeed.getAll() == null || insightObjectFeed.getAll().size() == 0) { logger.info("No insights found for ResourcePool: {}", resourcePoolId); return; } for(Insight insight : insightObjectFeed.getAll()) { String insightTitle = getReportSafeInsightTitle(insight); try { DataObjectFeed feed = readyAgendaPersister.retrieve(Arrays.asList(new ByInsightId(insight.getId()))); Integer waitingAgendaCount = feed.getAll() != null ? feed.getAll().size() : 0; if(waitingAgendaCount != null && waitingAgendaCount > 0) reportWaiting(insightTitle, waitingAgendaCount); logger.info("Insight: {} Waiting: {}", insightTitle, waitingAgendaCount); } catch(Exception e) { logger.error("Failed to process ResourcePool: {} Insight: {}", resourcePoolId, insightTitle, e); reportFailed(insightTitle); } } logger.info("Processed ResourcePool: {}", resourcePoolId); }
QueueMetricMonitor { public void monitor(String resourcePoolId) throws Throwable { DataObjectResponse<Insight> insightObjectFeed = insightClient.getObjects(Collections.singletonList(new ByResourcePoolId(resourcePoolId))); if(insightObjectFeed.isError()) { logger.error("Error getting any insights by resourcePoolId: {}", resourcePoolId); reportFailed("resourcePool"); return; } if(insightObjectFeed.getAll() == null || insightObjectFeed.getAll().size() == 0) { logger.info("No insights found for ResourcePool: {}", resourcePoolId); return; } for(Insight insight : insightObjectFeed.getAll()) { String insightTitle = getReportSafeInsightTitle(insight); try { DataObjectFeed feed = readyAgendaPersister.retrieve(Arrays.asList(new ByInsightId(insight.getId()))); Integer waitingAgendaCount = feed.getAll() != null ? feed.getAll().size() : 0; if(waitingAgendaCount != null && waitingAgendaCount > 0) reportWaiting(insightTitle, waitingAgendaCount); logger.info("Insight: {} Waiting: {}", insightTitle, waitingAgendaCount); } catch(Exception e) { logger.error("Failed to process ResourcePool: {} Insight: {}", resourcePoolId, insightTitle, e); reportFailed(insightTitle); } } logger.info("Processed ResourcePool: {}", resourcePoolId); } }
QueueMetricMonitor { public void monitor(String resourcePoolId) throws Throwable { DataObjectResponse<Insight> insightObjectFeed = insightClient.getObjects(Collections.singletonList(new ByResourcePoolId(resourcePoolId))); if(insightObjectFeed.isError()) { logger.error("Error getting any insights by resourcePoolId: {}", resourcePoolId); reportFailed("resourcePool"); return; } if(insightObjectFeed.getAll() == null || insightObjectFeed.getAll().size() == 0) { logger.info("No insights found for ResourcePool: {}", resourcePoolId); return; } for(Insight insight : insightObjectFeed.getAll()) { String insightTitle = getReportSafeInsightTitle(insight); try { DataObjectFeed feed = readyAgendaPersister.retrieve(Arrays.asList(new ByInsightId(insight.getId()))); Integer waitingAgendaCount = feed.getAll() != null ? feed.getAll().size() : 0; if(waitingAgendaCount != null && waitingAgendaCount > 0) reportWaiting(insightTitle, waitingAgendaCount); logger.info("Insight: {} Waiting: {}", insightTitle, waitingAgendaCount); } catch(Exception e) { logger.error("Failed to process ResourcePool: {} Insight: {}", resourcePoolId, insightTitle, e); reportFailed(insightTitle); } } logger.info("Processed ResourcePool: {}", resourcePoolId); } QueueMetricMonitor(
        ObjectPersister<ReadyAgenda> readyAgendaPersister,
        ObjectClient<Insight> insightClient,
        MetricReporter metricReporter); }
QueueMetricMonitor { public void monitor(String resourcePoolId) throws Throwable { DataObjectResponse<Insight> insightObjectFeed = insightClient.getObjects(Collections.singletonList(new ByResourcePoolId(resourcePoolId))); if(insightObjectFeed.isError()) { logger.error("Error getting any insights by resourcePoolId: {}", resourcePoolId); reportFailed("resourcePool"); return; } if(insightObjectFeed.getAll() == null || insightObjectFeed.getAll().size() == 0) { logger.info("No insights found for ResourcePool: {}", resourcePoolId); return; } for(Insight insight : insightObjectFeed.getAll()) { String insightTitle = getReportSafeInsightTitle(insight); try { DataObjectFeed feed = readyAgendaPersister.retrieve(Arrays.asList(new ByInsightId(insight.getId()))); Integer waitingAgendaCount = feed.getAll() != null ? feed.getAll().size() : 0; if(waitingAgendaCount != null && waitingAgendaCount > 0) reportWaiting(insightTitle, waitingAgendaCount); logger.info("Insight: {} Waiting: {}", insightTitle, waitingAgendaCount); } catch(Exception e) { logger.error("Failed to process ResourcePool: {} Insight: {}", resourcePoolId, insightTitle, e); reportFailed(insightTitle); } } logger.info("Processed ResourcePool: {}", resourcePoolId); } QueueMetricMonitor(
        ObjectPersister<ReadyAgenda> readyAgendaPersister,
        ObjectClient<Insight> insightClient,
        MetricReporter metricReporter); void monitor(String resourcePoolId); void setMetricReporter(MetricReporter metricReporter); }
QueueMetricMonitor { public void monitor(String resourcePoolId) throws Throwable { DataObjectResponse<Insight> insightObjectFeed = insightClient.getObjects(Collections.singletonList(new ByResourcePoolId(resourcePoolId))); if(insightObjectFeed.isError()) { logger.error("Error getting any insights by resourcePoolId: {}", resourcePoolId); reportFailed("resourcePool"); return; } if(insightObjectFeed.getAll() == null || insightObjectFeed.getAll().size() == 0) { logger.info("No insights found for ResourcePool: {}", resourcePoolId); return; } for(Insight insight : insightObjectFeed.getAll()) { String insightTitle = getReportSafeInsightTitle(insight); try { DataObjectFeed feed = readyAgendaPersister.retrieve(Arrays.asList(new ByInsightId(insight.getId()))); Integer waitingAgendaCount = feed.getAll() != null ? feed.getAll().size() : 0; if(waitingAgendaCount != null && waitingAgendaCount > 0) reportWaiting(insightTitle, waitingAgendaCount); logger.info("Insight: {} Waiting: {}", insightTitle, waitingAgendaCount); } catch(Exception e) { logger.error("Failed to process ResourcePool: {} Insight: {}", resourcePoolId, insightTitle, e); reportFailed(insightTitle); } } logger.info("Processed ResourcePool: {}", resourcePoolId); } QueueMetricMonitor(
        ObjectPersister<ReadyAgenda> readyAgendaPersister,
        ObjectClient<Insight> insightClient,
        MetricReporter metricReporter); void monitor(String resourcePoolId); void setMetricReporter(MetricReporter metricReporter);  }