Package com.snowflake.ingest.streaming
Interface SnowflakeStreamingIngestClient
- All Superinterfaces:
AutoCloseable
A class that is the starting point for using the Streaming Ingest client APIs, a single client
maps to exactly one account/database/schema/pipe in Snowflake; however, multiple clients can
point to the same account/database/schema/pipe. Each client will contain information for
Snowflake authentication and authorization, and it will be used to create one or more
`SnowflakeStreamingIngestChannel`
-
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Close the client, which will flush first and then release all the resourcesClose the client.voiddropChannel(String channelName) Drop the specified channel on the server using the channel namegetChannelStatus(List<String> channelNames) Return the channel status for the given list of channels from SnowflakeGet the client nameGet the database namegetLatestCommittedOffsetTokens(List<String> channelNames) Return the latest committed/persisted offset token for the given list of channels in SnowflakeGet the pipe nameGet the schema namevoidInitiates a flush by the Client which causes all outstanding buffered data to be flushed to Snowflake.booleanisClosed()Check if the client is closedopenChannel(String channelName) Open a channel with a given channel name.openChannel(String channelName, String offsetToken) Open a channel with a given channel name.waitForFlush(Duration timeoutDuration) Asynchronously waits for all buffered data in all channels managed by this client to be flushed to the Snowflake server side.
-
Method Details
-
close
void close()Close the client, which will flush first and then release all the resourcesTODO (SNOW-1916563): decide whether we want to match the V1 behavior
- Specified by:
closein interfaceAutoCloseable
-
close
Close the client. If waitForFlush=true this function will make sure all the data in all channels managed by this client is flushed to the Snowflake server side or return a timeout error if the timeout is reached.- Parameters:
waitForFlush- whether to wait for all channels to be flushedtimeoutDuration- timeout duration
-
initiateFlush
void initiateFlush()Initiates a flush by the Client which causes all outstanding buffered data to be flushed to Snowflake. Note that data can still be accepted by the Client - this is an asynchronous call and will return after flush is initiated for all Channels opened by this Client -
openChannel
Open a channel with a given channel name. The channel is opened on the account/database/schema/pipe defined by the current client. The channel will reuse the latest persisted offset token if the channel is reopened.- Parameters:
channelName- the open channel request- Returns:
- a
OpenChannelResultobject containing the channel and the channel status
-
openChannel
Open a channel with a given channel name. The channel is opened on the account/database/schema/pipe defined by the current client- Parameters:
channelName- the open channel requestoffsetToken- the optional offset token to set on the channel to be opened. If not provided and this reopens an existing channel, the latest persisted offset token will be reused.- Returns:
- a
OpenChannelResultobject containing the channel and the channel status
-
dropChannel
Drop the specified channel on the server using the channel nameNote that this call will blindly drop the latest version of the channel and any pending data will be lost. It will also delete Offset Token and other state from Snowflake servers. So only use it if you are completely done ingesting data for this channel. If you open a channel with the same name in the future, it will behave like a new channel.
Also see
SnowflakeStreamingIngestChannel.close()to close channels. That approach will drop the local version of the channel and if the channel has been concurrently reopened by another client, that version of the channel won't be affected.- Parameters:
channelName- the channel name to drop
-
getLatestCommittedOffsetTokens
Return the latest committed/persisted offset token for the given list of channels in Snowflake- Parameters:
channelNames- the list of channel names- Returns:
- the latest committed offset token for the channel
-
getChannelStatus
Return the channel status for the given list of channels from Snowflake- Parameters:
channelNames- the list of channel names- Returns:
- the channel status for the channel
-
isClosed
boolean isClosed()Check if the client is closed- Returns:
- a boolean which indicates whether the client is closed
-
waitForFlush
Asynchronously waits for all buffered data in all channels managed by this client to be flushed to the Snowflake server side. This method triggers a flush of all pending data across all channels and waits for the flush operations to complete.Behavior:
- If
timeoutDurationisnull, the operation will wait indefinitely - The method coordinates flush operations across all channels managed by this client
- If the client is already closed when this method is called, an exception is thrown immediately
- Parameters:
timeoutDuration- The maximum time to wait for all channels to flush. Ifnull, the operation will wait indefinitely.- Returns:
- A
CompletableFuture<Void>that completes successfully when all channels flush successfully within the timeout period. The future completes exceptionally with:TimeoutExceptionif the timeout was reached before all channels could flushSFExceptionwith error code "ClientClosed" if the client is closed- Other
SFExceptiontypes if flush operations encounter errors
- Throws:
IllegalArgumentException- iftimeoutDurationis negativeSFException- with error code "ClientClosed" if the client is already closed when called
- If
-
getDBName
String getDBName()Get the database name- Returns:
- name of the database
-
getSchemaName
String getSchemaName()Get the schema name- Returns:
- name of the schema
-
getPipeName
String getPipeName()Get the pipe name- Returns:
- name of the pipe
-
getClientName
String getClientName()Get the client name- Returns:
- the client name
-