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

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

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

  • Add the Codota plugin to your IDE and get smart completions
private void myMethod () {
BufferedReader b =
  • Codota IconInputStream in;new BufferedReader(new InputStreamReader(in))
  • Codota IconReader in;new BufferedReader(in)
  • Codota IconFile file;new BufferedReader(new FileReader(file))
  • Smart code suggestions by Codota
}
origin: inspectIT/inspectIT

/**
 * Notifies listeners about environment update.
 *
 * @param old
 *            Old environment instance.
 * @param updated
 *            Updated environment instance.
 */
private void publishEnvironmentUpdateEvent(Environment old, Environment updated) {
  Collection<Profile> removedProfiles = getProfileDifference(old, updated);
  Collection<Profile> addedProfiles = getProfileDifference(updated, old);
  EnvironmentUpdateEvent event = new EnvironmentUpdateEvent(this, old, updated, addedProfiles, removedProfiles);
  eventPublisher.publishEvent(event);
}
origin: inspectIT/inspectIT

/**
 * {@inheritDoc}
 */
@Override
protected Collection<ImmutableType> execute() {
  // always update with new Environment
  getConfigurationHolder().update(environmentUpdateEvent.getAfter(), getAgentId());
  Collection<ImmutableType> changedClassTypes = new HashSet<>();
  // then process removed and added assignments
  changedClassTypes.addAll(super.processRemovedAssignments(environmentUpdateEvent.getRemovedSensorAssignments(functionalAssignmentFactory)));
  changedClassTypes.addAll(super.processAddedAssignments(environmentUpdateEvent.getAddedSensorAssignments(functionalAssignmentFactory)));
  return changedClassTypes;
}
origin: inspectIT/inspectIT

/**
 * Returns all {@link AbstractClassSensorAssignment} that are contained in the added profiles.
 * Only active profiles are taken into account. Also includes the functional assignments that
 * might be added as the result of changes in the environment.
 *
 * @param functionalAssignmentFactory
 *            SpecialMethodSensorAssignmentFactory for resolving functional assignment updates.
 *
 * @return Returns all {@link AbstractClassSensorAssignment} that are "added".
 */
public Collection<AbstractClassSensorAssignment<?>> getAddedSensorAssignments(SpecialMethodSensorAssignmentFactory functionalAssignmentFactory) {
  Collection<AbstractClassSensorAssignment<?>> addedAssignments = getSensorAssignments(addedProfiles);
  addedAssignments.addAll(getFunctionalAssignmentsDifference(functionalAssignmentFactory, after, before));
  return addedAssignments;
}
origin: inspectIT/inspectIT

@Test
public void profileRemoved() {
  when(old.getId()).thenReturn(ID);
  when(updated.getId()).thenReturn(ID);
  AbstractClassSensorAssignment<?> assignment = mock(AbstractClassSensorAssignment.class);
  doReturn(Collections.singletonList(assignment)).when(profileData).getData(SensorAssignmentProfileData.class);
  when(profile.isActive()).thenReturn(true);
  EnvironmentUpdateEvent event = new EnvironmentUpdateEvent(this, old, updated, null, Collections.singletonList(profile));
  Collection<AbstractClassSensorAssignment<?>> removed = event.getRemovedSensorAssignments(functionalAssignmentFactory);
  assertThat(removed, hasSize(1));
  assertThat(removed, hasItem(assignment));
}
origin: inspectIT/inspectIT

@Test
public void profileAdded() {
  when(old.getId()).thenReturn(ID);
  when(updated.getId()).thenReturn(ID);
  AbstractClassSensorAssignment<?> assignment = mock(AbstractClassSensorAssignment.class);
  doReturn(Collections.singletonList(assignment)).when(profileData).getData(SensorAssignmentProfileData.class);
  when(profile.isActive()).thenReturn(true);
  EnvironmentUpdateEvent event = new EnvironmentUpdateEvent(this, old, updated, Collections.singletonList(profile), null);
  Collection<AbstractClassSensorAssignment<?>> added = event.getAddedSensorAssignments(functionalAssignmentFactory);
  assertThat(added, hasSize(1));
  assertThat(added, hasItem(assignment));
}
origin: inspectIT/inspectIT

@Test
public void environmentsAreNotEqual() {
  cacheMap.put(1L, cacheEntry);
  when(configurationHolder.isInitialized()).thenReturn(true);
  when(environment.getId()).thenReturn("id");
  when(event.getEnvironmentId()).thenReturn("otherId");
  eventListener.onApplicationEvent(event);
  verify(nextGenInstrumentationManager).getAgentCacheMap();
  verify(cacheEntry).getConfigurationHolder();
  verify(configurationHolder).isInitialized();
  verify(configurationHolder).getEnvironment();
  verify(environment).getId();
  verify(event).getEnvironmentId();
  verifyNoMoreInteractions(nextGenInstrumentationManager, cacheEntry, configurationHolder, environment, event);
  verifyZeroInteractions(objectFactory, updateJob, executor, future);
}
origin: inspectIT/inspectIT

  @Test
  public void removedAssignmentNoChange() {
    Collection<ClassType> types = Collections.singleton(classType);
    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.singletonList(sensorAssignment)).when(event).getRemovedSensorAssignments(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)).removeInstrumentationPoints(types, Collections.singleton(instrumentationApplier));
    verifyNoMoreInteractions(instrumentationService);
    verifyZeroInteractions(environment, agentConfiguration, eventPublisher);
  }
}
origin: inspectIT/inspectIT

