Search in sources :

Example 1 with DateAndTime

use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.DateAndTime in project openflowplugin by opendaylight.

the class StatisticsGatheringUtils method markDeviceStateSnapshotEnd.

/**
 * Writes snapshot gathering end timestamp + outcome.
 *
 * @param deviceInfo device info
 * @param txFacade tx manager
 * @param succeeded     outcome of currently finished gathering
 */
static void markDeviceStateSnapshotEnd(final DeviceInfo deviceInfo, final TxFacade txFacade, final boolean succeeded) {
    final InstanceIdentifier<SnapshotGatheringStatusEnd> statusEndPath = deviceInfo.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 {
        txFacade.writeToTransaction(LogicalDatastoreType.OPERATIONAL, statusEndPath, gatheringStatus);
    } catch (TransactionChainClosedException e) {
        LOG.warn("Can't write to transaction, transaction chain probably closed.");
        LOG.trace("Write to transaction exception: ", e);
    }
    txFacade.submitTransaction();
}
Also used : FlowCapableStatisticsGatheringStatus(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableStatisticsGatheringStatus) DateAndTime(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.DateAndTime) TransactionChainClosedException(org.opendaylight.controller.md.sal.common.api.data.TransactionChainClosedException) SnapshotGatheringStatusEnd(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.snapshot.gathering.status.grouping.SnapshotGatheringStatusEnd) SimpleDateFormat(java.text.SimpleDateFormat) Date(java.util.Date) SnapshotGatheringStatusEndBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.snapshot.gathering.status.grouping.SnapshotGatheringStatusEndBuilder)

Example 2 with DateAndTime

use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.DateAndTime in project genius by opendaylight.

the class InterfaceStateHelper method buildStateFromInterfaceInfo.

public static Interface buildStateFromInterfaceInfo(InterfaceInfo interfaceInfo) {
    BigInteger dpId = interfaceInfo.getDpId();
    int portno = interfaceInfo.getPortNo();
    NodeConnectorId nodeConnectorId = new NodeConnectorId("openflow:" + dpId.toString() + ":" + portno);
    return new InterfaceBuilder().setType(Other.class).setIfIndex(interfaceInfo.getInterfaceTag()).setAdminStatus(AdminStatus.Up).setOperStatus(OperStatus.Up).setLowerLayerIf(Lists.newArrayList(nodeConnectorId.getValue())).setPhysAddress(new PhysAddress(interfaceInfo.getMacAddress())).setKey(new InterfaceKey(interfaceInfo.getInterfaceName())).setStatistics(new StatisticsBuilder().setDiscontinuityTime(new DateAndTime(DateTimeFormatter.ISO_OFFSET_DATE_TIME.format(ZonedDateTime.now()))).build()).build();
}
Also used : NodeConnectorId(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorId) BigInteger(java.math.BigInteger) DateAndTime(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.DateAndTime) InterfaceBuilder(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.InterfaceBuilder) InterfaceKey(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.InterfaceKey) StatisticsBuilder(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state._interface.StatisticsBuilder) PhysAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.PhysAddress)

Example 3 with DateAndTime

use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.DateAndTime in project openflowplugin by opendaylight.

the class StatisticsGatheringUtils method markDeviceStateSnapshotStart.

/**
 * Writes snapshot gathering start timestamp + cleans end mark.
 *
 * @param deviceInfo device info
 * @param txFacade tx manager
 */
static void markDeviceStateSnapshotStart(final DeviceInfo deviceInfo, final TxFacade txFacade) {
    final InstanceIdentifier<FlowCapableStatisticsGatheringStatus> statusPath = deviceInfo.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(// TODO: reconsider if really need to clean end mark here
    null).build();
    try {
        txFacade.writeToTransaction(LogicalDatastoreType.OPERATIONAL, statusPath, gatheringStatus);
    } catch (final TransactionChainClosedException e) {
        LOG.warn("Can't write to transaction, transaction chain probably closed.");
        LOG.trace("Write to transaction exception: ", e);
    }
    txFacade.submitTransaction();
}
Also used : FlowCapableStatisticsGatheringStatus(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableStatisticsGatheringStatus) DateAndTime(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.DateAndTime) FlowCapableStatisticsGatheringStatusBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableStatisticsGatheringStatusBuilder) TransactionChainClosedException(org.opendaylight.controller.md.sal.common.api.data.TransactionChainClosedException) SimpleDateFormat(java.text.SimpleDateFormat) SnapshotGatheringStatusStartBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.snapshot.gathering.status.grouping.SnapshotGatheringStatusStartBuilder) Date(java.util.Date)

Aggregations

DateAndTime (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.DateAndTime)3 SimpleDateFormat (java.text.SimpleDateFormat)2 Date (java.util.Date)2 TransactionChainClosedException (org.opendaylight.controller.md.sal.common.api.data.TransactionChainClosedException)2 FlowCapableStatisticsGatheringStatus (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableStatisticsGatheringStatus)2 BigInteger (java.math.BigInteger)1 InterfaceBuilder (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.InterfaceBuilder)1 InterfaceKey (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.InterfaceKey)1 StatisticsBuilder (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state._interface.StatisticsBuilder)1 PhysAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.PhysAddress)1 FlowCapableStatisticsGatheringStatusBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableStatisticsGatheringStatusBuilder)1 SnapshotGatheringStatusEnd (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.snapshot.gathering.status.grouping.SnapshotGatheringStatusEnd)1 SnapshotGatheringStatusEndBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.snapshot.gathering.status.grouping.SnapshotGatheringStatusEndBuilder)1 SnapshotGatheringStatusStartBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.snapshot.gathering.status.grouping.SnapshotGatheringStatusStartBuilder)1 NodeConnectorId (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorId)1