Codota Logo
ThresholdChecker.checkThreshold
Code IndexAdd Codota to your IDE (free)

How to use
checkThreshold
method
in
rocks.inspectit.server.alerting.ThresholdChecker

Best Java code snippets using rocks.inspectit.server.alerting.ThresholdChecker.checkThreshold (Showing top 10 results out of 315)

  • Add the Codota plugin to your IDE and get smart completions
private void myMethod () {
StringBuilder s =
  • Codota Iconnew StringBuilder()
  • Codota Iconnew StringBuilder(32)
  • Codota IconString str;new StringBuilder(str)
  • Smart code suggestions by Codota
}
origin: inspectIT/inspectIT

/**
 * {@inheritDoc}
 */
@Override
public void run() {
  if (log.isDebugEnabled()) {
    log.debug("|-Checking alert definitions...");
  }
  long currentTime = System.currentTimeMillis();
  for (AlertingState alertingState : alertingStates) {
    try {
      long nextCheckTime = alertingState.getLastCheckTime() + alertingState.getAlertingDefinition().getTimeRange(TimeUnit.MILLISECONDS);
      if (nextCheckTime <= currentTime) {
        thresholdChecker.checkThreshold(alertingState);
      }
    } catch (Exception e) {
      if (log.isErrorEnabled()) {
        log.error("Unexpected exception occured.", e);
      }
    }
  }
}
origin: inspectIT/inspectIT

  @Test
  public void thresholdCheckerThrowsException() throws Exception {
    AlertingDefinition definitionOne = mock(AlertingDefinition.class);
    alertingScheduler.onApplicationEvent(new AlertingDefinitionCreatedEvent(this, definitionOne));
    doThrow(RuntimeException.class).when(thresholdChecker).checkThreshold(any(AlertingState.class));
    alertingScheduler.run();
    verify(thresholdChecker).checkThreshold(any(AlertingState.class));
    verifyNoMoreInteractions(thresholdChecker);
    verifyZeroInteractions(executorService);
  }
}
origin: inspectIT/inspectIT

@Test
public void influxDisconnected() throws BusinessException, Exception {
  when(influxDao.isConnected()).thenReturn(false);
  thresholdChecker.checkThreshold(alertingState);
  verify(influxDao).isConnected();
  verifyNoMoreInteractions(influxDao);
  verifyZeroInteractions(stateManager, alertingState);
}
origin: inspectIT/inspectIT

@Test
public void checkExistingAlertingStates() throws Exception {
  AlertingDefinition definitionOne = mock(AlertingDefinition.class);
  AlertingDefinition definitionTwo = mock(AlertingDefinition.class);
  when(definitionOne.getTimeRange(any(TimeUnit.class))).thenReturn(1L);
  when(definitionTwo.getTimeRange(any(TimeUnit.class))).thenReturn(3600000L);
  alertingScheduler.onApplicationEvent(new AlertingDefinitionCreatedEvent(this, definitionOne));
  alertingScheduler.onApplicationEvent(new AlertingDefinitionCreatedEvent(this, definitionTwo));
  doAnswer(new Answer<Void>() {
    @Override
    public Void answer(InvocationOnMock invocation) throws Throwable {
      ((AlertingState) invocation.getArguments()[0]).setLastCheckTime(System.currentTimeMillis());
      return null;
    }
  }).when(thresholdChecker).checkThreshold(any(AlertingState.class));
  alertingScheduler.run(); // both are checked
  Thread.sleep(10);
  alertingScheduler.run(); // only first is checked
  ArgumentCaptor<AlertingState> stateCaptor = ArgumentCaptor.forClass(AlertingState.class);
  verify(thresholdChecker, times(3)).checkThreshold(stateCaptor.capture());
  verifyNoMoreInteractions(thresholdChecker);
  verifyZeroInteractions(executorService);
  assertThat(stateCaptor.getAllValues().get(0).getAlertingDefinition(), equalTo(definitionOne));
  assertThat(stateCaptor.getAllValues().get(1).getAlertingDefinition(), equalTo(definitionTwo));
  assertThat(stateCaptor.getAllValues().get(2).getAlertingDefinition(), equalTo(definitionOne));
}
origin: inspectIT/inspectIT

