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


Java Record.setData方法代码示例

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


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

示例1: theTransformerShouldFailGracefullyWhenUnableToCompress

import com.amazonaws.services.kinesis.model.Record; //导入方法依赖的package包/类
@Test
public void theTransformerShouldFailGracefullyWhenUnableToCompress () {
  CloudWatchMessageModelSumologicTransformer transfomer = new CloudWatchMessageModelSumologicTransformer();
  
  String randomData = "Some random string without GZIP compression";
  ByteBuffer bufferedData = null;
  try {
    bufferedData = encoder.encode(CharBuffer.wrap(randomData));
  } catch (Exception e) {
    Assert.fail("Getting error: "+e.getMessage());
  }
  
  Record mockedRecord = new Record();
  mockedRecord.setData(bufferedData);
  
  CloudWatchLogsMessageModel messageModel = transfomer.toClass(mockedRecord);
  
  
  Assert.assertNull(messageModel);
}
 
开发者ID:SumoLogic,项目名称:sumologic-kinesis-connector,代码行数:21,代码来源:CloudWatchMessageModelSumologicTransformerTest.java

示例2: theTransformerShouldSucceedWhenTransformingAProperJSON

import com.amazonaws.services.kinesis.model.Record; //导入方法依赖的package包/类
@Test
public void theTransformerShouldSucceedWhenTransformingAProperJSON() {
  CloudWatchMessageModelSumologicTransformer transfomer = new CloudWatchMessageModelSumologicTransformer();
  
  String jsonData =  ""
                        +"{"
                        + "\"logEvents\": [{"
                        +                   "\"id\": \"3889492387492837492374982374897239847289374892\","
                        +                   "\"message\": \"1 23423532532 eni-ac9342k3492 10.1.1.75 66.175.209.17 123 123 17 1 76 1437755534 1437755549 ACCEPT OK\","
                        +                   "\"timestamp\": \"2342342342300\""
                        +                "}],"
                        + "\"logGroup\": \"MyFirstVPC\","
                        + "\"logStream\": \"eni-ac6a7de4-all\","
                        + "\"messageType\": \"DATA_MESSAGE\","
                        + "\"owner\": \"2342352352\","
                        + "\"subscriptionFilters\": [\"MyFirstVPC\"]" 
                        + "}"
                      +"";
  
  byte[] compressData = SumologicKinesisUtils.compressGzip(jsonData);
  
  ByteBuffer bufferedData = null;
  try {
    bufferedData = ByteBuffer.wrap(compressData);
  } catch (Exception e) {
    Assert.fail("Getting error: "+e.getMessage());
  }
  
  Record mockedRecord = new Record();
  mockedRecord.setData(bufferedData);
  
  CloudWatchLogsMessageModel messageModel = transfomer.toClass(mockedRecord);
  
  Assert.assertNotNull(messageModel);
}
 
开发者ID:SumoLogic,项目名称:sumologic-kinesis-connector,代码行数:36,代码来源:CloudWatchMessageModelSumologicTransformerTest.java

示例3: theTransformerShouldFailWhenTransformingAJSONWithTrailingCommas

import com.amazonaws.services.kinesis.model.Record; //导入方法依赖的package包/类
@Test
public void theTransformerShouldFailWhenTransformingAJSONWithTrailingCommas() {
  CloudWatchMessageModelSumologicTransformer transfomer = new CloudWatchMessageModelSumologicTransformer();
  
  String jsonData =  ""
                      +"{"
                      + "\"logEvents\": [{"
                      +                   "\"id\": \"3889492387492837492374982374897239847289374892\","
                      +                   "\"message\": \"1 23423532532 eni-ac9342k3492 10.1.1.75 66.175.209.17 123 123 17 1 76 1437755534 1437755549 ACCEPT OK\","
                      +                   "\"timestamp\": \"2342342342300\""
                      +                "}],"
                      + "\"logGroup\": \"MyFirstVPC\","
                      + "\"logStream\": \"eni-ac6a7de4-all\","
                      + "\"messageType\": \"DATA_MESSAGE\","
                      + "\"owner\": \"2342352352\","
                      + "\"subscriptionFilters\": [\"MyFirstVPC\"]," 
                      + "}"
                    +"";
                  
  byte[] compressData = SumologicKinesisUtils.compressGzip(jsonData);
  
  ByteBuffer bufferedData = null;
  try {
    bufferedData = ByteBuffer.wrap(compressData);
  } catch (Exception e) {
    Assert.fail("Getting error: "+e.getMessage());
  }
  
  Record mockedRecord = new Record();
  mockedRecord.setData(bufferedData);
  
  CloudWatchLogsMessageModel messageModel = null;
  messageModel = transfomer.toClass(mockedRecord);
  
  Assert.assertNull(messageModel);
}
 
开发者ID:SumoLogic,项目名称:sumologic-kinesis-connector,代码行数:37,代码来源:CloudWatchMessageModelSumologicTransformerTest.java

示例4: test

