本文整理匯總了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();
}