@Test
public void noViolationLowerThreshold() throws BusinessException, Exception {
  long time = System.currentTimeMillis();
  when(influxDao.isConnected()).thenReturn(true);
  when(influxDao.query(any(String.class))).thenReturn(queryResult);
  when(alertingState.getAlertingDefinition()).thenReturn(alertingDefinition);
  when(alertingDefinition.getThresholdType()).thenReturn(ThresholdType.LOWER_THRESHOLD);
  when(alertingDefinition.getThreshold()).thenReturn(5D);
  thresholdChecker.checkThreshold(alertingState);
  ArgumentCaptor<Long> timeCaptor = ArgumentCaptor.forClass(Long.class);
  verify(alertingState, times(2)).getLastCheckTime();
  verify(alertingState).setLastCheckTime(timeCaptor.capture());
  verify(alertingState, times(2)).getAlertingDefinition();
  assertThat(timeCaptor.getValue(), greaterThanOrEqualTo(time));
  verify(influxDao).query(any(String.class));
  verify(influxDao).isConnected();
  verify(stateManager).valid(alertingState);
  verify(alertingDefinition, times(2)).getThresholdType();
  verify(alertingDefinition).getThreshold();
  verify(alertingDefinition).getField();
  verify(alertingDefinition).getTags();
  verify(alertingDefinition).getMeasurement();
  verify(alertingDefinition).getTimeRange(TimeUnit.MILLISECONDS);
  verifyNoMoreInteractions(influxDao, alertingState, stateManager, alertingDefinition);
}
origin: inspectIT/inspectIT

@Test
public void violationLowerThreshold() throws BusinessException, Exception {
  long time = System.currentTimeMillis();
  when(influxDao.isConnected()).thenReturn(true);
  when(influxDao.query(any(String.class))).thenReturn(queryResult);
  when(alertingState.getAlertingDefinition()).thenReturn(alertingDefinition);
  when(alertingDefinition.getThresholdType()).thenReturn(ThresholdType.LOWER_THRESHOLD);
  when(alertingDefinition.getThreshold()).thenReturn(15D);
  thresholdChecker.checkThreshold(alertingState);
  ArgumentCaptor<Long> timeCaptor = ArgumentCaptor.forClass(Long.class);
  verify(alertingState).setLastCheckTime(timeCaptor.capture());
  verify(alertingState, times(2)).getLastCheckTime();
  verify(alertingState, times(2)).getAlertingDefinition();
  assertThat(timeCaptor.getValue(), greaterThanOrEqualTo(time));
  verify(influxDao).query(any(String.class));
  verify(influxDao).isConnected();
  verify(stateManager).violation(alertingState, 10D);
  verify(alertingDefinition, times(2)).getThresholdType();
  verify(alertingDefinition).getThreshold();
  verify(alertingDefinition).getField();
  verify(alertingDefinition).getTags();
  verify(alertingDefinition).getMeasurement();
  verify(alertingDefinition).getTimeRange(TimeUnit.MILLISECONDS);
  verifyNoMoreInteractions(influxDao, alertingState, stateManager, alertingDefinition);
}
origin: inspectIT/inspectIT

@Test
public void neverChecked() throws BusinessException, Exception {
  long time = System.currentTimeMillis();
  when(influxDao.isConnected()).thenReturn(true);
  when(influxDao.query(any(String.class))).thenReturn(new QueryResult());
  when(alertingState.getAlertingDefinition()).thenReturn(alertingDefinition);
  when(alertingState.getLastCheckTime()).thenReturn(-1L);
  thresholdChecker.checkThreshold(alertingState);
  ArgumentCaptor<Long> currentTimeCaptor = ArgumentCaptor.forClass(Long.class);
  verify(alertingState, times(2)).getLastCheckTime();
  verify(alertingState, times(2)).setLastCheckTime(currentTimeCaptor.capture());
  verify(alertingState, times(2)).getAlertingDefinition();
  assertThat(currentTimeCaptor.getValue(), greaterThanOrEqualTo(time));
  verify(alertingDefinition, times(2)).getTimeRange(TimeUnit.MILLISECONDS);
  verify(influxDao).query(any(String.class));
  verify(influxDao).isConnected();
  verify(stateManager).noData(alertingState);
  verify(alertingDefinition).getThresholdType();
  verify(alertingDefinition).getField();
  verify(alertingDefinition).getTags();
  verify(alertingDefinition).getMeasurement();
  verify(alertingDefinition, times(2)).getTimeRange(TimeUnit.MILLISECONDS);
  verifyNoMoreInteractions(influxDao, alertingState, stateManager, alertingDefinition);
}
origin: inspectIT/inspectIT

@Test
public void noData() throws BusinessException, Exception {
  long time = System.currentTimeMillis();
  when(influxDao.isConnected()).thenReturn(true);
  when(influxDao.query(any(String.class))).thenReturn(new QueryResult());
  when(alertingState.getAlertingDefinition()).thenReturn(alertingDefinition);
  thresholdChecker.checkThreshold(alertingState);
  ArgumentCaptor<Long> timeCaptor = ArgumentCaptor.forClass(Long.class);
  verify(alertingState, times(2)).getLastCheckTime();
  verify(alertingState).setLastCheckTime(timeCaptor.capture());
  verify(alertingState).getAlertingDefinition();
  assertThat(timeCaptor.getValue(), greaterThanOrEqualTo(time));
  verify(influxDao).query(any(String.class));
  verify(influxDao).isConnected();
  verify(stateManager).noData(alertingState);
  verify(alertingDefinition).getThresholdType();
  verify(alertingDefinition).getField();
  verify(alertingDefinition).getTags();
  verify(alertingDefinition).getMeasurement();
  verify(alertingDefinition).getTimeRange(TimeUnit.MILLISECONDS);
  verifyNoMoreInteractions(influxDao, alertingState, stateManager, alertingDefinition);
}
origin: inspectIT/inspectIT

