下面列出了org.apache.hadoop.mapreduce.CounterGroup#getName ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
public JobTaskAttemptCounterInfo(TaskAttempt taskattempt) {
this.id = MRApps.toString(taskattempt.getID());
total = taskattempt.getCounters();
taskAttemptCounterGroup = new ArrayList<TaskCounterGroupInfo>();
if (total != null) {
for (CounterGroup g : total) {
if (g != null) {
TaskCounterGroupInfo cginfo = new TaskCounterGroupInfo(g.getName(), g);
if (cginfo != null) {
taskAttemptCounterGroup.add(cginfo);
}
}
}
}
}
public JobCounterInfo(AppContext ctx, Job job) {
getCounters(ctx, job);
counterGroup = new ArrayList<CounterGroupInfo>();
this.id = MRApps.toString(job.getID());
if (total != null) {
for (CounterGroup g : total) {
if (g != null) {
CounterGroup mg = map == null ? null : map.getGroup(g.getName());
CounterGroup rg = reduce == null ? null : reduce
.getGroup(g.getName());
CounterGroupInfo cginfo = new CounterGroupInfo(g.getName(), g,
mg, rg);
counterGroup.add(cginfo);
}
}
}
}
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;
}
public JobTaskAttemptCounterInfo(TaskAttempt taskattempt) {
this.id = MRApps.toString(taskattempt.getID());
total = taskattempt.getCounters();
taskAttemptCounterGroup = new ArrayList<TaskCounterGroupInfo>();
if (total != null) {
for (CounterGroup g : total) {
if (g != null) {
TaskCounterGroupInfo cginfo = new TaskCounterGroupInfo(g.getName(), g);
if (cginfo != null) {
taskAttemptCounterGroup.add(cginfo);
}
}
}
}
}
public JobCounterInfo(AppContext ctx, Job job) {
getCounters(ctx, job);
counterGroup = new ArrayList<CounterGroupInfo>();
this.id = MRApps.toString(job.getID());
if (total != null) {
for (CounterGroup g : total) {
if (g != null) {
CounterGroup mg = map == null ? null : map.getGroup(g.getName());
CounterGroup rg = reduce == null ? null : reduce
.getGroup(g.getName());
CounterGroupInfo cginfo = new CounterGroupInfo(g.getName(), g,
mg, rg);
counterGroup.add(cginfo);
}
}
}
}
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;
}
private void assertMapTask(int i, Counters counters) {
for (CounterGroup counterGroup : counters) {
String name = counterGroup.getName();
boolean jobCounterGroup = false;
if (name.equals("org.apache.hadoop.mapreduce.JobCounter")) {
jobCounterGroup = true;
} else if (name.equals("org.apache.hadoop.mapred.JobInProgress$Counter")) {
jobCounterGroup = true;
}
if (jobCounterGroup) {
for (Counter counter : counterGroup) {
if (counter.getName().equals("TOTAL_LAUNCHED_MAPS")) {
assertEquals(1, counter.getValue());
return;
}
}
}
}
fail();
}
public JobTaskCounterInfo(Task task) {
total = task.getCounters();
this.id = MRApps.toString(task.getID());
taskCounterGroup = new ArrayList<TaskCounterGroupInfo>();
if (total != null) {
for (CounterGroup g : total) {
if (g != null) {
TaskCounterGroupInfo cginfo = new TaskCounterGroupInfo(g.getName(), g);
taskCounterGroup.add(cginfo);
}
}
}
}
public JobTaskCounterInfo(Task task) {
total = task.getCounters();
this.id = MRApps.toString(task.getID());
taskCounterGroup = new ArrayList<TaskCounterGroupInfo>();
if (total != null) {
for (CounterGroup g : total) {
if (g != null) {
TaskCounterGroupInfo cginfo = new TaskCounterGroupInfo(g.getName(), g);
taskCounterGroup.add(cginfo);
}
}
}
}
private MapReduceCounterData getCounterData(Counters counters) {
MapReduceCounterData holder = new MapReduceCounterData();
if (counters != null) {
for (CounterGroup group : counters) {
String groupName = group.getName();
for (Counter counter : group) {
holder.set(groupName, counter.getName(), counter.getValue());
}
}
}
return holder;
}