Example usage for java.util.concurrent ConcurrentHashMap ConcurrentHashMap

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

Introduction

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

Prototype

public ConcurrentHashMap() 

Source Link

Document

Creates a new, empty map with the default initial table size (16).

Usage

From source file:com.kolich.pusachat.spring.beans.ChatRooms.java

@Override
public void afterPropertiesSet() throws Exception {
    chatRooms_ = new ConcurrentHashMap<UUID, ChatRoom>();
    // Reverse maps.
    keysToRooms_ = new ConcurrentHashMap<String, UUID>();
    roomsToKeys_ = new ConcurrentHashMap<UUID, String>();
    // Extract a configuration property that instructions how often
    // the chat room cleaner thread should wake up and remove "dead"
    // users from all of the rooms.
    final long removeInactiveUsersAfterMs = properties_.getRemoveInactiveAfter();
    // Setup a new thread factory builder.
    executor_ = newSingleThreadScheduledExecutor(
            new ThreadFactoryBuilder().setDaemon(true).setNameFormat("inactive-user-cleaner-%d").build());
    // Schedule a new cleaner at a "fixed" interval.
    executor_.scheduleAtFixedRate(new InactiveUserCleanerExecutor(this, removeInactiveUsersAfterMs), 0L, // initial delay
            removeInactiveUsersAfterMs, // repeat every
            MILLISECONDS); // units
}

From source file:com.netflix.discovery.shared.Application.java

public Application() {
    instances = new LinkedHashSet<InstanceInfo>();
    instancesMap = new ConcurrentHashMap<String, InstanceInfo>();
}

From source file:ai.grakn.engine.backgroundtasks.InMemoryTaskManager.java

private InMemoryTaskManager() {
    instantiatedTasks = new ConcurrentHashMap<>();
    stateStorage = InMemoryStateStorage.getInstance();
    stateUpdateLock = new ReentrantLock();

    ConfigProperties properties = ConfigProperties.getInstance();
    schedulingService = Executors.newScheduledThreadPool(1);
    executorService = Executors.newFixedThreadPool(properties.getAvailableThreads());
}

From source file:org.toobsframework.transformpipeline.domain.XSLUriResolverImpl.java

public void afterPropertiesSet() throws Exception {
    if (this.classpathBase == null) {
        this.classpathBase = new ArrayList<String>();
        this.classpathBase.add("xsl/");
    }//from w  w w.  ja  v a 2s . com
    if (this.contextBase == null) {
        this.contextBase = new ArrayList<String>();
        this.contextBase.add("/WEB-INF/xsl/");
    }
    sourceMap = new ConcurrentHashMap<String, URL>();
    sourceMap.put(COMPONENT_MANAGER_XSL, resolveClasspathResource(COMPONENT_MANAGER_XSL, ""));
    this.doReload = configuration.doReload();
}

From source file:iwein.samples.store.SimpleMessageStore.java

/**
 * Creates a SimpleMessageStore with a maximum size limited by the given capacity, or unlimited size if the given
 * capacity is less than 1. The capacities are applied independently to messages stored via
 * {@link #addMessage(Message)} and to those stored via {@link #addMessageToGroup(Object, Message)}. In both cases
 * the capacity applies to the number of messages that can be stored, and once that limit is reached attempting to
 * store another will result in an exception.
 *//* w w w . j a v  a 2  s .c  om*/
public SimpleMessageStore(int individualCapacity, int groupCapacity) {
    this.idToMessage = new ConcurrentHashMap<UUID, Message<?>>();
    this.correlationToMessageGroup = new ConcurrentHashMap<Object, SimpleMessageGroup>();
    this.individualUpperBound = new UpperBound(individualCapacity);
    this.groupUpperBound = new UpperBound(groupCapacity);
}

From source file:com.centeractive.ws.server.endpoint.GenericContextDomEndpoint.java

public GenericContextDomEndpoint() {
    this.services = new ConcurrentHashMap<String, RequestResponder>();
}

From source file:cn.org.eshow.framwork.http.AbRequestParams.java

/**
 * default boundary is auto generate {@link #getBoundary()}
 *///from w  ww .  ja  v  a  2s.  co m
