Codota Logo
ProfileUpdateEvent
Code IndexAdd Codota to your IDE (free)

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

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

  • Add the Codota plugin to your IDE and get smart completions
private void myMethod () {
LocalDateTime l =
  • Codota Iconnew LocalDateTime()
  • Codota IconLocalDateTime.now()
  • Codota IconDateTimeFormatter formatter;String text;formatter.parseLocalDateTime(text)
  • Smart code suggestions by Codota
}
origin: inspectIT/inspectIT

/**
 * Notifies listeners about profile update.
 *
 * @param old
 *            Old profile instance.
 * @param updated
 *            Updated profile instance.
 */
private void publishProfileUpdateEvent(Profile old, Profile updated) {
  ProfileUpdateEvent profileUpdateEvent = new ProfileUpdateEvent(this, old, updated);
  eventPublisher.publishEvent(profileUpdateEvent);
}
origin: inspectIT/inspectIT

/**
 * {@inheritDoc}
 */
@Override
protected Collection<ImmutableType> execute() {
  // always update configuration
  getConfigurationHolder().update(getEnvironment(), getAgentId());
  Collection<ImmutableType> changedClassTypes = new HashSet<>();
  // first process all removed and added assignments
  changedClassTypes.addAll(super.processRemovedAssignments(profileUpdateEvent.getRemovedSensorAssignments()));
  changedClassTypes.addAll(super.processAddedAssignments(profileUpdateEvent.getAddedSensorAssignments()));
  return changedClassTypes;
}
origin: inspectIT/inspectIT

@Test
public void emptyCacheMap() {
  when(event.isProfileActive()).thenReturn(true);
  when(event.getProfileId()).thenReturn("id_1");
  eventListener.onApplicationEvent(event);
  verify(event).isProfileActive();
  verify(nextGenInstrumentationManager).getAgentCacheMap();
  verifyNoMoreInteractions(event, nextGenInstrumentationManager);
  verifyZeroInteractions(cacheEntry, configurationHolder, environment, updateJob, future, objectFactory, executor);
}
origin: inspectIT/inspectIT

/**
 * Returns all {@link AbstractClassSensorAssignment} that are "added" as result of this update.
 * If profile was activated then it means that all assignments after the update are considered
 * for adding.
 *
 * @return Returns all {@link AbstractClassSensorAssignment} that are "removed".
 */
public Collection<AbstractClassSensorAssignment<?>> getAddedSensorAssignments() {
  if (isProfileDeactivated()) {
    // if it was deactivated then nothing is for adding
    return Collections.emptyList();
  } else if (isProfileActivated()) {
    // if activated then we consider all new assignment to be for adding
    return getAllSensorAssignments(after);
  } else {
    // otherwise find the difference
    return getAssignmentsDifference(after, before);
  }
}
origin: inspectIT/inspectIT

@Test
public void profileNotActive() {
  cacheMap.put(1L, cacheEntry);
  eventListener.onApplicationEvent(event);
  verify(event).isProfileActive();
  verify(event).isProfileDeactivated();
  verifyNoMoreInteractions(event);
  verifyZeroInteractions(cacheEntry, configurationHolder, environment, updateJob, future, nextGenInstrumentationManager, objectFactory, executor);
}
origin: inspectIT/inspectIT

@Test
public void noChange() {
  when(old.getId()).thenReturn(ID);
  when(updated.getId()).thenReturn(ID);
  doReturn(Collections.singletonList(assignment)).when(oldProfileData).getData(SensorAssignmentProfileData.class);
  doReturn(Collections.singletonList(assignment)).when(updatedProfileData).getData(SensorAssignmentProfileData.class);
  when(old.isActive()).thenReturn(true);
  when(updated.isActive()).thenReturn(true);
  ProfileUpdateEvent event = new ProfileUpdateEvent(this, old, updated);
  Collection<AbstractClassSensorAssignment<?>> added = event.getAddedSensorAssignments();
  assertThat(added, is(empty()));
}
origin: inspectIT/inspectIT

@Test
public void activated() {
  when(old.getId()).thenReturn(ID);
  when(updated.getId()).thenReturn(ID);
  doReturn(Collections.singletonList(assignment)).when(oldProfileData).getData(SensorAssignmentProfileData.class);
  doReturn(Collections.singletonList(assignment)).when(updatedProfileData).getData(SensorAssignmentProfileData.class);
  when(old.isActive()).thenReturn(false);
  when(updated.isActive()).thenReturn(true);
  ProfileUpdateEvent event = new ProfileUpdateEvent(this, old, updated);
  Collection<AbstractClassSensorAssignment<?>> removed = event.getRemovedSensorAssignments();
  assertThat(removed, is(empty()));
}
origin: inspectIT/inspectIT

