Example usage for java.util.concurrent ConcurrentMap entrySet

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

Introduction

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

Prototype

Set<Map.Entry<K, V>> entrySet();

Source Link

Document

Returns a Set view of the mappings contained in this map.

Usage

From source file:com.splout.db.hazelcast.DistributedRegistry.java

public void dumpRegistry() {
    ConcurrentMap<String, Object> members = hzInstance.getMap(registryName);
    System.out.println("Registry [" + registryName + "] {");
    for (Entry<String, Object> entry : members.entrySet()) {
        System.out.println("\t" + entry.getKey() + " -> " + entry.getValue());
    }// ww  w.j  a  v  a2s.com
    System.out.println("}");
}

From source file:com.shawn.dubbo.service.impl.ConsumerServiceImpl.java

public List<String> findAddressesByApplication(String application) {
    List<String> ret = new ArrayList<String>();
    ConcurrentMap<String, Map<Long, URL>> consumerUrls = getRegistryCache().get(Constants.CONSUMERS_CATEGORY);
    for (Map.Entry<String, Map<Long, URL>> e1 : consumerUrls.entrySet()) {
        Map<Long, URL> value = e1.getValue();
        for (Map.Entry<Long, URL> e2 : value.entrySet()) {
            URL u = e2.getValue();
            if (application.equals(u.getParameter(Constants.APPLICATION_KEY))) {
                String addr = u.getAddress();
                if (addr != null)
                    ret.add(addr);/*w  w w . j a  v  a2  s .c om*/
            }
        }
    }

    return ret;
}

From source file:com.fhzz.dubbo.service.impl.ConsumerServiceImpl.java

public List<String> findAddresses() {
    List<String> ret = new ArrayList<String>();
    ConcurrentMap<String, Map<Long, URL>> consumerUrls = getRegistryCache().get(Constants.CONSUMERS_CATEGORY);
    if (null == consumerUrls)
        return ret;

    for (Map.Entry<String, Map<Long, URL>> e1 : consumerUrls.entrySet()) {
        Map<Long, URL> value = e1.getValue();
        for (Map.Entry<Long, URL> e2 : value.entrySet()) {
            URL u = e2.getValue();
            String app = u.getAddress();
            if (app != null)
                ret.add(app);/*from w w  w.ja v  a  2  s .  c o m*/
        }
    }

    return ret;
}

From source file:com.fhzz.dubbo.service.impl.ConsumerServiceImpl.java

public List<String> findApplications() {
    List<String> ret = new ArrayList<String>();
    ConcurrentMap<String, Map<Long, URL>> consumerUrls = getRegistryCache().get(Constants.CONSUMERS_CATEGORY);
    if (consumerUrls == null)
        return ret;

    for (Map.Entry<String, Map<Long, URL>> e1 : consumerUrls.entrySet()) {
        Map<Long, URL> value = e1.getValue();
        for (Map.Entry<Long, URL> e2 : value.entrySet()) {
            URL u = e2.getValue();
            String app = u.getParameter(Constants.APPLICATION_KEY);
            if (app != null)
                ret.add(app);//from ww  w  .  java  2  s  . c om
        }
    }

    return ret;
}

From source file:com.fhzz.dubbo.service.impl.ConsumerServiceImpl.java

public List<String> findAddressesByApplication(String application) {
    List<String> ret = new ArrayList<String>();
    ConcurrentMap<String, Map<Long, URL>> consumerUrls = getRegistryCache().get(Constants.CONSUMERS_CATEGORY);
    if (consumerUrls == null)
        return ret;

    for (Map.Entry<String, Map<Long, URL>> e1 : consumerUrls.entrySet()) {
        Map<Long, URL> value = e1.getValue();
        for (Map.Entry<Long, URL> e2 : value.entrySet()) {
            URL u = e2.getValue();
            if (application.equals(u.getParameter(Constants.APPLICATION_KEY))) {
                String addr = u.getAddress();
                if (addr != null)
                    ret.add(addr);//from  w ww.ja v a  2  s  .c  om
            }
        }
    }

    return ret;
}

From source file:com.fhzz.dubbo.service.impl.ConsumerServiceImpl.java

