Search in sources :

Example 46 with Objects

use of java.util.Objects in project opennms by OpenNMS.

the class GeneratorConfigBuilder method build.

public GeneratorConfig build() {
    final GeneratorConfig config = new GeneratorConfig();
    if (label != null) {
        config.setLabel(label);
    }
    if (providerId != null) {
        config.setProviderId(providerId);
        // if a label is not provided with new providerId
        if (label == null)
            config.setLabel(providerId);
    }
    if (preferredLayout != null) {
        config.setPreferredLayout(preferredLayout);
    }
    if (hierarchy != null && !hierarchy.trim().isEmpty()) {
        final List<String> layers = Arrays.asList(hierarchy.split(",")).stream().filter(Objects::nonNull).map(String::trim).filter(h -> !h.isEmpty()).collect(Collectors.toList());
        config.setLayerHierarchies(layers);
    }
    if (filter != null && !filter.trim().isEmpty()) {
        final List<String> filters = Arrays.asList(filter.split(";")).stream().filter(Objects::nonNull).map(String::trim).filter(h -> !h.isEmpty()).collect(Collectors.toList());
        config.setFilters(filters);
    }
    if (breadcrumbStrategy != null) {
        try {
            BreadcrumbStrategy validValue = BreadcrumbStrategy.valueOf(breadcrumbStrategy);
            config.setBreadcrumbStrategy(validValue.name());
        } catch (IllegalArgumentException ex) {
            LOG.warn("Given breadcrumbStrategy {} does not exist. Valid values are {}. Ignoring.", breadcrumbStrategy, BreadcrumbStrategy.values());
        }
    }
    return config;
}
Also used : Objects(java.util.Objects) Arrays(java.util.Arrays) List(java.util.List) BreadcrumbStrategy(org.opennms.features.topology.api.support.breadcrumbs.BreadcrumbStrategy) Logger(org.slf4j.Logger) NodeParamLabels(org.opennms.features.topology.plugins.topo.asset.layers.NodeParamLabels) Event(org.opennms.netmgt.xml.event.Event) LoggerFactory(org.slf4j.LoggerFactory) EventUtils(org.opennms.netmgt.model.events.EventUtils) Collectors(java.util.stream.Collectors) BreadcrumbStrategy(org.opennms.features.topology.api.support.breadcrumbs.BreadcrumbStrategy)

Example 47 with Objects

use of java.util.Objects in project opennms by OpenNMS.

the class JMXCollector method collect.

