Return statistics for each datanode.
@return array of data node reports
@throw IOException
494795
public DatanodeInfo[] getDataNodeStats(final boolean useStandby)
    throws IOException {
    return new StandbyCaller<DatanodeInfo[]>() {
      @Override
      DatanodeInfo[] call(DistributedFileSystem fs) throws IOException {
        return fs.getDataNodeStats();
      }
    }.callFS(useStandby);
  }
248706
public String getStatData() throws IOException {
        Jenkins j = Jenkins.getInstance();

        JSONObject o = new JSONObject();
        o.put("stat",1);
        o.put("install", j.getLegacyInstanceId());
        o.put("servletContainer", j.servletContext.getServerInfo());
        o.put("version", Jenkins.VERSION);

        List<JSONObject> nodes = new ArrayList<>();
        for( Computer c : j.getComputers() ) {
            JSONObject  n = new JSONObject();
            if(c.getNode()==j) {
                n.put("master",true);
                n.put("jvm-vendor", System.getProperty("java.vm.vendor"));
                n.put("jvm-name", System.getProperty("java.vm.name"));
                n.put("jvm-version", System.getProperty("java.version"));
            }
            n.put("executors",c.getNumExecutors());
            DescriptorImpl descriptor = j.getDescriptorByType(DescriptorImpl.class);
            n.put("os", descriptor.get(c));
            nodes.add(n);
        }
        o.put("nodes",nodes);

        List<JSONObject> plugins = new ArrayList<>();
        for( PluginWrapper pw : j.getPluginManager().getPlugins() ) {
            if(!pw.isActive())  continue;   // treat disabled plugins as if they are uninstalled
            JSONObject p = new JSONObject();
            p.put("name",pw.getShortName());
            p.put("version",pw.getVersion());
            plugins.add(p);
        }
        o.put("plugins",plugins);

        JSONObject jobs = new JSONObject();
        // capture the descriptors as these should be small compared with the number of items
        // so we will walk all items only once and we can short-cut the search of descriptors
        TopLevelItemDescriptor[] descriptors = Items.all().toArray(new TopLevelItemDescriptor[0]);
        int[] counts = new int[descriptors.length];
        for (TopLevelItem item: j.allItems(TopLevelItem.class)) {
            TopLevelItemDescriptor d = item.getDescriptor();
            for (int i = 0; i < descriptors.length; i++) {
                if (d == descriptors[i]) {
                    counts[i]++;
                    // no point checking any more, we found the match
                    break;
                }
            }
        }
        for (int i = 0; i < descriptors.length; i++) {
            jobs.put(descriptors[i].getJsonSafeClassName(), counts[i]);
        }
        o.put("jobs",jobs);

        try {
            ByteArrayOutputStream baos = new ByteArrayOutputStream();

            // json -> UTF-8 encode -> gzip -> encrypt -> base64 -> string
            try (OutputStream cipheros = new CombinedCipherOutputStream(baos,getKey(),"AES");
                 OutputStream zipos = new GZIPOutputStream(cipheros);
                 OutputStreamWriter w = new OutputStreamWriter(zipos, StandardCharsets.UTF_8)) {
                o.write(w);
            }

            return new String(Base64.getEncoder().encode(baos.toByteArray()));
        } catch (GeneralSecurityException e) {
            throw new Error(e); // impossible
        }
    }
507848
public List<Node> getNodes(Collection<Long> nodeIds)
	{
		if(nodeIds.isEmpty()) return Collections.emptyList();
		return getSomeElements(NODE + "s?" + NODE + "s=" + toCommaList(nodeIds), Node.class);
	}
1313682
public List<ITopicNode> getAllTopicNodes() {
        final ArrayList<ITopicNode> topicNodes = new ArrayList<ITopicNode>();
        for (final Entry<Integer, List<ITopicNode>> topicEntry : topics.entrySet()) {
            topicNodes.addAll(topicEntry.getValue());
        }

        return topicNodes;
    }
