当前位置: 首页>>代码示例>>Java>>正文


Java EventDeserializer类代码示例

本文整理汇总了Java中org.apache.flume.serialization.EventDeserializer的典型用法代码示例。如果您正苦于以下问题:Java EventDeserializer类的具体用法?Java EventDeserializer怎么用?Java EventDeserializer使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


EventDeserializer类属于org.apache.flume.serialization包,在下文中一共展示了EventDeserializer类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: validateMiniParse

import org.apache.flume.serialization.EventDeserializer; //导入依赖的package包/类
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();
}
 
开发者ID:moueimei,项目名称:flume-release-1.7.0,代码行数:20,代码来源:TestBlobDeserializer.java

示例2: build

import org.apache.flume.serialization.EventDeserializer; //导入依赖的package包/类
@Override
public EventDeserializer build(Context context, ResettableInputStream resettableInputStream) {
    Settings settings = createSettings(context);
    LDVFactory factory = new LDVFactory(settings);
    ResettableInputStreamWrapper wrapper = new ResettableInputStreamWrapper(resettableInputStream);
    LDVReader reader = factory.openReader(wrapper);

    Map<String, String> additionalHeaders = context.getSubProperties(Builder.HEADERS);
    boolean lowerCaseSchemaHeader=context.getBoolean("lowercase.header.schema", true);
    boolean lowerCaseTableHeader=context.getBoolean("lowercase.header.table", true);
    int bufferSize = context.getInteger("buffer.size", 256 * 1024);

    LDVEventBuilder eventBuilder = new LDVEventBuilder(additionalHeaders,
            bufferSize,
            lowerCaseSchemaHeader,
            lowerCaseTableHeader);

    return new LDVEventDeserializer(resettableInputStream, reader, eventBuilder);
}
 
开发者ID:jcustenborder,项目名称:hadoop-goldengate,代码行数:20,代码来源:LDVEventDeserializer.java

示例3: readEvents

import org.apache.flume.serialization.EventDeserializer; //导入依赖的package包/类
@Test
public void readEvents() throws Exception {
    Context context = new Context(params);
    LDVEventDeserializer.Builder builder = new LDVEventDeserializer.Builder();
    EventDeserializer eventDeserializer = builder.build(context, resettableFileInputStream);
    Assert.assertNotNull("eventDeserializer should not be null", eventDeserializer);
    List<Event> events = eventDeserializer.readEvents(expected.length * 2);
    Assert.assertEquals("expected array does not match events list",  expected.length, events.size());
    for(int i=0;i<expected.length;i++){
        Message message = expected[i];
        Event event = events.get(i);

        //Header size needs to account for the schema literal
        Assert.assertEquals(message.getMetadata().size() + 1, event.getHeaders().size());

        for(CharSequence key:message.getMetadata().keySet()){
            Assert.assertEquals(
                    String.format("Message at index %s: key %s does not match.", i, key),
                    message.getMetadata().get(key),
                    event.getHeaders().get(key)
            );
        }
    }
}
 
开发者ID:jcustenborder,项目名称:hadoop-goldengate,代码行数:25,代码来源:LDVEventDeserializerTest.java

示例4: validateReadAndMark

import org.apache.flume.serialization.EventDeserializer; //导入依赖的package包/类
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();
}
 
开发者ID:Stratio,项目名称:ingestion,代码行数:22,代码来源:XmlXpathDeserializerTest.java

示例5: validateReadAndMarkWithHeader

import org.apache.flume.serialization.EventDeserializer; //导入依赖的package包/类
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();
}
 
开发者ID:Stratio,项目名称:ingestion,代码行数:23,代码来源:XmlXpathDeserializerTest.java

示例6: validateReset

import org.apache.flume.serialization.EventDeserializer; //导入依赖的package包/类
private void validateReset(EventDeserializer des) throws IOException {
    Event evt = des.readEvent();
    assertEquals("Everyday Italian", new String(evt.getBody()));
    des.mark();

    List<Event> events = des.readEvents(3);
    assertEquals(3, events.size());
    assertEquals("Harry Potter", new String(events.get(0).getBody()));
    assertEquals("XQuery Kick Start", new String(events.get(1).getBody()));
    assertEquals("Learning XML", new String(events.get(2).getBody()));

    des.reset(); // reset!

    events = des.readEvents(3);
    assertEquals(3, events.size());
    assertEquals("Harry Potter", new String(events.get(0).getBody()));
    assertEquals("XQuery Kick Start", new String(events.get(1).getBody()));
    assertEquals("Learning XML", new String(events.get(2).getBody()));

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

}
 
开发者ID:Stratio,项目名称:ingestion,代码行数:24,代码来源:XmlXpathDeserializerTest.java

示例7: readDeserializerEvents

