Tabnine Logo
ClassInstrumentationChangedEvent
Code IndexAdd Tabnine to your IDE (free)

How to use
ClassInstrumentationChangedEvent
in
rocks.inspectit.server.ci.event

Best Java code snippets using rocks.inspectit.server.ci.event.ClassInstrumentationChangedEvent (Showing top 19 results out of 315)

origin: inspectIT/inspectIT

@Test
public void successful() {
  List<InstrumentationDefinition> instrumentationDefinitions = Arrays.asList(mock(InstrumentationDefinition.class));
  ClassInstrumentationChangedEvent event = new ClassInstrumentationChangedEvent(this, 10L, instrumentationDefinitions);
  assertThat(event.getAgentId(), is(equalTo(10L)));
  assertThat(instrumentationDefinitions, is(equalTo(event.getInstrumentationDefinitions())));
}
origin: inspectIT/inspectIT

/**
 * Handles an event of type {@link ClassInstrumentationChangedEvent}.
 *
 * @param event
 *            the event instance
 */
private void handleClassInstrumentationChangedEvent(ClassInstrumentationChangedEvent event) {
  if (log.isDebugEnabled()) {
    log.debug("Putting instrumentation definitions for agent {} into the definition buffer.", event.getAgentId());
  }
  Map<String, InstrumentationDefinition> pendingDefinitions = definitionBuffer.get(event.getAgentId());
  if (pendingDefinitions == null) {
    pendingDefinitions = new HashMap<>();
    definitionBuffer.put(event.getAgentId(), pendingDefinitions);
  }
  for (InstrumentationDefinition definition : event.getInstrumentationDefinitions()) {
    pendingDefinitions.put(definition.getClassName(), definition);
  }
  AgentStatusData agentStatusData = agentStatusDataProvider.getAgentStatusDataMap().get(event.getAgentId());
  if (agentStatusData != null) {
    if (agentStatusData.getInstrumentationStatus() != InstrumentationStatus.PENDING) {
      agentStatusData.setInstrumentationStatus(InstrumentationStatus.PENDING);
      agentStatusData.setPendingSinceTime(System.currentTimeMillis());
    }
  }
}
origin: inspectIT/inspectIT

  @Test(expectedExceptions = IllegalArgumentException.class)
  @SuppressWarnings("unchecked")
  public void emptyDefinitions() {
    new ClassInstrumentationChangedEvent(this, 10L, Collections.EMPTY_LIST);
  }
}
origin: inspectIT/inspectIT

@Test
public void addedAssignment() throws RemoteException, BusinessException {
  Collection<ClassType> types = Collections.singleton(classType);
  doReturn(instrumentationApplier).when(configurationResolver).getInstrumentationApplier(sensorAssignment, environment);
  doReturn(types).when(classCacheSearchNarrower).narrowByClassSensorAssignment(classCache, sensorAssignment);
  doReturn(types).when(instrumentationService).addInstrumentationPoints(eq(types), eq(agentConfiguration), Matchers.<Collection<IInstrumentationApplier>> any());
  doReturn(Collections.singletonList(sensorAssignment)).when(event).getAddedSensorAssignments(functionalAssignmentFactory);
  job.setEnvironmentUpdateEvent(event);
  job.run();
  verify(configurationHolder, times(1)).update(updateEnvironment, PLATFORM_ID);
  ArgumentCaptor<Collection> captor = ArgumentCaptor.forClass(Collection.class);
  verify(instrumentationService, times(1)).addInstrumentationPoints(eq(types), eq(agentConfiguration), captor.capture());
  assertThat((Collection<IInstrumentationApplier>) captor.getValue(), hasSize(1));
  assertThat(((Collection<IInstrumentationApplier>) captor.getValue()).iterator().next(), is(instrumentationApplier));
  ArgumentCaptor<ClassInstrumentationChangedEvent> eventCaptor = ArgumentCaptor.forClass(ClassInstrumentationChangedEvent.class);
  verify(eventPublisher).publishEvent(eventCaptor.capture());
  assertThat(eventCaptor.getValue().getAgentId(), is(equalTo(PLATFORM_ID)));
  assertThat(eventCaptor.getValue().getInstrumentationDefinitions(), contains(org.hamcrest.Matchers.<InstrumentationDefinition> hasProperty("className", equalTo("fqn"))));
  verifyNoMoreInteractions(eventPublisher);
  verifyZeroInteractions(environment, agentConfiguration);
}
origin: inspectIT/inspectIT

