本文整理汇总了Java中org.apache.kafka.connect.connector.ConnectRecord类的典型用法代码示例。如果您正苦于以下问题:Java ConnectRecord类的具体用法?Java ConnectRecord怎么用?Java ConnectRecord使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ConnectRecord类属于org.apache.kafka.connect.connector包,在下文中一共展示了ConnectRecord类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: assertRecord
import org.apache.kafka.connect.connector.ConnectRecord; //导入依赖的package包/类
public static void assertRecord(ConnectRecord expected, ConnectRecord actual, String message) {
final String prefix = null != message ? message + ": " : "";
if (null == expected) {
assertNull(actual, prefix + "actual should be null.");
return;
}
assertNotNull(actual, prefix + "actual should not be null.");
assertEquals(expected.kafkaPartition(), actual.kafkaPartition(), prefix + "kafkaPartition() does not match.");
assertEquals(expected.topic(), actual.topic(), prefix + "topic() does not match.");
assertEquals(expected.timestamp(), actual.timestamp(), prefix + "timestamp() does not match.");
assertSchema(expected.keySchema(), actual.keySchema(), prefix + "keySchema() does not match");
assertValue(expected.key(), actual.key(), prefix + "key() does not match.");
assertSchema(expected.valueSchema(), actual.valueSchema(), prefix + "valueSchema() does not match");
assertValue(expected.value(), actual.value(), prefix + "value() does not match.");
}
示例2: assertSourceRecord
import org.apache.kafka.connect.connector.ConnectRecord; //导入依赖的package包/类
void assertSourceRecord(final Map<String, ?> expected, final ConnectRecord record, final String topic) throws JsonProcessingException {
assertNotNull(record, "record should not be null.");
assertNotNull(record.value(), "record.value() should not be null.");
assertEquals(topic, record.topic(), "topic does not match.");
assertTrue(record.key() instanceof Struct, "record.key() should be a struct");
assertTrue(record.value() instanceof Struct, "record.value() should be a struct");
Struct keyStruct = (Struct) record.key();
keyStruct.validate();
Struct valueStruct = (Struct) record.value();
valueStruct.validate();
for (Map.Entry<String, ?> entry : expected.entrySet()) {
Object structValue = valueStruct.get(entry.getKey());
if (entry.getValue() instanceof Map) {
String text = ObjectMapperFactory.INSTANCE.writeValueAsString(entry.getValue());
String structText = (String) structValue;
assertEquals(text, structText, entry.getKey() + " should match.");
} else {
assertEquals(entry.getValue(), structValue, entry.getKey() + " should match.");
}
}
}
示例3: apply
import org.apache.kafka.connect.connector.ConnectRecord; //导入依赖的package包/类
@TestFactory
public Stream<DynamicTest> apply() throws IOException {
List<TestCase> testCases = TestDataUtils.loadJsonResourceFiles(this.getClass().getPackage().getName() + ".records", TestCase.class);
return testCases.stream().map(testCase -> dynamicTest(testCase.testName(), () -> {
ConnectRecord actual = this.transformation.apply(testCase.input);
assertRecord(testCase.expected, actual);
}));
}
示例4: requireSinkRecord
import org.apache.kafka.connect.connector.ConnectRecord; //导入依赖的package包/类
public static SinkRecord requireSinkRecord(ConnectRecord<?> record, String purpose) {
if (!(record instanceof SinkRecord)) {
throw new DataException("Only SinkRecord supported for [" + purpose + "], found: " + nullSafeClassName(record));
}
return (SinkRecord) record;
}
示例5: noOp
import org.apache.kafka.connect.connector.ConnectRecord; //导入依赖的package包/类
public static <R extends ConnectRecord<R>> TransformationChain<R> noOp() {
return new TransformationChain<R>(Collections.<Transformation<R>>emptyList());
}
示例6: newTranformations
import org.apache.kafka.connect.connector.ConnectRecord; //导入依赖的package包/类
public <R extends ConnectRecord<R>> Transformation<R> newTranformations(
String transformationClassOrAlias
) {
return null;
}
示例7: ConnectTemplateHashModel
import org.apache.kafka.connect.connector.ConnectRecord; //导入依赖的package包/类
ConnectTemplateHashModel(ConnectRecord connectRecord, Struct struct) {
this.connectRecord = connectRecord;
this.struct = struct;
}
示例8: execute
import org.apache.kafka.connect.connector.ConnectRecord; //导入依赖的package包/类
public String execute(String templateName, ConnectRecord record, Struct struct, Map<String, ?> additionalValues) {
ConnectTemplateHashModel connectTemplateHashModel = new ConnectTemplateHashModel(record, struct);
return executeInternal(templateName, connectTemplateHashModel);
}
示例9: extract
import org.apache.kafka.connect.connector.ConnectRecord; //导入依赖的package包/类
@Override
public Long extract(ConnectRecord<?> record) {
return Time.SYSTEM.milliseconds();
}
示例10: shouldChangeSchema
import org.apache.kafka.connect.connector.ConnectRecord; //导入依赖的package包/类
boolean shouldChangeSchema(
ConnectRecord<?> record,
Schema currentkeySchema,
Schema currentValueSchema
);
示例11: extract
import org.apache.kafka.connect.connector.ConnectRecord; //导入依赖的package包/类
@Override
public Long extract(ConnectRecord<?> record) {
return time.milliseconds();
}
示例12: extract
import org.apache.kafka.connect.connector.ConnectRecord; //导入依赖的package包/类
Long extract(ConnectRecord<?> record);