List of usage examples for java.util Map toString
public String toString()
From source file:org.apache.flink.streaming.connectors.kafka.api.persistent.PersistentKafkaSource.java
@Override public void open(Configuration parameters) throws Exception { super.open(parameters); ConsumerConnector consumer = Consumer.createJavaConsumerConnector(this.consumerConfig); // 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 = consumer.createMessageStreams(topicCountMap); if (streams.size() != 1) { throw new RuntimeException("Expected only one message stream but got " + streams.size()); }// ww w . java 2s.c om 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, consumerConfig.groupId()); this.iteratorToRead = kafkaStreams.get(0).iterator(); this.consumer = consumer; zkClient = new ZkClient(consumerConfig.zkConnect(), consumerConfig.zkSessionTimeoutMs(), consumerConfig.zkConnectionTimeoutMs(), new KafkaZKStringSerializer()); // most likely the number of offsets we're going to store here will be lower than the number of partitions. int numPartitions = getNumberOfPartitions(); LOG.debug("The topic {} has {} partitions", topicName, numPartitions); this.lastOffsets = new long[numPartitions]; this.commitedOffsets = new long[numPartitions]; // check if there are offsets to restore if (restoreState != null) { if (restoreState.length != numPartitions) { throw new IllegalStateException( "There are " + restoreState.length + " offsets to restore for topic " + topicName + " but " + "there are only " + numPartitions + " in the topic"); } LOG.info("Setting restored offsets {} in ZooKeeper", Arrays.toString(restoreState)); setOffsetsInZooKeeper(restoreState); this.lastOffsets = restoreState; } else { // initialize empty offsets Arrays.fill(this.lastOffsets, -1); } Arrays.fill(this.commitedOffsets, 0); // just to make it clear pendingCheckpoints.clear(); running = true; }
From source file:com.cc.signalinfo.activities.MainActivity.java
/** * For my own usage and if a user wants to see it or give me feedback. * * @param debugInfo - the signal data to dump *//*from w w w . j ava 2 s .co m*/ private void displayDebugInfo(SignalArrayWrapper debugInfo) { if (enableDebug) { View view = findViewById(R.id.debugInfo); if (!view.isEnabled()) { view.setEnabled(true); view.setVisibility(View.VISIBLE); view = findViewById(R.id.debugArray); view.setEnabled(true); view.setVisibility(View.VISIBLE); } Map<String, String> debugMapRelative = new SignalMapWrapper(debugInfo.getFilteredArray(), tm) .getPercentSignalMap(true); Map<String, String> debugMapStrict = new SignalMapWrapper(debugInfo.getFilteredArray(), tm) .getPercentSignalMap(false); setTextViewText(R.id.debugArray, String.format("%s \n\n %s \n\n %s \n\n %s", debugInfo.getRawData(), Arrays.toString(debugInfo.getFilteredArray()), debugMapRelative.toString(), debugMapStrict.toString())); } }
From source file:edu.vt.vbi.patric.portlets.CircosGenomeViewerPortlet.java
public void processAction(ActionRequest request, ActionResponse response) throws PortletException, IOException { Map<String, Object> parameters = new LinkedHashMap<>(); int fileCount = 0; try {/*from w w w . jav a 2 s . c o m*/ List<FileItem> items = new PortletFileUpload(new DiskFileItemFactory()).parseRequest(request); for (FileItem item : items) { if (item.isFormField()) { parameters.put(item.getFieldName(), item.getString()); } else { if (item.getFieldName().matches("file_(\\d+)$")) { parameters.put("file_" + fileCount, item); fileCount++; } } } } catch (FileUploadException e) { LOGGER.error(e.getMessage(), e); } LOGGER.debug(parameters.toString()); // Generate Circo Image CircosData circosData = new CircosData(request); Circos circosConf = circosGenerator.createCircosImage(circosData, parameters); if (circosConf != null) { String baseUrl = "https://" + request.getServerName(); String redirectUrl = baseUrl + "/portal/portal/patric/CircosGenomeViewer/CircosGenomeViewerWindow?action=b&cacheability=PAGE&imageId=" + circosConf.getUuid() + "&trackList=" + StringUtils.join(circosConf.getTrackList(), ","); LOGGER.trace("redirect: {}", redirectUrl); response.sendRedirect(redirectUrl); } }
From source file:com.amazonaws.mobileconnectors.pinpoint.targeting.notification.NotificationClient.java
/** * Handles pinpoint FCM push messages by posting a local notification when * the app is in the background, or sending a local broadcast if the app is * in the foreground. Also on Api level 19 devices and above, if local * notifications have been disabled and the app is in the background, a * local broadcast is sent.//from w w w. j a v a 2 s. co m * * @param from the from string received by the FCM service, * @param data the bundle received from the FCM service * @return {@link CampaignPushResult}. */ public CampaignPushResult handleFCMCampaignPush(final String from, final Map<String, String> data) { log.info("Handling FCM Notification: " + data.toString()); final Bundle bundle = new Bundle(); for (final Map.Entry<String, String> entry : data.entrySet()) { bundle.putString(entry.getKey(), entry.getValue()); } return handleCampaignPush(from, bundle, PinpointNotificationReceiver.class, FCM_INTENT_ACTION); }
From source file:com.urgoo.message.activities.MainActivity.java
/** * ?// w ww. ja va2 s . co m */ private void orderPay() { Handler handler = new Handler() { @Override public void handleMessage(Message msg) { super.handleMessage(msg); Map responseMap = (Map) msg.obj; // payID = responseMap.get("payID").toString(); android.util.Log.e("orderPay", responseMap.toString()); } }; Map callbackMap = new HashMap(); Map autoFillMap = new HashMap(); // autoFillMap.put("mobile", "18310839846");//??? // autoFillMap.put("realName", "");//?? // autoFillMap.put("cardNo", "620904789023452324");//?? // autoFillMap.put("identity", "42070419900611503X");//??? // autoFillMap.put("revmobile", "15692125542");//? String mchName = ""; String mchID = "SYT002"; String outTradeNo = "123456789123000"; String body = "Android LE 1s "; String detail = "Android LE 1s 1099"; String confirmOrder = "N"; String attach = "attach?"; String totalFee = "88"; String paidAmount = "50"; String unpaidAmount = "25"; String limitPay = "01"; String feeType = "CNY"; String goodsTag = "WXG"; String timeValid = "120"; String deviceInfo = "34234234"; String random = "123456"; String sign = "2537C258F911DDA060F5547A32A12992"; HRSDK.Pay.orderPay(openID, personUnionID, mchName, mchID, outTradeNo, body, detail, random, sign, attach, confirmOrder, totalFee, paidAmount, unpaidAmount, limitPay, feeType, goodsTag, timeValid, deviceInfo, autoFillMap, callbackMap, MainActivity.this, handler); }
From source file:io.logspace.hq.core.solr.event.SolrNativeQueryService.java
@Override public NativeQueryResult executeNativeQuery(Map<String, String[]> parameters) { SolrParams params = createSolrParams(parameters); try {/*from ww w . j a v a 2 s. c o m*/ QueryRequest request = new QueryRequest(params, METHOD.POST); request.setResponseParser(new InputStreamResponseParser("json")); QueryResponse response = request.process(this.solrClient); InputStream inputStream = (InputStream) response.getResponse().get("stream"); if (inputStream != null) { return new SolrNativeQueryResult(inputStream); } return new SolrNativeQueryResult(this.serializeResponse(params, response)); } catch (SolrException | SolrServerException | IOException e) { throw new DataRetrievalException( "Could not execute direct query with parameters " + parameters.toString() + ".", e); } }
From source file:gtu._work.ui.SqlCreaterUI.java
private void executeBtnPreformed() { try {/*from w w w. j a v a2s . c o m*/ logArea.setText(""); File srcFile = JCommonUtil.filePathCheck(excelFilePathText.getText(), "?", false); if (srcFile == null) { return; } if (!srcFile.getName().endsWith(".xlsx")) { JCommonUtil._jOptionPane_showMessageDialog_error("excel"); return; } if (StringUtils.isBlank(sqlArea.getText())) { return; } File saveFile = JCommonUtil._jFileChooser_selectFileOnly_saveFile(); if (saveFile == null) { JCommonUtil._jOptionPane_showMessageDialog_error("?"); return; } String sqlText = sqlArea.getText(); StringBuffer sb = new StringBuffer(); Map<Integer, String> refMap = new HashMap<Integer, String>(); Pattern sqlPattern = Pattern.compile("\\$\\{(\\w+)\\}", Pattern.MULTILINE); Matcher matcher = sqlPattern.matcher(sqlText); while (matcher.find()) { String val = StringUtils.trim(matcher.group(1)).toUpperCase(); refMap.put(ExcelUtil.cellEnglishToPos(val), val); matcher.appendReplacement(sb, "\\$\\{" + val + "\\}"); } matcher.appendTail(sb); appendLog(refMap.toString()); sqlText = sb.toString(); sqlArea.setText(sqlText); Configuration cfg = new Configuration(); StringTemplateLoader stringTemplatge = new StringTemplateLoader(); stringTemplatge.putTemplate("aaa", sqlText); cfg.setTemplateLoader(stringTemplatge); cfg.setObjectWrapper(new DefaultObjectWrapper()); Template temp = cfg.getTemplate("aaa"); BufferedWriter writer = new BufferedWriter( new OutputStreamWriter(new FileOutputStream(saveFile), "utf8")); BufferedInputStream bis = new BufferedInputStream(new FileInputStream(srcFile)); XSSFWorkbook xssfWorkbook = new XSSFWorkbook(bis); Sheet sheet = xssfWorkbook.getSheetAt(0); for (int j = 0; j < sheet.getPhysicalNumberOfRows(); j++) { Row row = sheet.getRow(j); if (row == null) { continue; } Map<String, Object> root = new HashMap<String, Object>(); for (int index : refMap.keySet()) { root.put(refMap.get(index), formatCellType(row.getCell(index))); } appendLog(root.toString()); StringWriter out = new StringWriter(); temp.process(root, out); out.flush(); String writeStr = out.getBuffer().toString(); appendLog(writeStr); writer.write(writeStr); writer.newLine(); } bis.close(); writer.flush(); writer.close(); JCommonUtil._jOptionPane_showMessageDialog_info("? : \n" + saveFile); } catch (Exception ex) { JCommonUtil.handleException(ex); } }
From source file:org.nuxeo.ecm.core.schema.types.resolver.ObjectResolverServiceImpl.java
@Override public ObjectResolver getResolver(String type, Map<String, String> parameters) { Class<? extends ObjectResolver> resolverClass = resolvers.get(type); if (resolverClass == null) { return null; }/*from w w w . j a v a 2 s . c om*/ ObjectResolver resolver = null; try { resolver = resolverClass.newInstance(); } catch (InstantiationException | IllegalAccessException e) { log.warn(String.format("Unable to instanciate %s - missing public constructor with no param", resolverClass.getCanonicalName())); return null; } try { resolver.configure(parameters != null ? parameters : new HashMap<String, String>()); } catch (IllegalArgumentException e) { log.info(String.format("Unable to configure %s with parameters %s", resolverClass.getCanonicalName(), parameters.toString())); return null; } return resolver; }
From source file:com.saggezza.jtracker.track.TrackerC.java
/** * {@inheritDoc}/* w w w .j a v a 2 s. c om*/ * @param eventVendor The vendor the the event information. * @param eventName A name for the unstructured event being tracked. * @param dictInfo The unstructured information being tracked in dictionary form. * @param context Additional JSON context for the tracking call (optional) * @throws org.json.JSONException * @throws java.io.IOException */ public void trackGenericEvent(String eventVendor, String eventName, Map<String, Object> dictInfo, String context) throws JSONException, IOException { assert this.stringContractor.checkContract(this.contracts, PlowContractor.nonEmptyString, eventVendor); assert this.stringContractor.checkContract(this.contracts, PlowContractor.nonEmptyString, eventName); assert this.stringContractor.checkContract(this.contracts, PlowContractor.nonEmptyDict, dictInfo.toString()); if (context != null && !context.equals("")) { JSONObject jsonContext = stringToJSON(context); this.payload = this.payload.trackGenericEvent_config(eventVendor, eventName, dictInfo, jsonContext); } else { this.payload = this.payload.trackGenericEvent_config(eventVendor, eventName, dictInfo, null); } this.track(); }
From source file:com.saggezza.jtracker.track.TrackerC.java
/** * {@inheritDoc}// ww w . j a va2s . co m * @param eventVendor The vendor the the event information. * @param eventName A name for the unstructured event being tracked. * @param dictInfo The unstructured information being tracked in dictionary form. * @param context Additional JSON context for the tracking call (optional) * @throws org.json.JSONException * @throws java.io.IOException */ public void trackUnstructEvent(String eventVendor, String eventName, Map<String, Object> dictInfo, String context) throws JSONException, IOException { assert this.stringContractor.checkContract(this.contracts, PlowContractor.nonEmptyString, eventVendor); assert this.stringContractor.checkContract(this.contracts, PlowContractor.nonEmptyString, eventName); assert this.stringContractor.checkContract(this.contracts, PlowContractor.nonEmptyDict, dictInfo.toString()); JSONObject jsonDict = mapToJSON(dictInfo); //Make compatible for Map<String, Object> if (context != null && !context.equals("")) { JSONObject jsonContext = stringToJSON(context); this.payload = this.payload.trackUnstructEvent_config(eventVendor, eventName, jsonDict, jsonContext); } else { this.payload = this.payload.trackUnstructEvent_config(eventVendor, eventName, jsonDict, null); } this.track(); }