Refine search
@GET @Path("/version") public Response version() throws IOException, ExecutionException, InterruptedException { JMXNodeTool nodeTool; try { nodeTool = JMXNodeTool.instance(config); } catch (JMXConnectionException e) { logger.error( "Exception in fetching c* jmx tool . Msgl: {}", e.getLocalizedMessage(), e); return Response.status(503).entity("JMXConnectionException").build(); } return Response.ok( new JSONArray().put(nodeTool.getReleaseVersion()), MediaType.APPLICATION_JSON) .build(); }
protected void addCategoryProductData(final HttpServletRequest request, final JSONObject categoryData) throws JSONException { final List<Product> products = getProducts(request); final JSONArray itemList = new JSONArray(); for (int i = 0; i < products.size(); i++) { JSONObject item = new JSONObject(); item.put("@type", "ListItem"); item.put("position", i + 1); item.put("url", products.get(i).getUrl()); itemList.put(item); extensionManager.getProxy().addCategoryProductData(request, categoryData); } categoryData.put("itemListElement", itemList); }
/** * Put a key/value pair in the JSONObject, where the value will be a * JSONArray which is produced from a Collection. * @param key A key string. * @param value A Collection value. * @return this. * @throws JSONException JSONException */ public JSONObject put(String key, Collection value) throws JSONException { put(key, new JSONArray(value)); return this; }
protected JSONArray addContactData(final HttpServletRequest request) throws JSONException { final JSONArray contactList = new JSONArray(); final JSONObject contact = new JSONObject(); contact.put("@type", "ContactPoint"); contact.put("telephone", getSiteCustomerServiceNumber()); contact.put("contactType", "customerService"); extensionManager.getProxy().addContactData(request, contact); contactList.put(contact); return contactList; }
@SuppressWarnings("unchecked") public JSONArray ring(String keyspace) throws JSONException { JSONArray ring = new JSONArray(); Map<String, String> tokenToEndpoint = getTokenToEndpointMap(); List<String> sortedTokens = new ArrayList<>(tokenToEndpoint.keySet()); new DecimalFormat("##0.00%") .format(ownerships.get(token) == null ? 0.0F : ownerships.get(token)); ring.put( createJson( primaryEndpoint, dataCenter, rack, status, state, load, owns, token));
/** * Put a key/value pair in the JSONObject, where the value will be a * JSONArray which is produced from a Collection. * @param key A key string. * @param value A Collection value. * @return this. * @throws JSONException */ public JSONObject put(String key, Collection value) throws JSONException { put(key, new JSONArray(value)); return this; }
rootObj.put("pending tasks", cm.getPendingTasks()); JSONArray compStats = new JSONArray(); for (Map<String, String> c : cm.getCompactions()) { JSONObject cObj = new JSONObject(); cObj.put("id", c.get("id")); cObj.put("keyspace", c.get("keyspace")); cObj.put("columnfamily", c.get("columnfamily")); cObj.put("bytesComplete", c.get("bytesComplete")); + "%"; cObj.put("progress", percentComplete); compStats.put(cObj); rootObj.put("compaction stats", compStats);
public JSONObject toJSONObject() { JSONObject result = new JSONObject(); JSONObject readOnly = new JSONObject(); JSONObject readWrite = new JSONObject(); try { readOnly.put("users", new JSONArray(readOnlyUsers)); readOnly.put("roles", new JSONArray(readOnlyRoles)); readOnly.put("everyone", readOnlyEveryone); readWrite.put("users", new JSONArray(readWriteUsers)); readWrite.put("roles", new JSONArray(readWriteRoles)); readWrite.put("everyone", readWriteEveryone); result.put("readOnly", readOnly); result.put("readWrite", readWrite); } catch (JSONException ex) { throw new RuntimeException(ex); } return result; } }
JSONArray columns = new JSONArray(); columns.put("offset"); columns.put("sstables"); columns.put("write latency"); columns.put("read latency"); columns.put("row size"); columns.put("column count"); rootObj.put("columns", columns); JSONArray values = new JSONArray(); for (int i = 0; i < offsets.length; i++) { JSONArray row = new JSONArray(); row.put(offsets[i]); row.put(i < sprh.length ? sprh[i] : ""); values.put(row); rootObj.put("values", values); return Response.ok(rootObj, MediaType.APPLICATION_JSON).build();
/** * Put a value in the JSONArray, where the value will be a * JSONArray which is produced from a Collection. * @param index The subscript. * @param value A Collection value. * @return this. * @throws JSONException If the index is negative or if the value is * not finite. */ public JSONArray put(int index, Collection value) throws JSONException { put(index, new JSONArray(value)); return this; }
@GET @Path(BfConsts.SVC_GET_STATUS_RSC) @Produces(MediaType.APPLICATION_JSON) public JSONArray getStatus() { try { return new JSONArray( Arrays.asList( BfConsts.SVC_SUCCESS_KEY, (new JSONObject().put("idle", Driver.getIdle())).toString())); } catch (Exception e) { return new JSONArray(Arrays.asList(BfConsts.SVC_FAILURE_KEY, e.getMessage())); } }
JSONArray threadPoolArray = new JSONArray(); while (threads.hasNext()) { Entry<String, JMXEnabledThreadPoolExecutorMBean> thread = threads.next(); tpObj.put("pool name", thread.getKey()); tpObj.put("active", threadPoolProxy.getActiveCount()); tpObj.put("pending", threadPoolProxy.getPendingTasks()); tpObj.put("completed", threadPoolProxy.getCompletedTasks()); tpObj.put("blocked", threadPoolProxy.getCurrentlyBlockedTasks()); tpObj.put("total blocked", threadPoolProxy.getTotalBlockedTasks()); threadPoolArray.put(tpObj);
/** * Produce a JSONArray containing the names of the elements of this * JSONObject. * @return A JSONArray containing the key strings, or null if the JSONObject * is empty. */ public JSONArray names() { JSONArray ja = new JSONArray(); Iterator keys = keys(); while (keys.hasNext()) { ja.put(keys.next()); } return ja.length() == 0 ? null : ja; }
public void setTags(Set<String> tags) { if (tags == null || tags.isEmpty()) { throw new IllegalArgumentException("tags can't be null or empty."); } try { JSONArray tagArray = new JSONArray(tags); schema.put(FIELD_SCHEMA_TAGS, tagArray); } catch (JSONException e) { Preconditions.checkState(false, e.getMessage()); throw new RuntimeException(e); } schemaJSON = schema.toString(); }
JSONArray jArray = new JSONArray(); while (it.hasNext()) { AbstractBackupPath p = it.next(); if (!filter.isEmpty() && BackupFileType.valueOf(filter) != p.getType()) continue; JSONObject backupJSON = new JSONObject(); backupJSON.put("bucket", config.getBackupPrefix()); backupJSON.put("filename", p.getRemotePath()); backupJSON.put("app", p.getClusterName()); backupJSON.put("region", p.getRegion()); backupJSON.put("token", p.getToken()); jArray.put(backupJSON); backupJSON.put("num_files", "1"); jArray.put(backupJSON);
/** * Helper method to create the wirelog response to send to dev studio side * * @param synapseWireLogHolder * @return * @throws JSONException */ private JSONObject createWireLogResponse(SynapseWireLogHolder synapseWireLogHolder) throws JSONException { JSONObject wireLog = new JSONObject(); JSONArray mediatorLogs = new JSONArray(); //key mediator id json object, value SynapseBackEndWireLogs object Map<JSONObject, SynapseBackEndWireLogs> wireLogsMap = new HashMap<JSONObject, SynapseBackEndWireLogs>(); if (synapseWireLogHolder != null) { constructWireLogMap(synapseWireLogHolder, wireLogsMap); } fillWireLogJsonArray(wireLogsMap, mediatorLogs); wireLog.put(SynapseDebugCommandConstants.WIRELOGS, mediatorLogs); return wireLog; }
protected void addReviewData(final HttpServletRequest request, final Product product, final JSONObject productData) throws JSONException { final RatingSummary ratingSummary = ratingService.readRatingSummary(product.getId().toString(), RatingType.PRODUCT); if (ratingSummary != null && ratingSummary.getNumberOfRatings() > 0) { final JSONObject aggregateRating = new JSONObject(); aggregateRating.put("ratingCount", ratingSummary.getNumberOfRatings()); aggregateRating.put("ratingValue", ratingSummary.getAverageRating()); extensionManager.getProxy().addAggregateReviewData(request, product, aggregateRating); productData.put("aggregateRating", aggregateRating); final JSONArray reviews = new JSONArray(); for (final ReviewDetail reviewDetail : ratingSummary.getReviews()) { final JSONObject review = new JSONObject(); review.put("reviewBody", reviewDetail.getReviewText()); review.put("reviewRating", new JSONObject().put("ratingValue", reviewDetail.getRatingDetail().getRating())); review.put("author", reviewDetail.getCustomer().getFirstName()); review.put("datePublished", ISO_8601_FORMAT.format(reviewDetail.getReviewSubmittedDate())); extensionManager.getProxy().addReviewData(request, product, review); reviews.put(review); } productData.put("review", reviews); } } }
/** * Produce a JSONArray containing the values of the members of this * JSONObject. * @param names A JSONArray containing a list of key strings. This * determines the sequence of the values in the result. * @return A JSONArray of values. * @throws JSONException If any of the values are non-finite numbers. */ public JSONArray toJSONArray(JSONArray names) throws JSONException { if (names == null || names.length() == 0) { return null; } JSONArray ja = new JSONArray(); for (int i = 0; i < names.length(); i += 1) { ja.put(this.opt(names.getString(i))); } return ja; }