import com.amazonaws.services.kinesis.model.Record; //导入方法依赖的package包/类
@Test
public void test() {
  Record record = new Record();
  final Date expectedDate = new Date();
  final String expectedPartitionKey = "Testing";
  final byte[] expectedData = "Testing data".getBytes(Charsets.UTF_8);
  final String expectedSequenceNumber = "34523452";
  final String expectedTopic = "topic";

  final Struct expectedKey = new Struct(RecordConverter.SCHEMA_KINESIS_KEY)
      .put(RecordConverter.FIELD_PARTITION_KEY, expectedPartitionKey);
  final Struct expectedValue = new Struct(RecordConverter.SCHEMA_KINESIS_VALUE)
      .put(RecordConverter.FIELD_PARTITION_KEY, expectedPartitionKey)
      .put(RecordConverter.FIELD_DATA, expectedData)
      .put(RecordConverter.FIELD_APPROXIMATE_ARRIVAL_TIMESTAMP, expectedDate)
      .put(RecordConverter.FIELD_SEQUENCE_NUMBER, expectedSequenceNumber)
      .put(RecordConverter.FIELD_SHARD_ID, this.config.kinesisShardId)
      .put(RecordConverter.FIELD_STREAM_NAME, this.config.kinesisStreamName);
  final Map<String, Object> sourcePartition = ImmutableMap.of(RecordConverter.FIELD_SHARD_ID, SHARD_ID);
  final Map<String, Object> sourceOffset = ImmutableMap.of(RecordConverter.FIELD_SEQUENCE_NUMBER, expectedSequenceNumber);

  final SourceRecord expectedSourceRecord = new SourceRecord(
      sourcePartition,
      sourceOffset,
      expectedTopic,
      null,
      RecordConverter.SCHEMA_KINESIS_KEY,
      expectedKey,
      RecordConverter.SCHEMA_KINESIS_VALUE,
      expectedValue,
      expectedDate.getTime()
  );

  record.setData(ByteBuffer.wrap(expectedData));
  record.setApproximateArrivalTimestamp(expectedDate);
  record.setPartitionKey(expectedPartitionKey);
  record.setSequenceNumber(expectedSequenceNumber);

  SourceRecord actualRecord = this.recordConverter.sourceRecord(this.config.kinesisStreamName, this.config.kinesisShardId, record);
  assertNotNull(actualRecord, "record should not be null.");
  assertSourceRecord(expectedSourceRecord, actualRecord);
}
 
开发者ID:jcustenborder,项目名称:kafka-connect-kinesis,代码行数:43,代码来源:RecordConverterTest.java

示例5: theTransfomerShouldSeparateBatchesOfLogs

import com.amazonaws.services.kinesis.model.Record; //导入方法依赖的package包/类
@Test
public void theTransfomerShouldSeparateBatchesOfLogs() {
  CloudWatchMessageModelSumologicTransformer transfomer = new CloudWatchMessageModelSumologicTransformer();
  
  String jsonData =  ""
                      +"{"
                      + "\"logEvents\": [{"
                      +                   "\"id\": \"3889492387492837492374982374897239847289374892\","
                      +                   "\"message\": \"1 23423532532 eni-ac9342k3492 10.1.1.75 66.175.209.17 123 123 17 1 76 1437755534 1437755549 ACCEPT OK\","
                      +                   "\"timestamp\": \"2342342342300\""
                      +                "},"
                      +                "{"
                      +                   "\"id\": \"3289429357928375892739857238975235235235\","
                      +                   "\"message\": \"1 23423516 eni-ac9342k3492 10.1.1.75 66.175.209.17 123 123 17 1 76 1437755534 1437755549 REJECT OK\","
                      +                   "\"timestamp\": \"2342352351616\""
                      +                "}],"
                      + "\"logGroup\": \"MyFirstVPC\","
                      + "\"logStream\": \"eni-ac6a7de4-all\","
                      + "\"messageType\": \"DATA_MESSAGE\","
                      + "\"owner\": \"2342352352\","
                      + "\"subscriptionFilters\": [\"MyFirstVPC\"]" 
                      + "}"
                    +"";
                  
  byte[] compressData = SumologicKinesisUtils.compressGzip(jsonData);
  
  ByteBuffer bufferedData = null;
  try {
    bufferedData = ByteBuffer.wrap(compressData);
  } catch (Exception e) {
    Assert.fail("Getting error: "+e.getMessage());
  }
  
  Record mockedRecord = new Record();
  mockedRecord.setData(bufferedData);
  
  CloudWatchLogsMessageModel messageModel = null;
  messageModel = transfomer.toClass(mockedRecord);
  
  String debatchedMessage = transfomer.fromClass(messageModel);
  System.out.println(debatchedMessage);
  
  String[] messages = debatchedMessage.split("\n");
  Assert.assertTrue(messages.length == 2);
}
 
开发者ID:SumoLogic,项目名称:sumologic-kinesis-connector,代码行数:46,代码来源:CloudWatchMessageModelSumologicTransformerTest.java


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