Search in sources :

Example 6 with Timestamp

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

the class AbstractTopologyBuilder method registerDataChangeListener.

/**
 * Register to data tree change listener.
 */
private synchronized void registerDataChangeListener() {
    Preconditions.checkState(this.listenerRegistration == null, "Topology Listener on topology %s has been registered before.", this.getInstanceIdentifier());
    final InstanceIdentifier<Tables> tablesId = this.locRibReference.getInstanceIdentifier().child(LocRib.class).child(Tables.class, new TablesKey(this.afi, this.safi));
    final DataTreeIdentifier<T> id = new DataTreeIdentifier<>(LogicalDatastoreType.OPERATIONAL, getRouteWildcard(tablesId));
    this.listenerRegistration = this.dataProvider.registerDataTreeChangeListener(id, this);
    LOG.debug("Registered listener {} on topology {}. Timestamp={}", this, this.getInstanceIdentifier(), this.listenerScheduledRestartTime);
}
Also used : LocRib(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev171207.bgp.rib.rib.LocRib) DataTreeIdentifier(org.opendaylight.controller.md.sal.binding.api.DataTreeIdentifier) TablesKey(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev171207.rib.TablesKey) Tables(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev171207.rib.Tables)

Example 7 with Timestamp

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

the class SimplifiedOperationalListener method isConsistentForReconcile.

/**
 * Check if modification is consistent for reconciliation. We need fresh data, which means that current statistics
 * were collected after registration for reconcile and whole bunch of statistics was collected successfully.
 * @param modification from DS
 * @return status of modification
 */
private boolean isConsistentForReconcile(final DataTreeModification<Node> modification) {
    final NodeId nodeId = PathUtil.digNodeId(modification.getRootPath().getRootIdentifier());
    final FlowCapableStatisticsGatheringStatus gatheringStatus = modification.getRootNode().getDataAfter().getAugmentation(FlowCapableStatisticsGatheringStatus.class);
    if (gatheringStatus == null) {
        LOG.trace("Statistics gathering never started: {}", nodeId.getValue());
        return false;
    }
    final SnapshotGatheringStatusEnd gatheringStatusEnd = gatheringStatus.getSnapshotGatheringStatusEnd();
    if (gatheringStatusEnd == null) {
        LOG.trace("Statistics gathering is not over yet: {}", nodeId.getValue());
        return false;
    }
    if (!gatheringStatusEnd.isSucceeded()) {
        LOG.trace("Statistics gathering was not successful: {}", nodeId.getValue());
        return false;
    }
    try {
        Date timestampOfRegistration = reconciliationRegistry.getRegistrationTimestamp(nodeId);
        final SimpleDateFormat simpleDateFormat = new SimpleDateFormat(DATE_AND_TIME_FORMAT);
        Date timestampOfStatistics = simpleDateFormat.parse(gatheringStatusEnd.getEnd().getValue());
        if (timestampOfStatistics.after(timestampOfRegistration)) {
            LOG.debug("Fresh operational present: {}", nodeId.getValue());
            return true;
        }
    } catch (ParseException e) {
        LOG.warn("Timestamp parsing error {}", e);
    }
    LOG.debug("Fresh operational not present: {}", nodeId.getValue());
    return false;
}
Also used : FlowCapableStatisticsGatheringStatus(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableStatisticsGatheringStatus) NodeId(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId) ParseException(java.text.ParseException) SnapshotGatheringStatusEnd(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.snapshot.gathering.status.grouping.SnapshotGatheringStatusEnd) SimpleDateFormat(java.text.SimpleDateFormat) Date(java.util.Date)

Example 8 with Timestamp

use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Timestamp 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 9 with Timestamp

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

the class MappingMergeUtil method mergeXtrIdMappings.