@Test(expectedExceptions = IllegalArgumentException.class)
public void nullDefinitions() {
  new ClassInstrumentationChangedEvent(this, 10L, null);
}
origin: inspectIT/inspectIT

@Test
public void addedAssignment() throws RemoteException {
  Collection<ClassType> types = ImmutableList.of(classTypeOne, classTypeTwo);
  doReturn(instrumentationApplier).when(configurationResolver).getInstrumentationApplier(sensorAssignment, environment);
  doReturn(types).when(classCacheSearchNarrower).narrowByClassSensorAssignment(classCache, sensorAssignment);
  doReturn(types).when(instrumentationService).addInstrumentationPoints(eq(types), eq(agentConfiguration), Matchers.<Collection<IInstrumentationApplier>> any());
  doReturn(Collections.singleton(sensorAssignment)).when(event).getAddedSensorAssignments();
  job.setProfileUpdateEvent(event);
  job.run();
  ArgumentCaptor<Collection> captor = ArgumentCaptor.forClass(Collection.class);
  verify(instrumentationService, times(1)).addInstrumentationPoints(eq(types), eq(agentConfiguration), captor.capture());
  assertThat((Collection<IInstrumentationApplier>) captor.getValue(), hasSize(1));
  assertThat(((Collection<IInstrumentationApplier>) captor.getValue()).iterator().next(), is(instrumentationApplier));
  ArgumentCaptor<Collection> typeCaptor = ArgumentCaptor.forClass(Collection.class);
  verify(instrumentationService).getInstrumentationResults(typeCaptor.capture());
  assertThat((Collection<ClassType>) typeCaptor.getValue(), hasItems(classTypeOne, classTypeTwo));
  ArgumentCaptor<ClassInstrumentationChangedEvent> eventCaptor = ArgumentCaptor.forClass(ClassInstrumentationChangedEvent.class);
  verify(eventPublisher).publishEvent(eventCaptor.capture());
  assertThat(eventCaptor.getValue().getAgentId(), is(equalTo(10L)));
  Matcher<InstrumentationDefinition> matcherOne = org.hamcrest.Matchers.<InstrumentationDefinition> hasProperty("className", equalTo("fqnOne"));
  Matcher<InstrumentationDefinition> matcherTwo = org.hamcrest.Matchers.<InstrumentationDefinition> hasProperty("className", equalTo("fqnTwo"));
  assertThat(eventCaptor.getValue().getInstrumentationDefinitions(), hasItems(matcherOne, matcherTwo));
  verifyNoMoreInteractions(instrumentationService, eventPublisher);
  verifyZeroInteractions(environment);
}
origin: inspectIT/inspectIT

  @Test
  public void unknownPlatformId() throws Exception {
    when(definition.getClassName()).thenReturn("class.one");
    ClassInstrumentationChangedEvent event = new ClassInstrumentationChangedEvent(this, 10L, Arrays.asList(definition));
    messageGate.onApplicationEvent(event);
    messageGate.clear(20L);
    verifyZeroInteractions(messageProvider);
    assertThat(getDefinitionBuffer().get(10L).entrySet(), hasSize(1));
  }
}
origin: inspectIT/inspectIT

