List of usage examples for java.util.concurrent ConcurrentHashMap ConcurrentHashMap
public ConcurrentHashMap()
From source file:com.l2jfree.gameserver.util.DynamicExtension.java
/** * initialize all configured extensions/*from w ww.j a v a 2s . c om*/ * */ public void initExtensions() { _prop = new L2Properties(); _loadedExtensions = new ConcurrentHashMap<String, Object>(); try { _prop.load(new FileInputStream(CONFIG)); } catch (FileNotFoundException ex) { _log.info(ex.getMessage() + ": no extensions to load", ex); } catch (Exception ex) { _log.warn("could not load properties", ex); } classLoader = new JarClassLoader(); for (Object o : _prop.keySet()) { String k = (String) o; if (k.endsWith("Class")) { initExtension(_prop.getProperty(k)); } } }
From source file:io.pravega.controller.store.stream.ZKStreamMetadataStore.java
ZKStreamMetadataStore(CuratorFramework client, int bucketCount, Executor executor) { super(new ZKHostIndex(client, "/hostTxnIndex", executor), bucketCount); initialize();/*from w w w . ja va 2 s . com*/ storeHelper = new ZKStoreHelper(client, executor); bucketCacheMap = new ConcurrentHashMap<>(); bucketOwnershipCacheRef = new AtomicReference<>(); }
From source file:com.yahoo.pulsar.client.impl.ConnectionPool.java
public ConnectionPool(final PulsarClientImpl client, EventLoopGroup eventLoopGroup) { this.eventLoopGroup = eventLoopGroup; this.maxConnectionsPerHosts = client.getConfiguration().getConnectionsPerBroker(); pool = new ConcurrentHashMap<>(); bootstrap = new Bootstrap(); bootstrap.group(eventLoopGroup);/*from www . j a v a2s .co m*/ if (SystemUtils.IS_OS_LINUX && eventLoopGroup instanceof EpollEventLoopGroup) { bootstrap.channel(EpollSocketChannel.class); } else { bootstrap.channel(NioSocketChannel.class); } bootstrap.option(ChannelOption.CONNECT_TIMEOUT_MILLIS, 10000); bootstrap.option(ChannelOption.TCP_NODELAY, client.getConfiguration().isUseTcpNoDelay()); bootstrap.option(ChannelOption.ALLOCATOR, PooledByteBufAllocator.DEFAULT); bootstrap.handler(new ChannelInitializer<SocketChannel>() { public void initChannel(SocketChannel ch) throws Exception { ClientConfiguration clientConfig = client.getConfiguration(); if (clientConfig.isUseTls()) { SslContextBuilder builder = SslContextBuilder.forClient(); if (clientConfig.isTlsAllowInsecureConnection()) { builder.trustManager(InsecureTrustManagerFactory.INSTANCE); } else { if (clientConfig.getTlsTrustCertsFilePath().isEmpty()) { // Use system default builder.trustManager((File) null); } else { File trustCertCollection = new File(clientConfig.getTlsTrustCertsFilePath()); builder.trustManager(trustCertCollection); } } // Set client certificate if available AuthenticationDataProvider authData = clientConfig.getAuthentication().getAuthData(); if (authData.hasDataForTls()) { builder.keyManager(authData.getTlsPrivateKey(), (X509Certificate[]) authData.getTlsCertificates()); } SslContext sslCtx = builder.build(); ch.pipeline().addLast(TLS_HANDLER, sslCtx.newHandler(ch.alloc())); } ch.pipeline().addLast("frameDecoder", new PulsarLengthFieldFrameDecoder(MaxMessageSize, 0, 4, 0, 4)); ch.pipeline().addLast("handler", new ClientCnx(client)); } }); }
From source file:ch.algotrader.service.algo.AbstractAlgoOrderExecService.java
public AbstractAlgoOrderExecService(final OrderExecutionService orderExecutionService, final SimpleOrderService simpleOrderService) { Validate.notNull(orderExecutionService, "OrderExecutionService is null"); Validate.notNull(simpleOrderService, "OrderExecutionService is null"); this.orderExecutionService = orderExecutionService; this.simpleOrderService = simpleOrderService; this.algoOrderStates = new ConcurrentHashMap<>(); }
From source file:channellistmaker.channelfilemaker.ChannelDocumentMaker.java
public ChannelDocumentMaker(Map<MultiKey<Integer>, Channel> channels) { Map<MultiKey<Integer>, Channel> temp = new ConcurrentHashMap<>(); temp.putAll(channels);//from w w w . ja v a 2 s .c o m this.channels = Collections.unmodifiableMap(temp); }
From source file:org.craftercms.core.util.template.impl.spel.SpELStringTemplateCompiler.java
public SpELStringTemplateCompiler() { parser = new SpelExpressionParser(); parserContext = new TemplateParserContext(); expressionCache = new ConcurrentHashMap<String, Expression>(); }
From source file:au.gov.ga.earthsci.bookmark.properties.layer.LayersProperty.java
/** * Add additional layer state to this property. * /*from w w w. j a v a 2s.c o m*/ * @param id * The id of the layer * @param opacity * The opacity of the layer */ public void addLayer(String id, Pair<String, String>... keyandValues) { if (!layerStateInfo.containsKey(id)) { layerStateInfo.put(id, new ConcurrentHashMap<String, String>()); } for (Pair<String, String> pair : keyandValues) { layerStateInfo.get(id).put(pair.getKey(), pair.getValue()); } }
From source file:com.mobilehelix.appserver.session.SessionManager.java
@PostConstruct public void init() { globalSessionMap = new ConcurrentHashMap<>(); // Determine what type of app registry we have ... }
From source file:com.jivesoftware.os.upena.shared.Instance.java
@JsonCreator public Instance(@JsonProperty("clusterKey") ClusterKey clusterKey, @JsonProperty("hostKey") HostKey hostKey, @JsonProperty("serviceKey") ServiceKey serviceKey, @JsonProperty("releaseGroupKey") ReleaseGroupKey releaseGroupKey, @JsonProperty("instanceId") int instanceId, @JsonProperty("enabled") boolean enabled, @JsonProperty("locked") boolean locked, @JsonProperty("publicKey") String publicKey, @JsonProperty("restartTimestampGMTMillis") long restartTimestampGMTMillis, @JsonProperty("ports") Map<String, Port> ports) { this.clusterKey = clusterKey; this.hostKey = hostKey; this.serviceKey = serviceKey; this.releaseGroupKey = releaseGroupKey; this.instanceId = instanceId; this.enabled = enabled; this.locked = locked; this.publicKey = publicKey; this.restartTimestampGMTMillis = restartTimestampGMTMillis; this.ports = ports == null ? new ConcurrentHashMap<>() : ports; }
From source file:com.cloudera.lib.service.instrumentation.InstrumentationService.java
@Override @SuppressWarnings("unchecked") public void init() throws ServiceException { timersSize = getServiceConfig().getInt(CONF_TIMERS_SIZE, 10); counterLock = new ReentrantLock(); timerLock = new ReentrantLock(); variableLock = new ReentrantLock(); samplerLock = new ReentrantLock(); jvmVariables = new ConcurrentHashMap<String, VariableHolder>(); counters = new ConcurrentHashMap<String, Map<String, AtomicLong>>(); timers = new ConcurrentHashMap<String, Map<String, Timer>>(); variables = new ConcurrentHashMap<String, Map<String, VariableHolder>>(); samplers = new ConcurrentHashMap<String, Map<String, Sampler>>(); samplersList = new ArrayList<Sampler>(); all = new LinkedHashMap<String, Map<String, ?>>(); all.put("os-env", System.getenv()); all.put("sys-props", (Map<String, ?>) (Map) System.getProperties()); all.put("jvm", jvmVariables); all.put("counters", (Map) counters); all.put("timers", (Map) timers); all.put("variables", (Map) variables); all.put("samplers", (Map) samplers); jvmVariables.put("free.memory", new VariableHolder<Long>(new Instrumentation.Variable<Long>() { public Long getValue() { return Runtime.getRuntime().freeMemory(); }//from w ww . ja v a2s . c o m })); jvmVariables.put("max.memory", new VariableHolder<Long>(new Instrumentation.Variable<Long>() { public Long getValue() { return Runtime.getRuntime().maxMemory(); } })); jvmVariables.put("total.memory", new VariableHolder<Long>(new Instrumentation.Variable<Long>() { public Long getValue() { return Runtime.getRuntime().totalMemory(); } })); }