@BeforeMethod
public void setup() throws Exception {
  when(configurationHolder.getAgentConfiguration()).thenReturn(agentConfiguration);
  when(configurationHolder.getEnvironment()).thenReturn(environment);
  when(configurationHolder.getInstrumentationAppliers()).thenReturn(Collections.singletonList(holdedInstrumentationApplier));
  when(agentCacheEntry.getConfigurationHolder()).thenReturn(configurationHolder);
  when(agentCacheEntry.getClassCache()).thenReturn(classCache);
  when(agentCacheEntry.getId()).thenReturn(PLATFORM_ID);
  when(classCache.getInstrumentationService()).thenReturn(instrumentationService);
  when(classType.isClass()).thenReturn(true);
  when(classType.castToClass()).thenReturn(immutableClassType);
  when(classType.getFQN()).thenReturn("fqn");
  when(event.getAfter()).thenReturn(updateEnvironment);
}
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

EnvironmentUpdateEvent event = (EnvironmentUpdateEvent) captor.getValue();
assertThat(event.getAddedProfiles(), hasSize(1));
assertThat(event.getAddedProfiles(), hasItem(profile2));
assertThat(event.getRemovedProfiles(), hasSize(1));
assertThat(event.getRemovedProfiles(), hasItem(profile1));
origin: inspectIT/inspectIT

@Test
public void functionalNoChange() {
  when(old.getId()).thenReturn(ID);
  when(updated.getId()).thenReturn(ID);
  SpecialMethodSensorAssignment functionalAssignment = mock(SpecialMethodSensorAssignment.class);
  when(functionalAssignmentFactory.getSpecialAssignments(old)).thenReturn(Collections.singletonList(functionalAssignment));
  when(functionalAssignmentFactory.getSpecialAssignments(updated)).thenReturn(Collections.singletonList(functionalAssignment));
  EnvironmentUpdateEvent event = new EnvironmentUpdateEvent(this, old, updated, null, null);
  Collection<AbstractClassSensorAssignment<?>> removed = event.getRemovedSensorAssignments(functionalAssignmentFactory);
  assertThat(removed, is(empty()));
}
origin: inspectIT/inspectIT

@Test
public void profileRemovedNotActive() {
  when(old.getId()).thenReturn(ID);
  when(updated.getId()).thenReturn(ID);
  AbstractClassSensorAssignment<?> assignment = mock(AbstractClassSensorAssignment.class);
  doReturn(Collections.singletonList(assignment)).when(profileData).getData(SensorAssignmentProfileData.class);
  when(profile.isActive()).thenReturn(false);
  EnvironmentUpdateEvent event = new EnvironmentUpdateEvent(this, old, updated, Collections.singletonList(profile), null);
  Collection<AbstractClassSensorAssignment<?>> added = event.getAddedSensorAssignments(functionalAssignmentFactory);
  assertThat(added, is(empty()));
}
origin: inspectIT/inspectIT

if (!Objects.equals(environment.getId(), event.getEnvironmentId())) {
  continue;
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
public void functionalRemoved() {
  when(old.getId()).thenReturn(ID);
  when(updated.getId()).thenReturn(ID);
  SpecialMethodSensorAssignment functionalAssignment = mock(SpecialMethodSensorAssignment.class);
  when(functionalAssignmentFactory.getSpecialAssignments(old)).thenReturn(Collections.singletonList(functionalAssignment));
  when(functionalAssignmentFactory.getSpecialAssignments(updated)).thenReturn(Collections.<SpecialMethodSensorAssignment> emptyList());
  EnvironmentUpdateEvent event = new EnvironmentUpdateEvent(this, old, updated, null, null);
  Collection<AbstractClassSensorAssignment<?>> removed = event.getRemovedSensorAssignments(functionalAssignmentFactory);
  assertThat(removed, hasSize(1));
  assertThat(removed, hasItem(functionalAssignment));
}
origin: inspectIT/inspectIT

@Test
public void functionalNoChange() {
  when(old.getId()).thenReturn(ID);
  when(updated.getId()).thenReturn(ID);
  SpecialMethodSensorAssignment functionalAssignment = mock(SpecialMethodSensorAssignment.class);
  when(functionalAssignmentFactory.getSpecialAssignments(old)).thenReturn(Collections.singletonList(functionalAssignment));
  when(functionalAssignmentFactory.getSpecialAssignments(updated)).thenReturn(Collections.singletonList(functionalAssignment));
  EnvironmentUpdateEvent event = new EnvironmentUpdateEvent(this, old, updated, null, null);
  Collection<AbstractClassSensorAssignment<?>> added = event.getAddedSensorAssignments(functionalAssignmentFactory);
  assertThat(added, is(empty()));
}
origin: inspectIT/inspectIT

@Test
@SuppressWarnings({ "unchecked", "rawtypes" })
public void successful() throws InterruptedException, ExecutionException, TimeoutException {
  cacheMap.put(1L, cacheEntry);
  when(configurationHolder.isInitialized()).thenReturn(true);
  when(environment.getId()).thenReturn("id");
  when(event.getEnvironmentId()).thenReturn("id");
  when(objectFactory.getObject()).thenReturn(updateJob);
  when(executor.submit(updateJob)).thenReturn((Future) future);
  eventListener.onApplicationEvent(event);
  verify(nextGenInstrumentationManager).getAgentCacheMap();
  verify(cacheEntry).getConfigurationHolder();
  verify(configurationHolder).isInitialized();
  verify(configurationHolder).getEnvironment();
  verify(environment).getId();
  verify(event).getEnvironmentId();
  verify(objectFactory).getObject();
  verify(updateJob).setAgentCacheEntry(cacheEntry);
  verify(updateJob).setEnvironmentUpdateEvent(event);
  verify(executor).submit(updateJob);
  verify(future).get(1, TimeUnit.MINUTES);
  verifyNoMoreInteractions(nextGenInstrumentationManager, cacheEntry, configurationHolder, environment, event, objectFactory, updateJob, executor, future);
}
origin: inspectIT/inspectIT

  @Test(expectedExceptions = IllegalArgumentException.class)
  public void idsNotMatching() {
    when(updated.getId()).thenReturn(ID);
    when(old.getId()).thenReturn("smth");
    new EnvironmentUpdateEvent(this, old, updated, null, null);
  }
}
origin: inspectIT/inspectIT

