Example usage for java.util.concurrent ConcurrentHashMap values

List of usage examples for java.util.concurrent ConcurrentHashMap values

Introduction

In this page you can find the example usage for java.util.concurrent ConcurrentHashMap values.

Prototype

ValuesView values

To view the source code for java.util.concurrent ConcurrentHashMap values.

Click Source Link

Usage

From source file:org.apache.storm.localizer.LocalizedResourceRetentionSet.java

public void addResources(ConcurrentHashMap<String, LocallyCachedBlob> blobs) {
    CleanableLocalizedLocallyCachedBlob set = new CleanableLocalizedLocallyCachedBlob(blobs);
    for (LocallyCachedBlob b : blobs.values()) {
        currentSize += b.getSizeOnDisk();
        resourceCount++;/*ww w  .j a va  2 s .  c om*/
        if (b.isUsed()) {
            // always retain resources in use
            continue;
        }
        LocallyCachedBlobComparableResource cb = new LocallyCachedBlobComparableResource(b);
        noReferences.put(cb, set);
    }
}

From source file:org.bibsonomy.recommender.tags.multiplexer.RecommendedTagResultManager.java

/**
 * Returns all results cached for given query. If the query is not cached, null is 
 * returned/* ww  w  .  j  a  v  a2s  . co m*/
 * 
 * @param qid 
 * @return
 */
public Collection<SortedSet<RecommendedTag>> getResultForQuery(Long qid) {
    if (isCached(qid)) {
        ConcurrentHashMap<Long, SortedSet<RecommendedTag>> queryStore = resultStore.get(qid);
        if (queryStore != null)
            return queryStore.values();
    }
    return null;
}

From source file:org.wso2.carbon.databridge.streamdefn.registry.datastore.RegistryStreamDefinitionStore.java

public Collection<StreamDefinition> getAllStreamDefinitionsFromStore(int tenantId) {
    ConcurrentHashMap<String, StreamDefinition> map = new ConcurrentHashMap<String, StreamDefinition>();

    try {// ww  w .ja v  a2 s .  com
        UserRegistry registry = ServiceHolder.getRegistryService().getGovernanceSystemRegistry(tenantId);

        if (!registry.resourceExists(RegistryStreamDefinitionStoreUtil.getStreamDefinitionStorePath())) {
            registry.put(RegistryStreamDefinitionStoreUtil.getStreamDefinitionStorePath(),
                    registry.newCollection());
        } else {
            org.wso2.carbon.registry.core.Collection collection = (org.wso2.carbon.registry.core.Collection) registry
                    .get(RegistryStreamDefinitionStoreUtil.getStreamDefinitionStorePath());
            for (String streamNameCollection : collection.getChildren()) {

                org.wso2.carbon.registry.core.Collection innerCollection = (org.wso2.carbon.registry.core.Collection) registry
                        .get(streamNameCollection);
                for (String streamVersionCollection : innerCollection.getChildren()) {

                    Resource resource = (Resource) registry.get(streamVersionCollection);
                    try {
                        StreamDefinition streamDefinition = EventDefinitionConverterUtils
                                .convertFromJson(RegistryUtils.decodeBytes((byte[]) resource.getContent()));
                        map.put(streamDefinition.getStreamId(), streamDefinition);
                    } catch (Throwable e) {
                        log.error("Error in retrieving streamDefinition from the resource at "
                                + resource.getPath(), e);
                    }
                }
            }
        }

    } catch (RegistryException e) {
        log.error("Error in retrieving streamDefinitions from the registry", e);
    }

    return map.values();
}

From source file:org.wso2.carbon.device.mgt.input.adapter.thrift.internal.ThriftEventAdapterServiceComponent.java

