pabloem commented on code in PR #24629:
URL: https://github.com/apache/beam/pull/24629#discussion_r1053591484
##########
sdks/java/io/debezium/src/main/java/org/apache/beam/io/debezium/KafkaSourceConsumerFn.java:
##########
@@ -127,6 +134,45 @@ public Coder<OffsetHolder> getRestrictionCoder() {
return SerializableCoder.of(OffsetHolder.class);
}
+ protected SourceRecord getOneRecord(Map<String, String> configuration) {
+ try {
+ SourceConnector connector =
connectorClass.getDeclaredConstructor().newInstance();
+ connector.start(configuration);
+
+ SourceTask task = (SourceTask)
connector.taskClass().getDeclaredConstructor().newInstance();
+ task.initialize(new BeamSourceTaskContext(null));
+ task.start(connector.taskConfigs(1).get(0));
+ List<SourceRecord> records = Lists.newArrayList();
+ int loops = 0;
+ while (records.size() == 0) {
+ if (loops > 3) {
+ throw new RuntimeException("could not fetch database schema");
+ }
+ records = task.poll();
+ // Waiting for the Database snapshot to finish.
+ Thread.sleep(2000);
Review Comment:
i thought about it, but since this is at expansion time, I didn't want to
increase the wait time by a lot - and there's only one connection at a time, so
it should be safe IMO.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]