/// <exception cref="System.Exception"/> internal TestContext(Configuration conf, int numNameServices) { this.numNameServices = numNameServices; MiniDFSCluster.Builder bld = new MiniDFSCluster.Builder(conf).NumDataNodes(1).StoragesPerDatanode (1); if (numNameServices > 1) { bld.NnTopology(MiniDFSNNTopology.SimpleFederatedTopology(numNameServices)); } cluster = bld.Build(); cluster.WaitActive(); dfs = new DistributedFileSystem[numNameServices]; for (int i = 0; i < numNameServices; i++) { dfs[i] = cluster.GetFileSystem(i); } bpids = new string[numNameServices]; for (int i_1 = 0; i_1 < numNameServices; i_1++) { bpids[i_1] = cluster.GetNamesystem(i_1).GetBlockPoolId(); } datanode = cluster.GetDataNodes()[0]; blockScanner = datanode.GetBlockScanner(); for (int i_2 = 0; i_2 < numNameServices; i_2++) { dfs[i_2].Mkdirs(new Path("/test")); } data = datanode.GetFSDataset(); volumes = data.GetVolumes(); }
/// <exception cref="System.IO.IOException"/> protected override void DoGet(HttpServletRequest request, HttpServletResponse response ) { response.SetContentType("text/plain"); DataNode datanode = (DataNode)GetServletContext().GetAttribute("datanode"); BlockScanner blockScanner = datanode.GetBlockScanner(); StringBuilder buffer = new StringBuilder(8 * 1024); if (!blockScanner.IsEnabled()) { Log.Warn("Periodic block scanner is not running"); buffer.Append("Periodic block scanner is not running. " + "Please check the datanode log if this is unexpected." ); } else { buffer.Append("Block Scanner Statistics\n\n"); blockScanner.PrintStats(buffer); } string resp = buffer.ToString(); Log.Trace("Returned Servlet info {}", resp); response.GetWriter().Write(resp); }