protected void setDataBridgeSubscriberService(DataBridgeSubscriberService dataBridgeSubscriberService) {
    if (ThriftEventAdapterServiceHolder.getDataBridgeSubscriberService() == null) {
        ThriftEventAdapterServiceHolder.registerDataBridgeSubscriberService(dataBridgeSubscriberService);

        dataBridgeSubscriberService.subscribe(new AgentCallback() {
            @Override//  w ww .  j av  a 2  s  .c  o  m
            public void definedStream(StreamDefinition streamDefinition, int i) {

            }

            @Override
            public void removeStream(StreamDefinition streamDefinition, int i) {

            }

            @Override
            public void receive(List<Event> events, Credentials credentials) {
                try {
                    PrivilegedCarbonContext.startTenantFlow();
                    String tenantDomain = getTenantDomain(events, credentials);
                    PrivilegedCarbonContext.getThreadLocalCarbonContext().setTenantDomain(tenantDomain, true);
                    if (!tenantDomain.equalsIgnoreCase(MultitenantConstants.SUPER_TENANT_DOMAIN_NAME)) {
                        TenantAxisUtils.getTenantConfigurationContext(tenantDomain,
                                ThriftEventAdapterServiceHolder.getConfigurationContext());
                    }
                    for (Event event : events) {
                        ConcurrentHashMap<String, ThriftAdapter> adapters = ThriftEventAdapterServiceHolder
                                .getAdapterService(tenantDomain, event.getStreamId());
                        if (adapters != null) {
                            event = getStrippedEvent(event, credentials);
                            for (ThriftAdapter adapter : adapters.values()) {
                                adapter.getEventAdaptorListener().onEvent(event);
                            }
                        }
                        if (log.isDebugEnabled()) {
                            log.debug("Event received in wso2Event Adapter - " + event);
                        }
                    }
                } finally {
                    PrivilegedCarbonContext.endTenantFlow();
                }
            }
        });
    }
}

From source file:org.wso2.carbon.event.input.adapter.wso2event.internal.ds.WSO2EventAdapterServiceDS.java

protected void setDataBridgeSubscriberService(DataBridgeSubscriberService dataBridgeSubscriberService) {
    if (WSO2EventAdapterServiceValueHolder.getDataBridgeSubscriberService() == null) {
        WSO2EventAdapterServiceValueHolder.registerDataBridgeSubscriberService(dataBridgeSubscriberService);

        dataBridgeSubscriberService.subscribe(new AgentCallback() {
            @Override/*from   w ww  .ja v a 2  s .  co  m*/
            public void definedStream(StreamDefinition streamDefinition, int i) {

            }

            @Override
            public void removeStream(StreamDefinition streamDefinition, int i) {

            }

            @Override
            public void receive(List<Event> events, Credentials credentials) {
                try {
                    PrivilegedCarbonContext.startTenantFlow();
                    PrivilegedCarbonContext.getThreadLocalCarbonContext()
                            .setTenantId(credentials.getTenantId());
                    PrivilegedCarbonContext.getThreadLocalCarbonContext()
                            .setTenantDomain(credentials.getDomainName());
                    for (Event event : events) {
                        ConcurrentHashMap<String, WSO2EventAdapter> adapters = WSO2EventAdapterServiceValueHolder
                                .getAdapterService(credentials.getDomainName(), event.getStreamId());
                        if (adapters != null) {
                            for (WSO2EventAdapter adapter : adapters.values()) {
                                adapter.getEventAdaptorListener().onEvent(event);
                            }
                        }
                        if (log.isDebugEnabled()) {
                            log.debug("Event received in wso2Event Adapter - " + event);
                        }
                    }
                } finally {
                    PrivilegedCarbonContext.endTenantFlow();
                }
            }
        });
    }
}

From source file:org.wso2.carbon.event.output.adaptor.websocket.WebsocketEventAdaptor.java

@Override
public void removeConnectionInfo(OutputEventAdaptorMessageConfiguration outputEventAdaptorMessageConfiguration,
        OutputEventAdaptorConfiguration outputEventAdaptorConfiguration, int tenantId) {
    /**//from  ww  w  . j  a va2  s  .c o m
     * Clearing all the sessions created.
     */
    for (ConcurrentHashMap<String, Session> urlSessionMap : outputEventAdaptorSessionMap.values()) {
        for (Session session : urlSessionMap.values()) {
            try {
                session.close();
            } catch (IOException e) {
                log.error(e.getMessage(), e);
            }
        }
    }
}

From source file:services.SimulationService.java

public void notifyPlanet(Planet planet, IoBuffer packet) {

    ConcurrentHashMap<IoSession, Client> clients = core.getActiveConnectionsMap();

    for (Client client : clients.values()) {

        if (client.getParent() == null)
            continue;

        if (client.getParent().getPlanet() == null)
            continue;
        else if (client.getParent().getPlanet() == planet)
            client.getSession().write(packet);

    }/*from   w ww  .  ja v  a  2s  .  c  o m*/

}

From source file:services.SimulationService.java

public void notifyAllClients(IoBuffer packet) {

    ConcurrentHashMap<IoSession, Client> clients = core.getActiveConnectionsMap();

    for (Client client : clients.values()) {

        if (client.getParent() == null)
            continue;

        client.getSession().write(packet);

    }//w w  w. j a va 2s . c o  m

}