Я использую Apache Crunch для написания кода, уменьшающего карту. У меня есть следующий класс, который содержит некоторые данные, которые передаются в коде сокращения карты, но я получаю исключение - не уверен почему.
Вот интерфейс класса
package com.ca.analytics.pa.datamodel;
import java.io.Serializable;
import java.util.List;
public interface MilestoneDatum extends Comparable<MilestoneDatum>, Serializable {
public String getMilestoneID();
public String getMilestoneDefinitionID();
public String getCreateDtTm();
public String getClient();
public String getDomain();
public String getUserName();
public String getPrimaryEventID();
public String getSourceID();
public String getInsertDtTm();
public List<MilestoneAttributeDatum> getAttributes();
public void setAttributes(List<MilestoneAttributeDatum> attributes);
public static class BuilderFactory {
public static DatumBuilder<MilestoneDatum> create() {
return new MilestoneDatumImpl.Builder();
}
}
}
Вот сама реализация класса .. (здесь у меня пустой конструктор по умолчанию ..)
package com.ca.analytics.pa.datamodel;
import java.util.List;
import com.google.common.base.MoreObjects;
import com.google.common.base.Objects;
import com.google.common.collect.ComparisonChain;
import com.google.common.collect.Ordering;
public class MilestoneDatumImpl implements MilestoneDatum {
private static final long serialVersionUID = -5034829549271201929L;
public MilestoneDatumImpl() {} // Kept public for Serialization support
// Milestone
private String milestoneID;
private String milestoneDefinitionID;
private String createDtTm;
private String client;
private String domain;
private String userName;
private String primaryEventID;
private String sourceID;
private String insertDtTm;
private List<MilestoneAttributeDatum> attributes;
public String getMilestoneID() {
return milestoneID;
}
public String getMilestoneDefinitionID() {
return milestoneDefinitionID;
}
public String getCreateDtTm() {
return createDtTm;
}
public String getClient() {
return client;
}
public String getDomain() {
return domain;
}
public String getUserName() {
return userName;
}
public String getPrimaryEventID() {
return primaryEventID;
}
public String getSourceID() {
return sourceID;
}
public String getInsertDtTm() {
return insertDtTm;
}
public List<MilestoneAttributeDatum> getAttributes() {
return attributes;
}
public void setAttributes(List<MilestoneAttributeDatum> attributes) {
this.attributes = attributes;
}
public static class Builder implements DatumBuilder<MilestoneDatum> {
// Milestone
private String milestoneID;
private String milestoneDefinitionID;
private String createDtTm;
private String client;
private String domain;
private String userName;
private String primaryEventID;
private String sourceID;
private String insertDtTm;
private List<MilestoneAttributeDatum> attributes;
public Builder withMilestoneID(String milestoneID) {
this.milestoneID = milestoneID;
return this;
}
public Builder withMilestoneDefinitionID(String milestoneDefinitionID) {
this.milestoneDefinitionID = milestoneDefinitionID;
return this;
}
public Builder withCreateDtTm(String createDtTm) {
this.createDtTm = createDtTm;
return this;
}
public Builder withClient(String client) {
this.client = client;
return this;
}
public Builder withDomain(String domain) {
this.domain = domain;
return this;
}
public Builder withUserName(String userName) {
this.userName = userName;
return this;
}
public Builder withPrimaryEventID(String primaryEventID) {
this.primaryEventID = primaryEventID;
return this;
}
public Builder withSourceID(String sourceID) {
this.sourceID = sourceID;
return this;
}
public Builder withInsertDtTm(String insertDtTm) {
this.insertDtTm = insertDtTm;
return this;
}
public Builder withAttributes(List<MilestoneAttributeDatum> attributes) {
this.attributes = attributes;
return this;
}
@Override
public MilestoneDatum build() {
MilestoneDatumImpl datum = new MilestoneDatumImpl();
datum.milestoneID = this.milestoneID;
datum.milestoneDefinitionID = this.milestoneDefinitionID;
datum.createDtTm = this.createDtTm;
datum.client = this.client;
datum.domain = this.domain;
datum.userName = this.userName;
datum.primaryEventID = this.primaryEventID;
datum.sourceID = this.sourceID;
datum.insertDtTm = this.insertDtTm;
datum.attributes = this.attributes;
return datum;
}
}
@Override
public int compareTo(MilestoneDatum that) {
return ComparisonChain.start()
.compare(this.milestoneID , that.getMilestoneID())
.compare(this.milestoneDefinitionID, that.getMilestoneDefinitionID())
.compare(this.createDtTm , that.getCreateDtTm())
.compare(this.client , that.getClient())
.compare(this.domain , that.getDomain())
.compare(this.userName , that.getUserName())
.compare(this.primaryEventID , that.getPrimaryEventID())
.compare(this.sourceID , that.getSourceID())
.compare(this.insertDtTm , that.getInsertDtTm())
.compare(this.attributes, that.getAttributes(), Ordering.<MilestoneAttributeDatum>natural().lexicographical())
.result();
}
@Override
public int hashCode() {
return Objects.hashCode(
this.milestoneID,
this.milestoneDefinitionID,
this.createDtTm,
this.client,
this.domain,
this.userName,
this.primaryEventID,
this.sourceID,
this.insertDtTm,
this.attributes
);
}
@Override
public boolean equals(Object obj) {
if (this == obj) return true;
if (obj == null) return false;
if (getClass() != obj.getClass()) return false;
MilestoneDatum other = (MilestoneDatum) obj;
return Objects.equal(this.milestoneID , other.getMilestoneID())
&& Objects.equal(this.milestoneDefinitionID, other.getMilestoneDefinitionID())
&& Objects.equal(this.createDtTm , other.getCreateDtTm())
&& Objects.equal(this.client , other.getClient())
&& Objects.equal(this.domain , other.getDomain())
&& Objects.equal(this.userName , other.getUserName())
&& Objects.equal(this.primaryEventID , other.getPrimaryEventID())
&& Objects.equal(this.sourceID , other.getSourceID())
&& Objects.equal(this.insertDtTm , other.getInsertDtTm())
&& Objects.equal(this.attributes , other.getAttributes());
}
@Override
public String toString() {
return MoreObjects.toStringHelper(this)
.add("milestoneID" , milestoneID)
.add("milestoneDefinitionID", milestoneDefinitionID)
.add("createDtTm" , createDtTm)
.add("client" , client)
.add("domain" , domain)
.add("userName" , userName)
.add("primaryEventID" , primaryEventID)
.add("sourceID" , sourceID)
.add("insertDtTm" , insertDtTm)
.add("attributes" , attributes)
.toString();
}
}
Вот исключение, которое я получаю во время фазы карты.
2019-01-10 12:44:30,537 WARN [main] org.apache.hadoop.mapred.YarnChild: Exception running child : java.lang.RuntimeException: java.lang.NoSuchMethodException: com.cerner.ca.analytics.pa.datamodel.MilestoneDatum.<init>()
at org.apache.avro.specific.SpecificData.newInstance(SpecificData.java:338)
at org.apache.avro.specific.SpecificData.newRecord(SpecificData.java:354)
at org.apache.avro.reflect.ReflectData.newRecord(ReflectData.java:782)
at org.apache.avro.generic.GenericDatumReader.readRecord(GenericDatumReader.java:220)
at org.apache.avro.generic.GenericDatumReader.readWithoutConversion(GenericDatumReader.java:174)
at org.apache.avro.generic.GenericDatumReader.read(GenericDatumReader.java:152)
at org.apache.avro.generic.GenericDatumReader.read(GenericDatumReader.java:144)
at org.apache.avro.file.DataFileStream.next(DataFileStream.java:233)
at org.apache.crunch.types.avro.AvroRecordReader.nextKeyValue(AvroRecordReader.java:77)
at org.apache.crunch.impl.mr.run.CrunchRecordReader.nextKeyValue(CrunchRecordReader.java:147)
at org.apache.hadoop.mapred.MapTask$NewTrackingRecordReader.nextKeyValue(MapTask.java:562)
at org.apache.hadoop.mapreduce.task.MapContextImpl.nextKeyValue(MapContextImpl.java:80)
at org.apache.hadoop.mapreduce.lib.map.WrappedMapper$Context.nextKeyValue(WrappedMapper.java:91)
at org.apache.hadoop.mapreduce.Mapper.run(Mapper.java:144)
at org.apache.hadoop.mapred.MapTask.runNewMapper(MapTask.java:793)
at org.apache.hadoop.mapred.MapTask.run(MapTask.java:341)
at org.apache.hadoop.mapred.YarnChild$2.run(YarnChild.java:164)
at java.security.AccessController.doPrivileged(Native Method)
at javax.security.auth.Subject.doAs(Subject.java:422)
at org.apache.hadoop.security.UserGroupInformation.doAs(UserGroupInformation.java:1917)
at org.apache.hadoop.mapred.YarnChild.main(YarnChild.java:158)
Caused by: java.lang.NoSuchMethodException: com.cerner.ca.analytics.pa.datamodel.MilestoneDatum.<init>()
at java.lang.Class.getConstructor0(Class.java:3082)
at java.lang.Class.getDeclaredConstructor(Class.java:2178)
at org.apache.avro.specific.SpecificData.newInstance(SpecificData.java:332)
... 20 more