@Test
public void noViolationUpperThreshold() throws BusinessException, Exception {
  long time = System.currentTimeMillis();
  when(influxDao.isConnected()).thenReturn(true);
  when(influxDao.query(any(String.class))).thenReturn(queryResult);
  when(alertingState.getAlertingDefinition()).thenReturn(alertingDefinition);
  when(alertingDefinition.getThresholdType()).thenReturn(ThresholdType.UPPER_THRESHOLD);
  when(alertingDefinition.getThreshold()).thenReturn(15D);
  thresholdChecker.checkThreshold(alertingState);
  ArgumentCaptor<Long> timeCaptor = ArgumentCaptor.forClass(Long.class);
  verify(alertingState, times(2)).getLastCheckTime();
  verify(alertingState).setLastCheckTime(timeCaptor.capture());
  verify(alertingState, times(2)).getAlertingDefinition();
  assertThat(timeCaptor.getValue(), greaterThanOrEqualTo(time));
  verify(influxDao).query(any(String.class));
  verify(influxDao).isConnected();
  verify(stateManager).valid(alertingState);
  verify(alertingDefinition, times(2)).getThresholdType();
  verify(alertingDefinition).getThreshold();
  verify(alertingDefinition).getField();
  verify(alertingDefinition).getTags();
  verify(alertingDefinition).getMeasurement();
  verify(alertingDefinition).getTimeRange(TimeUnit.MILLISECONDS);
  verifyNoMoreInteractions(influxDao, alertingState, stateManager, alertingDefinition);
}
origin: inspectIT/inspectIT

@Test
public void violationUpperThreshold() throws BusinessException, Exception {
  long time = System.currentTimeMillis();
  when(influxDao.isConnected()).thenReturn(true);
  when(influxDao.query(any(String.class))).thenReturn(queryResult);
  when(alertingState.getAlertingDefinition()).thenReturn(alertingDefinition);
  when(alertingDefinition.getThresholdType()).thenReturn(ThresholdType.UPPER_THRESHOLD);
  when(alertingDefinition.getThreshold()).thenReturn(5D);
  thresholdChecker.checkThreshold(alertingState);
  ArgumentCaptor<Long> timeCaptor = ArgumentCaptor.forClass(Long.class);
  verify(alertingState, times(2)).getLastCheckTime();
  verify(alertingState).setLastCheckTime(timeCaptor.capture());
  verify(alertingState, times(2)).getAlertingDefinition();
  assertThat(timeCaptor.getValue(), greaterThanOrEqualTo(time));
  verify(influxDao).query(any(String.class));
  verify(influxDao).isConnected();
  verify(stateManager).violation(alertingState, 10D);
  verify(alertingDefinition, times(2)).getThresholdType();
  verify(alertingDefinition).getThreshold();
  verify(alertingDefinition).getField();
  verify(alertingDefinition).getTags();
  verify(alertingDefinition).getMeasurement();
  verify(alertingDefinition).getTimeRange(TimeUnit.MILLISECONDS);
  verifyNoMoreInteractions(influxDao, alertingState, stateManager, alertingDefinition);
}
rocks.inspectit.server.alertingThresholdCheckercheckThreshold

Javadoc

Checks whether the threshold defined by the AlertingDefinition contained in the given AlertingState has been violated. The result is given to the AlertingStateLifecycleManager.

Popular methods of ThresholdChecker

  • isViolating
    Checks whether the given double value violates the threshold of the given AlertingDefinition.

Popular in Java

  • Reading from database using SQL prepared statement
  • onRequestPermissionsResult (Fragment)
  • getContentResolver (Context)
  • getSharedPreferences (Context)
  • HttpURLConnection (java.net)
    An URLConnection for HTTP (RFC 2616 [http://tools.ietf.org/html/rfc2616]) used to send and receive d
  • SocketException (java.net)
    This SocketException may be thrown during socket creation or setting options, and is the superclass
  • NoSuchElementException (java.util)
    Thrown when trying to retrieve an element past the end of an Enumeration or Iterator.
  • Scanner (java.util)
    A parser that parses a text string of primitive types and strings with the help of regular expressio
  • TimeZone (java.util)
    TimeZone represents a time zone offset, and also figures out daylight savings. Typically, you get a
  • Semaphore (java.util.concurrent)
    A counting semaphore. Conceptually, a semaphore maintains a set of permits. Each #acquire blocks if
Codota Logo
  • Products

    Search for Java codeSearch for JavaScript codeEnterprise
  • IDE Plugins

    IntelliJ IDEAWebStormAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogCodota Academy Plugin user guide Terms of usePrivacy policyJava Code IndexJavascript Code Index
Get Codota for your IDE now