本文整理汇总了Java中org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.meters.MeterKey类的典型用法代码示例。如果您正苦于以下问题:Java MeterKey类的具体用法?Java MeterKey怎么用?Java MeterKey使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
MeterKey类属于org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.meters包,在下文中一共展示了MeterKey类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: retrieveMeterIdentifier
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.meters.MeterKey; //导入依赖的package包/类
private InstanceIdentifier<Meter> retrieveMeterIdentifier(final MeterId meterId, Node node) {
KeyedInstanceIdentifier<Meter, MeterKey> flowIID = null;
try {
final InstanceIdentifier<Node> nodePath = InstanceIdentifier
.create(Nodes.class)
.child(Node.class, node.getKey());
flowIID = nodePath
.augmentation(FlowCapableNode.class)
.child(Meter.class, new MeterKey(meterId));
} catch (Exception e) {
LOG.error(e.getMessage());
}
return flowIID.builder().build();
}
示例2: createMeter
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.meters.MeterKey; //导入依赖的package包/类
public MeterId createMeter(final String id, final long dropRate) throws MeterCreationExeption {
MeterBandHeadersBuilder meterBandHeadersBuilder = new MeterBandHeadersBuilder();
MeterBandHeaderBuilder meterBandHeaderBuilder = new MeterBandHeaderBuilder();
MeterBuilder meterBuilder = new MeterBuilder();
final long meterIdLong = meterQueueService.getNextMeterId(id);
final MeterId meterId = new MeterId(meterIdLong);
MeterFlags meterFlags = new MeterFlags(false, true, false, false);
meterBuilder.setKey(new MeterKey(meterId));
meterBuilder.setMeterId(meterId);
meterBuilder.setFlags(meterFlags);
int bandKey = 0;
DropBuilder dropBuilder = new DropBuilder();
dropBuilder.setDropBurstSize(0L);
dropBuilder.setDropRate(dropRate);
MeterBandTypesBuilder meterBandTypesBuilder = new MeterBandTypesBuilder();
meterBandTypesBuilder.setFlags(new MeterBandType(true, false, false));
Drop drop = dropBuilder.build();
BandId bandId = new BandId((long)bandKey);
meterBandHeaderBuilder.setBandBurstSize(drop.getDropBurstSize());
meterBandHeaderBuilder.setBandRate(drop.getDropRate());
meterBandHeaderBuilder.setKey(new MeterBandHeaderKey(bandId));
meterBandHeaderBuilder.setBandId(bandId);
meterBandHeaderBuilder.setMeterBandTypes(meterBandTypesBuilder.build());
meterBandHeaderBuilder.setBandType(drop);
meterBandHeadersBuilder.setMeterBandHeader(Lists.newArrayList(meterBandHeaderBuilder.build()));
meterBuilder.setMeterBandHeaders(meterBandHeadersBuilder.build());
final Meter meter = meterBuilder.build();
final Map<Node, List<NodeConnector>> nodeListMap = TopologyUtils.getNodes(dataBroker);
final Set<Boolean> metersCreationResults = new HashSet<>();
for (Map.Entry<Node, List<NodeConnector>> entry : nodeListMap.entrySet()) {
final InstanceIdentifier<Meter> instanceIdentifier = retrieveMeterIdentifier(meterId,
entry.getKey());
final boolean result = mdsalUtils.put(LogicalDatastoreType.CONFIGURATION, instanceIdentifier, meter);
metersCreationResults.add(result);
}
//If only one meter was created with success, the result is true.
if (!metersCreationResults.contains(Boolean.TRUE)) {
throw new MeterCreationExeption();
}
return meter.getMeterId();
}