@Test
public void removedAssignment() throws RemoteException, BusinessException {
  Collection<ClassType> types = Collections.singleton(classType);
  doReturn(instrumentationApplier).when(configurationResolver).getInstrumentationApplier(sensorAssignment, environment);
  doReturn(types).when(classCacheSearchNarrower).narrowByClassSensorAssignment(classCache, sensorAssignment);
  doReturn(types).when(instrumentationService).removeInstrumentationPoints(eq(types), Matchers.<Collection<IInstrumentationApplier>> any());
  doReturn(Collections.singletonList(sensorAssignment)).when(event).getRemovedSensorAssignments(functionalAssignmentFactory);
  job.setEnvironmentUpdateEvent(event);
  job.run();
  verify(configurationHolder, times(1)).update(updateEnvironment, PLATFORM_ID);
  verify(instrumentationService, times(1)).removeInstrumentationPoints(types, Collections.singleton(instrumentationApplier));
  ArgumentCaptor<Collection> captor = ArgumentCaptor.forClass(Collection.class);
  Collection<IInstrumentationApplier> appliers = configurationHolder.getInstrumentationAppliers();
  verify(instrumentationService, times(1)).addInstrumentationPoints(captor.capture(), eq(agentConfiguration), eq(appliers));
  assertThat((Collection<ClassType>) captor.getValue(), hasSize(1));
  assertThat(((Collection<ClassType>) captor.getValue()).iterator().next(), is(classType));
  ArgumentCaptor<ClassInstrumentationChangedEvent> eventCaptor = ArgumentCaptor.forClass(ClassInstrumentationChangedEvent.class);
  verify(eventPublisher).publishEvent(eventCaptor.capture());
  assertThat(eventCaptor.getValue().getAgentId(), is(equalTo(PLATFORM_ID)));
  assertThat(eventCaptor.getValue().getInstrumentationDefinitions(), contains(org.hamcrest.Matchers.<InstrumentationDefinition> hasProperty("className", equalTo("fqn"))));
  verifyNoMoreInteractions(eventPublisher);
  verifyZeroInteractions(environment, agentConfiguration);
}
origin: inspectIT/inspectIT

@Test
@SuppressWarnings("unchecked")
public void changeEventNoAgentStatusData() throws Exception {
  when(definitionOne.getClassName()).thenReturn("class.one");
  ClassInstrumentationChangedEvent eventOne = new ClassInstrumentationChangedEvent(this, 10L, Arrays.asList(definitionOne));
  when(agentStatusDataProvider.getAgentStatusDataMap()).thenReturn(Collections.EMPTY_MAP);
  messageGate.onApplicationEvent(eventOne);
  verify(agentStatusDataProvider).getAgentStatusDataMap();
  verifyNoMoreInteractions(agentStatusDataProvider);
  verifyZeroInteractions(statusData, messageProvider);
}
origin: inspectIT/inspectIT

@Test
public void removedAssignment() throws RemoteException {
  Collection<ClassType> types = ImmutableList.of(classTypeOne, classTypeTwo);
  doReturn(instrumentationApplier).when(configurationResolver).getInstrumentationApplier(sensorAssignment, environment);
  doReturn(types).when(classCacheSearchNarrower).narrowByClassSensorAssignment(classCache, sensorAssignment);
  doReturn(types).when(instrumentationService).removeInstrumentationPoints(eq(types), Matchers.<Collection<IInstrumentationApplier>> any());
  doReturn(Collections.singleton(sensorAssignment)).when(event).getRemovedSensorAssignments();
  job.setProfileUpdateEvent(event);
  job.run();
  ArgumentCaptor<Collection> captor = ArgumentCaptor.forClass(Collection.class);
  verify(instrumentationService, times(1)).removeInstrumentationPoints(eq(types), captor.capture());
  assertThat((Collection<IInstrumentationApplier>) captor.getValue(), hasSize(1));
  assertThat(((Collection<IInstrumentationApplier>) captor.getValue()).iterator().next(), is(instrumentationApplier));
  ArgumentCaptor<Collection> typeCaptor = ArgumentCaptor.forClass(Collection.class);
  verify(instrumentationService).getInstrumentationResults(typeCaptor.capture());
  assertThat((Collection<ClassType>) typeCaptor.getValue(), hasItems(classTypeOne, classTypeTwo));
  Collection<IInstrumentationApplier> appliers = configurationHolder.getInstrumentationAppliers();
  verify(instrumentationService, times(1)).addInstrumentationPoints(captor.capture(), eq(agentConfiguration), eq(appliers));
  assertThat((Collection<ClassType>) captor.getValue(), hasSize(2));
  assertThat(((Collection<ClassType>) captor.getValue()).iterator().next(), is(classTypeOne));
  ArgumentCaptor<ClassInstrumentationChangedEvent> eventCaptor = ArgumentCaptor.forClass(ClassInstrumentationChangedEvent.class);
  verify(eventPublisher).publishEvent(eventCaptor.capture());
  assertThat(eventCaptor.getValue().getAgentId(), is(equalTo(10L)));
  Matcher<InstrumentationDefinition> matcherOne = org.hamcrest.Matchers.<InstrumentationDefinition> hasProperty("className", equalTo("fqnOne"));
  Matcher<InstrumentationDefinition> matcherTwo = org.hamcrest.Matchers.<InstrumentationDefinition> hasProperty("className", equalTo("fqnTwo"));
  assertThat(eventCaptor.getValue().getInstrumentationDefinitions(), hasItems(matcherOne, matcherTwo));
  verifyNoMoreInteractions(instrumentationService, eventPublisher);
  verifyZeroInteractions(environment);
}
origin: inspectIT/inspectIT