154247
public function getNodes()
    {
        $nodes = [];
        $data = $this->getState();

        foreach ($data['nodes'] as $id => $name) {
            $nodes[] = new Node($id, $this->getClient());
        }

        return $nodes;
    }
1144591
public Collection<Block> processReport(DatanodeID nodeID,
      BlockListAsLongs newReport
  ) throws IOException {
    // To minimize startup time, we discard any second (or later) block reports
    // that we receive while still in startup phase.
    // Checking this without holding fsnamesystem so that duplicate 
    // block reports won't wait for too long time thus getting into old gen
    if (isInStartupSafeMode()) {
      synchronized (datanodeMap) {
        DatanodeDescriptor node = getDatanode(nodeID);
        if (node != null && node.receivedFirstFullBlockReport()) {
          NameNode.stateChangeLog.info("BLOCK* NameSystem.processReport: "
              + "discarded non-initial block report from " + nodeID.getName()
              + " because namenode still in startup phase");
          return new LinkedList<Block>();
        }
      }
    }

    int processTime;
    Collection<Block> toAdd = null, toRemove = null, toInvalidate = null, toRetry = null;
    boolean firstReport = false;
    writeLock();
    try {
      long startTime = now();
      if (NameNode.stateChangeLog.isDebugEnabled()) {
         NameNode.stateChangeLog.debug("BLOCK* NameSystem.processReport: "
          + "from " + nodeID.getName() + " " +
          newReport.getNumberOfBlocks() + " blocks");
      }
      DatanodeDescriptor node = getDatanode(nodeID);
      if (node == null || !node.isAlive) {
        throw new IOException("ProcessReport from dead or unregistered node: "
          + nodeID.getName());
      }
      
      if (this.getNameNode().shouldRetryAbsentBlocks()) {
        toRetry = new LinkedList<Block>();
      }

      // check the case when the NN does not know of any replicas on this
      // datanode. This typically happens when the NN restarts and the first
      // report from this datanode is being processed. Short-circuit the
      // processing in this case: just add all these replicas to this
      // datanode. This helps NN restart times tremendously.
      firstReport = !node.receivedFirstFullBlockReport();
      if (firstReport) {   
        if (!isPopulatingReplQueuesInternal()
            && newReport.getNumberOfBlocks() > parallelBRblocksPerShard
            && parallelBRenabled) {
          // first report, with no replication queues initialized
          InitialReportWorker.processReport(this, toRetry, newReport, node,
              initialBlockReportExecutor);
        } else {
          // first report, with replication queues initialized
          // or queues not initialized but the report has too few blocks to
          // be processed in parallel
          Block iblk = new Block(); // a fixed new'ed block to be reused with index i
          for (int i = 0; i < newReport.getNumberOfBlocks(); ++i) {
            newReport.getBlock(iblk, i);
            if (!addStoredBlockInternal(iblk, node, null, true, null)
                && this.getNameNode().shouldRetryAbsentBlock(iblk, null)) {
              toRetry.add(new Block(iblk));
            }
          }
        }
        node.setReceivedFirstFullBlockReport();
      } else {

        //
        // Modify the (block-->datanode) map, according to the difference
        // between the old and new block report.
        //
        toAdd = new LinkedList<Block>();
        toRemove = new LinkedList<Block>();
        toInvalidate = new LinkedList<Block>();
        node.reportDiff(blocksMap, newReport, toAdd, toRemove, toInvalidate,
            toRetry, this);

        for (Block b : toRemove) {
          removeStoredBlock(b, node);
        }
        for (Block b : toAdd) {
          addStoredBlock(b, node, null);
        }
        for (Block b : toInvalidate) {
          addToInvalidatesNoLog(b, node, false);
        }
      }
      processTime = (int)(now() - startTime);
      NameNode.getNameNodeMetrics().blockReport.inc(processTime);
    } finally {
      InjectionHandler.processEvent(InjectionEvent.FSNAMESYSTEM_BLOCKREPORT_COMPLETED);
      writeUnlock();
      checkSafeMode();
    }
    if (toInvalidate != null) {
      for (Block b : toInvalidate) {
        NameNode.stateChangeLog.info("BLOCK* NameSystem.processReport: block "
          + b + " on " + nodeID.getName() + " size " + b.getNumBytes()
          + " does not belong to any file.");
      }
    }
    String shortCircuit = firstReport ? " (shortCircuit first report)" : "";
    NameNode.stateChangeLog.info("BLOCK* NameSystem.processReport"+ shortCircuit 
        + ": from " + nodeID.getName() + " with " + newReport.getNumberOfBlocks()
        + " blocks took " + processTime + "ms"
        + (toAdd == null ? "." : (": #toAdd = " + toAdd.size() +
                                 " #toRemove = " + toRemove.size() +
                                 " #toInvalidate = " + toInvalidate.size() +
                                 ".")));
    if(firstReport && isInSafeMode()) {
      LOG.info("BLOCK* NameSystem.processReport: " + getReportingNodes() +
          " data nodes reporting, " +
          getSafeBlocks() + "/" + getBlocksTotal() +
          " blocks safe (" + getSafeBlockRatio() + ")");
    }
    return toRetry;
  }