import org.apache.flume.serialization.EventDeserializer; //导入依赖的package包/类
private List<Event> readDeserializerEvents(int numEvents) throws IOException {
  EventDeserializer des = currentFile.get().getDeserializer();
  List<Event> events = des.readEvents(numEvents);
  if (events.isEmpty() && firstTimeRead) {
    events.add(EventBuilder.withBody(new byte[0]));
  }
  firstTimeRead = false;
  return events;
}
 
开发者ID:moueimei,项目名称:flume-release-1.7.0,代码行数:10,代码来源:ReliableSpoolingFileEventReader.java

示例8: testSimpleViaBuilder

import org.apache.flume.serialization.EventDeserializer; //导入依赖的package包/类
@Test
public void testSimpleViaBuilder() throws IOException {
  ResettableInputStream in = new ResettableTestStringInputStream(mini);
  EventDeserializer.Builder builder = new BlobDeserializer.Builder();
  EventDeserializer des = builder.build(new Context(), in);
  validateMiniParse(des);
}
 
开发者ID:moueimei,项目名称:flume-release-1.7.0,代码行数:8,代码来源:TestBlobDeserializer.java

示例9: testSimpleViaFactory

import org.apache.flume.serialization.EventDeserializer; //导入依赖的package包/类
@Test
public void testSimpleViaFactory() throws IOException {
  ResettableInputStream in = new ResettableTestStringInputStream(mini);
  EventDeserializer des;
  des = EventDeserializerFactory.getInstance(BlobDeserializer.Builder.class.getName(),
                                             new Context(), in);
  validateMiniParse(des);
}
 
开发者ID:moueimei,项目名称:flume-release-1.7.0,代码行数:9,代码来源:TestBlobDeserializer.java

示例10: testBatch

import org.apache.flume.serialization.EventDeserializer; //导入依赖的package包/类
@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();
}
 
开发者ID:moueimei,项目名称:flume-release-1.7.0,代码行数:14,代码来源:TestBlobDeserializer.java

示例11: testMaxLineLength

import org.apache.flume.serialization.EventDeserializer; //导入依赖的package包/类
@Test
public void testMaxLineLength() throws IOException {
  String longLine = "abcdefghijklmnopqrstuvwxyz\n";
  Context ctx = new Context();
  ctx.put(BlobDeserializer.MAX_BLOB_LENGTH_KEY, "10");

  ResettableInputStream in = new ResettableTestStringInputStream(longLine);
  EventDeserializer des = new BlobDeserializer(ctx, in);

  assertEventBodyEquals("abcdefghij", des.readEvent());
  assertEventBodyEquals("klmnopqrst", des.readEvent());
  assertEventBodyEquals("uvwxyz\n", des.readEvent());
  assertNull(des.readEvent());
}
 
开发者ID:moueimei,项目名称:flume-release-1.7.0,代码行数:15,代码来源:TestBlobDeserializer.java

示例12: build

import org.apache.flume.serialization.EventDeserializer; //导入依赖的package包/类
@Override
public EventDeserializer build(Context context, ResettableInputStream in) {
    if (!(in instanceof Seekable)) {
        throw new IllegalArgumentException(
                "Cannot use this deserializer without a Seekable input stream");
    }
    try {
        return new XmlXpathDeserializer(context, in);
    } catch (IOException ex) {
        throw new RuntimeException(ex);
    }
}
 
开发者ID:Stratio,项目名称:ingestion,代码行数:13,代码来源:XmlXpathDeserializer.java

示例13: testReadsAndMark

import org.apache.flume.serialization.EventDeserializer; //导入依赖的package包/类
@Test
public void testReadsAndMark() throws IOException {
    Context context = new Context();
    context.put("expression", "/bookstore/book");
    EventDeserializer des = new XmlXpathDeserializer.Builder().build(context, getTestInputStream());
    validateReadAndMark(des);
}
 
开发者ID:Stratio,项目名称:ingestion,代码行数:8,代码来源:XmlXpathDeserializerTest.java

示例14: testReset

import org.apache.flume.serialization.EventDeserializer; //导入依赖的package包/类
@Test
public void testReset() throws IOException {
    Context context = new Context();
    context.put("expression", "/bookstore/book/title/text()");
    EventDeserializer des = new XmlXpathDeserializer.Builder().build(context, getTestInputStream());
    validateReset(des);
}
 
开发者ID:Stratio,项目名称:ingestion,代码行数:8,代码来源:XmlXpathDeserializerTest.java

示例15: testHeader

import org.apache.flume.serialization.EventDeserializer; //导入依赖的package包/类
@Test
public void testHeader() throws IOException {
  Context context = new Context();
  context.put("expression", "/bookstore/book");
  context.put("outputHeader", "myHeader");
  context.put("outputBody", "false");
  EventDeserializer des = new XmlXpathDeserializer.Builder().build(context, getTestInputStream());
  validateReadAndMarkWithHeader(des);
}
 
开发者ID:Stratio,项目名称:ingestion,代码行数:10,代码来源:XmlXpathDeserializerTest.java


注:本文中的org.apache.flume.serialization.EventDeserializer类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。