Class ExtractionPipelineRuns.Heartbeat

java.lang.Object
com.cognite.client.ExtractionPipelineRuns.Heartbeat
All Implemented Interfaces:
Closeable, AutoCloseable
Enclosing class:
ExtractionPipelineRuns

public abstract static class ExtractionPipelineRuns.Heartbeat extends Object implements Closeable
An object that can issue a regular "heartbeat" by posting regular ExtractionPipelineRun with seen status to Cognite Data Fusion.
  • Field Details

    • MIN_INTERVAL

      protected static final Duration MIN_INTERVAL
    • DEFAULT_INTERVAL

      protected static final Duration DEFAULT_INTERVAL
    • MAX_INTERVAL

      protected static final Duration MAX_INTERVAL
    • LOG

      protected final org.slf4j.Logger LOG
    • executor

      protected final ScheduledThreadPoolExecutor executor
    • recurringTask

      protected ScheduledFuture<?> recurringTask
  • Constructor Details

    • Heartbeat

      public Heartbeat()
  • Method Details

    • of

      public static ExtractionPipelineRuns.Heartbeat of(CogniteClient client, String extractionPipelineExtId)
      Create the heartbeat object. The heartbeat object will post a regular heartbeat to a specified extraction pipeline. You start the heartbeat by calling start(). This will start a background thread posting a heartbeat to Cognite Data Fusion until you call stop(). You can also push a single heartbeat by calling sendHeartbeat().
      Parameters:
      client - The cognite client for connecting to CDF.
      extractionPipelineExtId - The external id of the extraction pipeline to post the heartbeat to.
      Returns:
      the heartbeat object.
    • withInterval

      public ExtractionPipelineRuns.Heartbeat withInterval(Duration interval)
      Sets the heartbeat interval. When you activate the heartbeat thread via start(), a ExtractionPipelineRun with state seen will be uploaded to Cognite Data Fusion at every heartbeat interval. The default heartbeat interval is 60 seconds.
      Parameters:
      interval - The target heartbeat interval.
      Returns:
      The ExtractionPipelineRuns.Heartbeat with the upload interval configured.
    • sendHeartbeat

      public void sendHeartbeat() throws Exception
      Push a heartbeat ExtractionPipelineRun.Status.SEEN to Cognite Data Fusion.
      Throws:
      Exception
    • start

      public boolean start()
      Start the heartbeat thread to perform an upload every interval. The default heartbeat interval is every 60 seconds. If the heartbeat thread has already been started (for example by an earlier call to start() then this method does nothing and returns false.
      Returns:
      true if the heartbeat thread started successfully, false if the heartbeat thread has already been started.
    • close

      public void close()
      A mirror of the stop() method to support auto close in a try-with-resources statement.
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable
      See Also:
    • stop

      public boolean stop()
      Stops the heartbeat thread if it is running.
      Returns:
      true if the heartbeat thread stopped successfully, false if the heartbeat thread was not started in the first place.