401145
public List<String> getNodeTypes() {
        List<String> result = new ArrayList<String>();

        List<?> configuredNodeTypes = doc.getArray(FieldName.NODE_TYPES);
        if (configuredNodeTypes != null) {
            for (Object configuredNodeType : configuredNodeTypes) {
                result.add(configuredNodeType.toString());
            }
        }

        return result;
    }
82412
public function toArray() {
			$array = array();

			foreach ($this->data as $k => $v) {
				$nodes = explode('.', $k);
				$loc = &$array;

				foreach ($nodes as $i => $node)
					if ($i === sizeof($nodes) - 1)
						$loc[$node] = $v;
					else if (!isset($array[$node])) {
						$loc[$node] = array();

						$loc = &$loc[$node];
					}
			}

			return $array;
		}
210255
private List<NodeData> childNodesData() throws RepositoryException, AccessDeniedException
   {
      List<NodeData> storedNodes = new ArrayList<NodeData>(dataManager.getChildNodesData(nodeData()));
      Collections.sort(storedNodes, new NodeDataOrderComparator());
      return storedNodes;
   }
73878
public java.util.List<NodeSnapshot> getNodeSnapshots() {
        if (nodeSnapshots == null) {
            nodeSnapshots = new com.amazonaws.internal.SdkInternalList<NodeSnapshot>();
        }
        return nodeSnapshots;
    }
1091265
@Override
	public FileBaseStatistics getStatistics(BaseStatistics cachedStats) throws IOException {
		
		final FileBaseStatistics cachedFileStats = cachedStats instanceof FileBaseStatistics ?
			(FileBaseStatistics) cachedStats : null;
				
		try {
			return getFileStats(cachedFileStats, getFilePaths(), new ArrayList<>(getFilePaths().length));
		} catch (IOException ioex) {
			if (LOG.isWarnEnabled()) {
				LOG.warn("Could not determine statistics for paths '" + Arrays.toString(getFilePaths()) + "' due to an io error: "
						+ ioex.getMessage());
			}
		}
		catch (Throwable t) {
			if (LOG.isErrorEnabled()) {
				LOG.error("Unexpected problem while getting the file statistics for paths '" + Arrays.toString(getFilePaths()) + "': "
						+ t.getMessage(), t);
			}
		}
		
		// no statistics available
		return null;
	}
