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


Java S3EventNotification.getRecords方法代码示例

本文整理汇总了Java中com.amazonaws.services.s3.event.S3EventNotification.getRecords方法的典型用法代码示例。如果您正苦于以下问题:Java S3EventNotification.getRecords方法的具体用法?Java S3EventNotification.getRecords怎么用?Java S3EventNotification.getRecords使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.amazonaws.services.s3.event.S3EventNotification的用法示例。


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

示例1: parse

import com.amazonaws.services.s3.event.S3EventNotification; //导入方法依赖的package包/类
/**
 * Helper method that parses a JSON object from a resource on the classpath
 * as an instance of the provided type.
 *
 * @param resource
 *            the path to the resource (relative to this class)
 * @param clazz
 *            the type to parse the JSON into
 */
public static <T> T parse(String resource, Class<T> clazz)
		throws IOException {

	InputStream stream = TestUtils.class.getResourceAsStream(resource);
	try {
		if (clazz == S3Event.class) {
			String json = IOUtils.toString(stream);
			S3EventNotification event = S3EventNotification.parseJson(json);

			@SuppressWarnings("unchecked")
			T result = (T) new S3Event(event.getRecords());
			return result;

		} else if (clazz == SNSEvent.class) {
			return snsEventMapper.readValue(stream, clazz);
		} else if (clazz == DynamodbEvent.class) {
			return dynamodbEventMapper.readValue(stream, clazz);
		} else {
			return mapper.readValue(stream, clazz);
		}
	} finally {
		stream.close();
	}
}
 
开发者ID:EixoX,项目名称:jetfuel,代码行数:34,代码来源:TestUtils.java

示例2: parse

import com.amazonaws.services.s3.event.S3EventNotification; //导入方法依赖的package包/类
/**
 * Helper method that parses a JSON object from a resource on the classpath
 * as an instance of the provided type.
 *
 * @param resource the path to the resource (relative to this class)
 * @param clazz the type to parse the JSON into
 */
public static <T> T parse(String resource, Class<T> clazz)
        throws IOException {

    InputStream stream = TestUtils.class.getResourceAsStream(resource);
    try {
        if (clazz == S3Event.class) {
            String json = IOUtils.toString(stream);
            S3EventNotification event = S3EventNotification.parseJson(json);

            @SuppressWarnings("unchecked")
            T result = (T) new S3Event(event.getRecords());
            return result;

        } else {
            return mapper.readValue(stream, clazz);
        }
    } finally {
        stream.close();
    } 
}
 
开发者ID:taichi,项目名称:sirusi,代码行数:28,代码来源:TestUtils.java

示例3: handler

import com.amazonaws.services.s3.event.S3EventNotification; //导入方法依赖的package包/类
@Override
public void handler(SNSEvent event, Context context) throws HandlerException {
  if (!initialized) {
    init(context);
  }
  this.source = this.sources.get(0);
  this.inputFiles = new ArrayList<String>(0);

  for (SNSRecord record : event.getRecords()) {
    /*
     * Parse SNS as a S3 notification
     */
    String json = record.getSNS().getMessage();
    S3EventNotification s3Event = S3EventNotification.parseJson(json);

    /*
     * Validate the S3 file matches the regex
     */
    List<S3EventNotificationRecord> toProcess =
        new ArrayList<S3EventNotificationRecord>(s3Event.getRecords());
    for (S3EventNotificationRecord s3Record : s3Event.getRecords()) {
      String s3Path = String.format("s3://%s/%s", s3Record.getS3().getBucket().getName(),
          s3Record.getS3().getObject().getKey());
      try {
        this.source = SourceUtils.getSource(s3Path, this.sources);
      } catch (SourceNotFoundException e) {
        logger.warn("skipping processing " + s3Path);
        toProcess.remove(s3Record);
      }
    }

    if (toProcess.size() == 0) {
      logger.warn("Nothing to process");
      return;
    }

    this.inputFiles.addAll(toProcess.stream().map(m -> {
      return m.getS3().getObject().getKey();
    }).collect(Collectors.toList()));

    this.recordIterator = new S3EventIterator(context, toProcess, s3ClientFactory);

    super.process(context);
  }
}
 
开发者ID:Nextdoor,项目名称:bender,代码行数:46,代码来源:SNSS3Handler.java

示例4: handler

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

  /*
   * Validate the S3 file matches the regex
   */
  List<S3EventNotificationRecord> toProcess =
      new ArrayList<S3EventNotificationRecord>(event.getRecords());
  for (S3EventNotificationRecord record : event.getRecords()) {
    String s3Path = String.format("s3://%s/%s", record.getS3().getBucket().getName(),
        record.getS3().getObject().getKey());
    try {
      this.source = SourceUtils.getSource(s3Path, this.sources);
    } catch (SourceNotFoundException e) {
      logger.warn("Skipping processing " + s3Path);
      toProcess.remove(record);
    }
  }

  if (toProcess.size() == 0) {
    logger.warn("Nothing to process");
    return;
  }

  this.recordIterator = new S3EventIterator(context, toProcess, s3ClientFactory);

  super.process(context);
}
 
开发者ID:Nextdoor,项目名称:bender,代码行数:31,代码来源:S3Handler.java


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