@Test public void testFindCurrentByHostAndName() throws Exception { AlertCurrentEntity entity = m_dao.findCurrentByHostAndName( m_cluster.getClusterId(), "h2", "Alert Definition 1"); assertNull(entity); entity = m_dao.findCurrentByHostAndName(m_cluster.getClusterId(), "h1", "Alert Definition 1"); assertNotNull(entity); assertNotNull(entity.getAlertHistory()); assertNotNull(entity.getAlertHistory().getAlertDefinition()); }
public AlertCurrentEntity findCurrentByHostAndName(long clusterId, String hostName, String alertName) { if( m_configuration.isAlertCacheEnabled() ){ AlertCacheKey key = new AlertCacheKey(clusterId, alertName, hostName); try { return m_currentAlertCache.get(key); } catch (ExecutionException executionException) { Throwable cause = executionException.getCause(); if (!(cause instanceof AlertNotYetCreatedException)) { LOG.warn("Unable to retrieve alert for key {} from the cache", key); } } } return findCurrentByHostAndNameInJPA(clusterId, hostName, alertName); }
AlertsDAO implements Cleanable { public AlertCurrentEntity findCurrentByHostAndName(long clusterId, String hostName, String alertName) { if( m_configuration.isAlertCacheEnabled() ){ AlertCacheKey key = new AlertCacheKey(clusterId, alertName, hostName); try { return m_currentAlertCache.get(key); } catch (ExecutionException executionException) { Throwable cause = executionException.getCause(); if (!(cause instanceof AlertNotYetCreatedException)) { LOG.warn("Unable to retrieve alert for key {} from the cache", key); } } } return findCurrentByHostAndNameInJPA(clusterId, hostName, alertName); } }
AlertsDAO implements Cleanable { public AlertCurrentEntity findCurrentByHostAndName(long clusterId, String hostName, String alertName) { if( m_configuration.isAlertCacheEnabled() ){ AlertCacheKey key = new AlertCacheKey(clusterId, alertName, hostName); try { return m_currentAlertCache.get(key); } catch (ExecutionException executionException) { Throwable cause = executionException.getCause(); if (!(cause instanceof AlertNotYetCreatedException)) { LOG.warn("Unable to retrieve alert for key {} from the cache", key); } } } return findCurrentByHostAndNameInJPA(clusterId, hostName, alertName); } @Inject  AlertsDAO(Configuration configuration); }
AlertsDAO implements Cleanable { public AlertCurrentEntity findCurrentByHostAndName(long clusterId, String hostName, String alertName) { if( m_configuration.isAlertCacheEnabled() ){ AlertCacheKey key = new AlertCacheKey(clusterId, alertName, hostName); try { return m_currentAlertCache.get(key); } catch (ExecutionException executionException) { Throwable cause = executionException.getCause(); if (!(cause instanceof AlertNotYetCreatedException)) { LOG.warn("Unable to retrieve alert for key {} from the cache", key); } } } return findCurrentByHostAndNameInJPA(clusterId, hostName, alertName); } @Inject  AlertsDAO(Configuration configuration); @RequiresSession AlertHistoryEntity findById(long alertId); @RequiresSession List<AlertHistoryEntity> findAll(); @RequiresSession List<AlertHistoryEntity> findAll(long clusterId); @RequiresSession List<AlertHistoryEntity> findAll(long clusterId,
      List<AlertState> alertStates); @RequiresSession List<AlertHistoryEntity> findAll(long clusterId, Date startDate,
      Date endDate); @RequiresSession List<AlertHistoryEntity> findAll(AlertHistoryRequest request); @Transactional List<AlertCurrentEntity> findAll(AlertCurrentRequest request); int getCount(Predicate predicate); @RequiresSession List<AlertCurrentEntity> findCurrent(); @RequiresSession AlertCurrentEntity findCurrentById(long alertId); @RequiresSession List<AlertCurrentEntity> findCurrentByDefinitionId(long definitionId); @RequiresSession List<AlertCurrentEntity> findCurrentByCluster(long clusterId); @RequiresSession AlertSummaryDTO findCurrentCounts(long clusterId, String serviceName, String hostName); @RequiresSession Map<String, AlertSummaryDTO> findCurrentPerHostCounts(long clusterId); @RequiresSession AlertHostSummaryDTO findCurrentHostCounts(long clusterId); @RequiresSession List<AlertCurrentEntity> findCurrentByService(long clusterId,
      String serviceName); AlertCurrentEntity findCurrentByHostAndName(long clusterId, String hostName,
      String alertName); @Transactional void removeByDefinitionId(long definitionId); @Transactional int removeCurrentByHistoryId(long historyId); @Transactional int removeCurrentDisabledAlerts(); @Transactional int removeCurrentByService(long clusterId, String serviceName); @Transactional int removeCurrentByHost(String hostName); @Transactional int removeCurrentByServiceComponentHost(long clusterId, String serviceName,
      String componentName, String hostName); @Transactional void create(AlertHistoryEntity alert); @Transactional void refresh(AlertHistoryEntity alert); @Transactional AlertHistoryEntity merge(AlertHistoryEntity alert); @Transactional void remove(AlertHistoryEntity alert); @Transactional void create(AlertCurrentEntity alert); @Transactional void refresh(AlertCurrentEntity alert); @Transactional AlertCurrentEntity merge(AlertCurrentEntity alert); AlertCurrentEntity merge(AlertCurrentEntity alert, boolean updateCacheOnly); @Transactional void remove(AlertCurrentEntity alert); @RequiresSession AlertSummaryDTO findAggregateCounts(long clusterId, String alertName); AlertCurrentEntity findCurrentByNameNoHost(long clusterId, String alertName); @Transactional void flushCachedEntitiesToJPA(); @Transactional @Override long cleanup(TimeBasedCleanupPolicy policy); }
