Example usage for java.util.concurrent ConcurrentMap values

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

Introduction

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

Prototype

Collection<V> values();

Source Link

Document

Returns a Collection view of the values contained in this map.

Usage

From source file:org.opendaylight.vpnservice.elan.internal.ElanInterfaceManager.java

public static List<Bucket> getRemoteBCGroupBucketsOfElanL2GwDevices(ElanInstance elanInfo, BigInteger dpnId,
        int bucketId) {
    List<Bucket> listBucketInfo = new ArrayList<Bucket>();
    ConcurrentMap<String, L2GatewayDevice> map = ElanL2GwCacheUtils
            .getInvolvedL2GwDevices(elanInfo.getElanInstanceName());
    for (L2GatewayDevice device : map.values()) {
        String interfaceName = ElanL2GatewayUtils.getExternalTunnelInterfaceName(String.valueOf(dpnId),
                device.getHwvtepNodeId());
        if (interfaceName == null) {
            continue;
        }/* ww  w  .  j a  va 2s.  c o  m*/
        List<Action> listActionInfo = ElanUtils.buildItmEgressActions(interfaceName, elanInfo.getVni());
        listBucketInfo.add(MDSALUtil.buildBucket(listActionInfo, MDSALUtil.GROUP_WEIGHT, bucketId,
                MDSALUtil.WATCH_PORT, MDSALUtil.WATCH_GROUP));
        bucketId++;
    }
    return listBucketInfo;
}

From source file:org.apache.hadoop.hive.metastore.HiveClientCache.java

/**
 * Note: This doesn't check if they are being used or not, meant only to be called during shutdown etc.
 *//*from   w ww  .  j  a va 2 s.  c om*/
void closeAllClientsQuietly() {
    try {
        ConcurrentMap<HiveClientCacheKey, ICacheableMetaStoreClient> elements = hiveCache.asMap();
        for (ICacheableMetaStoreClient cacheableHiveMetaStoreClient : elements.values()) {
            cacheableHiveMetaStoreClient.tearDown();
        }
    } catch (Exception e) {
        LOG.warn("Clean up of hive clients in the cache failed. Ignored", e);
    }

    if (this.enableStats) {
        LOG.info("Cache statistics after shutdown: size=" + hiveCache.size() + " " + hiveCache.stats());
    }
}

From source file:org.onosproject.store.trivial.SimpleGroupStore.java

@Override
public void deviceInitialAuditCompleted(DeviceId deviceId, boolean completed) {
    synchronized (deviceAuditStatus) {
        if (completed) {
            log.debug("deviceInitialAuditCompleted: AUDIT " + "completed for device {}", deviceId);
            deviceAuditStatus.put(deviceId, true);
            // Execute all pending group requests
            ConcurrentMap<GroupKey, StoredGroupEntry> pendingGroupRequests = getPendingGroupKeyTable(deviceId);
            for (Group group : pendingGroupRequests.values()) {
                GroupDescription tmp = new DefaultGroupDescription(group.deviceId(), group.type(),
                        group.buckets(), group.appCookie(), group.givenGroupId(), group.appId());
                storeGroupDescriptionInternal(tmp);
            }//from www  .j  av a  2s  .c o  m
            getPendingGroupKeyTable(deviceId).clear();
        } else {
            if (deviceAuditStatus.get(deviceId)) {
                log.debug("deviceInitialAuditCompleted: Clearing AUDIT " + "status for device {}", deviceId);
                deviceAuditStatus.put(deviceId, false);
            }
        }
    }
}

From source file:org.opendaylight.vpnservice.elan.l2gw.utils.ElanL2GatewayUtils.java

/**
 * Delete elan l2 gateway devices ucast local macs from dpn.
 *
 * @param elanName/* w w  w  .j  a v a2  s .co  m*/
 *            the elan name
 * @param dpnId
 *            the dpn id
 */
public static void deleteElanL2GwDevicesUcastLocalMacsFromDpn(final String elanName, final BigInteger dpnId) {
    ConcurrentMap<String, L2GatewayDevice> elanL2GwDevices = ElanL2GwCacheUtils
            .getInvolvedL2GwDevices(elanName);
    if (elanL2GwDevices == null || elanL2GwDevices.isEmpty()) {
        LOG.trace("No L2 gateway devices in Elan [{}] cache.", elanName);
        return;
    }
    final ElanInstance elan = ElanUtils.getElanInstanceByName(elanName);
    if (elan == null) {
        LOG.error("Could not find Elan by name: {}", elanName);
        return;
    }
    LOG.info("Deleting Elan [{}] L2GatewayDevices UcastLocalMacs from Dpn [{}]", elanName, dpnId);

    final Long elanTag = elan.getElanTag();
    for (final L2GatewayDevice l2GwDevice : elanL2GwDevices.values()) {
        List<MacAddress> localMacs = getL2GwDeviceLocalMacs(l2GwDevice);
        if (localMacs != null && !localMacs.isEmpty()) {
            for (final MacAddress mac : localMacs) {
                String jobKey = elanName + ":" + mac.getValue();
                ElanClusterUtils.runOnlyInLeaderNode(jobKey, "delete l2gw macs from dmac table",
                        new Callable<List<ListenableFuture<Void>>>() {
                            @Override
                            public List<ListenableFuture<Void>> call() {
                                List<ListenableFuture<Void>> futures = Lists.newArrayList();

                                futures.addAll(ElanUtils.deleteDmacFlowsToExternalMac(elanTag, dpnId,
                                        l2GwDevice.getHwvtepNodeId(), mac.getValue()));
                                return futures;
                            }
                        });
            }
        }
    }
}

