+ private static InstanceIdentifier<FlowCapableNode> assembleFlowCapableNodeInstanceIdentifier(final DeviceState deviceState) {
+ return deviceState.getNodeInstanceIdentifier().augmentation(FlowCapableNode.class);
+ }
+
+ /**
+ * Writes snapshot gathering start timestamp + cleans end mark
+ *
+ * @param deviceContext txManager + node path keeper
+ */
+ static void markDeviceStateSnapshotStart(final DeviceContext deviceContext) {
+ final InstanceIdentifier<FlowCapableStatisticsGatheringStatus> statusPath = deviceContext.getDeviceState()
+ .getNodeInstanceIdentifier().augmentation(FlowCapableStatisticsGatheringStatus.class);
+
+ final SimpleDateFormat simpleDateFormat = new SimpleDateFormat(DATE_AND_TIME_FORMAT);
+ final FlowCapableStatisticsGatheringStatus gatheringStatus = new FlowCapableStatisticsGatheringStatusBuilder()
+ .setSnapshotGatheringStatusStart(new SnapshotGatheringStatusStartBuilder()
+ .setBegin(new DateAndTime(simpleDateFormat.format(new Date())))
+ .build())
+ .setSnapshotGatheringStatusEnd(null) // TODO: reconsider if really need to clean end mark here
+ .build();
+ try {
+ deviceContext.writeToTransaction(LogicalDatastoreType.OPERATIONAL, statusPath, gatheringStatus);
+ } catch (final Exception e) {
+ LOG.warn("Can't write to transaction: {}", e);
+ }
+
+ deviceContext.submitTransaction();
+ }
+
+ /**
+ * Writes snapshot gathering end timestamp + outcome
+ *
+ * @param deviceContext txManager + node path keeper
+ * @param succeeded outcome of currently finished gathering
+ */
+ static void markDeviceStateSnapshotEnd(final DeviceContext deviceContext, final boolean succeeded) {
+ final InstanceIdentifier<SnapshotGatheringStatusEnd> statusEndPath = deviceContext.getDeviceState()
+ .getNodeInstanceIdentifier().augmentation(FlowCapableStatisticsGatheringStatus.class)
+ .child(SnapshotGatheringStatusEnd.class);
+
+ final SimpleDateFormat simpleDateFormat = new SimpleDateFormat(DATE_AND_TIME_FORMAT);
+ final SnapshotGatheringStatusEnd gatheringStatus = new SnapshotGatheringStatusEndBuilder()
+ .setEnd(new DateAndTime(simpleDateFormat.format(new Date())))
+ .setSucceeded(succeeded)
+ .build();
+ try {
+ deviceContext.writeToTransaction(LogicalDatastoreType.OPERATIONAL, statusEndPath, gatheringStatus);
+ } catch (Exception e) {
+ LOG.warn("Can't write to transaction: {}", e);
+ }
+
+ deviceContext.submitTransaction();