@Override
public CollectionSet collect(CollectionAgent agent, Map<String, Object> map) {
    final Map<String, String> stringMap = JmxUtils.convertToUnmodifiableStringMap(map);
    final InetAddress ipaddr = agent.getAddress();
    final JmxCollection jmxCollection = (JmxCollection) map.get(JMX_COLLECTION_KEY);
    final MBeanServer mBeanServer = (MBeanServer) map.get(JMX_MBEAN_SERVER_KEY);
    final String collectionName = ParameterMap.getKeyedString(map, ParameterName.COLLECTION.toString(), serviceName);
    final String port = ParameterMap.getKeyedString(map, ParameterName.PORT.toString(), null);
    final String friendlyName = ParameterMap.getKeyedString(map, ParameterName.FRIENDLY_NAME.toString(), port);
    final String collDir = JmxUtils.getCollectionDirectory(stringMap, friendlyName, serviceName);
    final int retries = ParameterMap.getKeyedInteger(map, ParameterName.RETRY.toString(), 3);
    InetAddress ipAddr = agent.getAddress();
    int nodeID = agent.getNodeId();
    // Retrieve the name of the JMX data collector
    final String hostAddress = InetAddressUtils.str(ipAddr);
    LOG.debug("initialize: InetAddress={}, collectionName={}", hostAddress, collectionName);
    JMXNodeInfo nodeInfo = new JMXNodeInfo(nodeID);
    LOG.debug("nodeInfo: {} {} {}", hostAddress, nodeID, agent);
    /*
         * Retrieve list of MBean objects to be collected from the
         * remote agent which are to be stored in the node-level RRD file.
         * These objects pertain to the node itself not any individual
         * interfaces.
         */
    Map<String, List<Attrib>> attrMap = JMXDataCollectionConfigDao.getAttributeMap(jmxCollection, serviceName(), hostAddress);
    nodeInfo.setAttributeMap(attrMap);
    Map<String, JMXDataSource> dsList = buildDataSourceList(collectionName, attrMap);
    nodeInfo.setDsMap(dsList);
    nodeInfo.setMBeans(JMXDataCollectionConfigDao.getMBeanInfo(jmxCollection));
    // Metrics collected from JMX are currently modeled as node level resources,
    // but live in a sub-directory set to the service name
    final NodeLevelResource nodeResource = new NodeLevelResource(agent.getNodeId(), collDir);
    // This parent resource used for generic resource
    final NodeLevelResource parentResource = new NodeLevelResource(agent.getNodeId());
    // Used to gather the results
    final CollectionSetBuilder collectionSetBuilder = new CollectionSetBuilder(agent);
    LOG.debug("connecting to {} on node ID {}", InetAddressUtils.str(ipaddr), nodeInfo.getNodeId());
    try {
        // create config for JmxCollector
        final JmxCollectorConfig config = new JmxCollectorConfig();
        config.setAgentAddress(InetAddressUtils.str(ipaddr));
        config.setConnectionName(getConnectionName());
        config.setRetries(retries);
        config.setServiceProperties(stringMap);
        config.setJmxCollection(jmxCollection);
        final DefaultJmxCollector jmxCollector = new DefaultJmxCollector();
        jmxCollector.collect(config, mBeanServer, new JmxSampleProcessor() {

            @Override
            public void process(JmxAttributeSample attributeSample, ObjectName objectName) {
                final String mbeanObjectName = attributeSample.getMbean().getObjectname();
                final String attributeName = attributeSample.getCollectedAttribute().getName();
                final String dsKey = mbeanObjectName + "|" + attributeName;
                final JMXDataSource ds = nodeInfo.getDsMap().get(dsKey);
                if (ds == null) {
                    LOG.info("Could not find datasource for {}. Skipping.", dsKey);
                    return;
                }
                String resourceType = attributeSample.getMbean().getResourceType();
                if (resourceType != null) {
                    final String parsedObjectName = fixGroupName(objectName.getCanonicalName());
                    final Resource resource = new DeferredGenericTypeResource(parentResource, resourceType, parsedObjectName);
                    addNumericAttributeToCollectionSet(ds, attributeSample, resource);
                    addStringAttributesToCollectionSet(ds, attributeSample, resource, objectName);
                } else {
                    addNumericAttributeToCollectionSet(ds, attributeSample, nodeResource);
                }
            }

            @Override
            public void process(JmxCompositeSample compositeSample, ObjectName objectName) {
                final String mbeanObjectName = compositeSample.getMbean().getObjectname();
                final String attributeName = compositeSample.getCollectedAttribute().getName();
                final String dsKey = mbeanObjectName + "|" + attributeName + "|" + compositeSample.getCompositeKey();
                final JMXDataSource ds = nodeInfo.getDsMap().get(dsKey);
                if (ds == null) {
                    LOG.info("Could not find datasource for {}. Skipping.", dsKey);
                    return;
                }
                String resourceType = compositeSample.getMbean().getResourceType();
                if (resourceType != null) {
                    final String parsedObjectName = fixGroupName(objectName.getCanonicalName());
                    final Resource resource = new DeferredGenericTypeResource(parentResource, resourceType, parsedObjectName);
                    addNumericAttributeToCollectionSet(ds, compositeSample, resource);
                    addStringAttributesToCollectionSet(ds, compositeSample, resource, objectName);
                } else {
                    addNumericAttributeToCollectionSet(ds, compositeSample, nodeResource);
                }
            }

            private void addStringAttributesToCollectionSet(JMXDataSource ds, AbstractJmxSample sample, Resource resource, ObjectName objectName) {
                final String groupName = fixGroupName(JmxUtils.getGroupName(stringMap, sample.getMbean()));
                final String domain = objectName.getDomain();
                final Hashtable<String, String> properties = objectName.getKeyPropertyList();
                properties.forEach((key, value) -> collectionSetBuilder.withStringAttribute(resource, groupName, key, value));
                if (domain != null) {
                    collectionSetBuilder.withStringAttribute(resource, groupName, "domain", objectName.getDomain());
                }
            }

            private void addNumericAttributeToCollectionSet(JMXDataSource ds, AbstractJmxSample sample, Resource resource) {
                final String groupName = fixGroupName(JmxUtils.getGroupName(stringMap, sample.getMbean()));
                // Only numeric data comes back from JMX in data collection
                final String valueAsString = sample.getCollectedValueAsString();
                final Double value = NumericAttributeUtils.parseNumericValue(valueAsString);
                // Construct the metric identifier (used by NRTG)
                String metricId = groupName;
                metricId = metricId.replace("_type_", ":type=");
                metricId = metricId.replace("_", ".");
                metricId = metricId.concat(".");
                metricId = metricId.concat(ds.getName());
                metricId = "JMX_".concat(metricId);
                collectionSetBuilder.withIdentifiedNumericAttribute(resource, groupName, ds.getName(), value, ds.getType(), metricId);
            }
        });
    } catch (final Exception e) {
        LOG.debug("{} Collector.collect: IOException while collecting address: {}", serviceName, agent.getAddress(), e);
    }
    return collectionSetBuilder.build();
}
Also used : CollectionAgent(org.opennms.netmgt.collection.api.CollectionAgent) AlphaNumeric(org.opennms.core.utils.AlphaNumeric) JmxCollection(org.opennms.netmgt.config.collectd.jmx.JmxCollection) AbstractJmxSample(org.opennms.netmgt.jmx.samples.AbstractJmxSample) LoggerFactory(org.slf4j.LoggerFactory) HashMap(java.util.HashMap) CollectionSetBuilder(org.opennms.netmgt.collection.support.builder.CollectionSetBuilder) DeferredGenericTypeResource(org.opennms.netmgt.collection.support.builder.DeferredGenericTypeResource) NumericAttributeUtils(org.opennms.netmgt.collection.support.NumericAttributeUtils) InetAddress(java.net.InetAddress) DefaultJmxCollector(org.opennms.netmgt.jmx.impl.DefaultJmxCollector) MBeanServer(org.opennms.netmgt.config.jmx.MBeanServer) Map(java.util.Map) JmxUtils(org.opennms.netmgt.jmx.JmxUtils) JMXDataCollectionConfigDao(org.opennms.netmgt.config.JMXDataCollectionConfigDao) SimpleEntry(java.util.AbstractMap.SimpleEntry) Hashtable(java.util.Hashtable) ParameterMap(org.opennms.core.utils.ParameterMap) JmxCollectorConfig(org.opennms.netmgt.jmx.JmxCollectorConfig) JmxCompositeSample(org.opennms.netmgt.jmx.samples.JmxCompositeSample) Resource(org.opennms.netmgt.collection.support.builder.Resource) JmxAttributeSample(org.opennms.netmgt.jmx.samples.JmxAttributeSample) Logger(org.slf4j.Logger) InetAddressUtils(org.opennms.core.utils.InetAddressUtils) AbstractRemoteServiceCollector(org.opennms.netmgt.collection.api.AbstractRemoteServiceCollector) ObjectName(javax.management.ObjectName) JmxConfigDao(org.opennms.netmgt.dao.jmx.JmxConfigDao) Collectors(java.util.stream.Collectors) NodeLevelResource(org.opennms.netmgt.collection.support.builder.NodeLevelResource) BeanUtils(org.opennms.core.spring.BeanUtils) Objects(java.util.Objects) List(java.util.List) JmxSampleProcessor(org.opennms.netmgt.jmx.JmxSampleProcessor) Stream(java.util.stream.Stream) ParameterName(org.opennms.netmgt.collection.api.ServiceParameters.ParameterName) Attrib(org.opennms.netmgt.config.collectd.jmx.Attrib) CollectionSet(org.opennms.netmgt.collection.api.CollectionSet) JmxConnectors(org.opennms.netmgt.jmx.connection.JmxConnectors) Collections(java.util.Collections) RrdRepository(org.opennms.netmgt.rrd.RrdRepository) CollectionSetBuilder(org.opennms.netmgt.collection.support.builder.CollectionSetBuilder) NodeLevelResource(org.opennms.netmgt.collection.support.builder.NodeLevelResource) JmxCollection(org.opennms.netmgt.config.collectd.jmx.JmxCollection) AbstractJmxSample(org.opennms.netmgt.jmx.samples.AbstractJmxSample) List(java.util.List) MBeanServer(org.opennms.netmgt.config.jmx.MBeanServer) DefaultJmxCollector(org.opennms.netmgt.jmx.impl.DefaultJmxCollector) JmxCollectorConfig(org.opennms.netmgt.jmx.JmxCollectorConfig) Hashtable(java.util.Hashtable) JmxSampleProcessor(org.opennms.netmgt.jmx.JmxSampleProcessor) JmxCompositeSample(org.opennms.netmgt.jmx.samples.JmxCompositeSample) DeferredGenericTypeResource(org.opennms.netmgt.collection.support.builder.DeferredGenericTypeResource) Resource(org.opennms.netmgt.collection.support.builder.Resource) NodeLevelResource(org.opennms.netmgt.collection.support.builder.NodeLevelResource) ObjectName(javax.management.ObjectName) DeferredGenericTypeResource(org.opennms.netmgt.collection.support.builder.DeferredGenericTypeResource) JmxAttributeSample(org.opennms.netmgt.jmx.samples.JmxAttributeSample) InetAddress(java.net.InetAddress)