public void onApplicationEvent(ProfileUpdateEvent event) {
  if (!event.isProfileActive() && !event.isProfileDeactivated()) {
    return;
    if (CollectionUtils.isEmpty(environment.getProfileIds()) || !environment.getProfileIds().contains(event.getProfileId())) {
      continue;
origin: inspectIT/inspectIT

  @Test
  public void stillActive() {
    when(old.getId()).thenReturn(ID);
    when(updated.getId()).thenReturn(ID);
    when(old.isActive()).thenReturn(true);
    when(updated.isActive()).thenReturn(true);
    ProfileUpdateEvent event = new ProfileUpdateEvent(this, old, updated);
    boolean deactivated = event.isProfileDeactivated();
    assertThat(deactivated, is(false));
  }
}
origin: inspectIT/inspectIT

@Test
public void wasActive() {
  when(old.getId()).thenReturn(ID);
  when(updated.getId()).thenReturn(ID);
  when(old.isActive()).thenReturn(true);
  when(updated.isActive()).thenReturn(true);
  ProfileUpdateEvent event = new ProfileUpdateEvent(this, old, updated);
  boolean activated = event.isProfileActivated();
  assertThat(activated, is(false));
}
origin: inspectIT/inspectIT

  @Test
  public void removedAssignmentNoChange() throws RemoteException {
    Collection<ClassType> types = ImmutableList.of(classTypeOne, classTypeTwo);
    doReturn(instrumentationApplier).when(configurationResolver).getInstrumentationApplier(sensorAssignment, environment);
    doReturn(types).when(classCacheSearchNarrower).narrowByClassSensorAssignment(classCache, sensorAssignment);
    doReturn(Collections.emptyList()).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));
    verifyNoMoreInteractions(instrumentationService);
    verifyZeroInteractions(environment, eventPublisher);
  }
}
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

/**
 * Finds {@link AbstractClassSensorAssignment}s that exists in first profile and not in the
 * second one.
 *
 * @param p1
 *            First profile
 * @param p2
 *            Second profile
 * @return {@link AbstractClassSensorAssignment}s that exists in first profile and not in the
 *         second one.
 */
private Collection<AbstractClassSensorAssignment<?>> getAssignmentsDifference(Profile p1, Profile p2) {
  Collection<AbstractClassSensorAssignment<?>> results1 = getAllSensorAssignments(p1);
  Collection<AbstractClassSensorAssignment<?>> results2 = getAllSensorAssignments(p2);
  return CollectionSubtractUtils.subtractSafe(results1, results2);
}
origin: inspectIT/inspectIT

@Test
public void deactivated() {
  when(old.getId()).thenReturn(ID);
  when(updated.getId()).thenReturn(ID);
  doReturn(Collections.singletonList(assignment)).when(oldProfileData).getData(SensorAssignmentProfileData.class);
  doReturn(Collections.singletonList(assignment)).when(updatedProfileData).getData(SensorAssignmentProfileData.class);
  when(old.isActive()).thenReturn(true);
  when(updated.isActive()).thenReturn(false);
  ProfileUpdateEvent event = new ProfileUpdateEvent(this, old, updated);
  Collection<AbstractClassSensorAssignment<?>> added = event.getAddedSensorAssignments();
  assertThat(added, is(empty()));
}
origin: inspectIT/inspectIT

@Test
public void noChange() {
  when(old.getId()).thenReturn(ID);
  when(updated.getId()).thenReturn(ID);
  doReturn(Collections.singletonList(assignment)).when(oldProfileData).getData(SensorAssignmentProfileData.class);
  doReturn(Collections.singletonList(assignment)).when(updatedProfileData).getData(SensorAssignmentProfileData.class);
  when(old.isActive()).thenReturn(true);
  when(updated.isActive()).thenReturn(true);
  ProfileUpdateEvent event = new ProfileUpdateEvent(this, old, updated);
  Collection<AbstractClassSensorAssignment<?>> removed = event.getRemovedSensorAssignments();
  assertThat(removed, is(empty()));
}
origin: inspectIT/inspectIT

/**
 * Returns all {@link AbstractClassSensorAssignment} that are "removed" as result of this
 * update. If profile was deactivated then it means that all assignments before the update are
 * considered for removal.
 *
 * @return Returns all {@link AbstractClassSensorAssignment} that are "removed".
 */
