本文整理汇总了Java中org.onosproject.net.meter.MeterId类的典型用法代码示例。如果您正苦于以下问题:Java MeterId类的具体用法?Java MeterId怎么用?Java MeterId使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
MeterId类属于org.onosproject.net.meter包,在下文中一共展示了MeterId类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: processVlanFiler
import org.onosproject.net.meter.MeterId; //导入依赖的package包/类
@Override
protected Builder processVlanFiler(FilteringObjective filt, VlanIdCriterion vlan, PortCriterion port) {
log.debug("adding rule for VLAN: {}", vlan.vlanId());
TrafficSelector.Builder selector = DefaultTrafficSelector.builder();
TrafficTreatment.Builder treatment = DefaultTrafficTreatment.builder();
selector.matchVlanId(vlan.vlanId());
selector.matchInPort(port.port());
/* Static treatment for VLAN_CIRCUIT_TABLE */
treatment.setVlanPcp(MAX_VLAN_PCP);
treatment.setQueue(0);
treatment.meter(MeterId.meterId(defaultMeterId.id())); /* use default meter (Green) */
treatment.transition(L3_IF_MAC_DA_TABLE);
return DefaultFlowRule.builder()
.withSelector(selector.build())
.withTreatment(treatment.build())
.withPriority(CONTROLLER_PRIORITY)
.makePermanent()
.forTable(VLAN_CIRCUIT_TABLE);
}
示例2: buildMeters
import org.onosproject.net.meter.MeterId; //导入依赖的package包/类
private Collection<Meter> buildMeters(DeviceId deviceId,
List<OFMeterStats> entries) {
return entries.stream().map(stat -> {
DefaultMeter.Builder builder = DefaultMeter.builder();
Collection<Band> bands = buildBands(stat.getBandStats());
builder.forDevice(deviceId)
.withId(MeterId.meterId(stat.getMeterId()))
//FIXME: need to encode appId in meter id, but that makes
// things a little annoying for debugging
.fromApp(coreService.getAppId("org.onosproject.core"))
.withBands(bands);
DefaultMeter meter = builder.build();
meter.setState(MeterState.ADDED);
meter.setLife(stat.getDurationSec());
meter.setProcessedBytes(stat.getByteInCount().getValue());
meter.setProcessedPackets(stat.getPacketInCount().getValue());
meter.setReferenceCount(stat.getFlowCount());
// marks the meter as seen on the dataplane
pendingOperations.invalidate(stat.getMeterId());
return meter;
}).collect(Collectors.toSet());
}
示例3: submit
import org.onosproject.net.meter.MeterId; //导入依赖的package包/类
@Override
public Meter submit(MeterRequest request) {
MeterId id = allocateMeterId(request.deviceId());
Meter.Builder mBuilder = DefaultMeter.builder()
.forDevice(request.deviceId())
.fromApp(request.appId())
.withBands(request.bands())
.withId(id)
.withUnit(request.unit());
if (request.isBurst()) {
mBuilder.burst();
}
DefaultMeter m = (DefaultMeter) mBuilder.build();
m.setState(MeterState.PENDING_ADD);
store.storeMeter(m).whenComplete((result, error) ->
onComplete.accept(request, result, error));
return m;
}
示例4: withdraw
import org.onosproject.net.meter.MeterId; //导入依赖的package包/类
@Override
public void withdraw(MeterRequest request, MeterId meterId) {
Meter.Builder mBuilder = DefaultMeter.builder()
.forDevice(request.deviceId())
.fromApp(request.appId())
.withBands(request.bands())
.withId(meterId)
.withUnit(request.unit());
if (request.isBurst()) {
mBuilder.burst();
}
DefaultMeter m = (DefaultMeter) mBuilder.build();
m.setState(MeterState.PENDING_REMOVE);
store.deleteMeter(m).whenComplete((result, error) ->
onComplete.accept(request, result, error));
}
示例5: pushMeterMetrics
import org.onosproject.net.meter.MeterId; //导入依赖的package包/类
@Override
public void pushMeterMetrics(DeviceId deviceId, Collection<Meter> meterEntries) {
//FIXME: FOLLOWING CODE CANNOT BE TESTED UNTIL SOMETHING THAT
//FIXME: IMPLEMENTS METERS EXISTS
Map<Pair<DeviceId, MeterId>, Meter> storedMeterMap = store.getAllMeters().stream()
.collect(Collectors.toMap(m -> Pair.of(m.deviceId(), m.id()), m -> m));
meterEntries.stream()
.filter(m -> storedMeterMap.remove(Pair.of(m.deviceId(), m.id())) != null)
.forEach(m -> store.updateMeterState(m));
storedMeterMap.values().stream().forEach(m -> {
if (m.state() == MeterState.PENDING_ADD) {
provider().performMeterOperation(m.deviceId(),
new MeterOperation(m,
MeterOperation.Type.MODIFY));
} else if (m.state() == MeterState.PENDING_REMOVE) {
store.deleteMeterNow(m);
}
});
}
示例6: testMeterEncode
import org.onosproject.net.meter.MeterId; //导入依赖的package包/类
/**
* Tests encoding of a Meter object.
*/
@Test
public void testMeterEncode() {
Band band1 = DefaultBand.builder()
.ofType(Band.Type.DROP)
.burstSize(10)
.withRate(10).build();
Band band2 = DefaultBand.builder()
.ofType(Band.Type.REMARK)
.burstSize(10)
.withRate(10)
.dropPrecedence((short) 10).build();
Meter meter = DefaultMeter.builder()
.fromApp(APP_ID)
.withId(MeterId.meterId(1L))
.forDevice(NetTestTools.did("d1"))
.withBands(ImmutableList.of(band1, band2))
.withUnit(Meter.Unit.KB_PER_SEC).build();
ObjectNode meterJson = meterCodec.encode(meter, context);
assertThat(meterJson, matchesMeter(meter));
}
示例7: testTrafficTreatmentEncode
import org.onosproject.net.meter.MeterId; //导入依赖的package包/类
/**
* Tests encoding of a traffic treatment object.
*/
@Test
public void testTrafficTreatmentEncode() {
Instruction output = Instructions.createOutput(PortNumber.portNumber(0));
Instruction modL2Src = Instructions.modL2Src(MacAddress.valueOf("11:22:33:44:55:66"));
Instruction modL2Dst = Instructions.modL2Dst(MacAddress.valueOf("44:55:66:77:88:99"));
MeterId meterId = MeterId.meterId(0);
Instruction meter = Instructions.meterTraffic(meterId);
Instruction transition = Instructions.transition(1);
TrafficTreatment.Builder tBuilder = DefaultTrafficTreatment.builder();
TrafficTreatment treatment = tBuilder
.add(output)
.add(modL2Src)
.add(modL2Dst)
.add(meter)
.add(transition)
.build();
ObjectNode treatmentJson = trafficTreatmentCodec.encode(treatment, context);
assertThat(treatmentJson, TrafficTreatmentJsonMatcher.matchesTrafficTreatment(treatment));
}
示例8: testPerformMeterOperationDeviceIdMeterRemove
import org.onosproject.net.meter.MeterId; //导入依赖的package包/类
@Test
public void testPerformMeterOperationDeviceIdMeterRemove() {
DeviceId mockDeviceId = DeviceId.deviceId("netconf:1.2.3.4:830");
Band cbsBand = DefaultBand.builder()
.ofType(Band.Type.REMARK) //Committed - CIR & CBS
.withRate(37500L)
.burstSize(2000)
.dropPrecedence((short) 0)
.build();
Meter.Builder mBuilder = DefaultMeter.builder()
.forDevice(mockDeviceId)
.withId(MeterId.meterId(1))
.fromApp(new DefaultApplicationId(101, "unit.test"))
.burst()
.withBands(new HashSet<Band>() { { add(cbsBand); } });
MeterOperation meterOp = new MeterOperation(mBuilder.build(), Type.REMOVE);
meterProvider.performMeterOperation(mockDeviceId, meterOp);
//The NETCONF XML generated by this matches the pattern
// sampleXmlRegexEditConfigBwpGroup1
// in MockNetconfSession
}
示例9: buildMeters
import org.onosproject.net.meter.MeterId; //导入依赖的package包/类
private Collection<Meter> buildMeters(DeviceId deviceId,
List<OFMeterStats> entries) {
return entries.stream().map(stat -> {
DefaultMeter.Builder builder = DefaultMeter.builder();
Collection<Band> bands = buildBands(stat.getBandStats());
builder.forDevice(deviceId)
.withId(MeterId.meterId(stat.getMeterId()))
//FIXME: need to encode appId in meter id, but that makes
// things a little annoying for debugging
.fromApp(coreService.getAppId("org.onosproject.core"))
.withBands(bands);
DefaultMeter meter = builder.build();
meter.setState(MeterState.ADDED);
meter.setLife(stat.getDurationSec());
meter.setProcessedBytes(stat.getByteInCount().getValue());
meter.setProcessedPackets(stat.getPacketInCount().getValue());
if (stat.getVersion().getWireVersion() < OFVersion.OF_15.getWireVersion()) {
meter.setReferenceCount(stat.getFlowCount());
}
// marks the meter as seen on the dataplane
pendingOperations.invalidate(stat.getMeterId());
return meter;
}).collect(Collectors.toSet());
}
示例10: submit
import org.onosproject.net.meter.MeterId; //导入依赖的package包/类
@Override
public Meter submit(MeterRequest request) {
MeterId id = allocateMeterId(request.deviceId());
Meter.Builder mBuilder = DefaultMeter.builder()
.forDevice(request.deviceId())
.fromApp(request.appId())
.withBands(request.bands())
.withId(id)
.withUnit(request.unit());
if (request.isBurst()) {
mBuilder.burst();
}
DefaultMeter m = (DefaultMeter) mBuilder.build();
m.setState(MeterState.PENDING_ADD);
store.storeMeter(networkId(), m).whenComplete((result, error) ->
onComplete.accept(request, result, error));
return m;
}
示例11: withdraw
import org.onosproject.net.meter.MeterId; //导入依赖的package包/类
@Override
public void withdraw(MeterRequest request, MeterId meterId) {
Meter.Builder mBuilder = DefaultMeter.builder()
.forDevice(request.deviceId())
.fromApp(request.appId())
.withBands(request.bands())
.withId(meterId)
.withUnit(request.unit());
if (request.isBurst()) {
mBuilder.burst();
}
DefaultMeter m = (DefaultMeter) mBuilder.build();
m.setState(MeterState.PENDING_REMOVE);
store.deleteMeter(networkId(), m).whenComplete((result, error) ->
onComplete.accept(request, result, error));
}
示例12: pushMeterMetrics
import org.onosproject.net.meter.MeterId; //导入依赖的package包/类
@Override
public void pushMeterMetrics(DeviceId deviceId, Collection<Meter> meterEntries) {
//FIXME: FOLLOWING CODE CANNOT BE TESTED UNTIL SOMETHING THAT
//FIXME: IMPLEMENTS METERS EXISTS
Map<Pair<DeviceId, MeterId>, Meter> storedMeterMap =
store.getAllMeters(networkId()).stream()
.collect(Collectors.toMap(m -> Pair.of(m.deviceId(), m.id()), Function.identity()));
meterEntries.stream()
.filter(m -> storedMeterMap.remove(Pair.of(m.deviceId(), m.id())) != null)
.forEach(m -> store.updateMeterState(networkId(), m));
storedMeterMap.values().forEach(m -> {
if (m.state() == MeterState.PENDING_ADD) {
provider().performMeterOperation(networkId(), m.deviceId(),
new MeterOperation(m,
MeterOperation.Type.MODIFY));
} else if (m.state() == MeterState.PENDING_REMOVE) {
store.deleteMeterNow(networkId(), m);
}
});
}
示例13: testNoDeleteMeter
import org.onosproject.net.meter.MeterId; //导入依赖的package包/类
/**
* Test no delete meter.
*/
@Test
public void testNoDeleteMeter() {
// Init the store
initMeterStore();
// Simulate the allocation of an id
MeterId idOne = meterStore.allocateMeterId(did1);
// Create the key
MeterKey keyOne = MeterKey.key(did1, idOne);
// Let's create a meter
Meter meterOne = DefaultMeter.builder()
.forDevice(did1)
.fromApp(APP_ID)
.withId(mid1)
.withUnit(Meter.Unit.KB_PER_SEC)
.withBands(Collections.singletonList(b1))
.build();
// Set the state
((DefaultMeter) meterOne).setState(MeterState.PENDING_REMOVE);
// Delete meter
meterStore.deleteMeter(meterOne);
// Verify No delete
assertThat(0, is(meterStore.getAllMeters().size()));
assertThat(0, is(meterStore.getAllMeters(did1).size()));
assertNull(meterStore.getMeter(keyOne));
}
示例14: execute
import org.onosproject.net.meter.MeterId; //导入依赖的package包/类
@Override
protected void execute() {
MeterService service = get(MeterService.class);
CoreService coreService = get(CoreService.class);
DeviceId deviceId = DeviceId.deviceId(uri);
MeterId meterId = MeterId.meterId(Long.parseLong(meterIdstr, 16));
Band b = new DefaultBand(Band.Type.DROP, 0L, 0L, (short) 0);
MeterRequest.Builder builder = DefaultMeterRequest.builder()
.forDevice(deviceId)
.withBands(Collections.singleton(b))
.withUnit(Meter.Unit.PKTS_PER_SEC)
.fromApp(coreService.registerApplication(appId));
MeterRequest meterRequest = builder.remove();
service.withdraw(meterRequest, meterId);
log.info("Requested meter removal: {}", meterRequest.toString());
print("Requested meter removal: %s", meterRequest.toString());
}
示例15: execute
import org.onosproject.net.meter.MeterId; //导入依赖的package包/类
@Override
protected void execute() {
if (!isNullOrEmpty(meterstr)) {
meterId = MeterId.meterId(Long.parseLong(meterstr));
}
MeterService service = get(MeterService.class);
if (meterId != null && uri != null) {
Meter m = service.getMeter(DeviceId.deviceId(uri), meterId);
if (m != null) {
print("%s", m);
} else {
error("Meter %s not found for device %s", meterId, uri);
}
} else {
Collection<Meter> meters = service.getAllMeters();
if (uri == null) {
printMeters(meters);
} else {
printMeters(Collections2.filter(meters,
m -> m.deviceId().equals(DeviceId.deviceId(uri))));
}
}
}