List of usage examples for java.util Map toString
public String toString()
From source file:de.unioninvestment.eai.portal.portlet.crud.domain.model.JolokiaMBeanServerConnectionTest.java
@Test public void shouldInvoke() throws IOException, AttributeNotFoundException, InstanceNotFoundException, MBeanException, ReflectionException, J4pException, MalformedObjectNameException, ParseException { ArrayList<String> currentState = new ArrayList<String>(); currentState.add("currentState"); Object[] params = new Object[] { "org.apache.servicemix:ContainerName=ServiceMix,Type=ServiceAssembly,*", currentState, new ArrayList<String>() }; String[] signature = new String[] { "java.lang.String", "java.util.List", "java.util.List" }; ObjectName objectName = new ObjectName(REMOTE_SCRIPTING_MBEAN_NAME); JolokiaMBeanServerConnection jolokiaMBeanServerConnection = new JolokiaMBeanServerConnection(); jolokiaMBeanServerConnection.setJ4pClient(j4pClientMock); J4pExecRequest request = new J4pExecRequest(REMOTE_SCRIPTING_MBEAN_NAME, "query(java.lang.String,java.util.List,java.util.List)", params); J4pResponse<J4pExecRequest> response = new J4pResponse<J4pExecRequest>(request, (JSONObject) new JSONParser().parse(TEST_RESPONSE_IVOKE)) { };/* w w w.j av a 2s . co m*/ when(j4pClientMock.execute(any(J4pExecRequest.class))).thenReturn(response); @SuppressWarnings("rawtypes") Map result = (Map) jolokiaMBeanServerConnection.invoke(objectName, "query", params, signature); assertTrue(result.size() == 3); assertTrue(TEST_RESULT_IVOKE.equals(result.toString())); }
From source file:org.couchbase.mock.http.query.QueryServer.java
private void handlePrepared(Map<String, Object> body, HttpResponse response) { // Check the encoded plan String name = (String) body.get("prepared"); String encoded = (String) body.get("encoded_plan"); if (name == null || encoded == null) { System.err.println(body.toString()); doError(response, "missing field", 4040); return;/*from w ww.j a va 2s . c om*/ } String decoded = Base64.decode(encoded); if (decoded.isEmpty()) { doError(response, "could not decode base64", 4070); return; } Map<String, Object> mm = JsonUtils.decodeAsMap(decoded); int randNum = ((Number) mm.get("randomNumber")).intValue(); if (randNum == randNumber) { Map<String, Object> payload = resultMeta(); addResult(payload, okRow()); String resStr = JsonUtils.encode(payload); HandlerUtil.makeJsonResponse(response, resStr); } else { doError(response, "index deleted or node hosting the index is down - cause: queryport.indexNotFound", 5000); } }
From source file:com.mongodb.hadoop.splitter.MultiMongoCollectionSplitter.java
@Override public List<InputSplit> calculateSplits() throws SplitFailedException { List<MongoClientURI> inputURIs = MongoConfigUtil.getMongoURIs(this.conf, MongoConfigUtil.INPUT_URI); List<InputSplit> returnVal = new LinkedList<InputSplit>(); List<MongoSplitter> splitters = new LinkedList<MongoSplitter>(); //For each input URI that is specified, get the appropriate //splitter for each implementation. if (inputURIs.size() > 0) { LOG.info("Using global split settings for multiple URIs specified."); //Get options from the hadoop config. //Use these options for all URIs in the list. //Splitter class is ignored here, since it would just be referring //to MultiMongoCollectionSplitter here anyway. If the user needs //to customize the splitter class, they should use the JSON key for //the configuration instead. for (MongoClientURI uri : inputURIs) { MongoCollectionSplitter splitter; Configuration confForThisUri = new Configuration(conf); MongoConfigUtil.setInputURI(confForThisUri, uri); confForThisUri.set(MongoConfigUtil.MONGO_SPLITTER_CLASS, ""); splitter = MongoSplitterFactory.getSplitterByStats(uri, confForThisUri); splitters.add(splitter);/*from w ww.j a v a2 s .c o m*/ } } else { //Otherwise the user has set options per-collection. LOG.info("Loading multiple input URIs from JSON stored in " + MULTI_COLLECTION_CONF_KEY); DBObject multiUriConfig = MongoConfigUtil.getDBObject(this.conf, MULTI_COLLECTION_CONF_KEY); if (!(multiUriConfig instanceof List)) { throw new IllegalArgumentException( "Invalid JSON format in multi uri config key: Must be an array where each element " + "is an object describing the URI and config options for each split."); } for (Object obj : (List) multiUriConfig) { Map<String, Object> configMap; MongoClientURI inputURI; Configuration confForThisUri; try { configMap = (Map<String, Object>) obj; LOG.info("building config from " + configMap.toString()); confForThisUri = MongoConfigUtil.buildConfiguration(configMap); inputURI = MongoConfigUtil.getInputURI(confForThisUri); } catch (ClassCastException e) { throw new IllegalArgumentException( "Invalid JSON format in multi uri config key: each config item must be an " + "object with keys/values describing options for each URI."); } MongoSplitter splitter; Class<? extends MongoSplitter> splitterClass = MongoConfigUtil.getSplitterClass(confForThisUri); if (splitterClass != null) { LOG.info("Using custom splitter class for: " + inputURI + " " + splitterClass); //User wants to use a specific custom class for this URI. //Make sure that the custom class isn't this one if (splitterClass == MultiMongoCollectionSplitter.class) { throw new IllegalArgumentException("Can't nest uses of MultiMongoCollectionSplitter"); } //All clear. MongoCollectionSplitter collectionSplitter; collectionSplitter = (MongoCollectionSplitter) ReflectionUtils.newInstance(splitterClass, confForThisUri); //Since we use no-arg constructor, need to inject //configuration and input URI. collectionSplitter.setConfiguration(confForThisUri); splitter = collectionSplitter; } else { LOG.info("Fetching collection stats for " + inputURI + " to choose splitter implementation."); //No class was specified, so choose one by looking at //collection stats. splitter = MongoSplitterFactory.getSplitterByStats(inputURI, confForThisUri); } splitters.add(splitter); } } //Now we have splitters for all the input collections. //Run through all of em, get all the splits for each, //compile them into one big ol' list. for (MongoSplitter splitter : splitters) { returnVal.addAll(splitter.calculateSplits()); } return returnVal; }
From source file:it.geosolutions.unredd.StatsTests.java
/** * A simple test which runs the stats generation throught the RasterClassifiedStatistics, useful for test different data when problems occurs * You can configure the data used in /src/test/resources/testSimpleStats.properties to test your custom data and check if the stats are generated... * // w w w . j a va2s .com */ @Test public void simpleStatsTest() { RasterClassifiedStatistics rcs = new RasterClassifiedStatistics(); //load the test params Map<String, File> prop = loadTestParams(); //create the classification layers array List<DataFile> classificatorsList = new ArrayList<DataFile>(); for (int i = 0; i < prop.size() - 1; i++) { classificatorsList.add(new DataFile(prop.get(CLASSIFICATOR_PREFIX + (i + 1)))); } OutputStatsTest ost = null; try { // run the stats Map<MultiKey, List<Result>> results = rcs.execute(true, new DataFile(prop.get(DATA)), classificatorsList, Arrays.asList(STATS)); LOGGER.info(results.toString()); ost = OutputStatsTest.buildOutputStatsTest(); ost.outputStats(results); assertEquals(results.toString(), "{MultiKey[0]=[band 0 sum: 3449837399963,9688 Naccepted=9454812 (offered:9454812 - NoData:0 - NaN:0) Classifier:MultiKey[0]], MultiKey[1]=[band 0 sum: 1599142551508,9062 Naccepted=4355376 (offered:4355376 - NoData:0 - NaN:0) Classifier:MultiKey[1]]}"); } catch (IOException e) { LOGGER.error(e.getMessage(), e); } finally { new File(ost.getOutputFile()).deleteOnExit(); } }
From source file:org.cloudml.connectors.PyHrapiConnector.java
public String _generalAdd(String path, Map content, String resultKey) { try {//ww w . ja v a 2s . c o m String body = mapper.writeValueAsString(content); System.out.println(body); Map result = invokeToMap(path, "PUT", body); System.out.println(result); //return (String)result.get(resultKey); return result.toString(); } catch (Exception e) { e.printStackTrace(); return null; } }
From source file:gemlite.core.internal.mq.receiver.rabbit.RabbitMqReceiver.java
/*** * ? timestamp/*w ww . j a va2 s . c o m*/ * ?header,?timestamp * * @getParam() delivery * @return */ private long getTimestamp(QueueingConsumer.Delivery delivery) { BasicProperties prop = delivery.getProperties(); Map<String, Object> headers = prop.getHeaders(); long timestamp = -1; if (headers != null) { if (LogUtil.getMqSyncLog().isDebugEnabled()) LogUtil.getMqSyncLog().debug(headers.toString()); Object obj = headers.get(MqConstant.TIMESTAMP); if (obj != null) { if (LogUtil.getMqSyncLog().isDebugEnabled()) LogUtil.getMqSyncLog().debug(obj.toString()); Date dt = DateUtil.parse(obj.toString()); if (dt != null) timestamp = dt.getTime(); if (LogUtil.getMqSyncLog().isDebugEnabled()) LogUtil.getMqSyncLog().debug("Timestamp:" + timestamp); timestamp = 0; } } return timestamp; }
From source file:edu.unc.lib.dl.cdr.services.AbstractFedoraEnhancementService.java
@SuppressWarnings({ "unchecked", "rawtypes" }) protected Object executeCandidateQuery(String query, boolean countQuery) { String format = "json";//((countQuery) ? "count/json" : "json"); Map results = this.getTripleStoreQueryService().sendSPARQL(query, format); List<Map> bindings = (List<Map>) ((Map) results.get("results")).get("bindings"); if (LOG.isDebugEnabled()) LOG.debug(results.toString()); if (countQuery) { // TODO Mulgara doesn't support count queries in SPARQL, will need to redo for other triple stores return bindings.size(); /*Map binding = bindings.get(0); int count = Integer.parseInt((String) ((Map) binding.get("count")).get("value")); return count;*///from w w w .ja v a 2 s . c o m } else { List<PID> result = new ArrayList<PID>(); for (Map binding : bindings) { String pidURI = (String) ((Map) binding.get("pid")).get("value"); String label = (String) ((Map) binding.get("label")).get("value"); result.add(new LabeledPID(pidURI, label)); } return result; } }
From source file:org.oncoblocks.centromere.dataimport.cli.DataImportManager.java
/** * Builds the {@code dataSetMap} that associates data set labels and their corresponding metadata * and database IDs, by pulling the records from the database. * /* w w w . j ava 2 s .co m*/ * @return */ private Map<String, DataSetMetadata> initializeDataSetMap() { logger.debug("[CENTROMERE] Initializaing DataImportManager data set mappings."); Map<String, DataSetMetadata> map = new HashMap<>(); for (DataSetMetadata metadata : (Iterable<DataSetMetadata>) dataSetRepository.findAll()) { map.put(metadata.getLabel(), metadata); } logger.debug(String.format("[CENTROMERE] Data set map initialized: %s", map.toString())); return map; }
From source file:net.webpasswordsafe.server.service.LoginServiceImpl.java
@Override @Transactional(propagation = Propagation.REQUIRED, readOnly = true) public Map<Function, Boolean> getLoginAuthorizations(Set<Function> functions) { LOG.debug("inside getLoginAuthorizations"); User loggedInUser = getLogin();/*from w w w . j ava2 s . c om*/ // if passed null, load everything if (null == functions) { LOG.debug("functions was passed null"); functions = new HashSet<Function>(Arrays.asList(Function.values())); } LOG.debug("functions=" + functions.toString()); Map<Function, Boolean> authzMap = new HashMap<Function, Boolean>(functions.size()); for (Function function : functions) { authzMap.put(function, authorizer.isAuthorized(loggedInUser, function.name())); } LOG.debug("authzMap=" + authzMap.toString()); return authzMap; }
From source file:edu.stanford.junction.provider.xmpp.Junction.java
public void start() { Map<String, String> go = new HashMap<String, String>(); try {/* w ww . j a v a 2 s .co m*/ mSessionChat.sendMessage(go.toString()); } catch (XMPPException e) { // TODO Auto-generated catch block e.printStackTrace(); } }