public Collection<AbstractClassSensorAssignment<?>> getRemovedSensorAssignments() {
  if (isProfileDeactivated()) {
    // if deactivated then we consider all old assignment to be for removal
    return getAllSensorAssignments(before);
  } else if (isProfileActivated()) {
    // if it was activated then nothing is for removal
    return Collections.emptyList();
  } else {
    // otherwise find the difference
    return getAssignmentsDifference(before, after);
  }
}
origin: inspectIT/inspectIT

@Test
@SuppressWarnings({ "unchecked", "rawtypes" })
public void profileWasDeactivated() throws InterruptedException, ExecutionException, TimeoutException {
  cacheMap.put(1L, cacheEntry);
  when(event.isProfileDeactivated()).thenReturn(true);
  when(event.getProfileId()).thenReturn("id_1");
  when(configurationHolder.isInitialized()).thenReturn(true);
  when(environment.getProfileIds()).thenReturn(Sets.newHashSet("id_1"));
  when(objectFactory.getObject()).thenReturn(updateJob);
  when(executor.submit(updateJob)).thenReturn((Future) future);
  eventListener.onApplicationEvent(event);
  verify(event).isProfileActive();
  verify(event).isProfileDeactivated();
  verify(event).getProfileId();
  verify(nextGenInstrumentationManager).getAgentCacheMap();
  verify(cacheEntry).getConfigurationHolder();
  verify(configurationHolder).getEnvironment();
  verify(configurationHolder).isInitialized();
  verify(environment, times(2)).getProfileIds();
  verify(objectFactory).getObject();
  verify(executor).submit(updateJob);
  verify(updateJob).setAgentCacheEntry(cacheEntry);
  verify(updateJob).setProfileUpdateEvent(event);
  verify(future).get(1L, TimeUnit.MINUTES);
  verifyNoMoreInteractions(event, cacheEntry, configurationHolder, environment, updateJob, future, nextGenInstrumentationManager, objectFactory, executor);
}
origin: inspectIT/inspectIT

@Test
public void deactivated() {
  when(old.getId()).thenReturn(ID);
  when(updated.getId()).thenReturn(ID);
  when(old.isActive()).thenReturn(true);
  when(updated.isActive()).thenReturn(false);
  ProfileUpdateEvent event = new ProfileUpdateEvent(this, old, updated);
  boolean deactivated = event.isProfileDeactivated();
  assertThat(deactivated, is(true));
}
origin: inspectIT/inspectIT

  @Test
  public void stillNotActive() {
    when(old.getId()).thenReturn(ID);
    when(updated.getId()).thenReturn(ID);
    when(old.isActive()).thenReturn(false);
    when(updated.isActive()).thenReturn(false);
    ProfileUpdateEvent event = new ProfileUpdateEvent(this, old, updated);
    boolean activated = event.isProfileActivated();
    assertThat(activated, is(false));
  }
}
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);
}
rocks.inspectit.server.ci.eventProfileUpdateEvent

Javadoc

Event that signals that an Profile has been updated via CI.

Most used methods

  • <init>
    Default constructor.
  • getAddedSensorAssignments
    Returns all AbstractClassSensorAssignment that are "added" as result of this update. If profile was
  • getProfileId
    Returns id of the profile being updated.
  • getRemovedSensorAssignments
    Returns all AbstractClassSensorAssignment that are "removed" as result of this update. If profile wa
  • isProfileActivated
    If profile was activated as the result of the update action.
  • isProfileActive
    Returns if the profile is active.
  • isProfileDeactivated
    If profile was deactivated as the result of the update action.
  • getAllSensorAssignments
    Returns all AbstractClassSensorAssignments from the profile.
  • getAssignmentsDifference
    Finds AbstractClassSensorAssignments that exists in first profile and not in the second one.

Popular in Java

  • Reactive rest calls using spring rest template
  • orElseThrow (Optional)
    Return the contained value, if present, otherwise throw an exception to be created by the provided s
  • getSystemService (Context)
  • scheduleAtFixedRate (Timer)
    Schedules the specified task for repeated fixed-rate execution, beginning after the specified delay.
  • Component (java.awt)
    A component is an object having a graphical representation that can be displayed on the screen and t
  • Menu (java.awt)
  • InputStream (java.io)
    A readable source of bytes.Most clients will use input streams that read data from the file system (
  • RandomAccessFile (java.io)
    Allows reading from and writing to a file in a random-access manner. This is different from the uni-
  • Properties (java.util)
    The Properties class represents a persistent set of properties. The Properties can be saved to a st
  • Project (org.apache.tools.ant)
    Central representation of an Ant project. This class defines an Ant project with all of its targets,
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