From source file:org.polymap.p4.atlas.ui.SearchContentProvider.java

/**
*
*//*from ww  w . ja  v a 2  s .  c  o  m*/
protected void updateMap(IMap elm, int currentChildCount) {
    updateChildrenLoading(elm);

    ConcurrentMap<String, ILayer> children = new ConcurrentSkipListMap();
    List<UIJob> jobs = new ArrayList();
    for (ILayer layer : elm.layers) {
        UIJob job = UIJob.schedule(layer.label.get(), monitor -> {
            if (AtlasFeatureLayer.of(layer).get().isPresent()) {
                children.put(layer.label.get(), layer);
            }
        });
        jobs.add(job);
    }
    ;
    jobs.forEach(job -> job.joinAndDispatch(5000));

    updateChildren(elm, children.values().toArray(), currentChildCount);
}

From source file:org.opendaylight.vpnservice.dhcpservice.DhcpExternalTunnelManager.java

private L2GatewayDevice getDeviceFromTunnelIp(String elanInstanceName, IpAddress tunnelIp) {
    ConcurrentMap<String, L2GatewayDevice> devices = L2GatewayCacheUtils.getCache();
    for (L2GatewayDevice device : devices.values()) {
        if (device.getTunnelIp().equals(tunnelIp)) {
            return device;
        }//from w w w .  j a  va 2s  .c o  m
    }
    return null;
}

From source file:org.opendaylight.netvirt.dhcpservice.DhcpExternalTunnelManager.java

private boolean checkL2GatewayConnection(Pair<IpAddress, String> tunnelElanPair) {
    ConcurrentMap<String, L2GatewayDevice> l2GwDevices = ElanL2GwCacheUtils
            .getInvolvedL2GwDevices(tunnelElanPair.getRight());
    for (L2GatewayDevice device : l2GwDevices.values()) {
        if (device.getTunnelIp().equals(tunnelElanPair.getLeft())) {
            return true;
        }//from  w  w  w. jav  a2  s.c o m
    }
    return false;
}

From source file:org.opendaylight.netvirt.dhcpservice.DhcpExternalTunnelManager.java

private L2GatewayDevice getDeviceFromTunnelIp(String elanInstanceName, IpAddress tunnelIp) {
    ConcurrentMap<String, L2GatewayDevice> devices = L2GatewayCacheUtils.getCache();
    LOG.trace("In getDeviceFromTunnelIp devices {}", devices);
    for (L2GatewayDevice device : devices.values()) {
        if (tunnelIp.equals(device.getTunnelIp())) {
            return device;
        }/*w  ww  .ja  v  a2  s  .  c o m*/
    }
    return null;
}

From source file:org.honeysoft.akka.actor.BusinessActorTest.java

@Test
public void shouldBeValidWhenNoOneIsNull() throws Exception {
    //GIVEN//from   w  w  w. j  a va 2s .  c  o  m
    final ConcurrentMap<String, Object> threadSafeMap = new ConcurrentHashMap<String, Object>(1);
    field("logger").ofType(Logger.class).in(businessService).postDecorateWith(new TestLogger(threadSafeMap));

    //WHEN
    String testString = "test-string";
    businessActorRef.tell(testString);

    //THEN
    Awaitility.waitAtMost(Duration.FIVE_SECONDS).until(new Callable<Boolean>() {
        @Override
        public Boolean call() throws Exception {
            return !threadSafeMap.isEmpty();
        }
    });

    Assertions.assertThat(threadSafeMap).hasSize(1);
    Assertions.assertThat(threadSafeMap.values().iterator().next()).isEqualTo(testString);
}

From source file:org.onosproject.store.group.impl.DistributedGroupStore.java

private Group getMatchingExtraneousGroupbyBuckets(DeviceId deviceId, GroupBuckets buckets) {
    ConcurrentMap<GroupId, Group> extraneousMap = extraneousGroupEntriesById.get(deviceId);
    if (extraneousMap == null) {
        return null;
    }//  ww  w. j  a v a2  s  . c  o  m

    for (Group extraneousGroup : extraneousMap.values()) {
        if (extraneousGroup.buckets().equals(buckets)) {
            return extraneousGroup;
        }
    }
    return null;
}