public static MappingData mergeXtrIdMappings(List<Object> mappingDataList, List<MappingData> expiredMappingDataList, Set<IpAddressBinary> sourceRlocs) {
    MappingRecordBuilder mrb = null;
    XtrId xtrId = null;
    Long timestamp = Long.MAX_VALUE;
    for (int i = 0; i < mappingDataList.size(); i++) {
        MappingData mappingData = (MappingData) mappingDataList.get(i);
        MappingRecord record = mappingData.getRecord();
        // Skip expired mappings and add them to a list to be returned to the caller
        if (timestampIsExpired(mappingData.getTimestamp())) {
            expiredMappingDataList.add(mappingData);
            continue;
        }
        if (mrb == null) {
            mrb = new MappingRecordBuilder(record);
        }
        // Save the oldest valid timestamp
        if (mappingData.getTimestamp().getTime() < timestamp) {
            timestamp = mappingData.getTimestamp().getTime();
            xtrId = mappingData.getXtrId();
        }
        // Merge record fields and locators
        mergeCommonMappingRecordFields(mrb, record);
        mergeLocatorRecords(mrb, record);
        // Save source locator for use in Map-Notify
        sourceRlocs.add(record.getSourceRloc());
    }
    if (mrb == null) {
        LOG.warn("All mappings expired when merging! Unexpected!");
        return null;
    }
    mrb.setXtrId(xtrId);
    return new MappingData(mrb.build(), new Date(timestamp));
}
Also used : MappingRecordBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.container.MappingRecordBuilder) MappingRecord(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.container.MappingRecord) MappingData(org.opendaylight.lispflowmapping.lisp.type.MappingData) Date(java.util.Date) XtrId(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.XtrId)

Example 10 with Timestamp

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

the class LispMappingServiceTest method onMappingKeepAliveTest.

/**
 * Tests {@link LispMappingService#onMappingKeepAlive} method.
 */
@Test
public void onMappingKeepAliveTest() {
    final MappingKeepAlive mappingKeepAlive = Mockito.mock(MappingKeepAlive.class);
    Mockito.when(mappingKeepAlive.getMapRegisterCacheMetadata()).thenReturn(getDefaultMapRegisterCacheMetadata());
    lispMappingService.onMappingKeepAlive(mappingKeepAlive);
    Mockito.verify(mappingService).refreshMappingRegistration(IPV4_EID_1, null, TIMESTAMP);
    Mockito.verify(mappingService).refreshMappingRegistration(IPV4_EID_2, null, TIMESTAMP);
}
Also used : MappingKeepAlive(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.MappingKeepAlive) Test(org.junit.Test)

Aggregations

Date (java.util.Date)7 IpAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress)4 SimpleDateFormat (java.text.SimpleDateFormat)3 Test (org.junit.Test)3 AsNumber (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.AsNumber)3 Timestamp (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Timestamp)3 FlowCapableStatisticsGatheringStatus (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableStatisticsGatheringStatus)3 PeerHeaderBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.message.rev171207.peer.header.PeerHeaderBuilder)3 ByteBuf (io.netty.buffer.ByteBuf)2 TransactionChainClosedException (org.opendaylight.controller.md.sal.common.api.data.TransactionChainClosedException)2 Ipv4Address (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address)2 DateAndTime (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.DateAndTime)2 SnapshotGatheringStatusEnd (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.snapshot.gathering.status.grouping.SnapshotGatheringStatusEnd)2 EidLispAddress (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.map.register.cache.metadata.container.map.register.cache.metadata.EidLispAddress)2 PeerDistinguisher (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.message.rev171207.Peer.PeerDistinguisher)2 ImageProcessingException (com.drew.imaging.ImageProcessingException)1 BalloonStyle (de.micromata.opengis.kml.v_2_2_0.BalloonStyle)1 Folder (de.micromata.opengis.kml.v_2_2_0.Folder)1 Icon (de.micromata.opengis.kml.v_2_2_0.Icon)1 IconStyle (de.micromata.opengis.kml.v_2_2_0.IconStyle)1