• 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏吧

Java KinesisEvent类的典型用法和代码示例

java 2次浏览

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

KinesisEvent类属于com.amazonaws.services.lambda.runtime.events包,在下文中一共展示了KinesisEvent类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: testSerializeDateIndexName

点赞 2

import com.amazonaws.services.lambda.runtime.events.KinesisEvent; //导入依赖的package包/类
@Test
public void testSerializeDateIndexName() throws UnsupportedEncodingException, IOException {
  ElasticSearchTransportSerializer serializer =
      new ElasticSearchTransportSerializer(false, "event", "log-", "yyyy-MM-dd");

  KinesisEvent kevent = TestUtils.createEvent(this.getClass(), "basic_event.json");
  String payload = new String(kevent.getRecords().get(0).getKinesis().getData().array());
  InternalEvent record = new DummyEvent(payload, 1478737790000l);

  String actual = new String(serializer.serialize(record));
  String expected = TestUtils.getResourceString(this.getClass(), "datetime_output.txt");
  assertEquals(expected, actual);
}
 

开发者ID:Nextdoor,
项目名称:bender,
代码行数:14,
代码来源:ElasticSearchTansportSerializerTest.java

示例2: handler

点赞 2

import com.amazonaws.services.lambda.runtime.events.KinesisEvent; //导入依赖的package包/类
public void handler(KinesisEvent event, Context context) throws HandlerException {
  if (!initialized) {
    init(context);
  }

  this.recordIterator = new KinesisEventIterator(context, event.getRecords());

  /*
   * Get processors based on the source stream ARN
   */
  KinesisEventRecord firstRecord = event.getRecords().get(0);
  this.source = SourceUtils.getSource(firstRecord.getEventSourceARN(), sources);

  super.process(context);
}
 

开发者ID:Nextdoor,
项目名称:bender,
代码行数:16,
代码来源:KinesisHandler.java

示例3: createEvent

点赞 2

import com.amazonaws.services.lambda.runtime.events.KinesisEvent; //导入依赖的package包/类
public static KinesisEvent createEvent(Class clazz, String resource)
    throws UnsupportedEncodingException, IOException {
  /*
   * Create a kinesis record from a sample JSON file
   */
  String json =
      IOUtils.toString(new InputStreamReader(clazz.getResourceAsStream(resource), "UTF-8"));

  Date approximateArrivalTimestamp = new Date();
  approximateArrivalTimestamp.setTime(1478737790000l);

  Record rec = new Record();
  rec.withPartitionKey("1").withSequenceNumber("2").withData(ByteBuffer.wrap(json.getBytes()))
      .withApproximateArrivalTimestamp(approximateArrivalTimestamp);

  /*
   * Create a KinesisEventRecord and add single Record
   */
  KinesisEventRecord krecord = new KinesisEventRecord();
  krecord.setKinesis(rec);
  krecord.setEventSourceARN("arn:aws:kinesis:us-east-1:1234:stream/test-events-stream");
  krecord.setEventID("shardId-000000000000:1234");

  /*
   * Add single KinesisEventRecord to a KinesisEvent
   */
  KinesisEvent kevent = new KinesisEvent();
  List<KinesisEventRecord> events = new ArrayList<KinesisEventRecord>(1);
  events.add(krecord);
  kevent.setRecords(events);

  return kevent;
}
 

开发者ID:Nextdoor,
项目名称:bender,
代码行数:34,
代码来源:TestUtils.java

示例4: handleRequest

点赞 2

import com.amazonaws.services.lambda.runtime.events.KinesisEvent; //导入依赖的package包/类
@Override
public String handleRequest(KinesisEvent event, Context context) {
    if (eventProcessor instanceof LambdaContextAwareEventProcessor) {
        ((LambdaContextAwareEventProcessor)eventProcessor).initialize(context);
    }

    Observable.from(event.getRecords())
            .map(this::toBytes)
            .compose(eventProcessor)
            .count()
            .toBlocking()
            .subscribe();
    return "Done";
}
 

开发者ID:sonyxperiadev,
项目名称:lumber-mill,
代码行数:15,
代码来源:KinesisLambda.java

示例5: kinesisHandler

点赞 2

import com.amazonaws.services.lambda.runtime.events.KinesisEvent; //导入依赖的package包/类
public void kinesisHandler(KinesisEvent event, Context context){
    logger = context.getLogger();
    setup();
    for(KinesisEvent.KinesisEventRecord rec : event.getRecords()) {
        logger.log("Got message ");
        String msg = new String(rec.getKinesis().getData().array())+"\n";
        Record deliveryStreamRecord = new Record().withData(ByteBuffer.wrap(msg.getBytes()));

        PutRecordRequest putRecordRequest = new PutRecordRequest()
                .withDeliveryStreamName(deliveryStreamName)
                .withRecord(deliveryStreamRecord);

        logger.log("Putting message");
        firehoseClient.putRecord(putRecordRequest);
        logger.log("Successful Put");
    }
}
 

开发者ID:awslabs,
项目名称:aws-big-data-blog,
代码行数:18,
代码来源:KinesisToFirehose.java

示例6: convertEvent

点赞 2

import com.amazonaws.services.lambda.runtime.events.KinesisEvent; //导入依赖的package包/类
@Override
protected List<KinesisEventRecord> convertEvent(KinesisEvent event) {
	// TODO: maybe convert to List<Message>
	return event.getRecords();
}
 

开发者ID:kbastani,
项目名称:service-block-samples,
代码行数:6,
代码来源:SpringBootKinesisEventHandler.java

示例7: getTestEvent

点赞 2

import com.amazonaws.services.lambda.runtime.events.KinesisEvent; //导入依赖的package包/类
@Override
public KinesisEvent getTestEvent() throws Exception {
  return TestUtils.createEvent(this.getClass(), "basic_input.json");
}
 

开发者ID:Nextdoor,
项目名称:bender,
代码行数:5,
代码来源:KinesisHandlerTest.java

示例8: toBytes

点赞 2

import com.amazonaws.services.lambda.runtime.events.KinesisEvent; //导入依赖的package包/类
protected BytesEvent toBytes(KinesisEvent.KinesisEventRecord record) {
    BytesEvent bytesEvent = Codecs.BYTES.from(record.getKinesis().getData().array());
    bytesEvent.put(METADATA_KINESIS_EVENT_RECORD, record);
    bytesEvent.put(METADATA_MILLIS_BEHIND_LATEST, System.currentTimeMillis() - record.getKinesis().getApproximateArrivalTimestamp().getTime());
    return bytesEvent;
}
 

开发者ID:sonyxperiadev,
项目名称:lumber-mill,
代码行数:7,
代码来源:KinesisLambda.java


版权声明:本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系管理员进行删除。
喜欢 (0)