/** * Returned information is a JSON representation of a map with * volume name as the key and value is a map of volume attribute * keys to its values */ @Override // DataNodeMXBean public String getVolumeInfo() { Preconditions.checkNotNull(data, "Storage not yet initialized"); return JSON.toString(data.getVolumeInfoMap()); }
@Override public String getSnapshotStats() { Map<String, Object> info = new HashMap<String, Object>(); info.put("SnapshottableDirectories", this.getNumSnapshottableDirs()); info.put("Snapshots", this.getNumSnapshots()); return JSON.toString(info); }
/** * Returned information is a JSON representation of a map with * volume name as the key and value is a map of volume attribute * keys to its values */ @Override // DataNodeMXBean public String getVolumeInfo() { final Map<String, Object> info = new HashMap<String, Object>(); Collection<VolumeInfo> volumes = ((FSDataset)this.data).getVolumeInfo(); for (VolumeInfo v : volumes) { final Map<String, Object> innerInfo = new HashMap<String, Object>(); innerInfo.put("usedSpace", v.usedSpace); innerInfo.put("freeSpace", v.freeSpace); innerInfo.put("reservedSpace", v.reservedSpace); info.put(v.directory, innerInfo); } return JSON.toString(info); }
@Override // NameNodeMXBean public String getCorruptFiles() { List<String> list = new ArrayList<String>(); Collection<FSNamesystem.CorruptFileBlockInfo> corruptFileBlocks; try { corruptFileBlocks = listCorruptFileBlocks("/", null); int corruptFileCount = corruptFileBlocks.size(); if (corruptFileCount != 0) { for (FSNamesystem.CorruptFileBlockInfo c : corruptFileBlocks) { list.add(c.toString()); } } } catch (IOException e) { LOG.warn("Get corrupt file blocks returned error: " + e.getMessage()); } return JSON.toString(list); }
@Override // NameNodeMxBean public String getJournalTransactionInfo() { Map<String, String> txnIdMap = new HashMap<String, String>(); txnIdMap.put("LastAppliedOrWrittenTxId", Long.toString(this.getFSImage().getLastAppliedOrWrittenTxId())); txnIdMap.put("MostRecentCheckpointTxId", Long.toString(this.getFSImage().getMostRecentCheckpointTxId())); return JSON.toString(txnIdMap); }
/** * Convert a counters object into a JSON string */ public synchronized String makeJsonString() { Map<String, Map<String, Long>> data = new HashMap<String, Map<String, Long>>(); for (Group group : this) { Map<String, Long> groupData = new HashMap<String, Long>(); data.put(group.getDisplayName(), groupData); for (Counter counter : group) { groupData.put(counter.getDisplayName(), counter.getCounter()); } } return JSON.toString(data); }
protected Object filterJSON(Client from, Channel to, JSON.Generator generator) { String json = JSON.toString(generator); Object data = JSON.parse (json); return filter(from,to,data); }
public void setAdvice(JSON.Literal advice) { synchronized(this) { _adviceVersion++; _advice=advice; _multiFrameAdvice=new JSON.Literal(JSON.toString(multiFrameAdvice(advice))); } }
public void setAdvice(JSON.Literal advice) { synchronized(this) { _adviceVersion++; _advice=advice; _multiFrameAdvice=new JSON.Literal(JSON.toString(multiFrameAdvice(advice))); } }
protected Object filterJSON(Client from, Channel to, JSON.Generator generator) { String json=JSON.toString(generator); Object data=JSON.parse(json); return filter(from,to,data); }
/** * Method invoked by a JMX client to get the state of the CertificateLocalization service. * Under the attributes tab. * @return It returns a map with the name of the material and the number of references. */ @Override public String getState() { ImmutableMap<StorageKey, CryptoMaterial> state; try { lock.lock(); state = ImmutableMap.copyOf(materialLocation); } finally { lock.unlock(); } ReturnState<String, String> returnState = new ReturnState<>(); ReturnState<String, Integer> internalState = new ReturnState<>(); for (Map.Entry<StorageKey, CryptoMaterial> entry : state.entrySet()) { internalState.put(entry.getKey().username, entry.getValue().getRequestedApplications()); } returnState.put(JMX_MATERIALIZED_KEY, JSON.toString(internalState)); return JSON.toString(returnState); }
/** * Returned information is a JSON representation of a map with * name node host name as the key and block pool Id as the value */ @Override // DataNodeMXBean public String getNamenodeAddresses() { final Map<String, Integer> info = new HashMap<String, Integer>(); for (NamespaceService ns : namespaceManager.getAllNamenodeThreads()) { if (ns != null && ns.initialized()) { info.put(ns.getNNSocketAddress().getHostName(), ns.getNamespaceId()); } } return JSON.toString(info); }
/** * Returned information is a JSON representation of map with host name as the * key and value is a map of dead node attribute keys to its values */ @Override // NameNodeMXBean public String getDeadNodes() { final Map<String, Map<String, Object>> info = new HashMap<String, Map<String, Object>>(); final List<DatanodeDescriptor> dead = new ArrayList<DatanodeDescriptor>(); blockManager.getDatanodeManager().fetchDatanodes(null, dead, false); for (DatanodeDescriptor node : dead) { Map<String, Object> innerinfo = ImmutableMap.<String, Object>builder() .put("lastContact", getLastContact(node)) .put("decommissioned", node.isDecommissioned()) .put("xferaddr", node.getXferAddr()) .build(); info.put(node.getHostName() + ":" + node.getXferPort(), innerinfo); } return JSON.toString(info); }
/** * Returned information is a JSON representation of a map with * name node host name as the key and block pool Id as the value. * Note that, if there are multiple NNs in an NA nameservice, * a given block pool may be represented twice. */ @Override // DataNodeMXBean public String getNamenodeAddresses() { final Map<String, String> info = new HashMap<String, String>(); for (BPOfferService bpos : blockPoolManager.getAllNamenodeThreads()) { if (bpos != null) { for (BPServiceActor actor : bpos.getBPServiceActors()) { info.put(actor.getNNSocketAddress().getHostName(), bpos.getBlockPoolId()); } } } return JSON.toString(info); }
@GET @Path("{" + PATH + ":.*}") @Produces({MediaType.APPLICATION_JSON}) public Response get( @PathParam(PATH) @DefaultValue("UNKNOWN_" + PATH) final String path, @QueryParam(OP) @DefaultValue("UNKNOWN_" + OP) final String op ) throws IOException { LOG.info("get: " + PATH + "=" + path + ", " + OP + "=" + op); final Map<String, Object> m = new TreeMap<String, Object>(); m.put(PATH, path); m.put(OP, op); final String js = JSON.toString(m); return Response.ok(js).type(MediaType.APPLICATION_JSON).build(); } }
@GET @Path("{" + PATH + ":.*}") @Produces({MediaType.APPLICATION_JSON}) public Response get( @PathParam(PATH) @DefaultValue("UNKNOWN_" + PATH) final String path, @QueryParam(OP) @DefaultValue("UNKNOWN_" + OP) final String op ) throws IOException { LOG.info("get: " + PATH + "=" + path + ", " + OP + "=" + op); final Map<String, Object> m = new TreeMap<String, Object>(); m.put(PATH, path); m.put(OP, op); final String js = JSON.toString(m); return Response.ok(js).type(MediaType.APPLICATION_JSON).build(); } }
public void testTagsMetricsPair() throws IOException { TagsMetricsPair pair = new TagsMetricsPair(outputRecord.getTagsCopy(), outputRecord.getMetricsCopy()); String s = JSON.toString(pair); assertEquals( "[{\"testTag1\":\"testTagValue1\",\"testTag2\":\"testTagValue2\"},"+ "{\"testMetric1\":1,\"testMetric2\":33}]", s); }
public void testTagsMetricsPair() throws IOException { TagsMetricsPair pair = new TagsMetricsPair(outputRecord.getTagsCopy(), outputRecord.getMetricsCopy()); String s = JSON.toString(pair); assertEquals( "[{\"testTag1\":\"testTagValue1\",\"testTag2\":\"testTagValue2\"},"+ "{\"testMetric1\":1,\"testMetric2\":33}]", s); }
public void testTagsMetricsPair() throws IOException { TagsMetricsPair pair = new TagsMetricsPair(outputRecord.getTagsCopy(), outputRecord.getMetricsCopy()); String s = JSON.toString(pair); assertEquals( "[{\"testTag1\":\"testTagValue1\",\"testTag2\":\"testTagValue2\"},"+ "{\"testMetric1\":1,\"testMetric2\":33}]", s); }