Package com.cognite.client
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 regularExtractionPipelineRunwithseenstatus to Cognite Data Fusion.
-
-
Field Summary
Fields Modifier and Type Field Description protected static DurationDEFAULT_INTERVALprotected ScheduledThreadPoolExecutorexecutorprotected org.slf4j.LoggerLOGprotected static DurationMAX_INTERVALprotected static DurationMIN_INTERVALprotected ScheduledFuture<?>recurringTask
-
Constructor Summary
Constructors Constructor Description Heartbeat()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()A mirror of thestop()method to support auto close in atry-with-resourcesstatement.static ExtractionPipelineRuns.Heartbeatof(CogniteClient client, String extractionPipelineExtId)Create the heartbeat object.voidsendHeartbeat()Push 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.ExtractionPipelineRuns.HeartbeatwithInterval(Duration interval)Sets the heartbeat interval.
-
-
-
Field Detail
-
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
-
-
Method Detail
-
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
public ExtractionPipelineRuns.Heartbeat withInterval(Duration interval)
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
public void sendHeartbeat() throws ExceptionPush 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()
-
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.
-
-