List of usage examples for java.util Map toString
public String toString()
From source file:storage.StorageServiceWrapperController.java
@ResponseBody @RequestMapping(value = "/", method = RequestMethod.GET) public String listStorageServices() { final Map<String, StorageService> storageServices = new HashMap<>(); storageServices.putAll(appContext.getBeansOfType(StorageService.class)); storageServices.putAll(appContext.getParent().getBeansOfType(StorageService.class)); if (log.isDebugEnabled()) { for (final Map.Entry<String, StorageService> entry : storageServices.entrySet()) { log.debug("Storage service '{}' : '{}'", entry.getKey(), entry.getValue()); }//from ww w .java2 s. c o m } return storageServices.toString(); }
From source file:org.apache.solr.handler.TestSolrConfigHandlerConcurrent.java
private void invokeBulkCall(String cacheName, List<String> errs, Map val) throws Exception { String payload = "{" + "'set-property' : {'query.CACHENAME.size':'CACHEVAL1'," + " 'query.CACHENAME.initialSize':'CACHEVAL2'}," + "'set-property': {'query.CACHENAME.autowarmCount' : 'CACHEVAL3'}" + "}"; Set<String> errmessages = new HashSet<>(); for (int i = 1; i < 2; i++) {//make it ahigher number RestTestHarness publisher = restTestHarnesses.get(r.nextInt(restTestHarnesses.size())); String response;/*from www . j a v a2 s . co m*/ String val1; String val2; String val3; try { payload = payload.replaceAll("CACHENAME", cacheName); val1 = String.valueOf(10 * i + 1); payload = payload.replace("CACHEVAL1", val1); val2 = String.valueOf(10 * i + 2); payload = payload.replace("CACHEVAL2", val2); val3 = String.valueOf(10 * i + 3); payload = payload.replace("CACHEVAL3", val3); response = publisher.post("/config?wt=json", SolrTestCaseJ4.json(payload)); } finally { publisher.close(); } Map map = (Map) getVal(new JSONParser(new StringReader(response))); Object errors = map.get("errors"); if (errors != null) { errs.add(new String(Utils.toJSON(errors), StandardCharsets.UTF_8)); return; } DocCollection coll = cloudClient.getZkStateReader().getClusterState().getCollection("collection1"); List<String> urls = new ArrayList<>(); for (Slice slice : coll.getSlices()) { for (Replica replica : slice.getReplicas()) urls.add("" + replica.get(ZkStateReader.BASE_URL_PROP) + "/" + replica.get(ZkStateReader.CORE_NAME_PROP)); } //get another node String url = urls.get(urls.size()); long startTime = System.nanoTime(); long maxTimeoutSeconds = 20; while (TimeUnit.SECONDS.convert(System.nanoTime() - startTime, TimeUnit.NANOSECONDS) < maxTimeoutSeconds) { Thread.sleep(100); errmessages.clear(); Map respMap = getAsMap(url + "/config/overlay?wt=json", cloudClient); Map m = (Map) respMap.get("overlay"); if (m != null) m = (Map) m.get("props"); if (m == null) { errmessages.add(StrUtils.formatString( "overlay does not exist for cache: {0} , iteration: {1} response {2} ", cacheName, i, respMap.toString())); continue; } Object o = getObjectByPath(m, true, asList("query", cacheName, "size")); if (!val1.equals(o)) errmessages.add( StrUtils.formatString("'size' property not set, expected = {0}, actual {1}", val1, o)); o = getObjectByPath(m, true, asList("query", cacheName, "initialSize")); if (!val2.equals(o)) errmessages.add(StrUtils .formatString("'initialSize' property not set, expected = {0}, actual {1}", val2, o)); o = getObjectByPath(m, true, asList("query", cacheName, "autowarmCount")); if (!val3.equals(o)) errmessages.add(StrUtils .formatString("'autowarmCount' property not set, expected = {0}, actual {1}", val3, o)); if (errmessages.isEmpty()) break; } if (!errmessages.isEmpty()) { errs.addAll(errmessages); return; } } }
From source file:org.codelabor.system.file.web.controller.xplatform.FileController.java
@RequestMapping("/upload-test") public String upload(Model model, HttpServletRequest request, ServletContext context) throws Exception { logger.debug("upload-teset"); DataSetList outputDataSetList = new DataSetList(); VariableList outputVariableList = new VariableList(); try {// w ww. ja v a2 s .c om boolean isMultipart = ServletFileUpload.isMultipartContent(request); Map<String, Object> paramMap = RequestUtils.getParameterMap(request); logger.debug("paramMap: {}", paramMap.toString()); String mapId = (String) paramMap.get("mapId"); RepositoryType acceptedRepositoryType = repositoryType; String requestedRepositoryType = (String) paramMap.get("repositoryType"); if (StringUtils.isNotEmpty(requestedRepositoryType)) { acceptedRepositoryType = RepositoryType.valueOf(requestedRepositoryType); } if (isMultipart) { DiskFileItemFactory factory = new DiskFileItemFactory(); factory.setSizeThreshold(sizeThreshold); factory.setRepository(new File(tempRepositoryPath)); factory.setFileCleaningTracker(FileCleanerCleanup.getFileCleaningTracker(context)); ServletFileUpload upload = new ServletFileUpload(factory); upload.setFileSizeMax(fileSizeMax); upload.setSizeMax(requestSizeMax); upload.setHeaderEncoding(characterEncoding); upload.setProgressListener(new FileUploadProgressListener()); List<FileItem> fileItemList = upload.parseRequest(request); Iterator<FileItem> iter = fileItemList.iterator(); while (iter.hasNext()) { FileItem fileItem = iter.next(); logger.debug("fileItem: {}", fileItem.toString()); FileDTO fileDTO = null; if (fileItem.isFormField()) { paramMap.put(fileItem.getFieldName(), fileItem.getString(characterEncoding)); } else { if (fileItem.getName() == null || fileItem.getName().length() == 0) continue; // set DTO fileDTO = new FileDTO(); fileDTO.setMapId(mapId); fileDTO.setRealFilename(FilenameUtils.getName(fileItem.getName())); if (acceptedRepositoryType == RepositoryType.FILE_SYSTEM) { fileDTO.setUniqueFilename(uniqueFilenameGenerationService.getNextStringId()); } fileDTO.setContentType(fileItem.getContentType()); fileDTO.setRepositoryPath(realRepositoryPath); logger.debug("fileDTO: {}", fileDTO.toString()); UploadUtils.processFile(acceptedRepositoryType, fileItem.getInputStream(), fileDTO); } if (fileDTO != null) fileManager.insertFile(fileDTO); } } else { } XplatformUtils.setSuccessMessage( messageSource.getMessage("info.success", new Object[] {}, forcedLocale), outputVariableList); logger.debug("success"); } catch (Exception e) { logger.error("fail"); e.printStackTrace(); logger.error(e.getMessage()); throw new XplatformException(messageSource.getMessage("error.failure", new Object[] {}, forcedLocale), e); } model.addAttribute(OUTPUT_DATA_SET_LIST, outputDataSetList); model.addAttribute(OUTPUT_VARIABLE_LIST, outputVariableList); return VIEW_NAME; }
From source file:com.momoplan.pet.framework.manager.controller.GetServerController.java
@RequestMapping("/best.html") public void best(String license, HttpServletResponse response) throws Exception { long s = System.currentTimeMillis(); response.setCharacterEncoding("UTF-8"); String license_key = "license:" + license; logger.debug("license_key=" + license_key); //TODO check license String license_info = Config.publicConfig.get(license_key); logger.debug("license_info=" + license_info); logger.debug("nodeServiceUrl=" + nodeServiceUrl); URL u = new URL(nodeServiceUrl); URLConnection conn = u.openConnection(); InputStream is = conn.getInputStream(); byte[] buff = new byte[4096]; int t = 0;/* ww w . j a va 2s. co m*/ ByteArrayOutputStream bos = new ByteArrayOutputStream(); while ((t = is.read(buff)) != -1) { bos.write(buff, 0, t); } String nodes = new String(bos.toByteArray()); is.close(); bos.close(); JSONObject json = new JSONObject(nodes); boolean success = json.getBoolean("success"); JSONObject rtnJson = new JSONObject(); rtnJson.put("success", success); if (success) { try { JSONArray arr = json.getJSONArray("entity"); int len = arr.length(); Map<String, Object> tmp = new HashMap<String, Object>(); tmp.put("node", ""); tmp.put("totalCount", Integer.MAX_VALUE); for (int i = 0; i < len; i++) { JSONObject node = arr.getJSONObject(i); Integer c = node.getInt("totalCount"); if (c < (Integer) tmp.get("totalCount")) { tmp.put("node", node.getString("node")); tmp.put("totalCount", c); } } logger.debug(tmp.toString()); String nodeKey = (String) tmp.get("node"); String ipHost = Config.publicConfig.get(nodeKey); String[] hostArr = ipHost.split(":"); JSONObject entity = new JSONObject(); entity.put("ip", hostArr[0]); entity.put("port", hostArr[1]); rtnJson.put("entity", entity); } catch (Exception e) { logger.error("XXXXXX", e); rtnJson.put("entity", defNode); } } else { rtnJson.put("entity", json.get("entity")); } logger.debug(nodes); long e = System.currentTimeMillis(); logger.info("license_key=" + license_key + ";license_info=" + license_info + ";rtn=" + rtnJson.toString() + " -- " + (e - s) + "ms"); response.getWriter().write(rtnJson.toString()); }
From source file:org.deri.iris.queryrewriting.PositionDependenciesTest.java
@Test public void testPositionDependenciesInverse() throws Exception { ///* w ww . j av a2 s. c o m*/ // Theory: // // [R1] t(X,Y) -> t(Y,X). // final IPredicate t = Factory.BASIC.createPredicate("t", 2); final ILiteral txy = Factory.BASIC.createLiteral(true, t, tupleXY); final ILiteral tyx = Factory.BASIC.createLiteral(true, t, tupleYX); // Input structure final List<ILiteral> h1 = new LinkedList<ILiteral>(); final List<ILiteral> b1 = new LinkedList<ILiteral>(); b1.add(txy); h1.add(tyx); final IRule r1 = Factory.BASIC.createRule(h1, b1); final List<IRule> in = ImmutableList.of(r1); // // Comparison Structure: // // t[1] -> t[1] {<>, <R1,R1>} // t[2] -> t[2] {<>, <R1,R1>} // // t[1] -> t[2] {<R2>} // t[2] -> t[1] {<R2>} // final Map<Pair<IPosition, IPosition>, Set<List<IRule>>> cmp = new HashMap<Pair<IPosition, IPosition>, Set<List<IRule>>>(); final IPosition t1 = new Position(t.getPredicateSymbol(), 1); final IPosition t2 = new Position(t.getPredicateSymbol(), 2); final List<IRule> lEmpty = ImmutableList.of(); final List<IRule> lr1r1 = ImmutableList.of(r1, r1); final Set<List<IRule>> st1t1 = Sets.newLinkedHashSet(); st1t1.add(lEmpty); st1t1.add(lr1r1); final Set<List<IRule>> st2t2 = Sets.newLinkedHashSet(); st2t2.add(lEmpty); st2t2.add(lr1r1); // t[1] -> t[1] {<>, <R1,R1>} cmp.put(Pair.of(t1, t1), st1t1); // t[2] -> t[2] {<>, <R1,R1>} cmp.put(Pair.of(t2, t2), st2t2); // t[1] -> t[2] {<R1>} // t[2] -> t[1] {<R1>} final List<IRule> lr1 = ImmutableList.of(r1); final Set<List<IRule>> slr1 = Sets.newLinkedHashSet(); slr1.add(lr1); cmp.put(Pair.of(t1, t2), slr1); cmp.put(Pair.of(t2, t1), slr1); final Map<Pair<IPosition, IPosition>, Set<List<IRule>>> depGraph = DepGraphUtils .computePositionDependencyGraph(in); LOGGER.debug(depGraph.toString()); System.out.println("Actual:" + depGraph.toString()); System.out.println("Expected:" + cmp.toString()); assertEquals(true, depGraph.equals(cmp)); }
From source file:org.apache.flink.streaming.connectors.kafka.api.persistent.PersistentKafkaSource.java
private int getNumberOfPartitions() { scala.collection.immutable.List<String> scalaSeq = JavaConversions .asScalaBuffer(Collections.singletonList(topicName)).toList(); scala.collection.mutable.Map<String, Seq<Object>> list = ZkUtils.getPartitionsForTopics(zkClient, scalaSeq); Option<Seq<Object>> topicOption = list.get(topicName); if (topicOption.isEmpty()) { throw new IllegalArgumentException( "Unable to get number of partitions for topic " + topicName + " from " + list.toString()); }//from w w w. j av a 2 s .c o m Seq<Object> topic = topicOption.get(); return topic.size(); }
From source file:org.geosdi.geoplatform.services.GPWMSServiceImpl.java
private RasterLayerDTO convertLayerToRaster(Layer ancestorLayer, Layer layer, String urlServer) { RasterLayerDTO raster = new RasterLayerDTO(); raster.setUrlServer(this.getUrlServer(urlServer)); raster.setName(layer.getName());//from ww w . ja v a2 s .c o m raster.setAbstractText(layer.get_abstract()); if (layer.getTitle() == null || layer.getTitle().trim().equals("")) { raster.setTitle(layer.getName()); } else { raster.setTitle(layer.getTitle()); } Map<String, CRSEnvelope> additionalBounds = layer.getBoundingBoxes(); logger.debug("ADDITIONAL BOUNDS ###############################" + additionalBounds.toString()); if (!additionalBounds.isEmpty()) { if (additionalBounds.containsKey(EPSG_GOOGLE) || additionalBounds.containsKey(EPSG_3857)) { CRSEnvelope env = additionalBounds.get(EPSG_GOOGLE); if (env == null) { env = additionalBounds.get(EPSG_3857); } raster.setBbox(this.createBbox(env)); raster.setSrs(env.getEPSGCode()); } else { raster.setBbox(this.createBbox(layer.getLatLonBoundingBox())); raster.setSrs(EPSG_4326); } } else { additionalBounds = ancestorLayer.getBoundingBoxes(); if (additionalBounds.containsKey(EPSG_GOOGLE) || additionalBounds.containsKey(EPSG_3857)) { CRSEnvelope env = additionalBounds.get(EPSG_GOOGLE); if (env == null) { env = additionalBounds.get(EPSG_3857); } raster.setBbox(this.createBbox(env)); raster.setSrs(env.getEPSGCode()); logger.info("GOOGLE"); } else { raster.setBbox(this.createBbox(ancestorLayer.getLatLonBoundingBox())); raster.setSrs(EPSG_4326); logger.info("4326"); } } logger.debug("Raster Name: " + raster.getName()); logger.debug("Raster BBOX: " + raster.getBbox()); logger.debug("Raster SRS: " + raster.getSrs()); if (urlServer.contains(GEB)) { if (layer.getLatLonBoundingBox() != null) { raster.setBbox(this.createBbox(layer.getLatLonBoundingBox())); } raster.setSrs(EPSG_4326); } // Set LayerInfo of Raster Ith GPLayerInfo layerInfo = new GPLayerInfo(); layerInfo.setQueryable(layer.isQueryable()); if (layer.getKeywords() != null) { List<String> keywordList = Arrays.asList(layer.getKeywords()); if (keywordList.size() > 0) { layerInfo.setKeywords(keywordList); } } raster.setLayerInfo(layerInfo); // Set Styles of Raster Ith List<StyleImpl> stylesImpl = layer.getStyles(); logger.debug("\n*** Layer \"{}\" has {} SubLayers and {} StyleImpl ***", layer.getTitle(), layer.getLayerChildren().size(), stylesImpl.size()); raster.setStyleList(this.createStyleList(stylesImpl)); return raster; }
From source file:org.ofbiz.accounting.thirdparty.sagepay.SagePayServices.java
private static Map<String, String> buildSagePayProperties(Map<String, Object> context, Delegator delegator) { Map<String, String> sagePayConfig = new HashMap<String, String>(); String paymentGatewayConfigId = (String) context.get("paymentGatewayConfigId"); if (UtilValidate.isNotEmpty(paymentGatewayConfigId)) { try {//from www .jav a2s . c o m GenericValue sagePay = delegator.findOne("PaymentGatewaySagePay", UtilMisc.toMap("paymentGatewayConfigId", paymentGatewayConfigId), false); if (UtilValidate.isNotEmpty(sagePay)) { Map<String, Object> tmp = sagePay.getAllFields(); Set<String> keys = tmp.keySet(); for (String key : keys) { String value = tmp.get(key).toString(); sagePayConfig.put(key, value); } } } catch (GenericEntityException e) { Debug.logError(e, module); } } Debug.logInfo("SagePay Configuration : " + sagePayConfig.toString(), module); return sagePayConfig; }
From source file:org.apache.flink.streaming.connectors.kafka.KafkaITCase.java
/** * Read topic to list, only using Kafka code. * @return/*www . jav a2s .c o m*/ */ private static List<MessageAndMetadata<byte[], byte[]>> readTopicToList(String topicName, ConsumerConfig config, final int stopAfter) { ConsumerConnector consumerConnector = Consumer.createJavaConsumerConnector(config); // we request only one stream per consumer instance. Kafka will make sure that each consumer group // will see each message only once. Map<String, Integer> topicCountMap = Collections.singletonMap(topicName, 1); Map<String, List<KafkaStream<byte[], byte[]>>> streams = consumerConnector .createMessageStreams(topicCountMap); if (streams.size() != 1) { throw new RuntimeException("Expected only one message stream but got " + streams.size()); } List<KafkaStream<byte[], byte[]>> kafkaStreams = streams.get(topicName); if (kafkaStreams == null) { throw new RuntimeException("Requested stream not available. Available streams: " + streams.toString()); } if (kafkaStreams.size() != 1) { throw new RuntimeException( "Requested 1 stream from Kafka, bot got " + kafkaStreams.size() + " streams"); } LOG.info("Opening Consumer instance for topic '{}' on group '{}'", topicName, config.groupId()); ConsumerIterator<byte[], byte[]> iteratorToRead = kafkaStreams.get(0).iterator(); List<MessageAndMetadata<byte[], byte[]>> result = new ArrayList<MessageAndMetadata<byte[], byte[]>>(); int read = 0; while (iteratorToRead.hasNext()) { read++; result.add(iteratorToRead.next()); if (read == stopAfter) { LOG.info("Read " + read + " elements"); return result; } } return result; }
From source file:monasca.persister.repository.cassandra.CassandraMetricRepo.java
private String getMeta(String name, Metric metric, Map<String, Object> meta, String id) { if (meta.containsKey(name)) { return (String) meta.get(name); } else {/*w ww .j a v a2 s.c o m*/ logger.warn("[{}]: failed to find {} in message envelope meta data. metric message may be malformed. " + "setting {} to empty string.", id, name); logger.warn("[{}]: metric: {}", id, metric.toString()); logger.warn("[{}]: meta: {}", id, meta.toString()); return EMPTY_STR; } }