/**
 * Returns all {@link AbstractClassSensorAssignment} that are contained in the removed profiles.
 * Only active profiles are taken into account. Also includes the functional assignments that
 * might be removed as the result of changes in the environment.
 *
 * @param functionalAssignmentFactory
 *            SpecialMethodSensorAssignmentFactory for resolving functional assignment updates.
 *
 * @return Returns all {@link AbstractClassSensorAssignment} that are "removed".
 */
public Collection<AbstractClassSensorAssignment<?>> getRemovedSensorAssignments(SpecialMethodSensorAssignmentFactory functionalAssignmentFactory) {
  Collection<AbstractClassSensorAssignment<?>> removedAssignments = getSensorAssignments(removedProfiles);
  removedAssignments.addAll(getFunctionalAssignmentsDifference(functionalAssignmentFactory, before, after));
  return removedAssignments;
}
origin: inspectIT/inspectIT

@Test
public void profileRemovedNotActive() {
  when(old.getId()).thenReturn(ID);
  when(updated.getId()).thenReturn(ID);
  AbstractClassSensorAssignment<?> assignment = mock(AbstractClassSensorAssignment.class);
  doReturn(Collections.singletonList(assignment)).when(profileData).getData(SensorAssignmentProfileData.class);
  when(profile.isActive()).thenReturn(false);
  EnvironmentUpdateEvent event = new EnvironmentUpdateEvent(this, old, updated, null, Collections.singletonList(profile));
  Collection<AbstractClassSensorAssignment<?>> removed = event.getRemovedSensorAssignments(functionalAssignmentFactory);
  assertThat(removed, is(empty()));
}
rocks.inspectit.server.ci.eventEnvironmentUpdateEvent

Javadoc

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

Most used methods

  • <init>
    Default constructor.
  • getAddedSensorAssignments
    Returns all AbstractClassSensorAssignment that are contained in the added profiles. Only active prof
  • getAfter
    Gets #after.
  • getEnvironmentId
    Returns id of the environment being updated.
  • getRemovedSensorAssignments
    Returns all AbstractClassSensorAssignment that are contained in the removed profiles. Only active pr
  • getAddedProfiles
    Gets #addedProfiles.
  • getFunctionalAssignmentsDifference
    Returns the difference from the Functional assignments for the two environments. The resulting colle
  • getRemovedProfiles
    Gets #removedProfiles.
  • getSensorAssignments
    Collects all AbstractClassSensorAssignments from the given profiles. If profile is not active assign

Popular in Java

  • Creating JSON documents from java classes using gson
  • getSharedPreferences (Context)
  • onRequestPermissionsResult (Fragment)
  • putExtra (Intent)
  • ObjectMapper (com.fasterxml.jackson.databind)
    This mapper (or, data binder, or codec) provides functionality for converting between Java objects (
  • Iterator (java.util)
    An iterator over a collection. Iterator takes the place of Enumeration in the Java Collections Frame
  • List (java.util)
    A List is a collection which maintains an ordering for its elements. Every element in the List has a
  • Handler (java.util.logging)
    A Handler object accepts a logging request and exports the desired messages to a target, for example
  • Filter (javax.servlet)
    A filter is an object that performs filtering tasks on either the request to a resource (a servlet o
  • Base64 (org.apache.commons.codec.binary)
    Provides Base64 encoding and decoding as defined by RFC 2045.This class implements section 6.8. Base
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