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_InitScheduler.
@Test
public void test_InitScheduler(@TempDir Path tempDir) throws IOException {
// when
List<EdgeConnectorForKVSConfiguration> edgeConnectorForKVSConfigurationList = new ArrayList();
EdgeConnectorForKVSConfiguration edgeConnectorForKVSConfiguration = Mockito.spy(EdgeConnectorForKVSConfiguration.class);
when(edgeConnectorForKVSConfiguration.getKinesisVideoStreamName()).thenReturn(MOCK_KINESIS_VIDEO_STREAM_NAME);
when(edgeConnectorForKVSConfiguration.getLiveStreamingStartTime()).thenReturn(START_TIME_ALWAYS);
when(edgeConnectorForKVSConfiguration.getCaptureStartTime()).thenReturn(CAPTURE_START_TIME);
when(edgeConnectorForKVSConfiguration.getLiveStreamingStartTime()).thenReturn(LIVE_STREAMING_START_TIME);
when(edgeConnectorForKVSConfiguration.getVideoRecordFolderPath()).thenReturn(tempDir);
doNothing().when(edgeConnectorForKVSConfiguration).setVideoUploader(any());
doNothing().when(edgeConnectorForKVSConfiguration).setVideoUploader(any());
edgeConnectorForKVSConfigurationList.add(edgeConnectorForKVSConfiguration);
// Mock for initConfiguration
when(siteWiseManager.initEdgeConnectorForKVSServiceConfiguration(any())).thenReturn(edgeConnectorForKVSConfigurationList);
// Mock for initSecretsManager
when(secretsClient.getSecretValue(any())).thenReturn(gson.toJson(secretMap));
// then
edgeConnectorForKVSService.setUpSharedEdgeConnectorForKVSService();
edgeConnectorForKVSService.setUpCameraLevelEdgeConnectorForKVSService(edgeConnectorForKVSConfiguration);
}
use of com.aws.iot.edgeconnectorforkvs.model.EdgeConnectorForKVSConfiguration in project aws-iot-greengrass-edge-connector-for-kinesis-video-stream by awslabs.
the class DiskManagerUtil method buildRecordedFilesMap.
/**
* Method to initialize local cached video file records.
* The method all walk all given dir paths, generate Map, key is directoryPath, value is the
* ConcurrentLinkedQueue which contains all existing video files.
*
* @param edgeConnectorForKVSConfiguration EdgeConnectorForKVSConfiguration
* @throws IOException throw IOException
*/
public void buildRecordedFilesMap(@NonNull EdgeConnectorForKVSConfiguration edgeConnectorForKVSConfiguration) throws IOException {
Path directoryPath = edgeConnectorForKVSConfiguration.getVideoRecordFolderPath();
ConcurrentLinkedDeque<Path> recordedFilesQueue = new ConcurrentLinkedDeque<>();
recordedFilesMap.put(directoryPath, recordedFilesQueue);
int localDataRetentionPeriodInMinutes = edgeConnectorForKVSConfiguration.getLocalDataRetentionPeriodInMinutes();
recordedFilesRetentionPeriodMap.put(directoryPath, localDataRetentionPeriodInMinutes);
try (Stream<Path> walk = Files.walk(directoryPath)) {
walk.filter(p -> !Files.isDirectory(p)).sorted(Comparator.comparing(Path::getFileName)).collect(Collectors.toList()).forEach(p -> appendRecordFileToDirPath(directoryPath, p));
} catch (IOException e) {
log.error("Unable to initialize recorded files map for dir path: " + directoryPath);
log.error(e.getMessage());
throw new IOException(e);
}
}
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_Build_Recorder_Files_Success_Case.
@Test
public void testWatchService_Build_Recorder_Files_Success_Case(@TempDir Path tempDir) {
// when
List<EdgeConnectorForKVSConfiguration> edgeConnectorForKVSConfigurationList = Collections.singletonList(EdgeConnectorForKVSConfiguration.builder().videoRecordFolderPath(tempDir).localDataRetentionPeriodInMinutes(LOCAL_DATA_RETENTION_PERIOD_IN_MINUTES).build());
filePath = tempDir.resolve(FILE_NAME);
List<WatchEvent<?>> events = new ArrayList<>();
testWatchEventCallBack = new TestWatchEventCallBack(events);
diskManager = new DiskManager(edgeConnectorForKVSConfigurationList, diskManagerUtil, watchServiceExecutor, fileCleanerService, testWatchEventCallBack);
// then
diskManager.initDiskManager();
assertTrue(diskManagerUtil.getRecordedFilesMap().size() > 0);
}
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 test_GetEdgeConnectorForKVSConfigurationFromPath.
@Test
public void test_GetEdgeConnectorForKVSConfigurationFromPath(@TempDir Path tempDir) {
// when
EdgeConnectorForKVSConfiguration configuration = new EdgeConnectorForKVSConfiguration();
diskManagerUtil.getEdgeConnectorForKVSConfigurationMap().put(tempDir, configuration);
// then and verify
assertEquals(diskManagerUtil.getEdgeConnectorForKVSConfigurationFromPath(tempDir), configuration);
}
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_File_Monitor_Thread_Exists_Case.
@Test
public void testWatchService_File_Monitor_Thread_Exists_Case(@TempDir Path tempDir) throws InterruptedException, IOException {
// 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 and verify
diskManager.setupDiskManagerThread();
diskManager.setupDiskManagerThread();
Thread.sleep(3000);
filePath = tempDir.resolve(FILE_NAME);
Files.write(filePath, Collections.singletonList(MOCK_VALUE));
// then
try {
diskManager.setupDiskManagerThread();
Thread.sleep(3000);
} catch (EdgeConnectorForKVSException | InterruptedException e) {
assertEquals(e.getClass(), EdgeConnectorForKVSException.class);
}
}
Aggregations