List of usage examples for java.util.concurrent ConcurrentHashMap ConcurrentHashMap
public ConcurrentHashMap()
From source file:com.openteach.diamond.service.impl.AbstractServiceInvoker.java
@Override public void initialize() { super.initialize(); methodInvokerMap = new ConcurrentHashMap<String, MethodInvoker>(); }
From source file:com.baidu.fsg.uid.utils.NamingThreadFactory.java
public NamingThreadFactory(String name, boolean daemon, UncaughtExceptionHandler handler) { this.name = name; this.daemon = daemon; this.uncaughtExceptionHandler = handler; this.sequences = new ConcurrentHashMap<String, AtomicLong>(); }
From source file:com.chicm.cmraft.core.NodeConnectionManager.java
private void initServerList() { connections = new ConcurrentHashMap<>(); for (ServerInfo remote : getRaftNode().getRemoteServers()) { NodeConnection client = new DefaultNodeConnection(conf, remote); connections.put(remote, client); }/*from w ww .jav a2 s. com*/ }
From source file:com.clustercontrol.plugin.impl.OsScopeInitializerPlugin.java
@Override public void activate() { Set<String> builtinScopeFacilityIdSet = FacilityTreeAttributeConstant.getBuiltinScopeFacilityIdSet(); Map<String, CollectorPlatformMstEntity> platformMap = new ConcurrentHashMap<String, CollectorPlatformMstEntity>(); Set<String> platformIdSet = new HashSet<String>(); Set<String> osFacilityIdSet = new HashSet<String>(); String osParentFacilityId = FacilityTreeAttributeConstant.OS_PARENT_SCOPE; try {//from ww w . j a v a 2s .c o m for (CollectorPlatformMstEntity platformMstEntity : QueryUtil.getAllCollectorPlatformMst()) { String platformId = platformMstEntity.getPlatformId(); platformIdSet.add(platformId); platformMap.put(platformId, platformMstEntity); } for (FacilityInfo facilityEntity : QueryUtil.getChildFacilityEntity(osParentFacilityId)) { osFacilityIdSet.add(facilityEntity.getFacilityId()); } builtinScopeFacilityIdSet.addAll(osFacilityIdSet); osScopeIdSet.addAll(osFacilityIdSet); } catch (Exception e) { log.error(e); return; } //setting.cc_collector_platform_mst???setting.cc_cfg_facility??? //OSOS? JpaTransactionManager jtm = null; try { jtm = new JpaTransactionManager(); jtm.begin(); //osFacilityId?platformId??? Set<String> facilityIdToAddSet = new HashSet<String>(platformIdSet); facilityIdToAddSet.removeAll(osFacilityIdSet); HinemosEntityManager em = new JpaTransactionManager().getEntityManager(); long now = HinemosTime.currentTimeMillis(); FacilityInfo osParentFacilityEntity = QueryUtil.getFacilityPK_NONE(osParentFacilityId); for (String facilityIdToAdd : facilityIdToAddSet) { CollectorPlatformMstEntity platformMstEntity = platformMap.get(facilityIdToAdd); ScopeInfo facilityEntityToAdd = new ScopeInfo(facilityIdToAdd); facilityEntityToAdd.setFacilityName(platformMstEntity.getPlatformName()); facilityEntityToAdd.setDescription(platformMstEntity.getPlatformName()); facilityEntityToAdd.setDisplaySortOrder(platformMstEntity.getOrderNo()); facilityEntityToAdd.setFacilityType(osParentFacilityEntity.getFacilityType()); facilityEntityToAdd.setIconImage(osParentFacilityEntity.getIconImage()); facilityEntityToAdd.setValid(osParentFacilityEntity.getValid()); facilityEntityToAdd.setOwnerRoleId(osParentFacilityEntity.getOwnerRoleId()); facilityEntityToAdd.setCreateUserId(osParentFacilityEntity.getCreateUserId()); facilityEntityToAdd.setCreateDatetime(now); facilityEntityToAdd.setModifyUserId(osParentFacilityEntity.getModifyUserId()); facilityEntityToAdd.setModifyDatetime(now); facilityEntityToAdd.persistSelf(em); em.flush(); log.info(String.format("The OS scope %s will be added.", facilityIdToAdd)); FacilityRelationEntity relation = new FacilityRelationEntity(osParentFacilityId, facilityIdToAdd); em.persist(relation); } jtm.commit(); if (!facilityIdToAddSet.isEmpty()) { builtinScopeFacilityIdSet.addAll(facilityIdToAddSet); osScopeIdSet.addAll(facilityIdToAddSet); } } catch (Exception e) { log.error(e); if (jtm != null) { jtm.rollback(); } return; } finally { if (jtm != null) { jtm.close(); } } //setting.cc_collector_platform_mst????setting.cc_cfg_facility?? //OSOS? try { jtm = new JpaTransactionManager(); jtm.begin(); HinemosEntityManager em = jtm.getEntityManager(); Set<String> facilityIdToRemoveSet = new HashSet<String>(osFacilityIdSet); facilityIdToRemoveSet.removeAll(platformIdSet); for (String facilityIdToRemove : facilityIdToRemoveSet) { FacilityRelationEntity facilityRelationEntityToRemove = QueryUtil .getFacilityRelationPk(osParentFacilityId, facilityIdToRemove); em.remove(facilityRelationEntityToRemove); FacilityInfo facilityEntityToRemove = QueryUtil.getFacilityPK_NONE(facilityIdToRemove); log.info(String.format("The OS scope %s will be removed.", facilityIdToRemove)); em.remove(facilityEntityToRemove); } jtm.commit(); if (!facilityIdToRemoveSet.isEmpty()) { builtinScopeFacilityIdSet.removeAll(facilityIdToRemoveSet); osScopeIdSet.removeAll(facilityIdToRemoveSet); } } catch (Exception e) { log.error(e); if (jtm != null) { jtm.rollback(); } } finally { if (jtm != null) { jtm.close(); } } }
From source file:com.garethahealy.camel.file.loadbalancer.filter.DefaultPriorityFileFilterFactory.java
@Override public synchronized void init() { if (!inited.get()) { if (amountOfWatchers <= 0) { throw new IllegalArgumentException("AmountOfWatchers is less/equal to 0. Must be positive"); }//from w w w . j a va 2s . c o m if (maxMessagesPerPoll <= 0) { throw new IllegalArgumentException("MaxMessagesPerPoll is less/equal to 0. Must be positive"); } if (holder == null) { holder = new ConcurrentHashMap<Integer, PriorityFileFilter>(); } holder.clear(); counter.set(0); for (int i = 0; i < amountOfWatchers; i++) { PriorityFileFilter filter = new PriorityFileFilter(i, amountOfWatchers, maxMessagesPerPoll); filter.init(); holder.put(i, filter); } LOG.info("Created a holder of '{}' as amountOfWatchers is '{}'", holder.size(), amountOfWatchers); inited.set(true); } }
From source file:cn.caimatou.canting.utils.http.asynchttp.PersistentCookieStore.java
/** * Construct a persistent cookie store.// ww w . j av a 2 s. c om */ public PersistentCookieStore(Context context) { cookiePrefs = context.getSharedPreferences(COOKIE_PREFS, 0); cookies = new ConcurrentHashMap<String, Cookie>(); // Load any previously stored cookies into the store String storedCookieNames = cookiePrefs.getString(COOKIE_NAME_STORE, null); if (storedCookieNames != null) { String[] cookieNames = TextUtils.split(storedCookieNames, ","); for (String name : cookieNames) { String encodedCookie = cookiePrefs.getString(COOKIE_NAME_PREFIX + name, null); if (encodedCookie != null) { Cookie decodedCookie = decodeCookie(encodedCookie); if (decodedCookie != null) { cookies.put(name, decodedCookie); } } } // Clear out expired cookies clearExpired(new Date()); } }
From source file:com.wineaccess.sampler.SamplerAdapterHelper.java
/** * This method is used to add the sampler. * @param samplerPO take the input parameter for adding the sampler in database. * @return Map the output map//from w ww. jav a 2 s . co m */ public static Map<String, Object> addSampler(final AddSamplerPO samplerPO) { logger.info("add the sampler"); Map<String, Object> output = new ConcurrentHashMap<String, Object>(); Response response = null; final SamplerModel samplerName = SamplerRepository.getSamplerByName(samplerPO.getSamplerName()); if (samplerName == null) { final SamplerModel samplerModel = new SamplerModel(); samplerModel.setName(samplerPO.getSamplerName()); samplerModel.setIsEnabled(false); List<ProductDetails> products = samplerPO.getProducts(); for (ProductDetails details : products) { if (details == null) { response = ApplicationUtils.errorMessageGenerate(SystemErrorCode.ADD_SAMPLER_ERROR_110, SystemErrorCode.ADD_SAMPLER_ERROR_110_TEXT, RESPONSECODES.SUCCESSCODE.getResponseCodes()); } } if (response == null) { List<String> uniqueProducts = new ArrayList<String>(); for (ProductDetails details : products) { String productType = StringUtils.EMPTY; if (StringUtils.isEmpty(details.getProductType())) { MasterData productData = MasterDataRepository .getMasterDataByTypeAndName(MasterDataTypeEnum.Constants.PRODUCT_TYPE, "Wine"); productType = Long.toString(productData.getId()); } else { productType = details.getProductType(); } String checkUnique = ApplicationUtils.generateUniqueHash(details.getProductId(), productType); if (uniqueProducts.contains(checkUnique)) { response = ApplicationUtils.errorMessageGenerate(SystemErrorCode.ADD_SAMPLER_ERROR_112, SystemErrorCode.ADD_SAMPLER_ERROR_112_TEXT, RESPONSECODES.SUCCESSCODE.getResponseCodes()); } else { uniqueProducts.add(checkUnique); } } } if (response == null) { List<ProductDetails> detailList = new ArrayList<ProductDetails>(); for (ProductDetails details : products) { String productType = StringUtils.EMPTY; if (StringUtils.isEmpty(details.getProductType())) { MasterData productData = MasterDataRepository .getMasterDataByTypeAndName(MasterDataTypeEnum.Constants.PRODUCT_TYPE, "Wine"); productType = Long.toString(productData.getId()); } else { productType = details.getProductType(); } ProductItemModel productItemModel = ProductItemRepository .getByIdAndProduct(Long.parseLong(details.getProductId()), Long.parseLong(productType)); if (productItemModel != null) { final ProductDetails productDetails = new ProductDetails(); productDetails.setProductId(details.getProductId()); productDetails.setProductType(productType); productDetails.setQuantity(details.getQuantity()); detailList.add(productDetails); } else { response = ApplicationUtils.errorMessageGenerate(SystemErrorCode.ADD_SAMPLER_ERROR_111, SystemErrorCode.ADD_SAMPLER_ERROR_111_TEXT, RESPONSECODES.SUCCESSCODE.getResponseCodes()); } } if (response == null) { SamplerRepository.save(samplerModel); for (ProductDetails details : detailList) { final ProductSamplerModel productSamplerModel = new ProductSamplerModel(); productSamplerModel.setSamplerId(samplerModel); ProductItemModel itemModel = ProductItemRepository .getProductItemById(Long.parseLong(details.getProductId())); productSamplerModel.setProductId(itemModel); MasterData quantity = MasterDataRepository .getMasterDataById(Long.parseLong(details.getQuantity())); productSamplerModel.setQuantity(quantity); ProductSamplerRepository.save(productSamplerModel); } AddSamplerVO addSamplerVO = new AddSamplerVO(samplerModel.getId(), SystemErrorCode.ADD_SAMPLER_SUCCESS_TEXT); response = new com.wineaccess.response.SuccessResponse(addSamplerVO, RESPONSECODES.SUCCESSCODE.getResponseCodes()); } } } else { response = ApplicationUtils.errorMessageGenerate(SystemErrorCode.ADD_SAMPLER_ERROR_109, SystemErrorCode.ADD_SAMPLER_ERROR_109_TEXT, RESPONSECODES.SUCCESSCODE.getResponseCodes()); } logger.info("exit from add sampler"); output.put(OUTPUT_PARAM_KEY, response); return output; }
From source file:com.gwm.android.PreferencesCookieStore.java
/** * Construct a persistent cookie store.//from ww w. j av a 2s. c o m */ private PreferencesCookieStore(Context context) { cookiePrefs = context.getSharedPreferences(COOKIE_PREFS, 0); cookies = new ConcurrentHashMap<String, Cookie>(); // Load any previously stored cookies into the store String storedCookieNames = cookiePrefs.getString(COOKIE_NAME_STORE, null); if (storedCookieNames != null) { String[] cookieNames = TextUtils.split(storedCookieNames, ","); for (String name : cookieNames) { String encodedCookie = cookiePrefs.getString(COOKIE_NAME_PREFIX + name, null); if (encodedCookie != null) { Cookie decodedCookie = decodeCookie(encodedCookie); if (decodedCookie != null) { cookies.put(name, decodedCookie); } } } // Clear out expired cookies clearExpired(new Date()); } }
From source file:de.minestar.contao2.manager.PlayerManager.java
public void refresh() { this.onlineList = new HashMap<ContaoGroup, String>(); this.groupMap = new HashMap<ContaoGroup, HashSet<String>>(); this.playerMap = new ConcurrentHashMap<String, ContaoGroup>(); this.initGroupMap(); this.onReload(); }
From source file:ws.salient.aws.dynamodb.DynamoDBProfiles.java
public DynamoDBProfiles(DynamoDB dynamodb, AWSKMS kms, ObjectMapper json) { this.kms = kms; this.dynamodb = dynamodb; this.json = json; accounts = new ConcurrentHashMap(); }