Source:
public <L> void receivedEvent(InventoryEvent<L> event) { log.debug("Received inventory event"); ResourceManager<L> resourceManager = event.getResourceManager(); MonitoredEndpoint<EndpointConfiguration> endpoint = event.getSamplingService().getMonitoredEndpoint(); String endpointTenantId = endpoint.getEndpointConfiguration().getTenantId(); String tenantIdToUse = (endpointTenantId != null) ? endpointTenantId : config.getTenantId(); Map<String, String> headers = getTenantHeader(tenantIdToUse); InventoryPayloadBuilder<L> bldr = new InventoryPayloadBuilder<>(tenantIdToUse, feedId); long timestamp = System.currentTimeMillis(); event.getResourceTypeManager().ifPresent(resourceTypeManager -> { List<ResourceType<L>> allResourceTypes = resourceTypeManager.getResourceTypesBreadthFirst(); getMetricTypesToSync(allResourceTypes).forEach(mt -> { log.infof("Updating metric type: %s", mt.getID().getIDString()); performMetricTypeSync(bldr.buildMetricType(mt), tenantIdToUse); mt.setPersistedTime(timestamp); }); allResourceTypes.stream() .filter(this::needToRefresh) .forEach(rt -> { log.infof("Updating resource type: %s", rt.getID().getIDString()); performResourceTypeSync(bldr.buildResourceType(rt), tenantIdToUse); rt.setPersistedTime(timestamp); }); }); Set<ID> addedOrModifiedIds = event.getAddedOrModifiedRootResources().stream() .map(IDObject::getID) .collect(Collectors.toSet()); resourceManager.getRootResources().forEach(r -> { if (addedOrModifiedIds.contains(r.getID()) || needToRefresh(r)) { log.infof("Updating root resource: %s", r.getID().getIDString()); performResourceSync( bldr.buildRootResource(resourceManager, r), tenantIdToUse, resourceManager.size(r)); r.setPersistedTime(timestamp); } }); event.getRemovedRootResources().forEach(r -> { log.infof("Removing root resource: %s", r.getID().getIDString()); InventoryMetric metric = InventoryMetric.resource(feedId, r.getID().getIDString(), null, null); deleteMetric(metric, headers); }); }

Target:
public <L> void receivedEvent(InventoryEvent<L> event) { log.debug("Received inventory event"); ResourceManager<L> resourceManager = event.getResourceManager(); MonitoredEndpoint<EndpointConfiguration> endpoint = event.getSamplingService().getMonitoredEndpoint(); String endpointTenantId = endpoint.getEndpointConfiguration().getTenantId(); String tenantIdToUse = (endpointTenantId != null) ? endpointTenantId : config.getTenantId(); Map<String, String> headers = getTenantHeader(tenantIdToUse); InventoryPayloadBuilder<L> bldr = new InventoryPayloadBuilder<>(tenantIdToUse, feedId); long timestamp = System.currentTimeMillis(); event.getResourceTypeManager().ifPresent(resourceTypeManager -> { List<ResourceType<L>> allResourceTypes = resourceTypeManager.getResourceTypesBreadthFirst(); getMetricTypesToSync(allResourceTypes).forEach(mt -> { log.debugf("Updating metric type: %s", mt.getID().getIDString()); performMetricTypeSync(bldr.buildMetricType(mt), tenantIdToUse); mt.setPersistedTime(timestamp); }); allResourceTypes.stream() .filter(this::needToRefresh) .forEach(rt -> { log.debugf("Updating resource type: %s", rt.getID().getIDString()); performResourceTypeSync(bldr.buildResourceType(rt), tenantIdToUse); rt.setPersistedTime(timestamp); }); }); Set<ID> addedOrModifiedIds = event.getAddedOrModifiedRootResources().stream() .map(IDObject::getID) .collect(Collectors.toSet()); resourceManager.getRootResources().forEach(r -> { if (addedOrModifiedIds.contains(r.getID()) || needToRefresh(r)) { log.debugf("Updating root resource: %s", r.getID().getIDString()); performResourceSync( bldr.buildRootResource(resourceManager, r), tenantIdToUse, resourceManager.size(r)); r.setPersistedTime(timestamp); } }); event.getRemovedRootResources().forEach(r -> { log.debugf("Removing root resource: %s", r.getID().getIDString()); InventoryMetric metric = InventoryMetric.resource(feedId, r.getID().getIDString(), null, null); deleteMetric(metric, headers); }); }