AlertsDAO implements Cleanable { public AlertCurrentEntity findCurrentByHostAndName(long clusterId, String hostName, String alertName) { if( m_configuration.isAlertCacheEnabled() ){ AlertCacheKey key = new AlertCacheKey(clusterId, alertName, hostName); try { return m_currentAlertCache.get(key); } catch (ExecutionException executionException) { Throwable cause = executionException.getCause(); if (!(cause instanceof AlertNotYetCreatedException)) { LOG.warn("Unable to retrieve alert for key {} from the cache", key); } } } return findCurrentByHostAndNameInJPA(clusterId, hostName, alertName); } @Inject  AlertsDAO(Configuration configuration); @RequiresSession AlertHistoryEntity findById(long alertId); @RequiresSession List<AlertHistoryEntity> findAll(); @RequiresSession List<AlertHistoryEntity> findAll(long clusterId); @RequiresSession List<AlertHistoryEntity> findAll(long clusterId,
      List<AlertState> alertStates); @RequiresSession List<AlertHistoryEntity> findAll(long clusterId, Date startDate,
      Date endDate); @RequiresSession List<AlertHistoryEntity> findAll(AlertHistoryRequest request); @Transactional List<AlertCurrentEntity> findAll(AlertCurrentRequest request); int getCount(Predicate predicate); @RequiresSession List<AlertCurrentEntity> findCurrent(); @RequiresSession AlertCurrentEntity findCurrentById(long alertId); @RequiresSession List<AlertCurrentEntity> findCurrentByDefinitionId(long definitionId); @RequiresSession List<AlertCurrentEntity> findCurrentByCluster(long clusterId); @RequiresSession AlertSummaryDTO findCurrentCounts(long clusterId, String serviceName, String hostName); @RequiresSession Map<String, AlertSummaryDTO> findCurrentPerHostCounts(long clusterId); @RequiresSession AlertHostSummaryDTO findCurrentHostCounts(long clusterId); @RequiresSession List<AlertCurrentEntity> findCurrentByService(long clusterId,
      String serviceName); AlertCurrentEntity findCurrentByHostAndName(long clusterId, String hostName,
      String alertName); @Transactional void removeByDefinitionId(long definitionId); @Transactional int removeCurrentByHistoryId(long historyId); @Transactional int removeCurrentDisabledAlerts(); @Transactional int removeCurrentByService(long clusterId, String serviceName); @Transactional int removeCurrentByHost(String hostName); @Transactional int removeCurrentByServiceComponentHost(long clusterId, String serviceName,
      String componentName, String hostName); @Transactional void create(AlertHistoryEntity alert); @Transactional void refresh(AlertHistoryEntity alert); @Transactional AlertHistoryEntity merge(AlertHistoryEntity alert); @Transactional void remove(AlertHistoryEntity alert); @Transactional void create(AlertCurrentEntity alert); @Transactional void refresh(AlertCurrentEntity alert); @Transactional AlertCurrentEntity merge(AlertCurrentEntity alert); AlertCurrentEntity merge(AlertCurrentEntity alert, boolean updateCacheOnly); @Transactional void remove(AlertCurrentEntity alert); @RequiresSession AlertSummaryDTO findAggregateCounts(long clusterId, String alertName); AlertCurrentEntity findCurrentByNameNoHost(long clusterId, String alertName); @Transactional void flushCachedEntitiesToJPA(); @Transactional @Override long cleanup(TimeBasedCleanupPolicy policy);  }