Example 48 with Objects

use of java.util.Objects in project opennms by OpenNMS.

the class RangeChunker method chunk.

public Map<String, List<DiscoveryJob>> chunk(final DiscoveryConfiguration config) {
    final int chunkSize = config.getChunkSize().orElse(DiscoveryConfigFactory.DEFAULT_CHUNK_SIZE);
    final double packetsPerSecond = config.getPacketsPerSecond().orElse(DiscoveryConfigFactory.DEFAULT_PACKETS_PER_SECOND);
    // If the foreign source for the discovery config is not set than use
    // a value of null so that non-requisitioned nodes are created.
    // 
    // TODO: Use the "default" foreign source instead so that we can move
    // away from using non-requisitioned nodes.
    // 
    final String foreignSourceFromConfig = config.getForeignSource().isPresent() ? config.getForeignSource().get().trim() : null;
    // If the monitoring location for the discovery config is not set than use
    // the default localhost location
    final String locationFromConfig = config.getLocation().map(l -> {
        final String trimmed = l.trim();
        if ("".equals(trimmed)) {
            return null;
        }
        return trimmed;
    }).orElse(MonitoringLocationDao.DEFAULT_MONITORING_LOCATION_ID);
    final DiscoveryConfigFactory configFactory = new DiscoveryConfigFactory(config);
    final AtomicReference<IPPollRange> previousRange = new AtomicReference<>();
    return StreamSupport.stream(configFactory.getConfiguredAddresses().spliterator(), false).filter(address -> {
        // If there is no IP address filter set or the filter matches
        return ipAddressFilter.matches(address.getLocation(), address.getAddress());
    }).map(address -> {
        // Create a singleton IPPollRange
        return new IPPollRange(// Make sure that foreignSource is not null so that we can partition on the value
        address.getForeignSource() == null ? foreignSourceFromConfig : address.getForeignSource(), // Make sure that location is not null so that we can partition on the value
        address.getLocation() == null ? locationFromConfig : address.getLocation(), address.getAddress(), address.getAddress(), address.getTimeout(), address.getRetries());
    }).collect(Collectors.groupingBy(range -> {
        // Create a Map<ForeignSourceLocationKey,List<IPPollRange>>
        return new ForeignSourceLocationKey(// Make sure that foreignSource is not null so that we can partition on the value
        range.getForeignSource() == null ? foreignSourceFromConfig : range.getForeignSource(), // Make sure that location is not null so that we can partition on the value
        range.getLocation() == null ? locationFromConfig : range.getLocation());
    }, LinkedHashMap::new, Collectors.toList())).entrySet().stream().flatMap(entry -> {
        // Partition the list of address values
        return Lists.partition(entry.getValue(), chunkSize).stream().map(ranges -> {
            DiscoveryJob retval = new DiscoveryJob(ranges.stream().map(address -> {
                // then just extend the range to cover this address too
                if (isConsecutive(previousRange.get(), address)) {
                    previousRange.get().getAddressRange().incrementEnd();
                    return null;
                }
                previousRange.set(address);
                return address;
            }).filter(Objects::nonNull).collect(Collectors.toList()), entry.getKey().getForeignSource(), entry.getKey().getLocation(), packetsPerSecond);
            // Reset the previousRange value
            previousRange.set(null);
            return retval;
        }).collect(Collectors.toList()).stream();
    }).collect(Collectors.groupingBy(DiscoveryJob::getLocation, LinkedHashMap::new, Collectors.toList()));
}
Also used : DiscoveryConfiguration(org.opennms.netmgt.config.discovery.DiscoveryConfiguration) AtomicReference(java.util.concurrent.atomic.AtomicReference) Collectors(java.util.stream.Collectors) IPAddress(org.opennms.core.network.IPAddress) LinkedHashMap(java.util.LinkedHashMap) Objects(java.util.Objects) List(java.util.List) Lists(com.google.common.collect.Lists) Map(java.util.Map) DiscoveryConfigFactory(org.opennms.netmgt.config.DiscoveryConfigFactory) MonitoringLocationDao(org.opennms.netmgt.dao.api.MonitoringLocationDao) IPPollRange(org.opennms.netmgt.model.discovery.IPPollRange) BigInteger(java.math.BigInteger) StreamSupport(java.util.stream.StreamSupport) Preconditions(com.google.common.base.Preconditions) IPPollRange(org.opennms.netmgt.model.discovery.IPPollRange) AtomicReference(java.util.concurrent.atomic.AtomicReference) DiscoveryConfigFactory(org.opennms.netmgt.config.DiscoveryConfigFactory)