public AbRequestParams() {
    super();
    boundary = getBoundary();
    urlParams = new ConcurrentHashMap<String, String>();
    fileParams = new ConcurrentHashMap<String, ContentBody>();
    multiPart = new MultipartEntity(HttpMultipartMode.STRICT, boundary, Charset.forName("UTF-8"));
}

From source file:com.clustercontrol.notify.action.GetNotify.java

/**
 * ???<BR>/*from ww w .j  av a 2 s.com*/
 * ??SessionBean????
 *
 * @return 
 */
private Map<String, List<NotifyInfo>> getNotifyList() {

    Map<String, List<NotifyInfo>> dispDataMap = new ConcurrentHashMap<>();
    List<NotifyInfo> records = null;
    for (String managerName : EndpointManager.getActiveManagerSet()) {
        try {
            NotifyEndpointWrapper wrapper = NotifyEndpointWrapper.getWrapper(managerName);
            records = wrapper.getNotifyList();
            dispDataMap.put(managerName, records);
        } catch (InvalidRole_Exception e) {
            MessageDialog.openInformation(null, Messages.getString("message"),
                    Messages.getString("message.accesscontrol.16"));
        } catch (Exception e) {
            m_log.warn("getNotifyList(), " + HinemosMessage.replace(e.getMessage()), e);
            MessageDialog.openError(null, Messages.getString("error"),
                    Messages.getString("message.hinemos.failure.unexpected") + ", "
                            + HinemosMessage.replace(e.getMessage()));

        }
    }
    return dispDataMap;
}

From source file:com.cjwagner.InfoSecPriv.ExtensionServer.java

private static void initializeLogStore() {

    System.out.println("Date: " + new Date().getTime());
    System.out.println("Initializing Log Store...");

    int fileLoadCount = 0;
    storeSize = 0;//  w  w w.  ja  v a  2s .  c o m
    logStore = new ConcurrentHashMap<String, LoggerMessage>();
    File dir = new File(logDir);
    dir.mkdir();

    File[] files = dir.listFiles();
    for (File file : files) {
        String fullName = file.getName();
        String ext = getExtension(fullName);
        String ip = rmvExtension(fullName);
        if (!ext.equals(logFileExt) || ip.length() == 0) {
            continue;
        }
        LoggerMessage data = null;
        try {
            System.out.println(file.toString());
            String json = FileUtils.readFileToString(file, null);
            data = LoggerMessage.fromJSON(json);
        } catch (Exception e) {
            System.out.println("Failed to parse file: " + fullName + "  ERROR: " + e.getMessage());
            continue;
        }
        //data is verified at this point
        LoggerMessage rec = logStore.get(ip);
        if (rec == null) {
            logStore.put(ip, data);
        } else {
            rec.getLogs().addAll(data.getLogs());
        }
        storeSize += data.getLogs().size();
        fileLoadCount++;
    }
    System.out.println(
            "Initialization complete.  Files loaded: " + fileLoadCount + "  Total logs loaded: " + storeSize);
}

From source file:com.weibo.api.motan.registry.support.LocalRegistryService.java

@Override
public void doSubscribe(URL url, NotifyListener listener) {

    String subscribeKey = getSubscribeKey(url);
    ConcurrentHashMap<URL, ConcurrentHashSet<NotifyListener>> urlListeners = subscribeListeners
            .get(subscribeKey);/*from   www  .  ja v a  2 s.  c  o  m*/
    if (urlListeners == null) {
        subscribeListeners.putIfAbsent(subscribeKey,
                new ConcurrentHashMap<URL, ConcurrentHashSet<NotifyListener>>());
        urlListeners = subscribeListeners.get(subscribeKey);
    }

    ConcurrentHashSet<NotifyListener> listeners = urlListeners.get(url);
    if (listeners == null) {
        urlListeners.putIfAbsent(url, new ConcurrentHashSet<NotifyListener>());
        listeners = urlListeners.get(url);
    }

    listeners.add(listener);

    List<URL> urls = discover(url);
    if (urls != null && urls.size() > 0) {
        listener.notify(getUrl(), urls);
    }

    LoggerUtil.info("LocalRegistryService subscribe: url={}", url);
}