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

How to use
ConfigurationHolder
in
rocks.inspectit.server.instrumentation.config

Best Java code snippets using rocks.inspectit.server.instrumentation.config.ConfigurationHolder (Showing top 20 results out of 315)

  • Add the Codota plugin to your IDE and get smart completions
private void myMethod () {
Dictionary d =
  • Codota Iconnew Hashtable()
  • Codota IconBundle bundle;bundle.getHeaders()
  • Codota Iconnew Properties()
  • Smart code suggestions by Codota
}
origin: inspectIT/inspectIT

Environment cachedEnvironment = configurationHolder.getEnvironment();
if (configurationHolder.isInitialized() && Objects.equals(environment, cachedEnvironment)) {
  AgentConfig agentConfiguration = configurationHolder.getAgentConfiguration();
  Map<Collection<String>, InstrumentationDefinition> initial = classCache.getInstrumentationService().getInstrumentationResultsWithHashes();
  agentConfiguration.setInitialInstrumentationResults(initial);
configurationHolder.update(environment, id);
return configurationHolder.getAgentConfiguration();
origin: inspectIT/inspectIT

if (!configurationHolder.isInitialized()) {
  return Collections.emptyList();
Collection<JmxMonitoringApplier> jmxMonitoringAppliers = configurationHolder.getJmxMonitoringAppliers();
if (CollectionUtils.isEmpty(jmxMonitoringAppliers)) {
  return Collections.emptyList();
for (JmxAttributeDescriptor descriptor : attributeDescriptors) {
  for (JmxMonitoringApplier applier : jmxMonitoringAppliers) {
    if (applier.addMonitoringPoint(configurationHolder.getAgentConfiguration(), descriptor)) {
      results.add(descriptor);
      break;
origin: inspectIT/inspectIT

@Test
public void noEnvironment() {
  when(configurationHolder.isInitialized()).thenReturn(false);
  job.setEnvironment(null);
  job.run();
  verify(instrumentationService, times(1)).removeInstrumentationPoints();
  verify(configurationHolder, times(1)).update(null, PLATFORM_ID);
  verifyNoMoreInteractions(instrumentationService, eventPublisher);
}
origin: inspectIT/inspectIT

@Test
public void update() {
  long platformId = 11;
  Environment environment = mock(Environment.class);
  AgentConfig configuration = mock(AgentConfig.class);
  IInstrumentationApplier applier = mock(IInstrumentationApplier.class);
  JmxMonitoringApplier jmxApplier = mock(JmxMonitoringApplier.class);
  when(configurationCreator.environmentToConfiguration(environment, platformId)).thenReturn(configuration);
  when(configurationResolver.getInstrumentationAppliers(environment)).thenReturn(Collections.singleton(applier));
  when(configurationResolver.getJmxMonitoringAppliers(environment)).thenReturn(Collections.singleton(jmxApplier));
  holder.update(environment, platformId);
  assertThat(holder.isInitialized(), is(true));
  assertThat(holder.getEnvironment(), is(environment));
  assertThat(holder.getAgentConfiguration(), is(configuration));
  assertThat(holder.getInstrumentationAppliers(), hasSize(1));
  assertThat(holder.getInstrumentationAppliers(), hasItem(applier));
  assertThat(holder.getJmxMonitoringAppliers(), hasSize(1));
  assertThat(holder.getJmxMonitoringAppliers(), hasItem(jmxApplier));
  verify(configurationCreator).environmentToConfiguration(environment, platformId);
  verify(configurationResolver).getInstrumentationAppliers(environment);
  verify(configurationResolver).getJmxMonitoringAppliers(environment);
  verifyNoMoreInteractions(configurationCreator, configurationResolver);
}
origin: inspectIT/inspectIT

ConfigurationHolder configurationHolder = agentCacheEntry.getConfigurationHolder();
if (!configurationHolder.isInitialized()) {
  continue;
Environment environment = configurationHolder.getEnvironment();
if (!Objects.equals(environment.getId(), event.getEnvironmentId())) {
  continue;
origin: inspectIT/inspectIT

  @Test
  @SuppressWarnings({ "unchecked", "rawtypes" })
  public void yesEnvironment() {
    when(configurationHolder.isInitialized()).thenReturn(true);
    when(configurationHolder.getAgentConfiguration()).thenReturn(updateConfiguration);
    doReturn(Collections.singletonList(classType)).when(instrumentationService).addInstrumentationPoints(any(AgentConfig.class), any(Collection.class));

    job.setEnvironment(updateEnvironment);
    job.run();

    verify(instrumentationService, times(1)).removeInstrumentationPoints();
    verify(configurationHolder, times(1)).update(updateEnvironment, PLATFORM_ID);

    Collection<IInstrumentationApplier> appliers = configurationHolder.getInstrumentationAppliers();
    verify(instrumentationService, times(1)).addInstrumentationPoints(updateConfiguration, appliers);

    ArgumentCaptor<Collection> typeCaptor = ArgumentCaptor.forClass(Collection.class);
    verify(instrumentationService).getInstrumentationResults(typeCaptor.capture());
    assertThat((Collection<Type>) typeCaptor.getValue(), hasItems((Type) classType));

    verify(eventPublisher).publishEvent(any(ClassInstrumentationChangedEvent.class));

    verifyNoMoreInteractions(instrumentationService, updateConfiguration, updateEnvironment, 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 existingClassTypeInstrumented() throws BusinessException, ClassCacheModificationException {
  List<String> definedIPs = mock(List.class);
  String agentName = "agentName";
  String version = "v1";
  when(registrationService.registerPlatformIdent(definedIPs, agentName, version)).thenReturn(ID);
  manager.register(definedIPs, agentName, version);
  ClassType classType = mock(ClassType.class);
  when(classType.isClass()).thenReturn(true);
  when(classType.castToClass()).thenReturn(classType);
  when(lookupService.findByHash(HASH)).thenReturn(classType);
  when(configurationHolder.isInitialized()).thenReturn(true);
  AgentConfig configuration = mock(AgentConfig.class);
  Collection<IInstrumentationApplier> appliers = mock(Collection.class);
  InstrumentationDefinition instrumentationResult = mock(InstrumentationDefinition.class);
  when(configurationHolder.getAgentConfiguration()).thenReturn(configuration);
  when(configurationHolder.getInstrumentationAppliers()).thenReturn(appliers);
  when(instrumentationService.addAndGetInstrumentationResult(classType, configuration, appliers)).thenReturn(instrumentationResult);
  InstrumentationDefinition result = manager.analyze(ID, HASH, type);
  assertThat(result, is(instrumentationResult));
  verify(instrumentationService).addAndGetInstrumentationResult(classType, configuration, appliers);
  verifyNoMoreInteractions(instrumentationService);
  verifyZeroInteractions(modificationService);
}
origin: inspectIT/inspectIT

/**
 * {@inheritDoc}
 */
@Override
protected Collection<ImmutableType> execute() {
  Collection<ImmutableType> changedClassTypes = new HashSet<>();
  // add current instrumentation
  changedClassTypes.addAll(getClassCache().getLookupService().findInstrumentedTypes());
  // first remove all existing instrumentation points
  getClassCache().getInstrumentationService().removeInstrumentationPoints();
  // then update configuration holder
  ConfigurationHolder configurationHolder = getConfigurationHolder();
  configurationHolder.update(environment, getAgentId());
  // if we are initialized analyze the complete class cache
  if (configurationHolder.isInitialized()) {
    // then add instrumentation points
    Collection<IInstrumentationApplier> instrumentationAppliers = configurationHolder.getInstrumentationAppliers();
    Collection<? extends ImmutableClassType> instrumentedTypes = getClassCache().getInstrumentationService().addInstrumentationPoints(getAgentConfiguration(), instrumentationAppliers);
    changedClassTypes.addAll(instrumentedTypes);
  }
  return changedClassTypes;
}
origin: inspectIT/inspectIT

@Test
public void existingAgent() throws BusinessException {
  long id = 10;
  List<String> definedIPs = mock(List.class);
  String agentName = "agentName";
  String version = "v1";
  final AgentConfig configuration = mock(AgentConfig.class);
  Environment environment = mock(Environment.class);
  when(configurationResolver.getEnvironmentForAgent(definedIPs, agentName)).thenReturn(environment);
  when(registrationService.registerPlatformIdent(definedIPs, agentName, version)).thenReturn(id);
  when(configurationHolder.isInitialized()).thenReturn(true);
  when(configurationHolder.getEnvironment()).thenReturn(environment);
  when(configurationHolder.getAgentConfiguration()).thenReturn(configuration);
  Map<Collection<String>, InstrumentationDefinition> initialInstrumentations = mock(Map.class);
  when(instrumentationService.getInstrumentationResultsWithHashes()).thenReturn(initialInstrumentations);
  AgentConfig result = manager.register(definedIPs, agentName, version);
  assertThat(result, is(configuration));
  verify(configurationResolver).getEnvironmentForAgent(definedIPs, agentName);
  verify(registrationService).registerPlatformIdent(definedIPs, agentName, version);
  verify(configurationHolder).getEnvironment();
  verify(configurationHolder).getAgentConfiguration();
  verify(configurationHolder).isInitialized();
  verify(configuration).setInitialInstrumentationResults(initialInstrumentations);
  verify(configuration).setClassCacheExistsOnCmr(true);
  verify(classCache).getInstrumentationService();
  verify(instrumentationService).getInstrumentationResultsWithHashes();
  verifyNoMoreInteractions(configurationResolver, registrationService, configurationHolder, instrumentationService, classCache);
}
origin: inspectIT/inspectIT

  @Test
  public void notInitialziedWithoutEnvironment() {
    boolean initialized = holder.isInitialized();
    assertThat(initialized, is(false));
  }
}
origin: inspectIT/inspectIT

@Test
public void configurationHolderHasNoAppliers() throws BusinessException, ClassCacheModificationException {
  List<String> definedIPs = mock(List.class);
  String agentName = "agentName";
  String version = "v1";
  when(registrationService.registerPlatformIdent(definedIPs, agentName, version)).thenReturn(ID);
  manager.register(definedIPs, agentName, version);
  when(configurationHolder.isInitialized()).thenReturn(true);
  when(configurationHolder.getJmxMonitoringAppliers()).thenReturn(null);
  Collection<JmxAttributeDescriptor> toMonitor = manager.analyzeJmxAttributes(ID, Collections.singleton(descriptor));
  assertThat(toMonitor, is(empty()));
}
origin: inspectIT/inspectIT

@BeforeMethod
public void init() throws Exception {
  MockitoAnnotations.initMocks(this);
  job.log = LoggerFactory.getLogger(EnvironmentMappingUpdateJob.class);
  job.setAgentCacheEntry(agentCacheEntry);
  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(classCache.getLookupService()).thenReturn(lookupService);
  when(classType.isClass()).thenReturn(true);
  when(classType.castToClass()).thenReturn(immutableClassType);
}
origin: inspectIT/inspectIT

/**
 * @return Returns environment based on the {@link ConfigurationHolder}.
 */
protected Environment getEnvironment() {
  return getConfigurationHolder().getEnvironment();
}
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

/**
 * {@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

/**
 * @return Returns agent configuration based on the {@link ConfigurationHolder}.
 */
protected AgentConfig getAgentConfiguration() {
  return getConfigurationHolder().getAgentConfiguration();
}
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 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

@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(10L);
  when(classCache.getInstrumentationService()).thenReturn(instrumentationService);
  when(classTypeOne.isClass()).thenReturn(true);
  when(classTypeTwo.isClass()).thenReturn(true);
  when(classTypeOne.castToClass()).thenReturn(immutableClassTypeOne);
  when(classTypeTwo.castToClass()).thenReturn(immutableClassTypeTwo);
  when(immutableClassTypeOne.hasInstrumentationPoints()).thenReturn(true);
  when(immutableClassTypeOne.hasInstrumentationPoints()).thenReturn(false);
  when(classTypeOne.getFQN()).thenReturn("fqnOne");
  when(classTypeTwo.getFQN()).thenReturn("fqnTwo");
}
rocks.inspectit.server.instrumentation.configConfigurationHolder

Javadoc

Configuration holder joins together all relative information needed for the instrumentation of the specific class cache. The holder should be manager with the #update(Environment,long) method. When this is called the holder performs needed #agentConfiguration and #instrumentationAppliers updates.

Most used methods

  • getAgentConfiguration
    Gets #agentConfiguration.
  • getEnvironment
    Gets #environment.
  • getInstrumentationAppliers
    Gets #instrumentationAppliers.
  • getJmxMonitoringAppliers
    Gets #jmxMonitoringAppliers.
  • isInitialized
    Returns if the configuration in this holder is properly initialized.
  • update
    Updates the defined configuration in the holder with following tasks: 1. Creates the new #agentConfi

Popular in Java

  • Reactive rest calls using spring rest template
  • onRequestPermissionsResult (Fragment)
  • scheduleAtFixedRate (ScheduledExecutorService)
  • addToBackStack (FragmentTransaction)
  • Component (java.awt)
    A component is an object having a graphical representation that can be displayed on the screen and t
  • GridLayout (java.awt)
    The GridLayout class is a layout manager that lays out a container's components in a rectangular gri
  • EOFException (java.io)
    Thrown when a program encounters the end of a file or stream during an input operation.
  • URLConnection (java.net)
    The abstract class URLConnection is the superclass of all classes that represent a communications li
  • Date (java.sql)
    A class which can consume and produce dates in SQL Date format. Dates are represented in SQL as yyyy
  • TreeSet (java.util)
    A NavigableSet implementation based on a TreeMap. The elements are ordered using their Comparable, o
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