@Test
public void successful() throws Exception {
  when(definition.getClassName()).thenReturn("class.one");
  ClassInstrumentationChangedEvent event = new ClassInstrumentationChangedEvent(this, 10L, Arrays.asList(definition));
  messageGate.onApplicationEvent(event);
  messageGate.clear(10L);
  verifyZeroInteractions(messageProvider);
  assertThat(getDefinitionBuffer().get(10L).entrySet(), hasSize(0));
}
origin: inspectIT/inspectIT

@Test
public void agentRegisteredEvent() throws Exception {
  when(definitionOne.getClassName()).thenReturn("class.one");
  ClassInstrumentationChangedEvent event = new ClassInstrumentationChangedEvent(this, 10L, Collections.singletonList(definitionOne));
  messageGate.onApplicationEvent(event);
  AgentRegisteredEvent registeredEvent = new AgentRegisteredEvent(this, 10L);
  messageGate.onApplicationEvent(registeredEvent);
  assertThat(getDefinitionBuffer().get(10L).entrySet(), hasSize(0));
}
origin: inspectIT/inspectIT

ClassInstrumentationChangedEvent event = new ClassInstrumentationChangedEvent(this, getAgentId(), instrumentationDefinitions);
eventPublisher.publishEvent(event);
origin: inspectIT/inspectIT

  @Test
  @SuppressWarnings("unchecked")
  public void unknownPlatformId() throws Exception {
    when(definition.getClassName()).thenReturn("class.one");
    ClassInstrumentationChangedEvent event = new ClassInstrumentationChangedEvent(this, 10L, Arrays.asList(definition));
    messageGate.onApplicationEvent(event);
    when(agentStatusDataProvider.getAgentStatusDataMap()).thenReturn(Collections.EMPTY_MAP);
    assertThat(getDefinitionBuffer().get(10L).entrySet(), hasSize(1));
    messageGate.flush(20L);
    verifyZeroInteractions(messageProvider);
    assertThat(getDefinitionBuffer().get(10L).entrySet(), hasSize(1));
  }
}
origin: inspectIT/inspectIT

@Test
public void agentDeletedEvent() throws Exception {
  when(definitionOne.getClassName()).thenReturn("class.one");
  ClassInstrumentationChangedEvent event = new ClassInstrumentationChangedEvent(this, 10L, Collections.singletonList(definitionOne));
  messageGate.onApplicationEvent(event);
  AgentDeletedEvent deletedEvent = new AgentDeletedEvent(this, 10L);
  messageGate.onApplicationEvent(deletedEvent);
  assertThat(getDefinitionBuffer().get(10L).entrySet(), hasSize(0));
}
origin: inspectIT/inspectIT

