Java Code Examples for org.apache.flume.serialization.EventDeserializer#close()

The following examples show how to use org.apache.flume.serialization.EventDeserializer#close() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TestBlobDeserializer.java    From mt-flume with Apache License 2.0 6 votes vote down vote up
private void validateMiniParse(EventDeserializer des) throws IOException {
  Event evt;

  des.mark();
  evt = des.readEvent();
  assertEquals(new String(evt.getBody()), mini);
  des.reset(); // reset!

  evt = des.readEvent();
  assertEquals("data should be repeated, " +
      "because we reset() the stream", new String(evt.getBody()), mini);

  evt = des.readEvent();
  assertNull("Event should be null because there are no lines " +
      "left to read", evt);

  des.mark();
  des.close();
}
 
Example 2
Source File: XmlXpathDeserializerTest.java    From ingestion with Apache License 2.0 6 votes vote down vote up
private void validateReadAndMark(EventDeserializer des) throws IOException {
    Event evt;

    evt = des.readEvent();
    assertTrue(new String(evt.getBody()).contains("Giada De Laurentiis"));
    des.mark();

    evt = des.readEvent();
    assertTrue(new String(evt.getBody()).contains("J K. Rowling"));
    des.mark(); // reset!

    List<Event> readEvents = des.readEvents(2);
    assertEquals(2, readEvents.size());

    evt = des.readEvent();
    assertNull("Event should be null because there are no more books " + "left to read", evt);

    des.mark();
    des.mark();
    des.close();
}
 
Example 3
Source File: XmlXpathDeserializerTest.java    From ingestion with Apache License 2.0 6 votes vote down vote up
private void validateReadAndMarkWithHeader(EventDeserializer des) throws IOException {
    Event evt;

    evt = des.readEvent();
    System.out.println(evt.getHeaders().get("myHeader"));
    assertTrue(evt.getHeaders().get("myHeader").contains("Giada De Laurentiis"));
    des.mark();

    evt = des.readEvent();
    assertTrue(evt.getHeaders().get("myHeader").contains("J K. Rowling"));
    des.mark(); // reset!

    List<Event> readEvents = des.readEvents(2);
    assertEquals(2, readEvents.size());

    evt = des.readEvent();
    assertNull("Event should be null because there are no more books " + "left to read", evt);

    des.mark();
    des.mark();
    des.close();
}
 
Example 4
Source File: TestBlobDeserializer.java    From mt-flume with Apache License 2.0 5 votes vote down vote up
@Test
public void testBatch() throws IOException {
  ResettableInputStream in = new ResettableTestStringInputStream(mini);
  EventDeserializer des = new BlobDeserializer(new Context(), in);
  List<Event> events;

  events = des.readEvents(10); // try to read more than we should have
  assertEquals(1, events.size());
  assertEventBodyEquals(mini, events.get(0));

  des.mark();
  des.close();
}