本文整理匯總了Java中org.opendaylight.controller.sal.core.Bandwidth類的典型用法代碼示例。如果您正苦於以下問題:Java Bandwidth類的具體用法?Java Bandwidth怎麽用?Java Bandwidth使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
Bandwidth類屬於org.opendaylight.controller.sal.core包,在下文中一共展示了Bandwidth類的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: EdgeBean
import org.opendaylight.controller.sal.core.Bandwidth; //導入依賴的package包/類
/**
* EdgeBean object that includes complete node description
*
* @param link
* @param bandwidth
* @param headDescription
* @param tailDescription
*/
public EdgeBean(Edge link, Bandwidth bandwidth, String headDescription,
String tailDescription, String headPortDescription, String tailPortDescription) {
this();
this.source = link.getHeadNodeConnector();
this.destination = link.getTailNodeConnector();
// data
data.put("$bandwidth", bandwidth.toString());
data.put("$color", bandwidthColor(bandwidth));
data.put("$nodeToPort", destination.getID().toString());
data.put("$nodeFromPort", source.getID().toString());
data.put("$descFrom", headDescription);
data.put("$descTo", tailDescription);
data.put("$nodeFromPortName", source.toString());
data.put("$nodeToPortName", destination.toString());
data.put("$nodeFromPortDescription", headPortDescription);
data.put("$nodeToPortDescription", tailPortDescription);
}
示例2: bandwidthColor
import org.opendaylight.controller.sal.core.Bandwidth; //導入依賴的package包/類
private String bandwidthColor(Bandwidth bandwidth) {
String color = null;
long bandwidthValue = bandwidth.getValue();
if (bandwidthValue == 0) {
color = "#000";
} else if (bandwidthValue < Bandwidth.BW1Kbps) {
color = "#148AC6";
} else if (bandwidthValue < Bandwidth.BW1Mbps) {
color = "#2858A0";
} else if (bandwidthValue < Bandwidth.BW1Gbps) {
color = "#009393";
} else if (bandwidthValue < Bandwidth.BW1Tbps) {
color = "#C6C014";
} else if (bandwidthValue < Bandwidth.BW1Pbps) {
color = "#F9F464";
}
return color;
}
示例3: _pncs
import org.opendaylight.controller.sal.core.Bandwidth; //導入依賴的package包/類
public void _pncs(CommandInterpreter ci) {
String st = ci.nextArgument();
if (st == null) {
ci.println("Please enter node id");
return;
}
Node node = Node.fromString(st);
if (node == null) {
ci.println("Please enter node id");
return;
}
ci.println(" NodeConnector BandWidth(Gbps) Admin State");
Set<NodeConnector> nodeConnectorSet = getNodeConnectors(node);
if (nodeConnectorSet == null) {
return;
}
for (NodeConnector nodeConnector : nodeConnectorSet) {
if (nodeConnector == null) {
continue;
}
Map<String, Property> propMap = getNodeConnectorProps(nodeConnector);
Bandwidth bw = (Bandwidth) propMap.get(Bandwidth.BandwidthPropName);
Config config = (Config) propMap.get(Config.ConfigPropName);
State state = (State) propMap.get(State.StatePropName);
String out = nodeConnector + " ";
out += (bw != null) ? bw.getValue() / Math.pow(10, 9) : " ";
out += " ";
out += (config != null) ? config.getValue() : " ";
out += " ";
out += (state != null) ? state.getValue() : " ";
ci.println(out);
}
ci.println("Total number of NodeConnectors: " + nodeConnectorSet.size());
}
示例4: createProperty
import org.opendaylight.controller.sal.core.Bandwidth; //導入依賴的package包/類
/**
* Creates a Name/Tier/Bandwidth Property object based on given property
* name and value. Other property types are not supported yet.
*
* @param propName
* Name of the Property
* @param propValue
* Value of the Property
* @return {@link org.opendaylight.controller.sal.core.Property}
*/
@Override
public Property createProperty(String propName, String propValue) {
if (propName == null) {
log.debug("propName is null");
return null;
}
if (propValue == null) {
log.debug("propValue is null");
return null;
}
try {
if (propName.equalsIgnoreCase(Description.propertyName)) {
return new Description(propValue);
} else if (propName.equalsIgnoreCase(Tier.TierPropName)) {
int tier = Integer.parseInt(propValue);
return new Tier(tier);
} else if (propName.equalsIgnoreCase(Bandwidth.BandwidthPropName)) {
long bw = Long.parseLong(propValue);
return new Bandwidth(bw);
} else if (propName.equalsIgnoreCase(ForwardingMode.name)) {
int mode = Integer.parseInt(propValue);
return new ForwardingMode(mode);
} else {
log.debug("Not able to create {} property", propName);
}
} catch (Exception e) {
log.debug("createProperty caught exception {}", e.getMessage());
}
return null;
}
示例5: OFPortToProps
import org.opendaylight.controller.sal.core.Bandwidth; //導入依賴的package包/類
public static Set<Property> OFPortToProps(OFPhysicalPort port) {
Set<Property> props = new HashSet<Property>();
Bandwidth bw = InventoryServiceHelper.OFPortToBandWidth(port
.getCurrentFeatures());
if (bw != null) {
props.add(bw);
}
Bandwidth abw = InventoryServiceHelper.OFPortToBandWidth(port.getAdvertisedFeatures());
if (abw != null) {
AdvertisedBandwidth a = new AdvertisedBandwidth(abw.getValue());
if (a != null) {
props.add(a);
}
}
Bandwidth sbw = InventoryServiceHelper.OFPortToBandWidth(port.getSupportedFeatures());
if (sbw != null) {
SupportedBandwidth s = new SupportedBandwidth(sbw.getValue());
if (s != null) {
props.add(s);
}
}
Bandwidth pbw = InventoryServiceHelper.OFPortToBandWidth(port.getPeerFeatures());
if (pbw != null) {
PeerBandwidth p = new PeerBandwidth(pbw.getValue());
if (p != null) {
props.add(p);
}
}
props.add(new Name(port.getName()));
props.add(InventoryServiceHelper.OFPortToConfig(port.getConfig()));
props.add(InventoryServiceHelper.OFPortToState(port.getState()));
return props;
}
示例6: _pem
import org.opendaylight.controller.sal.core.Bandwidth; //導入依賴的package包/類
public void _pem(CommandInterpreter ci) {
String container = ci.nextArgument();
if (container == null) {
container = GlobalConstants.DEFAULT.toString();
}
ci.println("Container: " + container);
ci.println(" Edge Bandwidth");
Map<NodeConnector, Pair<Edge, Set<Property>>> edgePropsMap = edgeMap
.get(container);
if (edgePropsMap == null) {
return;
}
int count = 0;
for (Pair<Edge, Set<Property>> edgeProps : edgePropsMap.values()) {
if (edgeProps == null) {
continue;
}
long bw = 0;
Set<Property> props = edgeProps.getRight();
if (props != null) {
for (Property prop : props) {
if (prop.getName().equals(Bandwidth.BandwidthPropName)) {
bw = ((Bandwidth) prop).getValue();
}
}
}
count++;
ci.println(edgeProps.getLeft() + " " + bw);
}
ci.println("Total number of Edges: " + count);
}
示例7: initMaxThroughput
import org.opendaylight.controller.sal.core.Bandwidth; //導入依賴的package包/類
@Override
public synchronized void initMaxThroughput(
final Map<Edge, Number> EdgeWeightMap) {
if (mtp != null) {
log.error("Max Throughput Dijkstra is already enabled!");
return;
}
Transformer<Edge, ? extends Number> mtTransformer = null;
if (EdgeWeightMap == null) {
mtTransformer = new Transformer<Edge, Double>() {
public Double transform(Edge e) {
if (switchManager == null) {
log.error("switchManager is null");
return (double) -1;
}
NodeConnector srcNC = e.getTailNodeConnector();
NodeConnector dstNC = e.getHeadNodeConnector();
if ((srcNC == null) || (dstNC == null)) {
log.error("srcNC:{} or dstNC:{} is null", srcNC, dstNC);
return (double) -1;
}
Bandwidth bwSrc = (Bandwidth) switchManager
.getNodeConnectorProp(srcNC,
Bandwidth.BandwidthPropName);
Bandwidth bwDst = (Bandwidth) switchManager
.getNodeConnectorProp(dstNC,
Bandwidth.BandwidthPropName);
long srcLinkSpeed = 0, dstLinkSpeed = 0;
if ((bwSrc == null)
|| ((srcLinkSpeed = bwSrc.getValue()) == 0)) {
log.debug(
"srcNC: {} - Setting srcLinkSpeed to Default!",
srcNC);
srcLinkSpeed = DEFAULT_LINK_SPEED;
}
if ((bwDst == null)
|| ((dstLinkSpeed = bwDst.getValue()) == 0)) {
log.debug(
"dstNC: {} - Setting dstLinkSpeed to Default!",
dstNC);
dstLinkSpeed = DEFAULT_LINK_SPEED;
}
long avlSrcThruPut = srcLinkSpeed
- readService.getTransmitRate(srcNC);
long avlDstThruPut = dstLinkSpeed
- readService.getTransmitRate(dstNC);
// Use lower of the 2 available thruput as the available
// thruput
long avlThruPut = avlSrcThruPut < avlDstThruPut ? avlSrcThruPut
: avlDstThruPut;
if (avlThruPut <= 0) {
log.debug("Edge {}: Available Throughput {} <= 0!", e,
avlThruPut);
return (double) -1;
}
return (double) (Bandwidth.BW1Pbps / avlThruPut);
}
};
} else {
mtTransformer = new Transformer<Edge, Number>() {
public Number transform(Edge e) {
return EdgeWeightMap.get(e);
}
};
}
Short baseBW = Short.valueOf((short) 0);
// Initialize mtp also using the default topo
Graph<Node, Edge> g = this.topologyBWAware.get(baseBW);
if (g == null) {
log.error("Default Topology Graph is null");
return;
}
mtp = new DijkstraShortestPath<Node, Edge>(g, mtTransformer);
}
示例8: edgeUpdate
import org.opendaylight.controller.sal.core.Bandwidth; //導入依賴的package包/類
private boolean edgeUpdate(Edge e, UpdateType type, Set<Property> props) {
String srcType = null;
String dstType = null;
if (e == null || type == null) {
log.error("Edge or Update type are null!");
return false;
} else {
srcType = e.getTailNodeConnector().getType();
dstType = e.getHeadNodeConnector().getType();
if (srcType.equals(NodeConnector.NodeConnectorIDType.PRODUCTION)) {
log.debug("Skip updates for {}", e);
return false;
}
if (dstType.equals(NodeConnector.NodeConnectorIDType.PRODUCTION)) {
log.debug("Skip updates for {}", e);
return false;
}
}
Bandwidth bw = new Bandwidth(0);
boolean newEdge = false;
if (props != null)
props.remove(bw);
if (log.isDebugEnabled()) {
log.debug("edgeUpdate: {} bw: {}", e, bw.getValue());
}
Short baseBW = Short.valueOf((short) 0);
boolean add = (type == UpdateType.ADDED) ? true : false;
// Update base topo
newEdge = !updateTopo(e, baseBW, add);
if (newEdge == true) {
if (bw.getValue() != baseBW) {
// Update BW topo
updateTopo(e, (short) bw.getValue(), add);
}
}
return newEdge;
}
示例9: testGetEdges
import org.opendaylight.controller.sal.core.Bandwidth; //導入依賴的package包/類
@Test
public void testGetEdges() throws ConstructionException {
TopologyManagerImpl topoManagerImpl = new TopologyManagerImpl();
setNodeEdges(topoManagerImpl);
Map<Edge, Set<Property>> edgeProperty = topoManagerImpl.getEdges();
for (Iterator<Map.Entry<Edge, Set<Property>>> i = edgeProperty
.entrySet().iterator(); i.hasNext();) {
Map.Entry<Edge, Set<Property>> entry = i.next();
Edge e = entry.getKey();
NodeConnector headnc = e.getHeadNodeConnector();
NodeConnector tailnc = e.getTailNodeConnector();
Long headNodeId = (Long) headnc.getNode().getID();
Long headNcId = ((Short) headnc.getID()).longValue();
Long tailNcId = ((Short) tailnc.getID()).longValue();
if (headNodeId == 1 || headNodeId == 3 || headNodeId == 5) {
Assert.assertTrue((headNcId.equals(headNodeId) && tailNcId
.equals(headNodeId + 10))
|| (headNcId.equals(headNodeId + 10) && tailNcId
.equals(headNodeId))
|| (headNcId.equals(headNodeId + 1) && tailNcId
.equals(headNodeId + 11))
|| (headNcId.equals(headNodeId + 11) && tailNcId
.equals(headNodeId + 1)));
} else if (headNodeId == 11 || headNodeId == 13 || headNodeId == 15) {
Assert.assertTrue((headNcId.equals(headNodeId) && tailNcId
.equals(headNodeId - 10))
|| (headNcId.equals(headNodeId) && tailNcId
.equals(headNodeId - 10))
|| (headNcId.equals(headNodeId - 9) && tailNcId
.equals(headNodeId + 1))
|| (headNcId.equals(headNodeId + 1) && tailNcId
.equals(headNodeId - 9)));
}
Set<Property> prop = entry.getValue();
for (Property p : prop) {
String pName;
long pValue;
if (p instanceof Bandwidth) {
Bandwidth b = (Bandwidth) p;
pName = Bandwidth.BandwidthPropName;
pValue = b.getValue();
Assert.assertTrue(pName.equals(p.getName())
&& pValue == Bandwidth.BW100Gbps);
continue;
}
if (p instanceof Latency) {
Latency l = (Latency) p;
pName = Latency.LatencyPropName;
pValue = l.getValue();
Assert.assertTrue(pName.equals(p.getName())
&& pValue == Latency.LATENCY100ns);
continue;
}
if (p instanceof State) {
State state = (State) p;
pName = State.StatePropName;
pValue = state.getValue();
Assert.assertTrue(pName.equals(p.getName())
&& pValue == State.EDGE_UP);
continue;
}
}
i.remove();
}
Assert.assertTrue(edgeProperty.isEmpty());
}
示例10: pollTxBitRates
import org.opendaylight.controller.sal.core.Bandwidth; //導入依賴的package包/類
/**
* Continuously polls the transmit bit rate for all the node connectors from
* statistics manager and trigger the warning notification upward when the
* transmit rate is above a threshold which is a percentage of the edge
* bandwidth
*/
protected void pollTxBitRates() {
Map<NodeConnector, Pair<Edge, Set<Property>>> globalContainerEdges = edgeMap
.get(GlobalConstants.DEFAULT.toString());
if (globalContainerEdges == null) {
return;
}
for (NodeConnector connector : globalContainerEdges.keySet()) {
// Skip if node connector belongs to production switch
if (connector.getType().equals(
NodeConnector.NodeConnectorIDType.PRODUCTION)) {
continue;
}
// Get edge for which this node connector is head
Pair<Edge, Set<Property>> props = this.edgeMap.get(
GlobalConstants.DEFAULT.toString()).get(connector);
// On switch mgr restart the props get reset
if (props == null) {
continue;
}
Set<Property> propSet = props.getRight();
if (propSet == null) {
continue;
}
float bw = 0;
for (Property prop : propSet) {
if (prop instanceof Bandwidth) {
bw = ((Bandwidth) prop).getValue();
break;
}
}
// Skip if agent did not provide a bandwidth info for the edge
if (bw == 0) {
continue;
}
// Compare bandwidth usage
Long switchId = (Long) connector.getNode().getID();
Short port = (Short) connector.getID();
float rate = statsMgr.getTransmitRate(switchId, port);
if (rate > bwThresholdFactor * bw) {
if (!connectorsOverUtilized.contains(connector)) {
connectorsOverUtilized.add(connector);
this.bwUtilNotifyQ.add(new UtilizationUpdate(connector,
UpdateType.ADDED));
}
} else {
if (connectorsOverUtilized.contains(connector)) {
connectorsOverUtilized.remove(connector);
this.bwUtilNotifyQ.add(new UtilizationUpdate(connector,
UpdateType.REMOVED));
}
}
}
}