List of usage examples for java.util.concurrent ConcurrentHashMap ConcurrentHashMap
public ConcurrentHashMap()
From source file:net.brtly.monkeyboard.adb.DeviceManager.java
/** * Initialize the main DeviceManager instance. #init() can only be called * once, otherwise an IllegalStateException is thrown. * //from ww w . ja va 2 s . com * @param eventBus */ public static void init(EventBus eventBus) { if (_isInit) { throw new IllegalStateException("DeviceManager already inited!"); } INSTANCE = new DeviceManager(eventBus); LOG.debug("DeviceManager INIT"); INSTANCE._deviceThreadPool = new DeviceThreadPool(); INSTANCE._devices = new ConcurrentHashMap<String, DeviceState>(); INSTANCE._chimpDevices = new ConcurrentHashMap<String, IChimpDevice>(); INSTANCE._focusedDevice = null; // This mess makes a single threaded executor capable of executing // INSTANCE._workerExecutor = // MoreExecutors.listeningDecorator(Executors // .newSingleThreadExecutor(new ThreadFactoryBuilder() // .setNameFormat("DeviceManager-Worker-%d").build())); INSTANCE._workerExecutor = Executors .newSingleThreadExecutor(new ThreadFactoryBuilder().setNameFormat("DeviceManager").build()); // INSTANCE._workerExecutor = Executors // .newCachedThreadPool(new ThreadFactoryBuilder() // .setNameFormat("DeviceManager-worker-%d").build()); INSTANCE._state = DeviceManagerState.STOPPED; _isInit = true; }
From source file:nz.net.orcon.kanban.controllers.CacheImpl.java
@Scheduled(cron = "${cache.clearschedule}") public void clearCache() { this.cacheMap.clear(); this.cacheList = new ConcurrentHashMap<String, Map<String, String>>(); ;//from ww w.j a v a 2 s . c om }
From source file:com.jaspersoft.jasperserver.war.themes.ThemeCache.java
public ThemeCache() { name2uid = new ConcurrentHashMap<String, String>(); uid2name = new ConcurrentHashMap<String, String>(); themeMap = new ConcurrentHashMap<String, HierarchicalTheme>(); resourceMap = new ConcurrentHashMap<String, ThemeResource>(); themeRefreshThread = new RefreshThread(); themeRefreshThread.setDaemon(true);//w ww . j av a2s .c o m themeRefreshThread.start(); updatedURIs = new Stack<String>(); }
From source file:com.enonic.cms.web.portal.services.UserServicesAccessManagerImpl.java
private void initSiteRules(SiteKey site) { ConcurrentMap<String, AccessPermission> siteRules = new ConcurrentHashMap<String, AccessPermission>(); String allowRules = sitePropertiesService.getSiteProperty(site, SitePropertyNames.HTTP_SERVICES_ALLOW_PROPERTY); String denyRules = sitePropertiesService.getSiteProperty(site, SitePropertyNames.HTTP_SERVICES_DENY_PROPERTY); parseAndAddRules(allowRules, AccessPermission.ALLOW, siteRules, site); parseAndAddRules(denyRules, AccessPermission.DENY, siteRules, site); siteRules.putIfAbsent(ACCESS_RULE_ALL, DEFAULT_ACCESS_RULE); sitesAccessRules.putIfAbsent(site, siteRules); }
From source file:com.alibaba.jstorm.cluster.StormZkClusterState.java
public StormZkClusterState(Object cluster_state_spec) throws Exception { if (cluster_state_spec instanceof ClusterState) { solo = false;/* w w w. ja v a 2 s.c o m*/ cluster_state = (ClusterState) cluster_state_spec; } else { solo = true; cluster_state = new DistributedClusterState((Map) cluster_state_spec); } assignment_info_callback = new ConcurrentHashMap<String, RunnableCallback>(); supervisors_callback = new AtomicReference<RunnableCallback>(null); assignments_callback = new AtomicReference<RunnableCallback>(null); storm_base_callback = new ConcurrentHashMap<String, RunnableCallback>(); master_callback = new AtomicReference<RunnableCallback>(null); state_id = cluster_state.register(new ClusterStateCallback() { public <T> Object execute(T... args) { if (args == null) { LOG.warn("Input args is null"); return null; } else if (args.length < 2) { LOG.warn("Input args is invalid, args length:" + args.length); return null; } EventType zkEventTypes = (EventType) args[0]; String path = (String) args[1]; List<String> toks = PathUtils.tokenize_path(path); int size = toks.size(); if (size >= 1) { String params = null; String root = toks.get(0); RunnableCallback fn = null; if (root.equals(Cluster.ASSIGNMENTS_ROOT)) { if (size == 1) { // set null and get the old value fn = assignments_callback.getAndSet(null); } else { params = toks.get(1); fn = assignment_info_callback.remove(params); } } else if (root.equals(Cluster.SUPERVISORS_ROOT)) { fn = supervisors_callback.getAndSet(null); } else if (root.equals(Cluster.STORMS_ROOT) && size > 1) { params = toks.get(1); fn = storm_base_callback.remove(params); } else if (root.equals(Cluster.MASTER_ROOT)) { fn = master_callback.getAndSet(null); } else { LOG.error("Unknown callback for subtree " + path); } if (fn != null) { // FIXME How to set the args // fn.setArgs(params, zkEventTypes, path); fn.run(); } } return null; } }); String[] pathlist = JStormUtils.mk_arr(Cluster.SUPERVISORS_SUBTREE, Cluster.STORMS_SUBTREE, Cluster.ASSIGNMENTS_SUBTREE, Cluster.ASSIGNMENTS_BAK_SUBTREE, Cluster.TASKS_SUBTREE, Cluster.TASKBEATS_SUBTREE, Cluster.TASKERRORS_SUBTREE, Cluster.METRIC_SUBTREE, Cluster.BACKPRESSURE_SUBTREE); for (String path : pathlist) { cluster_state.mkdirs(path); } }
From source file:org.wrml.runtime.format.application.schema.json.JsonSchema.java
JsonSchema(final JsonSchemaLoader loader, final ObjectNode rootNode) { _JsonSchemaLoader = loader;// www . j av a 2 s.c o m _RootNode = rootNode; final SyntaxLoader syntaxLoader = _JsonSchemaLoader.getContext().getSyntaxLoader(); _SchemaUri = Definitions.PropertyType.$Schema.getValue(_RootNode, syntaxLoader); _ExtendsSet = new CopyOnWriteArraySet<>(); _Properties = new ConcurrentHashMap<>(); _Dependencies = new ConcurrentHashMap<>(); _Required = new CopyOnWriteArrayList<>(); _Links = new CopyOnWriteArrayList<>(); // TODO not pass the args... parseExtensions(rootNode, syntaxLoader); parseProperties(); parseLinks(); parseRequireds(); parseDependencies(); }
From source file:com.opentech.camel.task.threading.DefaultThreadPool.java
@Override public void initialize() { super.initialize(); pengingReleaseThreadRequest = new ConcurrentHashMap<String, WrapedTask>(); innerThreadPool = new ThreadPoolExecutor(coreThreadCount, maxThreadCount, keepAliveTime, TimeUnit.MILLISECONDS, workqueue, threadFactory) { @Override/*from w w w . j a v a 2 s .co m*/ protected void beforeExecute(Thread t, Runnable r) { super.beforeExecute(t, r); /*if(r instanceof WrapedTask) { WrapedTask wt = ((WrapedTask)r); //XXX NO NEED }*/ } @Override protected void afterExecute(Runnable r, Throwable t) { super.afterExecute(r, t); if (r instanceof WrapedTask) { WrapedTask wt = ((WrapedTask) r); if (null != pengingReleaseThreadRequest.putIfAbsent(Thread.currentThread().getName(), wt)) { throw new IllegalStateException("OMG Bug"); } // XXX Release thread resource here, not safe, because of thread not really released here } } }; }
From source file:com.turbospaces.spaces.SpaceReceiveAdapter.java
SpaceReceiveAdapter(final AbstractJSpace jSpace) { this.jSpace = jSpace; this.durableTransactions = new ConcurrentHashMap<Address, Cache<Long, SpaceTransactionHolder>>(); }
From source file:edu.msu.cme.rdp.kmer.cli.KmerCoverage.java
/** * // w w w .j a v a 2s.c om * @param kmerSize * @param contigReader one contig file * @throws IOException */ public KmerCoverage(int kmerSize, SequenceReader contigReader) throws IOException { kmerMaps[0] = new ConcurrentHashMap<Kmer, KmerAbund>(); // kmer map for the forward direction kmerMaps[1] = new ConcurrentHashMap<Kmer, KmerAbund>(); // kmer map for the reverse direction this.kmerSize = kmerSize; processContigFile(contigReader); }
From source file:com.demandware.vulnapp.challenge.impl.XSSChallenge.java
protected XSSChallenge(String name) { super(name);// w w w .j av a 2s . co m this.adminCookieValue = SecureRandomUtil.generateRandomHexString(6); this.messageMap = new ConcurrentHashMap<String, Queue<String>>(); }