use of com.aws.iot.edgeconnectorforkvs.model.EdgeConnectorForKVSConfiguration in project aws-iot-greengrass-edge-connector-for-kinesis-video-stream by awslabs.
the class DiskManagerTest method testWatchService_Path_Register_Failed_Case.
@Test
public void testWatchService_Path_Register_Failed_Case() {
// when
List<EdgeConnectorForKVSConfiguration> edgeConnectorForKVSConfigurationList = Collections.singletonList(EdgeConnectorForKVSConfiguration.builder().videoRecordFolderPath(Paths.get("NonExistentFile.txt")).localDataRetentionPeriodInMinutes(LOCAL_DATA_RETENTION_PERIOD_IN_MINUTES).build());
List<WatchEvent<?>> events = new ArrayList<>();
testWatchEventCallBack = new TestWatchEventCallBack(events);
diskManager = new DiskManager(edgeConnectorForKVSConfigurationList, diskManagerUtil, watchServiceExecutor, fileCleanerService, testWatchEventCallBack);
// then
try {
diskManager.setupDiskManagerThread();
} catch (EdgeConnectorForKVSException e) {
assertEquals(e.getClass(), EdgeConnectorForKVSException.class);
}
}
use of com.aws.iot.edgeconnectorforkvs.model.EdgeConnectorForKVSConfiguration in project aws-iot-greengrass-edge-connector-for-kinesis-video-stream by awslabs.
the class SiteWiseManager method buildEdgeConnectorForKVSConfiguration.
private EdgeConnectorForKVSConfiguration buildEdgeConnectorForKVSConfiguration(String cameraSiteWiseAssetId) throws IllegalAccessException {
DescribeAssetResponse assetResponse = siteWiseClient.describeAsset(cameraSiteWiseAssetId);
EdgeConnectorForKVSConfiguration edgeConnectorForKVSConfiguration = new EdgeConnectorForKVSConfiguration();
edgeConnectorForKVSConfiguration.setSiteWiseAssetId(cameraSiteWiseAssetId);
for (AssetProperty assetProperty : assetResponse.assetProperties()) {
GetAssetPropertyValueResponse result;
Field[] fields = edgeConnectorForKVSConfiguration.getClass().getDeclaredFields();
for (Field field : fields) {
if (field.getName().equalsIgnoreCase(assetProperty.name())) {
result = siteWiseClient.getAssetPropertyValue(cameraSiteWiseAssetId, assetProperty.id());
if (result != null && result.propertyValue() != null) {
if (field.getType() == String.class) {
field.set(edgeConnectorForKVSConfiguration, result.propertyValue().value().stringValue());
break;
} else if (field.getType() == Integer.TYPE || field.getType() == Integer.class) {
field.set(edgeConnectorForKVSConfiguration, result.propertyValue().value().integerValue());
break;
}
}
}
}
if (assetProperty.name().equalsIgnoreCase(Constants.SITE_WISE_VIDEO_UPLOADED_TIME_RANGE_MEASUREMENT_NAME)) {
edgeConnectorForKVSConfiguration.setVideoUploadedTimeRangePropertyId(assetProperty.id());
}
if (assetProperty.name().equalsIgnoreCase(Constants.SITE_WISE_VIDEO_RECORDED_TIME_RANGE_MEASUREMENT_NAME)) {
edgeConnectorForKVSConfiguration.setVideoRecordedTimeRangePropertyId(assetProperty.id());
}
if (assetProperty.name().equalsIgnoreCase(Constants.SITE_WISE_CACHED_VIDEO_AGE_OUT_ON_EDGE_MEASUREMENT_NAME)) {
edgeConnectorForKVSConfiguration.setCachedVideoAgeOutOnEdgePropertyId(assetProperty.id());
}
if (assetProperty.name().equalsIgnoreCase(Constants.SITE_WISE_VIDEO_UPLOAD_REQUEST_MEASUREMENT_NAME)) {
if (assetProperty.notification().state() == PropertyNotificationState.ENABLED) {
edgeConnectorForKVSConfiguration.setVideoUploadRequestMqttTopic(assetProperty.notification().topic());
} else {
log.warn("Video Upload Request MQTT Notification Disabled for Asset Id " + cameraSiteWiseAssetId);
}
}
}
return edgeConnectorForKVSConfiguration;
}
use of com.aws.iot.edgeconnectorforkvs.model.EdgeConnectorForKVSConfiguration in project aws-iot-greengrass-edge-connector-for-kinesis-video-stream by awslabs.
the class EdgeConnectorForKVSService method initKinesisVideoStream.
private void initKinesisVideoStream() {
for (EdgeConnectorForKVSConfiguration configuration : edgeConnectorForKVSConfigurationList) {
String kinesisVideoStreamName = configuration.getKinesisVideoStreamName();
Optional<StreamInfo> result = kvsClient.describeStream(kinesisVideoStreamName);
if (!result.isPresent()) {
log.info("Configured KinesisVideoStream name :" + kinesisVideoStreamName + " does not exist, creating it ...");
kvsClient.createStream(kinesisVideoStreamName);
log.info("Created KinesisVideoStream name :" + kinesisVideoStreamName);
}
}
}
use of com.aws.iot.edgeconnectorforkvs.model.EdgeConnectorForKVSConfiguration in project aws-iot-greengrass-edge-connector-for-kinesis-video-stream by awslabs.
the class VideoFileManagerTest method setUp.
@BeforeEach
@SuppressFBWarnings("DMI_HARDCODED_ABSOLUTE_FILENAME")
public void setUp() {
EdgeConnectorForKVSConfiguration edgeConnectorForKVSConfiguration = new EdgeConnectorForKVSConfiguration();
edgeConnectorForKVSConfiguration.setLocalDataRetentionPeriodInMinutes(LOCAL_DATA_RETENTION_PERIOD_IN_MINUTES);
edgeConnectorForKVSConfiguration.setStreamManager(streamManager);
when(streamManager.pushData(any(), any(), any(), any())).thenReturn(0L);
this.directoryPath = Paths.get("/mock/videoTest/");
edgeConnectorForKVSConfiguration.setVideoRecordFolderPath(directoryPath);
this.edgeConnectorForKVSConfigurationList = new ArrayList<>();
edgeConnectorForKVSConfigurationList.add(edgeConnectorForKVSConfiguration);
long video_file_1_timeStamp = LocalDateTime.now().minusMinutes(VIDEO_FILE_1_CACHED_TIME_IN_MINUTES).atZone(ZoneId.systemDefault()).toInstant().toEpochMilli();
long video_file_2_timeStamp = LocalDateTime.now().minusMinutes(VIDEO_FILE_2_CACHED_TIME_IN_MINUTES).atZone(ZoneId.systemDefault()).toInstant().toEpochMilli();
this.videoFilePath_1 = Paths.get("/mock/videoTest/video_" + video_file_1_timeStamp + ".mkv");
this.videoFilePath_2 = Paths.get("/mock/videoTest/video_" + video_file_2_timeStamp + ".mkv");
diskManagerUtil = new DiskManagerUtil();
diskManagerUtil.appendRecordFileToDirPath(directoryPath, videoFilePath_1);
diskManagerUtil.appendRecordFileToDirPath(directoryPath, videoFilePath_2);
videoFileManager = VideoFileManager.builder().diskManagerUtil(diskManagerUtil).edgeConnectorForKVSConfigurationList(edgeConnectorForKVSConfigurationList).build();
}
use of com.aws.iot.edgeconnectorforkvs.model.EdgeConnectorForKVSConfiguration in project aws-iot-greengrass-edge-connector-for-kinesis-video-stream by awslabs.
the class EdgeConnectorForKVSServiceTest method test_initMQTTSubscription_onStartLive.
@Test
public void test_initMQTTSubscription_onStartLive(@TempDir Path tempDir) throws IOException, InterruptedException {
// when
List<EdgeConnectorForKVSConfiguration> edgeConnectorForKVSConfigurationList = new ArrayList();
EdgeConnectorForKVSConfiguration edgeConnectorForKVSConfiguration = EdgeConnectorForKVSConfiguration.builder().kinesisVideoStreamName(MOCK_KINESIS_VIDEO_STREAM_NAME).captureStartTime(START_TIME_NEVER).liveStreamingStartTime(START_TIME_NEVER).videoUploadRequestMqttTopic(VIDEO_UPLOAD_REQUEST_MQTT_TOPIC).videoRecordFolderPath(tempDir).recordingRequestsCount(0).liveStreamingRequestsCount(0).build();
edgeConnectorForKVSConfigurationList.add(edgeConnectorForKVSConfiguration);
// Mock for initConfiguration
when(siteWiseManager.initEdgeConnectorForKVSServiceConfiguration(any())).thenReturn(edgeConnectorForKVSConfigurationList);
// Mock for initSecretsManager
when(secretsClient.getSecretValue(any())).thenReturn(gson.toJson(secretMap));
doAnswer(invocationOnMock -> {
VideoUploadRequestEvent event = invocationOnMock.getArgument(1);
event.onStart(IS_LIVE_TRUE, EVENT_TIMESTAMP, START_TIME, END_TIME);
return null;
}).when(videoUploadRequestHandler).subscribeToMqttTopic(any(), any());
// then
edgeConnectorForKVSService.setUpSharedEdgeConnectorForKVSService();
edgeConnectorForKVSService.setUpCameraLevelEdgeConnectorForKVSService(edgeConnectorForKVSConfiguration);
Thread.sleep(3000);
assertEquals(1, edgeConnectorForKVSConfiguration.getLiveStreamingRequestsCount());
assertEquals(1, edgeConnectorForKVSConfiguration.getRecordingRequestsCount());
}
Aggregations