1272172
@Override
    public String[] getAllCacheStatistics() {
        DCache cache = null;
        if (ServerCache.servletCacheEnabled) {
            cache = ServerCache.cache;
        }
        String stats[] = null;
        if (cache != null) {
            Map statistics = getCacheStatisticsMap(cache.getCacheStatistics());
            Iterator keys = statistics.keySet().iterator();
            Iterator values = statistics.values().iterator();
            stats = new String[statistics.size()];
            int i = 0;
            while (keys.hasNext()) {
                stats[i] = keys.next() + "=" + values.next();
                i++;
            }
        } else {
            stats = new String[0];
            // DYNA1059W=DYNA1059W: WebSphere Dynamic Cache instance named {0} cannot be used because of Dynamic Servlet cache service has not be started.
            Tr.error(tc, "DYNA1059W", new Object[] { DCacheBase.DEFAULT_CACHE_NAME });
        }

        return stats;
    }
852843
public Block[] getBlockReport(int namespaceId) throws IOException {
    ArrayList<Block> ret = new ArrayList<Block>();
    org.apache.hadoop.hdfs.server.datanode.NamespaceMap nm = volumeMap
        .getNamespaceMap(namespaceId);
    if (nm == null) {
      return new Block[0];
    }
    int n = nm.getNumBucket();
    for (int i = 0; i < n; i++) {
      BlockBucket bb = nm.getBucket(i);
      bb.getBlockReport(ret);
    }
    return ret.toArray(new Block[ret.size()]);
  }
53831
@Override
    public Collection<N> getNodes() {
        List<N> nodes = new ArrayList<>();
        Iterables.addAll(nodes, GraphTraversal.breadthFirstOrder(this, Collections.singleton(root)));
        return nodes;
    }
1353474
public List<HivePartitionDataset> findDatasets()
      throws IOException {
    List<HivePartitionDataset> list = new ArrayList<>();
    for (HivePartitionDataset hivePartitionDataset : super.findDatasets()) {
      CleanableHivePartitionDataset dataset =
          new CleanableHivePartitionDataset(hivePartitionDataset, this.fs, this.state);
      list.add(dataset);
    }
    return list;
  }
1081686
@Override
  public List<Dataset> findDatasets() throws IOException {
    Set<URI> leafDatasets = getValidDatasetURIs(this.commonRoot);
    if (leafDatasets.isEmpty()) {
      return ImmutableList.of();
    }

    // Parallel execution for copyDataset for performance consideration.
    final List<Dataset> result = new CopyOnWriteArrayList<>();
    Iterator<Callable<Void>> callableIterator =
        Iterators.transform(leafDatasets.iterator(), new Function<URI, Callable<Void>>() {
          @Override
          public Callable<Void> apply(final URI datasetURI) {
            return findDatasetsCallable(configClient, datasetURI, props, blacklistPatterns, result);
          }
        });

    this.executeItertorExecutor(callableIterator);
    log.info("found {} datasets in ConfigBasedDatasetsFinder", result.size());
    return result;
  }
724785
private DatanodeID[] getDatanodes(HttpServletRequest request)
  throws IOException {
    final String datanodes = request.getParameter("candidates");
    if (datanodes == null) {
      return null;
    }
    final String[] datanodeStrs = datanodes.split(" ");
    if (datanodeStrs.length == 0) {
      return null;
    }
    final DatanodeID[] dnIDs = new DatanodeID[datanodeStrs.length];
    for (int i=0; i<dnIDs.length; i++) {
      String hostName = datanodeStrs[i];
      int colon = datanodeStrs[i].indexOf(":");
      if (colon < 0) {
        throw new IOException("Invalid datanode name " + 
            datanodeStrs[i] + ", expecting name:port pair");
      } 
      hostName = datanodeStrs[i].substring(0, colon);
      int infoPort;
      try {
        infoPort = Integer.parseInt(datanodeStrs[i].substring(colon+1));
      } catch (NumberFormatException ne) {
        throw new IOException("Invalid datanode name " + 
            datanodeStrs[i] + ", expecting name:port pair", ne);
      }
      dnIDs[i] = new DatanodeID(hostName, null, infoPort, -1);
    }
    return dnIDs;
  }