Example 49 with Objects

use of java.util.Objects in project opennms by OpenNMS.

the class AbstractDaoRestServiceWithDTO method getPropertyValues.

@GET
@Path("properties/{propertyId}")
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
public Response getPropertyValues(@PathParam("propertyId") final String propertyId, @QueryParam("q") final String query, @QueryParam("limit") final Integer limit) {
    Set<SearchProperty> props = getQueryProperties();
    // Find the property with the matching ID
    Optional<SearchProperty> prop = props.stream().filter(p -> p.getId().equals(propertyId)).findAny();
    if (prop.isPresent()) {
        SearchProperty property = prop.get();
        if (property.values != null && property.values.size() > 0) {
            final Set<String> validValues;
            if (query != null && query.length() > 0) {
                validValues = property.values.keySet().stream().filter(v -> v.contains(query)).collect(Collectors.toSet());
            } else {
                validValues = property.values.keySet();
            }
            switch(property.type) {
                case FLOAT:
                    return Response.ok(new FloatCollection(validValues.stream().map(Float::parseFloat).collect(Collectors.toList()))).build();
                case INTEGER:
                    return Response.ok(new IntegerCollection(validValues.stream().map(Integer::parseInt).collect(Collectors.toList()))).build();
                case LONG:
                    return Response.ok(new LongCollection(validValues.stream().map(Long::parseLong).collect(Collectors.toList()))).build();
                case IP_ADDRESS:
                case STRING:
                    return Response.ok(new StringCollection(validValues)).build();
                case TIMESTAMP:
                    return Response.ok(new DateCollection(validValues.stream().map(v -> {
                        try {
                            return ISO8601DateEditor.stringToDate(v);
                        } catch (IllegalArgumentException | UnsupportedOperationException e) {
                            LOG.error("Invalid date in value list: " + v, e);
                            return null;
                        }
                    }).filter(Objects::nonNull).collect(Collectors.toList()))).build();
                default:
                    return Response.noContent().build();
            }
        }
        switch(property.type) {
            case FLOAT:
                List<Float> floats = new HibernateTemplate(m_sessionFactory).execute(new HibernateListCallback<Float>(property, query, limit));
                return Response.ok(new FloatCollection(floats)).build();
            case INTEGER:
                List<Integer> ints = new HibernateTemplate(m_sessionFactory).execute(new HibernateListCallback<Integer>(property, query, limit));
                return Response.ok(new IntegerCollection(ints)).build();
            case LONG:
                List<Long> longs = new HibernateTemplate(m_sessionFactory).execute(new HibernateListCallback<Long>(property, query, limit));
                return Response.ok(new LongCollection(longs)).build();
            case IP_ADDRESS:
                List<InetAddress> addresses = new HibernateTemplate(m_sessionFactory).execute(new HibernateListCallback<InetAddress>(property, query, limit));
                return Response.ok(new StringCollection(addresses.stream().map(InetAddressUtils::str).collect(Collectors.toList()))).build();
            case STRING:
                List<String> strings = new HibernateTemplate(m_sessionFactory).execute(new HibernateListCallback<String>(property, query, limit));
                return Response.ok(new StringCollection(strings)).build();
            case TIMESTAMP:
                List<Date> dates = new HibernateTemplate(m_sessionFactory).execute(new HibernateListCallback<Date>(property, query, limit));
                return Response.ok(new DateCollection(dates)).build();
            default:
                return Response.noContent().build();
        }
    } else {
        // 404
        return Response.status(Status.NOT_FOUND).build();
    }
}
Also used : QueryParameters(org.opennms.web.utils.QueryParameters) Produces(javax.ws.rs.Produces) Date(java.util.Date) SearchPropertyCollection(org.opennms.web.rest.support.SearchPropertyCollection) Path(javax.ws.rs.Path) SecurityContext(javax.ws.rs.core.SecurityContext) LoggerFactory(org.slf4j.LoggerFactory) Autowired(org.springframework.beans.factory.annotation.Autowired) CriteriaBuilderSearchVisitor(org.opennms.web.rest.support.CriteriaBuilderSearchVisitor) JaxbListWrapper(org.opennms.core.config.api.JaxbListWrapper) SearchConditionVisitor(org.apache.cxf.jaxrs.ext.search.SearchConditionVisitor) InetAddress(java.net.InetAddress) ReentrantReadWriteUpdateLock(com.googlecode.concurentlocks.ReentrantReadWriteUpdateLock) MediaType(javax.ws.rs.core.MediaType) QueryParam(javax.ws.rs.QueryParam) Consumes(javax.ws.rs.Consumes) Event(org.opennms.netmgt.xml.event.Event) Map(java.util.Map) ReadWriteUpdateLock(com.googlecode.concurentlocks.ReadWriteUpdateLock) Query(org.hibernate.Query) FloatCollection(org.opennms.web.rest.support.FloatCollection) HibernateCallback(org.springframework.orm.hibernate3.HibernateCallback) QueryParametersBuilder(org.opennms.web.utils.QueryParametersBuilder) DELETE(javax.ws.rs.DELETE) PropertyNotFoundException(org.apache.cxf.jaxrs.ext.search.PropertyNotFoundException) MessageFormatter(org.slf4j.helpers.MessageFormatter) MultivaluedMapImpl(org.opennms.web.rest.support.MultivaluedMapImpl) Context(javax.ws.rs.core.Context) InetAddressUtils(org.opennms.core.utils.InetAddressUtils) Collection(java.util.Collection) SessionFactory(org.hibernate.SessionFactory) Set(java.util.Set) Collectors(java.util.stream.Collectors) Criteria(org.opennms.core.criteria.Criteria) Serializable(java.io.Serializable) CriteriaBehavior(org.opennms.web.rest.support.CriteriaBehavior) Objects(java.util.Objects) List(java.util.List) Response(javax.ws.rs.core.Response) Optional(java.util.Optional) WebApplicationException(javax.ws.rs.WebApplicationException) UriInfo(javax.ws.rs.core.UriInfo) CriteriaBuilder(org.opennms.core.criteria.CriteriaBuilder) EventProxyException(org.opennms.netmgt.events.api.EventProxyException) HibernateException(org.hibernate.HibernateException) PathParam(javax.ws.rs.PathParam) GET(javax.ws.rs.GET) HibernateTemplate(org.springframework.orm.hibernate3.HibernateTemplate) SearchContext(org.apache.cxf.jaxrs.ext.search.SearchContext) Session(org.hibernate.Session) OnmsDao(org.opennms.netmgt.dao.api.OnmsDao) ISO8601DateEditor(org.opennms.web.api.ISO8601DateEditor) ArrayList(java.util.ArrayList) SQLException(java.sql.SQLException) IntegerCollection(org.opennms.web.rest.support.IntegerCollection) Qualifier(org.springframework.beans.factory.annotation.Qualifier) SearchBean(org.apache.cxf.jaxrs.ext.search.SearchBean) Status(javax.ws.rs.core.Response.Status) Order(org.opennms.core.criteria.Order) SearchProperty(org.opennms.web.rest.support.SearchProperty) POST(javax.ws.rs.POST) Logger(org.slf4j.Logger) StringCollection(org.opennms.web.rest.support.StringCollection) RestUtils(org.opennms.web.api.RestUtils) MultivaluedMap(javax.ws.rs.core.MultivaluedMap) LongCollection(org.opennms.web.rest.support.LongCollection) Lock(java.util.concurrent.locks.Lock) PUT(javax.ws.rs.PUT) SearchCondition(org.apache.cxf.jaxrs.ext.search.SearchCondition) Collections(java.util.Collections) EventProxy(org.opennms.netmgt.events.api.EventProxy) DateCollection(org.opennms.web.rest.support.DateCollection) CriteriaBuilderUtils(org.opennms.web.utils.CriteriaBuilderUtils) Transactional(org.springframework.transaction.annotation.Transactional) HibernateTemplate(org.springframework.orm.hibernate3.HibernateTemplate) InetAddressUtils(org.opennms.core.utils.InetAddressUtils) LongCollection(org.opennms.web.rest.support.LongCollection) DateCollection(org.opennms.web.rest.support.DateCollection) SearchProperty(org.opennms.web.rest.support.SearchProperty) FloatCollection(org.opennms.web.rest.support.FloatCollection) IntegerCollection(org.opennms.web.rest.support.IntegerCollection) Date(java.util.Date) StringCollection(org.opennms.web.rest.support.StringCollection) Objects(java.util.Objects) InetAddress(java.net.InetAddress) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET)

