List of usage examples for java.util.concurrent ConcurrentHashMap ConcurrentHashMap
public ConcurrentHashMap()
From source file:ch.entwine.weblounge.kernel.endpoint.RuntimeInformationEndpoint.java
/** * Creates a new instance of the runtime information endpoint. *//*from www . j a v a 2s . co m*/ public RuntimeInformationEndpoint() { runtimeInfoProviders = new ConcurrentHashMap<String, RuntimeInformationProvider>(); }
From source file:PalidromeArray.java
public PalidromeArray(BigInteger totalLength) { this.totalLength = totalLength; this.halfLength = totalLength.divide(TWO); if (MathUtil.isOdd(totalLength)) { isEven = false;/*www. j av a 2 s .c o m*/ halfLength = halfLength.add(BigInteger.ONE); } array = new ConcurrentHashMap<BigInteger, BigInteger>(); }
From source file:io.github.retz.scheduler.RetzScheduler.java
public RetzScheduler(Launcher.Configuration conf, Protos.FrameworkInfo frameworkInfo) { MAPPER.registerModule(new Jdk8Module()); PLANNER = PlannerFactory.create(conf.getServerConfig().getPlannerName()); this.conf = Objects.requireNonNull(conf); this.frameworkInfo = frameworkInfo; this.slaves = new ConcurrentHashMap<>(); this.filters = Protos.Filters.newBuilder().setRefuseSeconds(conf.getServerConfig().getRefuseSeconds()) .build();// w w w. j a v a 2 s .c o m MAX_JOB_SIZE = conf.getServerConfig().getMaxJobSize(); }
From source file:com.torrenttunes.android.model.MusicProvider.java
public MusicProvider() { mMusicListByArtist = new ConcurrentHashMap<>(); mMusicListById = new ConcurrentHashMap<>(); mFavoriteTracks = Collections.newSetFromMap(new ConcurrentHashMap<String, Boolean>()); }
From source file:com.launchkey.example.springmvc.AuthManager.java
@Autowired public AuthManager(LaunchKeyConfig config) throws ConfigurationException, IOException { final Long rocketKey = config.getRocketKey(); final String secretKey = config.getSecretKey(); final String privateKeyLocation = config.getPrivateKeyLocation(); boolean halt = false; if (rocketKey == null) { log.error("launchkey.rocket-key property not provided"); halt = true;// w w w . j a v a2s .c om } if (secretKey == null) { log.error("launchkey.secret-key property not provided"); halt = true; } if (privateKeyLocation == null) { log.error("launchkey.private-key-location property not provided"); halt = true; } if (halt) throw new ConfigurationException("Missing required LaunchKey configuration"); BufferedReader br = new BufferedReader(new FileReader(privateKeyLocation)); StringBuilder sb = new StringBuilder(); try { String line = br.readLine(); while (line != null) { sb.append(line); sb.append("\n"); line = br.readLine(); } } finally { br.close(); } String privateKey = sb.toString(); LaunchKeyClient launchKeyClient = LaunchKeyClient.factory(rocketKey, secretKey, privateKey, new BouncyCastleProvider()); this.authService = launchKeyClient.auth(); this.sessionAuthenticationMap = Collections.synchronizedMap(new HashMap<String, Boolean>()); this.sessionAuthRequestMap = new ConcurrentHashMap<String, String>(); this.userHashSessionMap = new ConcurrentHashMap<String, List<String>>(); }
From source file:eu.tradegrid.tinkerpop.persistor.TinkerpopPersistor.java
/** * Start the Tinkerpop Persistor module. *///from w w w . ja v a 2s . c om @Override public void start() { super.start(); address = getOptionalStringConfig("address", "tinkerpop.persistor"); tinkerpopConfig = loadTinkerpopConfig(); jsonUtility = new JsonUtility(tinkerpopConfig.getString("graphson.mode", "NORMAL")); queryCache = new ConcurrentHashMap<>(); eb.registerHandler(address, this); logger.info("TinkerpopPersistor module started"); }
From source file:com.legstar.coxb.transform.AbstractTransformer.java
/** * Create a transformer using a specific COBOL parameters set. * // w ww . j a v a 2 s . com * @param cobolContext the COBOL parameters set. */ public AbstractTransformer(final CobolContext cobolContext) { try { ICobolConvertersFactory factory = CobolConvertersFactory.createCobolConvertersFactory(); mCobolConverters = factory.createCobolConverters(); mCobolBindingVisitorsFactory = CobolBindingVisitorsFactory.createCobolBindingVisitorsFactory(); setCobolContext(cobolContext); _cobolComplexBindingCache = new ConcurrentHashMap<Long, ICobolComplexBinding>(); } catch (ClassLoadingException e) { throw new RuntimeException(e); } }
From source file:com.neophob.sematrix.jmx.PixelControllerStatus.java
/** * Register the JMX Bean./*from w w w .j a va2s. c om*/ * * @param configuredFps the configured fps */ public PixelControllerStatus(int configuredFps) { LOG.log(Level.INFO, "Initialize the PixelControllerStatus JMX Bean"); this.configuredFps = configuredFps; // initialize all buffers this.timeMeasureMapGlobal = new ConcurrentHashMap<TimeMeasureItemGlobal, CircularFifoBuffer>(); for (TimeMeasureItemGlobal timeMeasureItem : TimeMeasureItemGlobal.values()) { this.timeMeasureMapGlobal.put(timeMeasureItem, new CircularFifoBuffer(this.configuredFps * SECONDS)); } this.timeMeasureMapOutput = new ConcurrentHashMap<Output, Map<TimeMeasureItemOutput, CircularFifoBuffer>>(); this.outputList = new ArrayList<Output>(); startTime = System.currentTimeMillis(); // register MBean try { MBeanServer server = ManagementFactory.getPlatformMBeanServer(); ObjectName name = new ObjectName(JMX_BEAN_NAME); // check if the MBean is already registered if (!server.isRegistered(name)) { server.registerMBean(this, name); } } catch (JMException ex) { LOG.log(Level.WARNING, "Error while registering class as JMX Bean.", ex); } }
From source file:com.wineaccess.wine.WineAdapterHelper.java
/** * This method is used to add the wine in the database. * //from w w w. ja v a2 s . co m * @param winePO this is used to take the input. * @return output map containing response */ public static Map<String, Object> addWine(final WinePO winePO) { logger.info("start addWine method"); String errorMsg = StringUtils.EMPTY; final Map<String, Object> output = new ConcurrentHashMap<String, Object>(); Response response = null; try { MasterData wineStyle = null; MasterData vintage = null; MasterData varietal = null; MasterData bottleInMl = null; MasterData bottlesPerBox = null; WineryModel winery = null; MasterData wineSourcingId = null; ImporterModel importer = null; wineStyle = MasterDataRepository.getMasterDataById(Long.parseLong(winePO.getWineStyleId())); if (wineStyle == null) { // wine style not exist response = ApplicationUtils.errorMessageGenerate( SystemErrorCode.INVALID_WINE_STYLE, SystemErrorCode.INVALID_WINE_STYLE_TEXT, SUCCESS_CODE); logger.error("wine style not exist"); } if (response == null) { vintage = MasterDataRepository.getMasterDataById(Long.parseLong(winePO.getVintageId())); if (vintage == null) { // vintage not exist response = ApplicationUtils.errorMessageGenerate( SystemErrorCode.INVALID_VINTAGE, SystemErrorCode.INVALID_VINTAGE_TEXT, SUCCESS_CODE); logger.error("vintage not exist"); } } if (response == null) { varietal = MasterDataRepository.getMasterDataById(Long.parseLong(winePO.getVarietalId())); if (varietal == null) { // varietal not exist response = ApplicationUtils.errorMessageGenerate( SystemErrorCode.INVALID_VARIETAL, SystemErrorCode.INVALID_VARIETAL_TEXT, SUCCESS_CODE); logger.error("varietal not exist"); } } if (response == null) { bottleInMl = MasterDataRepository.getMasterDataById(Long.parseLong(winePO.getBottleInMlId())); if (bottleInMl == null) { // bottleInMlId not exist response = ApplicationUtils.errorMessageGenerate( SystemErrorCode.INVALID_BOTTLE_IN_ML, SystemErrorCode.INVALID_BOTTLE_IN_ML_TEXT, SUCCESS_CODE); logger.error("bottleInMlId not exist"); } } if (response == null) { if (winePO.getBottlesPerBoxId() != null) { if (!winePO.getBottlesPerBoxId().isEmpty()) { bottlesPerBox = MasterDataRepository .getMasterDataById(Long.parseLong(winePO.getBottlesPerBoxId())); if (bottlesPerBox == null) { // bottlesPerBox not exist response = ApplicationUtils.errorMessageGenerate( SystemErrorCode.INVALID_BOTTLES_PER_BOX, SystemErrorCode.INVALID_BOTTLES_PER_BOX_TEXT, SUCCESS_CODE); logger.error("bottlesPerBox not exist"); } } } } if (response == null) { winery = WineryRepository.getWineryById(Long.parseLong(winePO.getWineryId())); if (winery == null) { // winery not exist response = ApplicationUtils.errorMessageGenerate( SystemErrorCode.INVALID_WINERY, SystemErrorCode.INVALID_WINERY_TEXT, SUCCESS_CODE); logger.error("winery not exist"); } } if (response == null) { if (winePO.getWineSourcingId() != null) { if (!winePO.getWineSourcingId().isEmpty()) { wineSourcingId = MasterDataRepository .getMasterDataById(Long.parseLong(winePO.getWineSourcingId())); if (wineSourcingId == null) { // wineSourcingId not exist response = ApplicationUtils.errorMessageGenerate( SystemErrorCode.INVALID_SOURCING, SystemErrorCode.INVALID_SOURCING_TEXT, SUCCESS_CODE); logger.error("wineSourcingId not exist"); } } } } boolean isImported = false; if (response == null) { importer = winery.getActiveImporterId(); if (importer != null) { isImported = true; } } if (response == null) { final WineModel wineModel = new WineModel(); String wineFullName = PropertyholderUtils.getStringProperty("wine.full.name"); wineFullName = wineFullName.replace("<vintage>", vintage.getName() + " "); wineFullName = wineFullName.replace("<winery>", winery.getWineryName() + " "); wineFullName = wineFullName.replace("<winename>", winePO.getWineName()); wineModel.setWineFullName(wineFullName); wineModel.setWineName(winePO.getWineName()); wineModel.setVerietal(varietal); wineModel.setVintage(vintage); if (winePO.getWineShortName() != null) { if (!winePO.getWineShortName().isEmpty()) { wineModel.setWineryShortName(winePO.getWineShortName()); } else { wineModel.setWineryShortName(null); } } wineModel.setBottleInMl(bottleInMl); wineModel.setBottlesPerBox(bottlesPerBox); wineModel.setIsDeleted(false); if (winePO.getAlcoholPercentage() != null) { if (!winePO.getAlcoholPercentage().isEmpty()) { wineModel.setAlcoholPercentage(Double.parseDouble(winePO.getAlcoholPercentage())); } else { wineModel.setAlcoholPercentage(null); } } if (winePO.getNotes() != null) { if (!winePO.getNotes().isEmpty()) { wineModel.setNotes(winePO.getNotes()); } else { wineModel.setNotes(null); } } if (winePO.getWineLabel() != null) { if (!winePO.getWineLabel().isEmpty()) { wineModel.setWineLabel(winePO.getWineLabel()); } else { wineModel.setWineLabel(null); } } if (winePO.getPrivateLabel() != null) { if (!winePO.getPrivateLabel().isEmpty()) { wineModel.setPrivateLabel(winePO.getPrivateLabel()); } else { wineModel.setPrivateLabel(null); } } wineModel.setWineType(wineStyle); wineModel.setWineryId(winery); wineModel.setWineSourcingId(wineSourcingId); if (winePO.getSendToFullfillerOn() != null) { if (!winePO.getSendToFullfillerOn().isEmpty()) { wineModel.setSendToFullfillerOn(Boolean.parseBoolean(winePO.getSendToFullfillerOn())); } else { wineModel.setSendToFullfillerOn(null); } } if (winePO.getUsaArrivalDate() != null) { wineModel.setUsaArrivalDate(winePO.getUsaArrivalDate()); } if (winePO.getLicenseFFPartnerId() != null) { if (!winePO.getLicenseFFPartnerId().isEmpty()) { wineModel.setLicenseFullfillmentPartnerId(Long.parseLong(winePO.getLicenseFFPartnerId())); } else { wineModel.setLicenseFullfillmentPartnerId(null); } } if (winePO.getSellInMainStatesOnly() != null) { wineModel.setSellInMainStates(Boolean.parseBoolean(winePO.getSellInMainStatesOnly())); } if (winePO.getNameIfNotSellInAltStates() != null) { wineModel.setSellInAltStates(Boolean.parseBoolean(winePO.getNameIfNotSellInAltStates())); } wineModel.setIsImported(isImported); if (isImported) { wineModel.setImporterId(importer); } wineModel.setIsEnabled(Boolean.parseBoolean(winePO.getStatus())); MasterData masterData = MasterDataRepository.getMasterDataByTypeAndName("ProductType", "Wine"); if (masterData != null) { if (isImported) { if (importer.getWarehouseId() != null) { wineModel.setWarehouseId(importer.getWarehouseId()); } else if (winery.getWarehouseId() != null) { wineModel.setWarehouseId(winery.getWarehouseId()); } else { wineModel.setWarehouseId(null); } } else { if (winery.getWarehouseId() != null) { wineModel.setWarehouseId(winery.getWarehouseId()); } else { wineModel.setWarehouseId(null); } } WineryImporterContacts contactModel = null; if (importer != null) { contactModel = WineryImporterContactRepository.getImporterContactById(importer.getId()); } else { contactModel = WineryImporterContactRepository.getWineryContactById(winery.getId()); } wineModel.setContactId(contactModel); WineRepository.save(wineModel); WineRepository.updateWCAndActiveWCInWinery(winery.getId()); if (isImported) { WineRepository.updateWCAndActiveWCInImporter(importer.getId()); } ProductItemModel productItemModel = new ProductItemModel(); productItemModel.setProductId(masterData.getId()); productItemModel.setItemId(wineModel.getId()); ProductItemRepository.save(productItemModel); wineModel.setProduct(productItemModel); WineRepository.update(wineModel); WineVO wineVO = new WineVO(SystemErrorCode.WINE_ADD_SUCCESS_TEXT); BeanUtils.copyProperties(wineVO, wineModel); wineVO.setId(wineModel.getProduct().getId()); wineVO.setWineId(wineModel.getId()); wineVO.setWineryId(wineModel.getWineryId().getId()); if (wineModel.getWarehouseId() != null) { wineVO.setWarehouseId(wineModel.getWarehouseId().getId()); } response = new com.wineaccess.response.SuccessResponse(wineVO, SUCCESS_CODE); } else { response = ApplicationUtils.errorMessageGenerate( SystemErrorCode.WINE_ADD_WINE_INVALID_MASTER_DATA, SystemErrorCode.WINE_ADD_WINE_INVALID_MASTER_DATA_TEXT, SUCCESS_CODE); logger.error("Invalid Master Data "); } } } catch (Exception e) { errorMsg = e.getCause().getMessage(); } if (response == null) { if (errorMsg.contains("uk_wine")) { response = ApplicationUtils.errorMessageGenerate(SystemErrorCode.WINE_ADD_WINE_DUPLICATE, SystemErrorCode.WINE_ADD_WINE_DUPLICATE_TEXT, SUCCESS_CODE); logger.error("Duplicate entry for wine name "); } else { response = ApplicationUtils.errorMessageGenerate(SystemErrorCode.WINE_ADD_UNKNOWN_ERROR, SystemErrorCode.WINE_ADD_UNKNOWN_ERROR_TEXT, SUCCESS_CODE); logger.error("Unkonwn error "); } } output.put(OUPUT_PARAM_KEY, response); logger.info("exit addWine method"); return output; }
From source file:com.clustercontrol.notify.mail.view.action.MailTemplateDeleteAction.java
@Override public Object execute(ExecutionEvent event) throws ExecutionException { // ???/*from w w w. ja v a 2s . co m*/ this.viewPart = HandlerUtil.getActivePart(event); MailTemplateListView view = null; try { view = (MailTemplateListView) this.viewPart.getAdapter(MailTemplateListView.class); } catch (Exception e) { m_log.info("execute " + e.getMessage()); return null; } if (view == null) { m_log.info("execute: view is null"); return null; } MailTemplateListComposite composite = (MailTemplateListComposite) view.getListComposite(); StructuredSelection selection = (StructuredSelection) composite.getTableViewer().getSelection(); List<?> list = (List<?>) selection.toList(); Map<String, List<String>> deleteMap = new ConcurrentHashMap<String, List<String>>(); int size = 0; StringBuffer buf = new StringBuffer(); if (list != null && list.size() > 0) { for (Object obj : list) { List<?> objList = (List<?>) obj; String managerName = (String) objList.get(GetMailTemplateListTableDefine.MANAGER_NAME); if (deleteMap.get(managerName) != null) { continue; } deleteMap.put(managerName, new ArrayList<String>()); } for (Object obj : list) { List<?> objList = (List<?>) obj; String mailTemplateId = (String) objList.get(NotifyTableDefineNoCheckBox.NOTIFY_ID); String managerName = (String) objList.get(NotifyTableDefineNoCheckBox.MANAGER_NAME); if (size > 0) { buf.append(", "); } buf.append(mailTemplateId); deleteMap.get(managerName).add(mailTemplateId); size++; } } String[] args = { buf.toString() }; // ????????? if (size == 0) { MessageDialog.openWarning(null, Messages.getString("warning"), Messages.getString("message.notify.mail.8")); return null; } if (MessageDialog.openConfirm(null, Messages.getString("confirmed"), Messages.getString("message.notify.mail.7", args)) == false) { return null; } boolean result = false; for (Map.Entry<String, List<String>> entry : deleteMap.entrySet()) { String managerName = entry.getKey(); for (String mailTemplateId : entry.getValue()) { result = result | new DeleteMailTemplate().delete(managerName, mailTemplateId); } } if (result) { composite.update(); } return null; }