Skip to content

Commit

Permalink
FLUME-713: Update Preconditions in EventImpl to provide actionable er…
Browse files Browse the repository at this point in the history
…ror messages
  • Loading branch information
Jonathan Hsieh committed Jul 21, 2011
1 parent ec588eb commit 52eadd7
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions flume-core/src/main/java/com/cloudera/flume/core/EventImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -93,11 +93,16 @@ public EventImpl(byte[] s, long timestamp, Priority pri, long nanoTime,
public EventImpl(byte[] s, long timestamp, Priority pri, long nanoTime,
String host, Map<String, byte[]> fields) {
super(fields);
Preconditions.checkNotNull(s);
Preconditions.checkArgument(s.length <= MAX_BODY_SIZE);
Preconditions.checkNotNull(s,
"Failed when attempting to create event with null body");
Preconditions.checkArgument(s.length <= MAX_BODY_SIZE, "Failed when "
+ "attempting to create event with body with length (" + s.length
+ ") > max body size (" + MAX_BODY_SIZE + "). You may want to "
+ "increase flume.event.max.size.bytes in your flume-site.xml file");
// this string construction took ~5% of exec time!
// , "byte length is " + s.length + " which is not < " + MAX_BODY_SIZE);
Preconditions.checkNotNull(pri);
Preconditions.checkNotNull(pri, "Failed when atttempt to "
+ "create event with null priority");
this.body = s;
this.timestamp = timestamp;
this.pri = pri;
Expand Down Expand Up @@ -166,8 +171,8 @@ public String getHost() {
* the list.
*/
public static Event select(Event e, String... attrs) {
Event e2 = new EventImpl(e.getBody(), e.getTimestamp(), e.getPriority(), e
.getNanos(), e.getHost());
Event e2 = new EventImpl(e.getBody(), e.getTimestamp(), e.getPriority(),
e.getNanos(), e.getHost());
for (String a : attrs) {
byte[] data = e.get(a);
if (data == null) {
Expand All @@ -184,8 +189,8 @@ public static Event select(Event e, String... attrs) {
* *except* for those attributes specified by the list.
*/
public static Event unselect(Event e, String... attrs) {
Event e2 = new EventImpl(e.getBody(), e.getTimestamp(), e.getPriority(), e
.getNanos(), e.getHost());
Event e2 = new EventImpl(e.getBody(), e.getTimestamp(), e.getPriority(),
e.getNanos(), e.getHost());
List<String> as = Arrays.asList(attrs);
for (Entry<String, byte[]> ent : e.getAttrs().entrySet()) {
String a = ent.getKey();
Expand Down

0 comments on commit 52eadd7

Please sign in to comment.