mirror of
https://github.com/opennetworkinglab/onos.git
synced 2025-10-16 01:41:26 +02:00
[ONOS-2233] Implement of Tunnel monitoring, measurement and observation
1. add a tunnel statistics interface. 2. add a pcep tunnel statistics interface. 3. add a tunnelStatsCollector to poll statistic request ,The polling interval can be configurable. 4. extend the pcepTunnelProvider to handle tunnel statistic message Change-Id: I1187d586a1833ca4bee55529a65cd61eff0e612d
This commit is contained in:
parent
1a00251650
commit
2fff70fb65
@ -112,4 +112,11 @@ public interface PcepController {
|
||||
*/
|
||||
Boolean updateTunnelBandwidth(String id, long bandwidth);
|
||||
|
||||
/**
|
||||
* Send statistic request by tunnel id.
|
||||
*
|
||||
* @param pcepTunnelId PCEP tunnel id
|
||||
*/
|
||||
void getTunnelStatistics(String pcepTunnelId);
|
||||
|
||||
}
|
||||
|
@ -28,4 +28,13 @@ public interface PcepTunnelListener {
|
||||
*/
|
||||
void handlePCEPTunnel(PcepTunnel tunnel);
|
||||
|
||||
/**
|
||||
* Notify that get a tunnel statistic data from the network.
|
||||
*
|
||||
* @param tunnelStatistics tunnel statistic information.
|
||||
*/
|
||||
void handlePcepTunnelStatistics(PcepTunnelStatistics tunnelStatistics);
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,65 @@
|
||||
/*
|
||||
*
|
||||
* * Copyright 2015 Open Networking Laboratory
|
||||
* *
|
||||
* * Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* * you may not use this file except in compliance with the License.
|
||||
* * You may obtain a copy of the License at
|
||||
* *
|
||||
* * http://www.apache.org/licenses/LICENSE-2.0
|
||||
* *
|
||||
* * Unless required by applicable law or agreed to in writing, software
|
||||
* * distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* * See the License for the specific language governing permissions and
|
||||
* * limitations under the License.
|
||||
*
|
||||
*/
|
||||
|
||||
package org.onosproject.pcep.api;
|
||||
|
||||
import java.time.Duration;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Statistics of a PCEP tunnel.
|
||||
*/
|
||||
public interface PcepTunnelStatistics {
|
||||
|
||||
|
||||
/**
|
||||
* Returns the id of PCEP tunnel.
|
||||
*
|
||||
* @return PCEP tunnel id
|
||||
*/
|
||||
long id();
|
||||
|
||||
|
||||
/**
|
||||
* Returns the bandwidth utilization of a PCEP tunnel.
|
||||
*
|
||||
* @return PCEP bandwidth utilization
|
||||
*/
|
||||
double bandwidthUtilization();
|
||||
|
||||
/**
|
||||
* Returns the flow loss rate of a tunnel.
|
||||
*
|
||||
* @return tunnel flow loss rate
|
||||
*/
|
||||
double packetLossRate();
|
||||
|
||||
/**
|
||||
* Returns the end-to-end traffic flow delay of a tunnel.
|
||||
*
|
||||
* @return tunnel traffic flow delay
|
||||
*/
|
||||
Duration flowDelay();
|
||||
|
||||
/**
|
||||
* Returns the alarms on a tunnel.
|
||||
*
|
||||
* @return tunnel alarms
|
||||
*/
|
||||
List<String> alarms();
|
||||
}
|
@ -0,0 +1,168 @@
|
||||
/*
|
||||
*
|
||||
* * Copyright 2015 Open Networking Laboratory
|
||||
* *
|
||||
* * Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* * you may not use this file except in compliance with the License.
|
||||
* * You may obtain a copy of the License at
|
||||
* *
|
||||
* * http://www.apache.org/licenses/LICENSE-2.0
|
||||
* *
|
||||
* * Unless required by applicable law or agreed to in writing, software
|
||||
* * distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* * See the License for the specific language governing permissions and
|
||||
* * limitations under the License.
|
||||
*
|
||||
*/
|
||||
|
||||
package org.onosproject.incubator.net.tunnel;
|
||||
|
||||
import java.time.Duration;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Default implementation of immutable tunnel statistics.
|
||||
*/
|
||||
public final class DefaultTunnelStatistics implements TunnelStatistics {
|
||||
private final TunnelId tunnelId;
|
||||
private final double bwUtilization;
|
||||
private final double packetLossRatio;
|
||||
private final Duration flowDelay;
|
||||
private final List<String> alarms;
|
||||
|
||||
private DefaultTunnelStatistics(TunnelId tunnelId,
|
||||
double bwUtilization,
|
||||
double packetLossRatio,
|
||||
Duration flowDelay,
|
||||
List<String> alarms) {
|
||||
this.tunnelId = tunnelId;
|
||||
this.bwUtilization = bwUtilization;
|
||||
this.packetLossRatio = packetLossRatio;
|
||||
this.flowDelay = flowDelay;
|
||||
this.alarms = alarms;
|
||||
}
|
||||
|
||||
private DefaultTunnelStatistics() {
|
||||
this.tunnelId = null;
|
||||
this.bwUtilization = 0;
|
||||
this.packetLossRatio = 0;
|
||||
this.flowDelay = null;
|
||||
this.alarms = null;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public TunnelId id() {
|
||||
return this.tunnelId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double bandwidthUtilization() {
|
||||
return this.bwUtilization;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double packetLossRate() {
|
||||
return this.packetLossRatio;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Duration flowDelay() {
|
||||
return this.flowDelay;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public List<String> alarms() {
|
||||
return this.alarms;
|
||||
}
|
||||
|
||||
/**
|
||||
* Builder for tunnelStatistics.
|
||||
*/
|
||||
public static final class Builder {
|
||||
TunnelId tunnelId;
|
||||
double bwUtilization;
|
||||
double packetLossRatio;
|
||||
Duration flowDelay;
|
||||
List<String> alarms;
|
||||
|
||||
public Builder() {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Set tunnel id.
|
||||
*
|
||||
* @param tunnelId tunnel id
|
||||
* @return builder object
|
||||
*/
|
||||
public Builder setTunnelId(TunnelId tunnelId) {
|
||||
this.tunnelId = tunnelId;
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* set bandwidth utilization.
|
||||
*
|
||||
* @param bwUtilization bandwidth utilization
|
||||
* @return builder object
|
||||
*/
|
||||
public Builder setBwUtilization(double bwUtilization) {
|
||||
this.bwUtilization = bwUtilization;
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set packet loss ratio.
|
||||
*
|
||||
* @param packetLossRatio packet loss ratio
|
||||
* @return builder object
|
||||
*/
|
||||
public Builder setPacketLossRatio(double packetLossRatio) {
|
||||
this.packetLossRatio = packetLossRatio;
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set flow delay.
|
||||
*
|
||||
* @param flowDelay flow delay
|
||||
* @return builder object
|
||||
*/
|
||||
public Builder setFlowDelay(Duration flowDelay) {
|
||||
this.flowDelay = flowDelay;
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set alarms.
|
||||
*
|
||||
* @param alarms alarms of a tunnel
|
||||
* @return builder object
|
||||
*/
|
||||
public Builder setAlarms(List<String> alarms) {
|
||||
this.alarms = alarms;
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a TunnelStatistics object.
|
||||
*
|
||||
* @return DefaultTunnelStatistics
|
||||
*/
|
||||
public DefaultTunnelStatistics build() {
|
||||
return new DefaultTunnelStatistics(tunnelId,
|
||||
bwUtilization,
|
||||
packetLossRatio,
|
||||
flowDelay,
|
||||
alarms);
|
||||
}
|
||||
}
|
||||
}
|
@ -41,7 +41,7 @@ public interface TunnelStatistics {
|
||||
double bandwidthUtilization();
|
||||
|
||||
/**
|
||||
* Returns the packet loss rate of a tunnel.
|
||||
* Returns the packet loss ratio of a tunnel.
|
||||
*
|
||||
* @return tunnel packet loss ratio
|
||||
*/
|
||||
|
@ -19,5 +19,21 @@
|
||||
<groupId>org.onosproject</groupId>
|
||||
<artifactId>onos-pcep-controller-api</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.osgi</groupId>
|
||||
<artifactId>org.osgi.compendium</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.onosproject</groupId>
|
||||
<artifactId>onos-api</artifactId>
|
||||
<classifier>tests</classifier>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.onosproject</groupId>
|
||||
<artifactId>onos-incubator-net</artifactId>
|
||||
<version>${project.version} </version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
@ -16,7 +16,9 @@
|
||||
package org.onosproject.provider.pcep.tunnel.impl;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
import static com.google.common.base.Strings.isNullOrEmpty;
|
||||
import static org.onosproject.net.DefaultAnnotations.EMPTY;
|
||||
import static org.onlab.util.Tools.get;
|
||||
import static org.onosproject.net.DeviceId.deviceId;
|
||||
import static org.onosproject.net.PortNumber.portNumber;
|
||||
import static org.onosproject.pcep.api.PcepDpid.uri;
|
||||
@ -24,24 +26,29 @@ import static org.slf4j.LoggerFactory.getLogger;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Dictionary;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.ListIterator;
|
||||
import java.util.Optional;
|
||||
|
||||
import com.google.common.collect.Maps;
|
||||
import org.apache.felix.scr.annotations.Activate;
|
||||
import org.apache.felix.scr.annotations.Component;
|
||||
import org.apache.felix.scr.annotations.Deactivate;
|
||||
import org.apache.felix.scr.annotations.Property;
|
||||
import org.apache.felix.scr.annotations.Reference;
|
||||
import org.apache.felix.scr.annotations.ReferenceCardinality;
|
||||
import org.apache.felix.scr.annotations.Service;
|
||||
import org.onlab.packet.IpAddress;
|
||||
import org.onosproject.cfg.ComponentConfigService;
|
||||
import org.onosproject.core.DefaultGroupId;
|
||||
import org.onosproject.incubator.net.tunnel.DefaultOpticalTunnelEndPoint;
|
||||
import org.onosproject.incubator.net.tunnel.DefaultTunnel;
|
||||
import org.onosproject.incubator.net.tunnel.DefaultTunnelDescription;
|
||||
import org.onosproject.incubator.net.tunnel.IpTunnelEndPoint;
|
||||
import org.onosproject.incubator.net.tunnel.DefaultTunnelStatistics;
|
||||
import org.onosproject.incubator.net.tunnel.OpticalLogicId;
|
||||
import org.onosproject.incubator.net.tunnel.OpticalTunnelEndPoint;
|
||||
import org.onosproject.incubator.net.tunnel.Tunnel;
|
||||
@ -52,6 +59,8 @@ import org.onosproject.incubator.net.tunnel.TunnelName;
|
||||
import org.onosproject.incubator.net.tunnel.TunnelProvider;
|
||||
import org.onosproject.incubator.net.tunnel.TunnelProviderRegistry;
|
||||
import org.onosproject.incubator.net.tunnel.TunnelProviderService;
|
||||
import org.onosproject.incubator.net.tunnel.TunnelService;
|
||||
import org.onosproject.incubator.net.tunnel.TunnelStatistics;
|
||||
import org.onosproject.net.ConnectPoint;
|
||||
import org.onosproject.net.DefaultAnnotations;
|
||||
import org.onosproject.net.DefaultLink;
|
||||
@ -73,6 +82,8 @@ import org.onosproject.pcep.api.PcepTunnel;
|
||||
import org.onosproject.pcep.api.PcepTunnel.PATHTYPE;
|
||||
import org.onosproject.pcep.api.PcepTunnel.PathState;
|
||||
import org.onosproject.pcep.api.PcepTunnelListener;
|
||||
import org.onosproject.pcep.api.PcepTunnelStatistics;
|
||||
import org.osgi.service.component.annotations.Modified;
|
||||
import org.onosproject.pcep.controller.PccId;
|
||||
import org.onosproject.pcep.controller.PcepClient;
|
||||
import org.onosproject.pcep.controller.PcepClientController;
|
||||
@ -99,8 +110,7 @@ import org.onosproject.pcepio.types.PcepValueType;
|
||||
import org.onosproject.pcepio.types.StatefulIPv4LspIdentidiersTlv;
|
||||
import org.onosproject.pcepio.types.SymbolicPathNameTlv;
|
||||
import org.slf4j.Logger;
|
||||
|
||||
import static org.onosproject.pcep.api.PcepDpid.*;
|
||||
import org.osgi.service.component.ComponentContext;
|
||||
|
||||
/**
|
||||
* Provider which uses an PCEP controller to detect, update, create network
|
||||
@ -116,6 +126,11 @@ public class PcepTunnelProvider extends AbstractProvider implements TunnelProvid
|
||||
private static final String BANDWIDTH_UINT = "kbps";
|
||||
static final String PROVIDER_ID = "org.onosproject.provider.tunnel.pcep";
|
||||
|
||||
static final int POLL_INTERVAL = 10;
|
||||
@Property(name = "tunnelStatsPollFrequency", intValue = POLL_INTERVAL,
|
||||
label = "Frequency (in seconds) for polling tunnel statistics")
|
||||
private int tunnelStatsPollFrequency = POLL_INTERVAL;
|
||||
|
||||
private static final String TUNNLE_NOT_NULL = "Create failed,The given port may be wrong or has been occupied.";
|
||||
|
||||
@Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
|
||||
@ -126,9 +141,18 @@ public class PcepTunnelProvider extends AbstractProvider implements TunnelProvid
|
||||
|
||||
@Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
|
||||
protected PcepClientController pcepClientController;
|
||||
|
||||
@Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
|
||||
protected TunnelService tunnelService;
|
||||
|
||||
@Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
|
||||
protected ComponentConfigService cfgService;
|
||||
|
||||
TunnelProviderService service;
|
||||
|
||||
HashMap<String, TunnelId> tunnelMap = new HashMap<String, TunnelId>();
|
||||
HashMap<TunnelId, TunnelStatistics> tunnelStatisticsMap = new HashMap<>();
|
||||
private HashMap<Long, TunnelStatsCollector> collectors = Maps.newHashMap();
|
||||
|
||||
private InnerTunnelProvider listener = new InnerTunnelProvider();
|
||||
|
||||
@ -144,10 +168,19 @@ public class PcepTunnelProvider extends AbstractProvider implements TunnelProvid
|
||||
|
||||
@Activate
|
||||
public void activate() {
|
||||
cfgService.registerProperties(getClass());
|
||||
service = tunnelProviderRegistry.register(this);
|
||||
controller.addTunnelListener(listener);
|
||||
pcepClientController.addListener(listener);
|
||||
pcepClientController.addEventListener(listener);
|
||||
tunnelService.queryAllTunnels().forEach(tunnel -> {
|
||||
String pcepTunnelId = getPCEPTunnelKey(tunnel.tunnelId());
|
||||
TunnelStatsCollector tsc = new TunnelStatsCollector(pcepTunnelId, tunnelStatsPollFrequency);
|
||||
tsc.start();
|
||||
collectors.put(tunnel.tunnelId().id(), tsc);
|
||||
|
||||
});
|
||||
|
||||
log.info("Started");
|
||||
}
|
||||
|
||||
@ -155,10 +188,31 @@ public class PcepTunnelProvider extends AbstractProvider implements TunnelProvid
|
||||
public void deactivate() {
|
||||
tunnelProviderRegistry.unregister(this);
|
||||
controller.removeTunnelListener(listener);
|
||||
collectors.values().forEach(TunnelStatsCollector::stop);
|
||||
pcepClientController.removeListener(listener);
|
||||
log.info("Stopped");
|
||||
}
|
||||
|
||||
@Modified
|
||||
public void modified(ComponentContext context) {
|
||||
Dictionary<?, ?> properties = context.getProperties();
|
||||
int newTunnelStatsPollFrequency;
|
||||
try {
|
||||
String s = get(properties, "tunnelStatsPollFrequency");
|
||||
newTunnelStatsPollFrequency = isNullOrEmpty(s) ? tunnelStatsPollFrequency : Integer.parseInt(s.trim());
|
||||
|
||||
} catch (NumberFormatException | ClassCastException e) {
|
||||
newTunnelStatsPollFrequency = tunnelStatsPollFrequency;
|
||||
}
|
||||
|
||||
if (newTunnelStatsPollFrequency != tunnelStatsPollFrequency) {
|
||||
tunnelStatsPollFrequency = newTunnelStatsPollFrequency;
|
||||
collectors.values().forEach(tsc -> tsc.adjustPollInterval(tunnelStatsPollFrequency));
|
||||
log.info("New setting: tunnelStatsPollFrequency={}", tunnelStatsPollFrequency);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setupTunnel(Tunnel tunnel, Path path) {
|
||||
if (tunnel.type() != Tunnel.Type.MPLS) {
|
||||
@ -580,6 +634,21 @@ public class PcepTunnelProvider extends AbstractProvider implements TunnelProvid
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Build a DefaultTunnelStatistics from a PcepTunnelStatistics.
|
||||
*
|
||||
* @param statistics statistics data from a PCEP tunnel
|
||||
* @return TunnelStatistics
|
||||
*/
|
||||
private TunnelStatistics buildTunnelStatistics(PcepTunnelStatistics statistics) {
|
||||
DefaultTunnelStatistics.Builder builder = new DefaultTunnelStatistics.Builder();
|
||||
DefaultTunnelStatistics tunnelStatistics = builder.setBwUtilization(statistics.bandwidthUtilization())
|
||||
.setPacketLossRatio(statistics.packetLossRate())
|
||||
.setFlowDelay(statistics.flowDelay())
|
||||
.setAlarms(statistics.alarms())
|
||||
.build();
|
||||
return tunnelStatistics;
|
||||
}
|
||||
/**
|
||||
* Creates list of hops for ERO object from Path.
|
||||
*
|
||||
@ -844,6 +913,8 @@ public class PcepTunnelProvider extends AbstractProvider implements TunnelProvid
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
private class InnerTunnelProvider implements PcepTunnelListener, PcepEventListener, PcepClientListener {
|
||||
|
||||
@Override
|
||||
@ -1141,6 +1212,15 @@ public class PcepTunnelProvider extends AbstractProvider implements TunnelProvid
|
||||
public void clientDisconnected(PccId pccId) {
|
||||
// TODO
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public void handlePcepTunnelStatistics(PcepTunnelStatistics pcepTunnelStatistics) {
|
||||
TunnelId id = getTunnelId(String.valueOf(pcepTunnelStatistics.id()));
|
||||
TunnelStatistics tunnelStatistics = buildTunnelStatistics(pcepTunnelStatistics);
|
||||
tunnelStatisticsMap.put(id, tunnelStatistics);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -0,0 +1,104 @@
|
||||
/*
|
||||
*
|
||||
* * Copyright 2014-2015 Open Networking Laboratory
|
||||
* *
|
||||
* * Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* * you may not use this file except in compliance with the License.
|
||||
* * You may obtain a copy of the License at
|
||||
* *
|
||||
* * http://www.apache.org/licenses/LICENSE-2.0
|
||||
* *
|
||||
* * Unless required by applicable law or agreed to in writing, software
|
||||
* * distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* * See the License for the specific language governing permissions and
|
||||
* * limitations under the License.
|
||||
*
|
||||
*/
|
||||
|
||||
package org.onosproject.provider.pcep.tunnel.impl;
|
||||
|
||||
|
||||
import org.apache.felix.scr.annotations.Reference;
|
||||
import org.apache.felix.scr.annotations.ReferenceCardinality;
|
||||
import org.jboss.netty.util.HashedWheelTimer;
|
||||
import org.jboss.netty.util.Timeout;
|
||||
import org.jboss.netty.util.TimerTask;
|
||||
import org.onlab.util.Timer;
|
||||
import org.onosproject.pcep.api.PcepController;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
/*
|
||||
* Sends Stats Request and collect the tunnel statistics with a time interval.
|
||||
*/
|
||||
public class TunnelStatsCollector implements TimerTask {
|
||||
private final Logger log = LoggerFactory.getLogger(getClass());
|
||||
|
||||
@Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
|
||||
protected PcepController controller;
|
||||
|
||||
private int refreshInterval;
|
||||
private final HashedWheelTimer timer = Timer.getTimer();
|
||||
|
||||
private String pcepTunnelId;
|
||||
private Timeout timeout;
|
||||
private volatile boolean stopped;
|
||||
|
||||
|
||||
/**
|
||||
* Greate a tunnel status collector object.
|
||||
*
|
||||
* @param id tunnel whose status data will be collected
|
||||
* @param refreshInterval time interval for collecting statistic
|
||||
*/
|
||||
public TunnelStatsCollector(String id, int refreshInterval) {
|
||||
this.pcepTunnelId = id;
|
||||
this.refreshInterval = refreshInterval;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run(Timeout timeout) throws Exception {
|
||||
if (stopped || timeout.isCancelled()) {
|
||||
return;
|
||||
}
|
||||
log.trace("Collecting stats for {}", pcepTunnelId);
|
||||
|
||||
sendTunnelStatistic();
|
||||
if (!stopped && !timeout.isCancelled()) {
|
||||
log.trace("Scheduling stats collection in {} seconds for {}",
|
||||
this.refreshInterval, pcepTunnelId);
|
||||
timeout.getTimer().newTimeout(this, refreshInterval, TimeUnit.SECONDS);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void sendTunnelStatistic() {
|
||||
controller.getTunnelStatistics(pcepTunnelId);
|
||||
|
||||
}
|
||||
|
||||
synchronized void adjustPollInterval(int pollInterval) {
|
||||
this.refreshInterval = pollInterval;
|
||||
}
|
||||
|
||||
/**
|
||||
* Starts the collector.
|
||||
*/
|
||||
public synchronized void start() {
|
||||
log.info("Starting Tunnel Stats collection thread for {}", pcepTunnelId);
|
||||
stopped = false;
|
||||
timeout = timer.newTimeout(this, 1, TimeUnit.SECONDS);
|
||||
}
|
||||
|
||||
/**
|
||||
* Stops the collector.
|
||||
*/
|
||||
public synchronized void stop() {
|
||||
log.info("Stopping Tunnel Stats collection thread for {}", pcepTunnelId);
|
||||
stopped = true;
|
||||
timeout.cancel();
|
||||
}
|
||||
}
|
@ -77,4 +77,9 @@ public class PcepControllerAdapter implements PcepController {
|
||||
public Boolean updateTunnelBandwidth(String id, long bandwidth) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getTunnelStatistics(String pcepTunnelId) {
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -24,6 +24,7 @@ import java.util.List;
|
||||
import org.junit.After;
|
||||
import org.junit.Test;
|
||||
import org.onlab.packet.IpAddress;
|
||||
import org.onosproject.cfg.ComponentConfigAdapter;
|
||||
import org.onosproject.core.DefaultGroupId;
|
||||
import org.onosproject.incubator.net.tunnel.DefaultTunnel;
|
||||
import org.onosproject.incubator.net.tunnel.IpTunnelEndPoint;
|
||||
@ -49,13 +50,16 @@ public class PcepReleaseTunnelProviderTest {
|
||||
private final PcepClientControllerAdapter controller = new PcepClientControllerAdapter();
|
||||
private final PcepControllerAdapter ctl = new PcepControllerAdapter();
|
||||
private final PcepTunnelApiMapper pcepTunnelAPIMapper = new PcepTunnelApiMapper();
|
||||
private final TunnelServiceAdapter tunnelService = new TunnelServiceAdapter();
|
||||
|
||||
@Test
|
||||
public void testCasePcepReleaseTunnel() {
|
||||
tunnelProvider.tunnelProviderRegistry = registry;
|
||||
tunnelProvider.pcepClientController = controller;
|
||||
tunnelProvider.controller = ctl;
|
||||
tunnelProvider.tunnelService = tunnelService;
|
||||
tunnelProvider.pcepTunnelAPIMapper = pcepTunnelAPIMapper;
|
||||
tunnelProvider.cfgService = new ComponentConfigAdapter();
|
||||
tunnelProvider.activate();
|
||||
|
||||
Tunnel tunnel;
|
||||
|
@ -24,6 +24,7 @@ import java.util.List;
|
||||
import org.junit.After;
|
||||
import org.junit.Test;
|
||||
import org.onlab.packet.IpAddress;
|
||||
import org.onosproject.cfg.ComponentConfigAdapter;
|
||||
import org.onosproject.core.DefaultGroupId;
|
||||
import org.onosproject.incubator.net.tunnel.DefaultTunnel;
|
||||
import org.onosproject.incubator.net.tunnel.IpTunnelEndPoint;
|
||||
@ -46,6 +47,7 @@ public class PcepSetupTunnelProviderTest {
|
||||
private final TunnelProviderRegistryAdapter registry = new TunnelProviderRegistryAdapter();
|
||||
private final PcepClientControllerAdapter controller = new PcepClientControllerAdapter();
|
||||
private final PcepControllerAdapter ctl = new PcepControllerAdapter();
|
||||
private final TunnelServiceAdapter tunnelService = new TunnelServiceAdapter();
|
||||
|
||||
@Test
|
||||
public void testCasePcepSetupTunnel() {
|
||||
@ -53,6 +55,8 @@ public class PcepSetupTunnelProviderTest {
|
||||
tunnelProvider.tunnelProviderRegistry = registry;
|
||||
tunnelProvider.pcepClientController = controller;
|
||||
tunnelProvider.controller = ctl;
|
||||
tunnelProvider.cfgService = new ComponentConfigAdapter();
|
||||
tunnelProvider.tunnelService = tunnelService;
|
||||
tunnelProvider.activate();
|
||||
|
||||
|
||||
|
@ -38,6 +38,7 @@ import org.onosproject.net.Link;
|
||||
import org.onosproject.net.Path;
|
||||
import org.onosproject.net.PortNumber;
|
||||
import org.onosproject.net.provider.ProviderId;
|
||||
import org.onosproject.cfg.ComponentConfigAdapter;
|
||||
|
||||
public class PcepTunnelProviderTest {
|
||||
|
||||
@ -46,6 +47,7 @@ public class PcepTunnelProviderTest {
|
||||
private final TunnelProviderRegistryAdapter registry = new TunnelProviderRegistryAdapter();
|
||||
private final PcepClientControllerAdapter controller = new PcepClientControllerAdapter();
|
||||
private final PcepControllerAdapter ctl = new PcepControllerAdapter();
|
||||
private final TunnelServiceAdapter tunnelService = new TunnelServiceAdapter();
|
||||
|
||||
@Test
|
||||
public void testCasePcepSetupTunnel() {
|
||||
@ -53,6 +55,8 @@ public class PcepTunnelProviderTest {
|
||||
tunnelProvider.tunnelProviderRegistry = registry;
|
||||
tunnelProvider.pcepClientController = controller;
|
||||
tunnelProvider.controller = ctl;
|
||||
tunnelProvider.cfgService = new ComponentConfigAdapter();
|
||||
tunnelProvider.tunnelService = tunnelService;
|
||||
tunnelProvider.activate();
|
||||
|
||||
Tunnel tunnel;
|
||||
|
@ -24,6 +24,7 @@ import java.util.List;
|
||||
import org.junit.After;
|
||||
import org.junit.Test;
|
||||
import org.onlab.packet.IpAddress;
|
||||
import org.onosproject.cfg.ComponentConfigAdapter;
|
||||
import org.onosproject.core.DefaultGroupId;
|
||||
import org.onosproject.incubator.net.tunnel.DefaultTunnel;
|
||||
import org.onosproject.incubator.net.tunnel.IpTunnelEndPoint;
|
||||
@ -49,6 +50,8 @@ public class PcepUpdateTunnelProviderTest {
|
||||
private final PcepClientControllerAdapter controller = new PcepClientControllerAdapter();
|
||||
private final PcepControllerAdapter ctl = new PcepControllerAdapter();
|
||||
private final PcepTunnelApiMapper pcepTunnelAPIMapper = new PcepTunnelApiMapper();
|
||||
private final TunnelServiceAdapter tunnelService = new TunnelServiceAdapter();
|
||||
|
||||
|
||||
@Test
|
||||
public void testCasePcepUpdateTunnel() {
|
||||
@ -56,6 +59,8 @@ public class PcepUpdateTunnelProviderTest {
|
||||
tunnelProvider.pcepClientController = controller;
|
||||
tunnelProvider.controller = ctl;
|
||||
tunnelProvider.pcepTunnelAPIMapper = pcepTunnelAPIMapper;
|
||||
tunnelProvider.cfgService = new ComponentConfigAdapter();
|
||||
tunnelProvider.tunnelService = tunnelService;
|
||||
tunnelProvider.activate();
|
||||
|
||||
Tunnel tunnel;
|
||||
|
@ -0,0 +1,107 @@
|
||||
package org.onosproject.provider.pcep.tunnel.impl;
|
||||
|
||||
import org.onosproject.core.ApplicationId;
|
||||
import org.onosproject.incubator.net.tunnel.Tunnel;
|
||||
import org.onosproject.incubator.net.tunnel.TunnelEndPoint;
|
||||
import org.onosproject.incubator.net.tunnel.TunnelId;
|
||||
import org.onosproject.incubator.net.tunnel.TunnelListener;
|
||||
import org.onosproject.incubator.net.tunnel.TunnelName;
|
||||
import org.onosproject.incubator.net.tunnel.TunnelService;
|
||||
import org.onosproject.incubator.net.tunnel.TunnelSubscription;
|
||||
import org.onosproject.net.Annotations;
|
||||
import org.onosproject.net.DeviceId;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
|
||||
public class TunnelServiceAdapter implements TunnelService {
|
||||
@Override
|
||||
public Tunnel borrowTunnel(ApplicationId consumerId, TunnelId tunnelId, Annotations... annotations) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<Tunnel> borrowTunnel(ApplicationId consumerId, TunnelName tunnelName,
|
||||
Annotations... annotations) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<Tunnel> borrowTunnel(ApplicationId consumerId, TunnelEndPoint src, TunnelEndPoint dst,
|
||||
Annotations... annotations) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<Tunnel> borrowTunnel(ApplicationId consumerId, TunnelEndPoint src, TunnelEndPoint dst,
|
||||
Tunnel.Type type, Annotations... annotations) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean returnTunnel(ApplicationId consumerId, TunnelId tunnelId, Annotations... annotations) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean returnTunnel(ApplicationId consumerId, TunnelName tunnelName, Annotations... annotations) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean returnTunnel(ApplicationId consumerId, TunnelEndPoint src, TunnelEndPoint dst,
|
||||
Tunnel.Type type, Annotations... annotations) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean returnTunnel(ApplicationId consumerId, TunnelEndPoint src, TunnelEndPoint dst,
|
||||
Annotations... annotations) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Tunnel queryTunnel(TunnelId tunnelId) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<TunnelSubscription> queryTunnelSubscription(ApplicationId consumerId) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<Tunnel> queryTunnel(Tunnel.Type type) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<Tunnel> queryTunnel(TunnelEndPoint src, TunnelEndPoint dst) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<Tunnel> queryAllTunnels() {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int tunnelCount() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterable<Tunnel> getTunnels(DeviceId deviceId) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addListener(TunnelListener listener) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeListener(TunnelListener listener) {
|
||||
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user