-
Notifications
You must be signed in to change notification settings - Fork 4.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Stop using gentle close with heartbeat (#8036)
* use gentle close instead of gentle close with heartbeat when closing source * also lower destination process gentle close duration * add test connectors
- Loading branch information
Showing
8 changed files
with
118 additions
and
32 deletions.
There are no files selected for viewing
69 changes: 69 additions & 0 deletions
69
...est/src/main/java/io/airbyte/integrations/destination/e2e_test/FailAfterNDestination.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
package io.airbyte.integrations.destination.e2e_test; | ||
|
||
import static java.lang.Thread.sleep; | ||
|
||
import com.fasterxml.jackson.databind.JsonNode; | ||
import io.airbyte.integrations.BaseConnector; | ||
import io.airbyte.integrations.base.AirbyteMessageConsumer; | ||
import io.airbyte.integrations.base.Destination; | ||
import io.airbyte.protocol.models.AirbyteConnectionStatus; | ||
import io.airbyte.protocol.models.AirbyteConnectionStatus.Status; | ||
import io.airbyte.protocol.models.AirbyteMessage; | ||
import io.airbyte.protocol.models.AirbyteMessage.Type; | ||
import io.airbyte.protocol.models.ConfiguredAirbyteCatalog; | ||
import java.util.function.Consumer; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
public class FailAfterNDestination extends BaseConnector implements Destination { | ||
|
||
private static final Logger LOGGER = LoggerFactory.getLogger(FailAfterNDestination.class); | ||
|
||
@Override | ||
public AirbyteConnectionStatus check(final JsonNode config) { | ||
return new AirbyteConnectionStatus().withStatus(Status.SUCCEEDED); | ||
} | ||
|
||
@Override | ||
public AirbyteMessageConsumer getConsumer(final JsonNode config, | ||
final ConfiguredAirbyteCatalog catalog, | ||
final Consumer<AirbyteMessage> outputRecordCollector) { | ||
return new FailAfterNConsumer(config.get("num_messages").asLong(), outputRecordCollector); | ||
} | ||
|
||
public static class FailAfterNConsumer implements AirbyteMessageConsumer { | ||
|
||
private final Consumer<AirbyteMessage> outputRecordCollector; | ||
private final long numMessagesAfterWhichToFail; | ||
private long numMessagesSoFar; | ||
|
||
public FailAfterNConsumer(final long numMessagesAfterWhichToFail, final Consumer<AirbyteMessage> outputRecordCollector) { | ||
this.numMessagesAfterWhichToFail = numMessagesAfterWhichToFail; | ||
this.outputRecordCollector = outputRecordCollector; | ||
this.numMessagesSoFar = 0; | ||
} | ||
|
||
@Override | ||
public void start() {} | ||
|
||
@Override | ||
public void accept(final AirbyteMessage message) throws Exception { | ||
LOGGER.info("received record: {}", message); | ||
numMessagesSoFar += 1; | ||
LOGGER.info("received {} messages so far", numMessagesSoFar); | ||
|
||
if (numMessagesSoFar > numMessagesAfterWhichToFail) { | ||
throw new IllegalStateException("Forcing a fail after processing " + numMessagesAfterWhichToFail + " messages."); | ||
} | ||
|
||
if (message.getType() == Type.STATE) { | ||
LOGGER.info("emitting state: {}", message); | ||
outputRecordCollector.accept(message); | ||
} | ||
} | ||
|
||
@Override | ||
public void close() {} | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters