mirror of
https://github.com/opennetworkinglab/onos.git
synced 2025-10-20 20:02:17 +02:00
Added metered annotation to link
Change-Id: Ief7410d442e8e1c556cc97c0578aa5d717a7b127
This commit is contained in:
parent
2786122009
commit
0843f5d375
@ -241,6 +241,12 @@ public final class AnnotationKeys {
|
|||||||
*/
|
*/
|
||||||
public static final String FLAPPING = "flapping";
|
public static final String FLAPPING = "flapping";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Annotation key for identifying a metered link.
|
||||||
|
* The value of this key is expected to be a boolean for metered as true/false.
|
||||||
|
*/
|
||||||
|
public static final String METERED = "metered";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the value annotated object for the specified annotation key.
|
* Returns the value annotated object for the specified annotation key.
|
||||||
* The annotated value is expected to be String that can be parsed as double.
|
* The annotated value is expected to be String that can be parsed as double.
|
||||||
|
@ -48,6 +48,7 @@ public final class BasicLinkConfig extends AllowedEntityConfig<LinkKey> {
|
|||||||
public static final String FLAPPING = "flapping";
|
public static final String FLAPPING = "flapping";
|
||||||
public static final String IS_DURABLE = "durable";
|
public static final String IS_DURABLE = "durable";
|
||||||
public static final String IS_BIDIRECTIONAL = "bidirectional";
|
public static final String IS_BIDIRECTIONAL = "bidirectional";
|
||||||
|
public static final String IS_METERED = "metered";
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isValid() {
|
public boolean isValid() {
|
||||||
@ -55,12 +56,13 @@ public final class BasicLinkConfig extends AllowedEntityConfig<LinkKey> {
|
|||||||
type();
|
type();
|
||||||
|
|
||||||
return hasOnlyFields(ALLOWED, TYPE, METRIC, LATENCY, BANDWIDTH, JITTER, DELAY, LOSS, AVAILABILITY, FLAPPING,
|
return hasOnlyFields(ALLOWED, TYPE, METRIC, LATENCY, BANDWIDTH, JITTER, DELAY, LOSS, AVAILABILITY, FLAPPING,
|
||||||
IS_DURABLE, IS_BIDIRECTIONAL) &&
|
IS_DURABLE, IS_BIDIRECTIONAL, IS_METERED) &&
|
||||||
isBoolean(ALLOWED, OPTIONAL) && isNumber(METRIC, OPTIONAL) &&
|
isBoolean(ALLOWED, OPTIONAL) && isNumber(METRIC, OPTIONAL) &&
|
||||||
isNumber(LATENCY, OPTIONAL) && isNumber(BANDWIDTH, OPTIONAL) && isDecimal(JITTER, OPTIONAL) &&
|
isNumber(LATENCY, OPTIONAL) && isNumber(BANDWIDTH, OPTIONAL) && isDecimal(JITTER, OPTIONAL) &&
|
||||||
isDecimal(DELAY, OPTIONAL) && isDecimal(LOSS, OPTIONAL) && isDecimal(AVAILABILITY, OPTIONAL) &&
|
isDecimal(DELAY, OPTIONAL) && isDecimal(LOSS, OPTIONAL) && isDecimal(AVAILABILITY, OPTIONAL) &&
|
||||||
isDecimal(FLAPPING, OPTIONAL) &&
|
isDecimal(FLAPPING, OPTIONAL) &&
|
||||||
isBoolean(IS_BIDIRECTIONAL, OPTIONAL);
|
isBoolean(IS_BIDIRECTIONAL, OPTIONAL) &&
|
||||||
|
isBoolean(IS_METERED, OPTIONAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -306,6 +308,29 @@ public final class BasicLinkConfig extends AllowedEntityConfig<LinkKey> {
|
|||||||
return (BasicLinkConfig) setOrClear(FLAPPING, flapping);
|
return (BasicLinkConfig) setOrClear(FLAPPING, flapping);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns if link is metered in the network model or not.
|
||||||
|
*
|
||||||
|
* @return true for metered, false otherwise
|
||||||
|
*/
|
||||||
|
public Boolean isMetered() {
|
||||||
|
JsonNode res = object.path(IS_METERED);
|
||||||
|
if (res.isMissingNode()) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return res.asBoolean();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets durability for this link.
|
||||||
|
*
|
||||||
|
* @param isMetered true for metered, false otherwise
|
||||||
|
* @return this BasicLinkConfig
|
||||||
|
*/
|
||||||
|
public BasicLinkConfig isMetered(Boolean isMetered) {
|
||||||
|
return (BasicLinkConfig) setOrClear(IS_METERED, isMetered);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a {@link BasicLinkConfig} instance.
|
* Create a {@link BasicLinkConfig} instance.
|
||||||
* <p>
|
* <p>
|
||||||
|
@ -26,6 +26,7 @@ import org.onosproject.net.config.ConfigApplyDelegate;
|
|||||||
import java.time.Duration;
|
import java.time.Duration;
|
||||||
|
|
||||||
import static java.lang.Boolean.FALSE;
|
import static java.lang.Boolean.FALSE;
|
||||||
|
import static java.lang.Boolean.TRUE;
|
||||||
import static org.hamcrest.MatcherAssert.assertThat;
|
import static org.hamcrest.MatcherAssert.assertThat;
|
||||||
import static org.hamcrest.Matchers.is;
|
import static org.hamcrest.Matchers.is;
|
||||||
|
|
||||||
@ -68,7 +69,8 @@ public class BasicLinkConfigTest {
|
|||||||
.metric(METRIC)
|
.metric(METRIC)
|
||||||
.type(Link.Type.DIRECT)
|
.type(Link.Type.DIRECT)
|
||||||
.latency(LATENCY)
|
.latency(LATENCY)
|
||||||
.isBidirectional(FALSE);
|
.isBidirectional(FALSE)
|
||||||
|
.isMetered(TRUE);
|
||||||
|
|
||||||
assertThat(config.bandwidth(), is(BANDWIDTH));
|
assertThat(config.bandwidth(), is(BANDWIDTH));
|
||||||
assertThat(config.jitter(), is(JITTER));
|
assertThat(config.jitter(), is(JITTER));
|
||||||
@ -82,5 +84,6 @@ public class BasicLinkConfigTest {
|
|||||||
assertThat(config.latency(), is(LATENCY));
|
assertThat(config.latency(), is(LATENCY));
|
||||||
assertThat(config.isBidirectional(), is(FALSE));
|
assertThat(config.isBidirectional(), is(FALSE));
|
||||||
assertThat(config.isValid(), is(true));
|
assertThat(config.isValid(), is(true));
|
||||||
|
assertThat(config.isMetered(), is(TRUE));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -113,6 +113,9 @@ public final class BasicLinkOperator implements ConfigOperator {
|
|||||||
if (cfg.flapping() != DEF_FLAPPING) {
|
if (cfg.flapping() != DEF_FLAPPING) {
|
||||||
b.set(AnnotationKeys.FLAPPING, String.valueOf(cfg.flapping()));
|
b.set(AnnotationKeys.FLAPPING, String.valueOf(cfg.flapping()));
|
||||||
}
|
}
|
||||||
|
if (cfg.isMetered() != null) {
|
||||||
|
b.set(AnnotationKeys.METERED, String.valueOf(cfg.isMetered()));
|
||||||
|
}
|
||||||
return b.build();
|
return b.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user