Package com.cognite.client
Class ExtractionPipelineRuns.Heartbeat
java.lang.Object
com.cognite.client.ExtractionPipelineRuns.Heartbeat
- All Implemented Interfaces:
Closeable,AutoCloseable
- Enclosing class:
- ExtractionPipelineRuns
An object that can issue a regular "heartbeat" by posting regular
ExtractionPipelineRun with
seen status to Cognite Data Fusion.-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static final Durationprotected final ScheduledThreadPoolExecutorprotected final org.slf4j.Loggerprotected static final Durationprotected static final Durationprotected ScheduledFuture<?> -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()A mirror of thestop()method to support auto close in atry-with-resourcesstatement.of(CogniteClient client, String extractionPipelineExtId) Create the heartbeat object.voidPush a heartbeatExtractionPipelineRun.Status.SEENto Cognite Data Fusion.booleanstart()Start the heartbeat thread to perform an upload everyinterval.booleanstop()Stops the heartbeat thread if it is running.withInterval(Duration interval) Sets the heartbeat interval.
-
Field Details
-
MIN_INTERVAL
-
DEFAULT_INTERVAL
-
MAX_INTERVAL
-
LOG
protected final org.slf4j.Logger LOG -
executor
-
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 callingstart(). This will start a background thread posting a heartbeat to Cognite Data Fusion until you callstop(). You can also push a single heartbeat by callingsendHeartbeat().- Parameters:
client- The cognite client for connecting to CDF.extractionPipelineExtId- The external id of theextraction pipelineto post the heartbeat to.- Returns:
- the heartbeat object.
-
withInterval
Sets the heartbeat interval. When you activate the heartbeat thread viastart(), aExtractionPipelineRunwith stateseenwill 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.Heartbeatwith the upload interval configured.
-
sendHeartbeat
Push a heartbeatExtractionPipelineRun.Status.SEENto Cognite Data Fusion.- Throws:
Exception
-
start
public boolean start()Start the heartbeat thread to perform an upload everyinterval. The default heartbeat interval is every 60 seconds. If the heartbeat thread has already been started (for example by an earlier call tostart()then this method does nothing and returnsfalse.- Returns:
trueif the heartbeat thread started successfully,falseif the heartbeat thread has already been started.
-
close
public void close()A mirror of thestop()method to support auto close in atry-with-resourcesstatement.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- See Also:
-
stop
public boolean stop()Stops the heartbeat thread if it is running.- Returns:
trueif the heartbeat thread stopped successfully,falseif the heartbeat thread was not started in the first place.
-