/** * Returns the total number of counters, by summing the number of counters * in each group. */ public synchronized int countCounters() { int result = 0; for (CounterGroup group : this) { result += group.size(); } return result; }
/** * Returns the total number of counters, by summing the number of counters * in each group. */ public synchronized int countCounters() { int result = 0; for (CounterGroup group : this) { result += group.size(); } return result; }
Counters counters = job.getCounters(); for (CounterGroup group : counters) { System.out.println("* Counter Group: " + group.getDisplayName() + " (" + group.getName() + ")"); System.out.println(" number of counters in this group: " + group.size()); for (Counter counter : group) { System.out.println(" - " + counter.getDisplayName() + ": " + counter.getName() + ": "+counter.getValue()); } }
private static String checkForIngestLabelOverride(Counters ingestJobCounters) { CounterGroup jobQueueName = ingestJobCounters.getGroup(IngestProcess.METRICS_LABEL_OVERRIDE.name()); if (jobQueueName.size() > 0) { Counter myCounter = jobQueueName.iterator().next(); return myCounter.getName(); } return null; }
/** * Wait for a counter to appear in a group and then return the name of that * counter. If job finishes before counter appears, return null. * * @param job Job * @param group Name of the counter group * @return Name of the counter inside of the group, or null if job finishes * before counter appears */ public static String waitAndGetCounterNameFromGroup(Job job, String group) { try { while (job.getCounters().getGroup(group).size() == 0) { if (job.isComplete()) { return null; } Thread.sleep(SLEEP_MSECS); } return job.getCounters().getGroup(group).iterator().next().getName(); } catch (IOException | InterruptedException e) { throw new IllegalStateException( "waitAndGetCounterNameFromGroup: Exception occurred", e); } } }
static JhCounters toAvro(Counters counters, String name) { JhCounters result = new JhCounters(); result.name = new Utf8(name); result.groups = new ArrayList<JhCounterGroup>(0); if (counters == null) return result; for (CounterGroup group : counters) { JhCounterGroup g = new JhCounterGroup(); g.name = new Utf8(group.getName()); g.displayName = new Utf8(group.getDisplayName()); g.counts = new ArrayList<JhCounter>(group.size()); for (Counter counter : group) { JhCounter c = new JhCounter(); c.name = new Utf8(counter.getName()); c.displayName = new Utf8(counter.getDisplayName()); c.value = counter.getValue(); g.counts.add(c); } result.groups.add(g); } return result; }
static JhCounters toAvro(Counters counters, String name) { JhCounters result = new JhCounters(); result.name = new Utf8(name); result.groups = new ArrayList<JhCounterGroup>(0); if (counters == null) return result; for (CounterGroup group : counters) { JhCounterGroup g = new JhCounterGroup(); g.name = new Utf8(group.getName()); g.displayName = new Utf8(group.getDisplayName()); g.counts = new ArrayList<JhCounter>(group.size()); for (Counter counter : group) { JhCounter c = new JhCounter(); c.name = new Utf8(counter.getName()); c.displayName = new Utf8(counter.getDisplayName()); c.value = counter.getValue(); g.counts.add(c); } result.groups.add(g); } return result; }
static JhCounters toAvro(Counters counters, String name) { JhCounters result = new JhCounters(); result.name = new Utf8(name); result.groups = new ArrayList<JhCounterGroup>(0); if (counters == null) return result; for (CounterGroup group : counters) { JhCounterGroup g = new JhCounterGroup(); g.name = new Utf8(group.getName()); g.displayName = new Utf8(group.getDisplayName()); g.counts = new ArrayList<JhCounter>(group.size()); for (Counter counter : group) { JhCounter c = new JhCounter(); c.name = new Utf8(counter.getName()); c.displayName = new Utf8(counter.getDisplayName()); c.value = counter.getValue(); g.counts.add(c); } result.groups.add(g); } return result; }
CounterGroup counters = job.getCounters().getGroup(MultipleOutputs.class.getName()); assertEquals(9, counters.size()); assertEquals(4, counters.findCounter(TEXT).getValue()); assertEquals(2, counters.findCounter(SEQUENCE + "_A").getValue());
String group = "Random Group"; CounterGroup ctrGrp = ctrs.getGroup(group); assertEquals(0, ctrGrp.size());
static JhCounters toAvro(Counters counters, String name) { JhCounters result = new JhCounters(); result.name = new Utf8(name); result.groups = new GenericData.Array<JhCounterGroup>(0, GROUPS); if (counters == null) return result; for (CounterGroup group : counters) { JhCounterGroup g = new JhCounterGroup(); g.name = new Utf8(group.getName()); g.displayName = new Utf8(group.getDisplayName()); g.counts = new GenericData.Array<JhCounter>(group.size(), COUNTERS); for (Counter counter : group) { JhCounter c = new JhCounter(); c.name = new Utf8(counter.getName()); c.displayName = new Utf8(counter.getDisplayName()); c.value = counter.getValue(); g.counts.add(c); } result.groups.add(g); } return result; }
static JhCounters toAvro(Counters counters, String name) { JhCounters result = new JhCounters(); result.setName(new Utf8(name)); result.setGroups(new ArrayList<JhCounterGroup>(0)); if (counters == null) return result; for (CounterGroup group : counters) { JhCounterGroup g = new JhCounterGroup(); g.setName(new Utf8(group.getName())); g.setDisplayName(new Utf8(group.getDisplayName())); g.setCounts(new ArrayList<JhCounter>(group.size())); for (Counter counter : group) { JhCounter c = new JhCounter(); c.setName(new Utf8(counter.getName())); c.setDisplayName(new Utf8(counter.getDisplayName())); c.setValue(counter.getValue()); g.getCounts().add(c); } result.getGroups().add(g); } return result; }
CounterGroup counters = job.getCounters().getGroup(MultipleOutputs.class.getName()); assertEquals(6, counters.size()); assertEquals(4, counters.findCounter(TEXT).getValue()); assertEquals(2, counters.findCounter("a").getValue());
CounterGroup counters = job.getCounters().getGroup(MultipleOutputs.class.getName()); assertEquals(9, counters.size()); assertEquals(4, counters.findCounter(TEXT).getValue()); assertEquals(2, counters.findCounter(SEQUENCE + "_A").getValue());
out.print(totalGroup.size()); out.write("\">\n "); out.print(HtmlQuoting.quoteHtmlChars(totalGroup.getDisplayName()));