Search in sources :

Example 1 with MessageStreamDefinition

use of com.amazonaws.greengrass.streammanager.model.MessageStreamDefinition in project aws-iot-greengrass-edge-connector-for-kinesis-video-stream by awslabs.

the class StreamManager method createMessageStream.

/**
 * Creates a message stream where data is written to.
 *
 * @param msgStreamName - Name of the stream manager message stream
 */
public void createMessageStream(@NonNull String msgStreamName) {
    this.msgStreamName = msgStreamName;
    IoTSiteWiseConfig ioTSiteWiseConfig = new IoTSiteWiseConfig();
    ioTSiteWiseConfig.setIdentifier(UUID.randomUUID().toString());
    ioTSiteWiseConfig.setBatchSize(STREAM_MANAGER_SITEWISE_BATCH_SIZE);
    List<IoTSiteWiseConfig> ioTSiteWiseConfigs = new ArrayList<IoTSiteWiseConfig>();
    ioTSiteWiseConfigs.add(ioTSiteWiseConfig);
    try {
        if (streamManagerClient == null) {
            streamManagerClient = StreamManagerClientFactory.standard().build();
        }
        streamManagerClient.createMessageStream(new MessageStreamDefinition().withName(// Required.
        msgStreamName).withMaxSize(// Default is 256 MB.
        STREAM_MANAGER_MAX_STREAM_SIZE).withStreamSegmentSize(// Default is 16 MB.
        STREAM_MANAGER_STREAM_SEGMENT_SIZE).withTimeToLiveMillis(// By default, no TTL is enabled.
        null).withStrategyOnFull(// Required.
        StrategyOnFull.OverwriteOldestData).withPersistence(// Default is File.
        Persistence.File).withFlushOnWrite(// Default is false.
        false).withExportDefinition(new ExportDefinition().withIotSitewise(ioTSiteWiseConfigs)));
    } catch (Exception ex) {
        final String errorMsg = String.format("Error Creating Stream %s: %s", msgStreamName, ex.getMessage());
        log.error(errorMsg);
        throw new EdgeConnectorForKVSException(errorMsg, ex);
    }
}
Also used : EdgeConnectorForKVSException(com.aws.iot.edgeconnectorforkvs.model.exceptions.EdgeConnectorForKVSException) ArrayList(java.util.ArrayList) ExportDefinition(com.amazonaws.greengrass.streammanager.model.export.ExportDefinition) IoTSiteWiseConfig(com.amazonaws.greengrass.streammanager.model.export.IoTSiteWiseConfig) MessageStreamDefinition(com.amazonaws.greengrass.streammanager.model.MessageStreamDefinition) EdgeConnectorForKVSException(com.aws.iot.edgeconnectorforkvs.model.exceptions.EdgeConnectorForKVSException) JsonProcessingException(com.fasterxml.jackson.core.JsonProcessingException) StreamManagerException(com.amazonaws.greengrass.streammanager.client.exception.StreamManagerException)

Aggregations

StreamManagerException (com.amazonaws.greengrass.streammanager.client.exception.StreamManagerException)1 MessageStreamDefinition (com.amazonaws.greengrass.streammanager.model.MessageStreamDefinition)1 ExportDefinition (com.amazonaws.greengrass.streammanager.model.export.ExportDefinition)1 IoTSiteWiseConfig (com.amazonaws.greengrass.streammanager.model.export.IoTSiteWiseConfig)1 EdgeConnectorForKVSException (com.aws.iot.edgeconnectorforkvs.model.exceptions.EdgeConnectorForKVSException)1 JsonProcessingException (com.fasterxml.jackson.core.JsonProcessingException)1 ArrayList (java.util.ArrayList)1