SLSUtils { public static void generateNodeTableMapping(Set<NodeDetails> nodeDetails, String filePath) throws IOException { List<String> entries = new ArrayList<>(); for (NodeDetails nodeDetail : nodeDetails) { if (nodeDetail.getHostname().contains("/")) { String hostname = nodeDetail.getHostname(); int lIndex = hostname.lastIndexOf("/"); String node = hostname.substring(lIndex + 1); String rack = hostname.substring(0, lIndex); entries.add(node + " " + rack); } } Files.write(Paths.get(filePath), entries, StandardCharsets.UTF_8, StandardOpenOption.CREATE); }  static String[] getRackHostName(String hostname); static Set<NodeDetails> parseNodesFromRumenTrace(
      String jobTrace); static Set<NodeDetails> parseNodesFromSLSTrace(
      String jobTrace); static Set<NodeDetails> parseNodesFromNodeFile(
      String nodeFile, Resource nmDefaultResource); static Set<NodeDetails> generateNodes(int numNodes,
      int numRacks); static void generateNodeTableMapping(Set<NodeDetails> nodeDetails,
      String filePath); final static String DEFAULT_JOB_TYPE; }
@Test public void testGenerateNodeTableMapping() throws Exception { Set<NodeDetails> nodes = SLSUtils.generateNodes(3, 3); File tempFile = File.createTempFile("testslsutils", ".tmp"); tempFile.deleteOnExit(); String fileName = tempFile.getAbsolutePath(); SLSUtils.generateNodeTableMapping(nodes, fileName); List<String> lines = Files.readAllLines(Paths.get(fileName)); Assert.assertEquals(3, lines.size()); for (String line : lines) { Assert.assertTrue(line.contains("node")); Assert.assertTrue(line.contains("/rack")); } }