@Test
@SuppressWarnings("unchecked")
public void changeEventReplaceInstrumentationDefinition() throws Exception {
  when(definitionOne.getClassName()).thenReturn("class.one");
  when(definitionTwo.getClassName()).thenReturn("class.two");
  when(definitionThree.getClassName()).thenReturn("class.one");
  ClassInstrumentationChangedEvent eventOne = new ClassInstrumentationChangedEvent(this, 10L, Arrays.asList(definitionOne, definitionTwo));
  ClassInstrumentationChangedEvent eventTwo = new ClassInstrumentationChangedEvent(this, 10L, Arrays.asList(definitionThree));
  when(agentStatusDataProvider.getAgentStatusDataMap()).thenReturn(Collections.EMPTY_MAP);
  when(statusData.getInstrumentationStatus()).thenReturn(InstrumentationStatus.UP_TO_DATE, InstrumentationStatus.PENDING);
  messageGate.onApplicationEvent(eventOne);
  messageGate.onApplicationEvent(eventTwo);
  assertThat(getDefinitionBuffer().entrySet(), hasSize(1));
  assertThat(getDefinitionBuffer().get(10L).entrySet(), hasSize(2));
  assertThat(getDefinitionBuffer().get(10L), hasEntry("class.one", definitionThree));
  assertThat(getDefinitionBuffer().get(10L), hasEntry("class.two", definitionTwo));
}
origin: inspectIT/inspectIT

@Test
@SuppressWarnings("rawtypes")
public void successful() throws Exception {
  when(definition.getClassName()).thenReturn("class.one");
  ClassInstrumentationChangedEvent event = new ClassInstrumentationChangedEvent(this, 10L, Arrays.asList(definition));
  messageGate.onApplicationEvent(event);
  when(agentStatusDataProvider.getAgentStatusDataMap()).thenReturn(ImmutableMap.of(10L, statusData));
  when(statusData.getInstrumentationStatus()).thenReturn(InstrumentationStatus.PENDING);
  assertThat(getDefinitionBuffer().get(10L).entrySet(), hasSize(1));
  messageGate.flush(10L);
  ArgumentCaptor<IAgentMessage> messageCaptor = ArgumentCaptor.forClass(IAgentMessage.class);
  verify(messageProvider).provideMessage(eq(10L), messageCaptor.capture());
  verify(statusData).setInstrumentationStatus(InstrumentationStatus.UP_TO_DATE);
  verifyNoMoreInteractions(statusData, messageProvider);
  assertThat(((UpdatedInstrumentationMessage) messageCaptor.getValue()).getMessageContent(), contains(definition));
  assertThat(getDefinitionBuffer().get(10L).entrySet(), hasSize(0));
}
origin: inspectIT/inspectIT

@Test
@SuppressWarnings("unchecked")
public void changeEventAddInstrumentationDefinitionForDiffrentAgents() throws Exception {
  when(definitionOne.getClassName()).thenReturn("class.one");
  when(definitionTwo.getClassName()).thenReturn("class.two");
  when(definitionThree.getClassName()).thenReturn("class.one");
  ClassInstrumentationChangedEvent eventOne = new ClassInstrumentationChangedEvent(this, 10L, Arrays.asList(definitionOne, definitionTwo));
  ClassInstrumentationChangedEvent eventTwo = new ClassInstrumentationChangedEvent(this, 20L, Arrays.asList(definitionThree));
  when(agentStatusDataProvider.getAgentStatusDataMap()).thenReturn(Collections.EMPTY_MAP);
  when(statusData.getInstrumentationStatus()).thenReturn(InstrumentationStatus.UP_TO_DATE, InstrumentationStatus.PENDING);
  messageGate.onApplicationEvent(eventOne);
  messageGate.onApplicationEvent(eventTwo);
  assertThat(getDefinitionBuffer().entrySet(), hasSize(2));
  assertThat(getDefinitionBuffer().get(10L).entrySet(), hasSize(2));
  assertThat(getDefinitionBuffer().get(10L), hasEntry("class.one", definitionOne));
  assertThat(getDefinitionBuffer().get(10L), hasEntry("class.two", definitionTwo));
  assertThat(getDefinitionBuffer().get(20L).entrySet(), hasSize(1));
  assertThat(getDefinitionBuffer().get(20L), hasEntry("class.one", definitionThree));
}
origin: inspectIT/inspectIT