public List<String> findServicesByAddress(String address) {
    List<String> ret = new ArrayList<String>();
    ConcurrentMap<String, Map<Long, URL>> consumerUrls = getRegistryCache().get(Constants.CONSUMERS_CATEGORY);
    if (consumerUrls == null || address == null || address.length() == 0)
        return ret;

    for (Map.Entry<String, Map<Long, URL>> e1 : consumerUrls.entrySet()) {
        Map<Long, URL> value = e1.getValue();
        for (Map.Entry<Long, URL> e2 : value.entrySet()) {
            URL u = e2.getValue();
            if (address.equals(u.getAddress())) {
                ret.add(e1.getKey());/*from w  w  w . j  av  a 2 s  .  co  m*/
                break;
            }
        }
    }

    return ret;
}

From source file:com.fhzz.dubbo.service.impl.ConsumerServiceImpl.java

public List<String> findServicesByApplication(String application) {
    List<String> ret = new ArrayList<String>();
    ConcurrentMap<String, Map<Long, URL>> consumerUrls = getRegistryCache().get(Constants.CONSUMERS_CATEGORY);
    if (consumerUrls == null || application == null || application.length() == 0)
        return ret;

    for (Map.Entry<String, Map<Long, URL>> e1 : consumerUrls.entrySet()) {
        Map<Long, URL> value = e1.getValue();
        for (Map.Entry<Long, URL> e2 : value.entrySet()) {
            URL u = e2.getValue();
            if (application.equals(u.getParameter(Constants.APPLICATION_KEY))) {
                ret.add(e1.getKey());/*from  ww  w.  j ava2s  .co  m*/
                break;
            }
        }
    }

    return ret;
}

From source file:com.turbospaces.spaces.SpaceReceiveAdapter.java

@Override
public void viewAccepted(final View view) {
    final Address[] prevConnectors = clientConnectors;
    final Address[] newClientConnectors = getClientConnections(view);

    if (prevConnectors != null) {
        List<Address> l = new ArrayList<Address>(Arrays.asList(prevConnectors));
        l.removeAll(Arrays.asList(newClientConnectors));

        // automatically roll-back un-committed transactions, we can't leave them as this as they holds locks
        for (Address a : l) {
            Cache<Long, SpaceTransactionHolder> modificationContextFor = modificationContextFor(a);
            ConcurrentMap<Long, SpaceTransactionHolder> asMap = modificationContextFor.asMap();
            Set<Entry<Long, SpaceTransactionHolder>> entrySet = asMap.entrySet();
            for (Entry<Long, SpaceTransactionHolder> entry : entrySet) {
                Long transactionId = entry.getKey();
                SpaceTransactionHolder transactionHolder = entry.getValue();
                logger.warn(//w  w w  .jav  a2  s .  c o  m
                        "automatically rolling back transaction id={} due to client's connection disconnect",
                        transactionId);
                jSpace.syncTx(transactionHolder.getModificationContext(), false);
                modificationContextFor.invalidate(transactionId);
            }
        }
    }

    clientConnectors = newClientConnectors;
}

From source file:com.shawn.dubbo.service.impl.ProviderServiceImpl.java

public List<String> findAddressesByApplication(String application) {
    List<String> ret = new ArrayList<String>();
    ConcurrentMap<String, Map<Long, URL>> providerUrls = getRegistryCache().get(Constants.PROVIDERS_CATEGORY);
    for (Entry<String, Map<Long, URL>> e1 : providerUrls.entrySet()) {
        Map<Long, URL> value = e1.getValue();
        for (Entry<Long, URL> e2 : value.entrySet()) {
            URL u = e2.getValue();
            if (application.equals(u.getParameter(Constants.APPLICATION_KEY))) {
                String addr = u.getAddress();
                if (addr != null)
                    ret.add(addr);// w  w  w.  j  av a 2s  .  c o m
            }
        }
    }

    return ret;
}

From source file:com.alibaba.dubbo.governance.service.impl.ProviderServiceImpl.java

public List<String> findAddressesByApplication(String application) {
    List<String> ret = new ArrayList<String>();
    ConcurrentMap<String, Map<Long, URL>> providerUrls = getRegistryCache().get(Constants.PROVIDERS_CATEGORY);
    for (Map.Entry<String, Map<Long, URL>> e1 : providerUrls.entrySet()) {
        Map<Long, URL> value = e1.getValue();
        for (Map.Entry<Long, URL> e2 : value.entrySet()) {
            URL u = e2.getValue();
            if (application.equals(u.getParameter(Constants.APPLICATION_KEY))) {
                String addr = u.getAddress();
                if (addr != null)
                    ret.add(addr);//from ww  w .  ja  v  a 2 s  . c  o  m
            }
        }
    }

    return ret;
}