Example 50 with Objects

use of java.util.Objects in project caffeine by ben-manes.

the class CacheProxy method removeAll.

@Override
public void removeAll(Set<? extends K> keys) {
    requireNotClosed();
    keys.forEach(Objects::requireNonNull);
    boolean statsEnabled = statistics.isEnabled();
    long start = statsEnabled ? ticker.read() : 0L;
    Set<K> keysToRemove = new HashSet<>(keys);
    CacheWriterException e = deleteAllToCacheWriter(keysToRemove);
    long removed = keysToRemove.stream().map(this::removeNoCopyOrAwait).filter(Objects::nonNull).count();
    dispatcher.awaitSynchronous();
    if (statsEnabled) {
        statistics.recordRemovals(removed);
        statistics.recordRemoveTime(ticker.read() - start);
    }
    if (e != null) {
        throw e;
    }
}
Also used : Objects(java.util.Objects) HashSet(java.util.HashSet) CacheWriterException(javax.cache.integration.CacheWriterException)

Aggregations

Objects (java.util.Objects)83 List (java.util.List)45 Map (java.util.Map)37 Collectors (java.util.stream.Collectors)32 ArrayList (java.util.ArrayList)30 Set (java.util.Set)30 IOException (java.io.IOException)22 HashMap (java.util.HashMap)21 Optional (java.util.Optional)19 Collections (java.util.Collections)18 LoggerFactory (org.slf4j.LoggerFactory)17 Stream (java.util.stream.Stream)16 Logger (org.slf4j.Logger)16 HashSet (java.util.HashSet)14 Collection (java.util.Collection)13 InputStream (java.io.InputStream)12 ImmutableSet (com.google.common.collect.ImmutableSet)10 Result (ddf.catalog.data.Result)9 TimeUnit (java.util.concurrent.TimeUnit)9 Metacard (ddf.catalog.data.Metacard)8