@Test
public void changeEventAddInstrumentationDefinitions() throws Exception {
  when(definitionOne.getClassName()).thenReturn("class.one");
  when(definitionTwo.getClassName()).thenReturn("class.two");
  when(definitionThree.getClassName()).thenReturn("class.three");
  ClassInstrumentationChangedEvent eventOne = new ClassInstrumentationChangedEvent(this, 10L, Arrays.asList(definitionOne, definitionTwo));
  ClassInstrumentationChangedEvent eventTwo = new ClassInstrumentationChangedEvent(this, 10L, Arrays.asList(definitionThree));
  when(agentStatusDataProvider.getAgentStatusDataMap()).thenReturn(ImmutableMap.of(10L, statusData));
  when(statusData.getInstrumentationStatus()).thenReturn(InstrumentationStatus.UP_TO_DATE, InstrumentationStatus.PENDING);
  long currentTime = System.currentTimeMillis();
  messageGate.onApplicationEvent(eventOne);
  messageGate.onApplicationEvent(eventTwo);
  verify(definitionOne).getClassName();
  verify(definitionTwo).getClassName();
  verify(definitionThree).getClassName();
  verify(agentStatusDataProvider, times(2)).getAgentStatusDataMap();
  verify(statusData, times(2)).getInstrumentationStatus();
  verify(statusData).setInstrumentationStatus(InstrumentationStatus.PENDING);
  ArgumentCaptor<Long> timeCaptor = ArgumentCaptor.forClass(Long.class);
  verify(statusData).setPendingSinceTime(timeCaptor.capture());
  verifyNoMoreInteractions(definitionOne, definitionTwo, definitionThree, agentStatusDataProvider, statusData);
  verifyZeroInteractions(messageProvider);
  assertThat(timeCaptor.getValue(), greaterThanOrEqualTo(currentTime));
  assertThat(getDefinitionBuffer().entrySet(), hasSize(1));
  assertThat(getDefinitionBuffer().get(10L).entrySet(), hasSize(3));
  assertThat(getDefinitionBuffer().get(10L), hasEntry("class.one", definitionOne));
  assertThat(getDefinitionBuffer().get(10L), hasEntry("class.two", definitionTwo));
  assertThat(getDefinitionBuffer().get(10L), hasEntry("class.three", definitionThree));
}
rocks.inspectit.server.ci.eventClassInstrumentationChangedEvent

Javadoc

Class representing the event when the instrumentation of classes have been changed.

Most used methods

  • <init>
    Default constructor for the event.
  • getAgentId
    Gets #agentId.
  • getInstrumentationDefinitions
    Gets #instrumentationDefinitions.

Popular in Java

  • Running tasks concurrently on multiple threads
  • addToBackStack (FragmentTransaction)
  • scheduleAtFixedRate (Timer)
  • notifyDataSetChanged (ArrayAdapter)
  • Component (java.awt)
    A component is an object having a graphical representation that can be displayed on the screen and t
  • FileOutputStream (java.io)
    An output stream that writes bytes to a file. If the output file exists, it can be replaced or appen
  • Random (java.util)
    This class provides methods that return pseudo-random values.It is dangerous to seed Random with the
  • UUID (java.util)
    UUID is an immutable representation of a 128-bit universally unique identifier (UUID). There are mul
  • ConcurrentHashMap (java.util.concurrent)
    A plug-in replacement for JDK1.5 java.util.concurrent.ConcurrentHashMap. This version is based on or
  • JFileChooser (javax.swing)
  • Top PhpStorm plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now