@Test public void testTasksToBeProfiled() { Random rnd = new Random(); Configuration conf = new Configuration(); JavaProfilerOptions profilerOptions = getOptions(conf, ""); assertFalse(profilerOptions.shouldProfileJVM("v", 0)); profilerOptions = getOptions(conf, "v[0,1,2]"); assertTrue(profilerOptions.shouldProfileJVM("v", 0)); assertTrue(profilerOptions.shouldProfileJVM("v", 1)); assertTrue(profilerOptions.shouldProfileJVM("v", 2)); assertFalse(profilerOptions.shouldProfileJVM("v1", rnd.nextInt(Integer.MAX_VALUE))); profilerOptions = getOptions(conf, "v[,5]", "dummyOpts"); assertTrue(profilerOptions.shouldProfileJVM("v", 5)); profilerOptions = getOptions(conf, "v 1[1,5]", "dummyOpts"); assertTrue(profilerOptions.shouldProfileJVM("v 1", 1)); assertTrue(profilerOptions.shouldProfileJVM("v 1", 5)); assertFalse(profilerOptions.shouldProfileJVM("v", rnd.nextInt(Integer.MAX_VALUE))); assertFalse(profilerOptions.shouldProfileJVM("1", rnd.nextInt(Integer.MAX_VALUE))); profilerOptions = getOptions(conf, "v 1[1,5], 5 [50,60], m 1[10, 11],", "dummyOpts"); assertTrue(profilerOptions.shouldProfileJVM("v 1", 1)); assertTrue(profilerOptions.shouldProfileJVM("v 1", 5)); assertTrue(profilerOptions.shouldProfileJVM("m 1", 10)); assertTrue(profilerOptions.shouldProfileJVM("m 1", 11)); assertTrue(profilerOptions.shouldProfileJVM("5", 50)); assertTrue(profilerOptions.shouldProfileJVM("5", 60)); assertFalse(profilerOptions.shouldProfileJVM("5", 600)); assertFalse(profilerOptions.shouldProfileJVM("m 1", 1)); assertFalse(profilerOptions.shouldProfileJVM("1", rnd.nextInt(Integer.MAX_VALUE))); assertFalse(profilerOptions.shouldProfileJVM("", rnd.nextInt(Integer.MAX_VALUE))); profilerOptions = getOptions(conf, "v 1[1,5], 5 [50,60], @#425[10, 11]", "dummyOpts"); assertFalse(profilerOptions.shouldProfileJVM("v 1", 1)); assertFalse(profilerOptions.shouldProfileJVM("@#425", 10)); profilerOptions = getOptions(conf, "v[0,1,2];v2[5,6:8]"); assertTrue(profilerOptions.shouldProfileJVM("v", 0)); assertTrue(profilerOptions.shouldProfileJVM("v", 1)); assertTrue(profilerOptions.shouldProfileJVM("v", 2)); assertTrue(profilerOptions.shouldProfileJVM("v2", 5)); assertTrue(profilerOptions.shouldProfileJVM("v2", 6)); assertTrue(profilerOptions.shouldProfileJVM("v2", 7)); assertTrue(profilerOptions.shouldProfileJVM("v2", 8)); assertFalse(profilerOptions.shouldProfileJVM("v5", rnd.nextInt(Integer.MAX_VALUE))); profilerOptions = getOptions(conf, "v[1:3,5]"); assertTrue(profilerOptions.shouldProfileJVM("v", 1)); assertTrue(profilerOptions.shouldProfileJVM("v", 2)); assertTrue(profilerOptions.shouldProfileJVM("v", 3)); assertTrue(profilerOptions.shouldProfileJVM("v", 5)); assertFalse(profilerOptions.shouldProfileJVM("v5", rnd.nextInt(Integer.MAX_VALUE))); profilerOptions = getOptions(conf, "v[3:1,5]"); assertTrue(profilerOptions.shouldProfileJVM("v", 1)); assertTrue(profilerOptions.shouldProfileJVM("v", 2)); assertTrue(profilerOptions.shouldProfileJVM("v", 3)); assertTrue(profilerOptions.shouldProfileJVM("v", 5)); profilerOptions = getOptions(conf, "v[-1]"); assertFalse(profilerOptions.shouldProfileJVM("v", 1)); assertFalse(profilerOptions.shouldProfileJVM("v", -1)); profilerOptions = getOptions(conf, "v[]"); assertTrue(profilerOptions.shouldProfileJVM("v", 0)); assertTrue(profilerOptions.shouldProfileJVM("v", rnd.nextInt(Integer.MAX_VALUE))); profilerOptions = getOptions(conf, "v[,, ,]"); assertTrue(profilerOptions.shouldProfileJVM("v", rnd.nextInt(Integer.MAX_VALUE))); profilerOptions = getOptions(conf, "v[ ]"); assertTrue(profilerOptions.shouldProfileJVM("v", rnd.nextInt(Integer.MAX_VALUE))); profilerOptions = getOptions(conf, "v[:,,]"); assertFalse(profilerOptions.shouldProfileJVM("v", rnd.nextInt(Integer.MAX_VALUE))); profilerOptions = getOptions(conf, " v[3:1,4]"); assertTrue(profilerOptions.shouldProfileJVM("v", 4)); assertTrue(profilerOptions.shouldProfileJVM("v", 1)); assertTrue(profilerOptions.shouldProfileJVM("v", 3)); assertFalse(profilerOptions.shouldProfileJVM("v", rnd.nextInt(Integer.MAX_VALUE))); profilerOptions = getOptions(conf, " v[1:3,4, 5]"); assertTrue(profilerOptions.shouldProfileJVM("v", 4)); assertTrue(profilerOptions.shouldProfileJVM("v", 2)); assertTrue(profilerOptions.shouldProfileJVM("v", 4)); assertTrue(profilerOptions.shouldProfileJVM("v", 1)); assertTrue(profilerOptions.shouldProfileJVM("v", 5)); assertFalse(profilerOptions.shouldProfileJVM("v", rnd.nextInt(Integer.MAX_VALUE))); profilerOptions = getOptions(conf, " v[:,,:, 5]"); assertFalse(profilerOptions.shouldProfileJVM("v", 0)); assertFalse(profilerOptions.shouldProfileJVM("v", 5)); assertFalse(profilerOptions.shouldProfileJVM("v", 1)); profilerOptions = getOptions(conf, " v[ : ,,]"); assertFalse(profilerOptions.shouldProfileJVM("v", 0)); assertFalse(profilerOptions.shouldProfileJVM("v", rnd.nextInt(Integer.MAX_VALUE))); profilerOptions = getOptions(conf, "v12#fs[0,1,2]"); assertFalse(profilerOptions.shouldProfileJVM("v12#fs", 0)); assertFalse(profilerOptions.shouldProfileJVM("fs", 0)); assertFalse(profilerOptions.shouldProfileJVM("#", 0)); profilerOptions = getOptions(conf, "v[-3:1,5]"); assertFalse(profilerOptions.shouldProfileJVM("v", 0)); profilerOptions = getOptions(conf, " ^&*%[0,1,2]"); assertFalse(profilerOptions.shouldProfileJVM("^&*%", 0)); assertFalse(profilerOptions.shouldProfileJVM("v", 0)); profilerOptions = getOptions(conf, "^&*%[0,1,2]"); assertFalse(profilerOptions.shouldProfileJVM("^&*%", 0)); assertFalse(profilerOptions.shouldProfileJVM("v", 0)); assertFalse(profilerOptions.shouldProfileJVM("^&*%", rnd.nextInt(Integer.MAX_VALUE))); profilerOptions = getOptions(conf, "v[-1]"); assertFalse(profilerOptions.shouldProfileJVM("v", 1)); assertFalse(profilerOptions.shouldProfileJVM("v", -1)); assertFalse(profilerOptions.shouldProfileJVM("v", rnd.nextInt(Integer.MAX_VALUE))); profilerOptions = getOptions(conf, " [:, 4:]"); assertFalse(profilerOptions.shouldProfileJVM("v", 1)); assertFalse(profilerOptions.shouldProfileJVM("v", 4)); assertFalse(profilerOptions.shouldProfileJVM("", 0)); assertFalse(profilerOptions.shouldProfileJVM("v", rnd.nextInt(Integer.MAX_VALUE))); profilerOptions = getOptions(conf, "v[:,,:]"); assertFalse(profilerOptions.shouldProfileJVM("v", 1)); assertFalse(profilerOptions.shouldProfileJVM("v", 4)); assertFalse(profilerOptions.shouldProfileJVM("", 0)); assertFalse(profilerOptions.shouldProfileJVM("v", rnd.nextInt(Integer.MAX_VALUE))); profilerOptions = getOptions(conf, "v[:5,1]"); assertFalse(profilerOptions.shouldProfileJVM("v", 0)); assertFalse(profilerOptions.shouldProfileJVM("v", 1)); assertFalse(profilerOptions.shouldProfileJVM("v", 2)); assertFalse(profilerOptions.shouldProfileJVM("v", 3)); assertFalse(profilerOptions.shouldProfileJVM("v", 4)); assertFalse(profilerOptions.shouldProfileJVM("v", 5)); assertFalse(profilerOptions.shouldProfileJVM("v", 6)); assertFalse(profilerOptions.shouldProfileJVM("v", rnd.nextInt(Integer.MAX_VALUE))); profilerOptions = getOptions(conf, "v[1:,5]"); assertFalse(profilerOptions.shouldProfileJVM("v", 1)); assertFalse(profilerOptions.shouldProfileJVM("v", 5)); assertFalse(profilerOptions.shouldProfileJVM("v", rnd.nextInt(Integer.MAX_VALUE))); profilerOptions = getOptions(conf, "v[:1,5]"); assertFalse(profilerOptions.shouldProfileJVM("v", 0)); assertFalse(profilerOptions.shouldProfileJVM("v", 1)); assertFalse(profilerOptions.shouldProfileJVM("v", 5)); assertFalse(profilerOptions.shouldProfileJVM("v", -1)); assertFalse(profilerOptions.shouldProfileJVM("v", rnd.nextInt(Integer.MAX_VALUE))); profilerOptions = getOptions(conf, " v[1:,4, 5], [5,4]"); assertFalse(profilerOptions.shouldProfileJVM("v", 4)); assertFalse(profilerOptions.shouldProfileJVM("v", 1)); assertFalse(profilerOptions.shouldProfileJVM("v", 5)); assertFalse(profilerOptions.shouldProfileJVM("v", 3)); assertFalse(profilerOptions.shouldProfileJVM(" ", 4)); assertFalse(profilerOptions.shouldProfileJVM("v", rnd.nextInt(Integer.MAX_VALUE))); profilerOptions = getOptions(conf, " v[-3:1,4]"); assertFalse(profilerOptions.shouldProfileJVM("v", 4)); assertFalse(profilerOptions.shouldProfileJVM("v", 1)); assertFalse(profilerOptions.shouldProfileJVM("v", 3)); assertFalse(profilerOptions.shouldProfileJVM("v", -3)); assertFalse(profilerOptions.shouldProfileJVM("v", rnd.nextInt(Integer.MAX_VALUE))); }
public boolean shouldProfileJVM(String vertexName, int taskId) { if (tasksToProfileMap == null || taskId < 0) { return false; } BitSet taskSet = tasksToProfileMap.get(vertexName); return (taskSet == null) ? false : ((taskSet.isEmpty()) ? true : taskSet.get(taskId)); }
JavaProfilerOptions { public boolean shouldProfileJVM(String vertexName, int taskId) { if (tasksToProfileMap == null || taskId < 0) { return false; } BitSet taskSet = tasksToProfileMap.get(vertexName); return (taskSet == null) ? false : ((taskSet.isEmpty()) ? true : taskSet.get(taskId)); } }
JavaProfilerOptions { public boolean shouldProfileJVM(String vertexName, int taskId) { if (tasksToProfileMap == null || taskId < 0) { return false; } BitSet taskSet = tasksToProfileMap.get(vertexName); return (taskSet == null) ? false : ((taskSet.isEmpty()) ? true : taskSet.get(taskId)); } JavaProfilerOptions(Configuration conf); }
JavaProfilerOptions { public boolean shouldProfileJVM(String vertexName, int taskId) { if (tasksToProfileMap == null || taskId < 0) { return false; } BitSet taskSet = tasksToProfileMap.get(vertexName); return (taskSet == null) ? false : ((taskSet.isEmpty()) ? true : taskSet.get(taskId)); } JavaProfilerOptions(Configuration conf); String getProfilerOptions(String jvmOpts, String vertexName,
      int taskIdx); boolean shouldProfileJVM(String vertexName, int taskId); }
JavaProfilerOptions { public boolean shouldProfileJVM(String vertexName, int taskId) { if (tasksToProfileMap == null || taskId < 0) { return false; } BitSet taskSet = tasksToProfileMap.get(vertexName); return (taskSet == null) ? false : ((taskSet.isEmpty()) ? true : taskSet.get(taskId)); } JavaProfilerOptions(Configuration conf); String getProfilerOptions(String jvmOpts, String vertexName,
      int taskIdx); boolean shouldProfileJVM(String vertexName, int taskId);  }