import org.slf4j.LoggerFactory;
public class Sr02PCEPSessionProposalFactoryModule extends org.opendaylight.controller.config.yang.pcep.sr02.cfg.AbstractSr02PCEPSessionProposalFactoryModule {
+
+ private static final String VALUE_IS_NOT_SET = "value is not set.";
+
+ private static final int DEADTIMER_KEEPALIVE_RATIO = 4;
+
private static final Logger LOG = LoggerFactory.getLogger(Sr02PCEPSessionProposalFactoryModule.class);
public Sr02PCEPSessionProposalFactoryModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver) {
@Override
public void customValidation() {
- JmxAttributeValidationException.checkNotNull(getActive(), "value is not set.", activeJmxAttribute);
- JmxAttributeValidationException.checkNotNull(getInitiated(), "value is not set.", initiatedJmxAttribute);
- JmxAttributeValidationException.checkNotNull(getDeadTimerValue(), "value is not set.", deadTimerValueJmxAttribute);
- JmxAttributeValidationException.checkNotNull(getKeepAliveTimerValue(), "value is not set.", keepAliveTimerValueJmxAttribute);
+ JmxAttributeValidationException.checkNotNull(getActive(), VALUE_IS_NOT_SET, activeJmxAttribute);
+ JmxAttributeValidationException.checkNotNull(getInitiated(), VALUE_IS_NOT_SET, initiatedJmxAttribute);
+ JmxAttributeValidationException.checkNotNull(getDeadTimerValue(), VALUE_IS_NOT_SET, deadTimerValueJmxAttribute);
+ JmxAttributeValidationException.checkNotNull(getKeepAliveTimerValue(), VALUE_IS_NOT_SET, keepAliveTimerValueJmxAttribute);
if (getKeepAliveTimerValue() != 0) {
JmxAttributeValidationException.checkCondition(getKeepAliveTimerValue() >= 1, "minimum value is 1.",
keepAliveTimerValueJmxAttribute);
- if (getDeadTimerValue() != 0 && (getDeadTimerValue() / getKeepAliveTimerValue() != 4)) {
+ if (getDeadTimerValue() != 0 && (getDeadTimerValue() / getKeepAliveTimerValue() != DEADTIMER_KEEPALIVE_RATIO)) {
LOG.warn("DeadTimerValue should be 4 times greater than KeepAliveTimerValue");
}
}
if (getActive() && !getStateful()) {
setStateful(true);
}
- JmxAttributeValidationException.checkNotNull(getStateful(), "value is not set.", statefulJmxAttribute);
- JmxAttributeValidationException.checkNotNull(getSrCapable(), "value is not set.", srCapableJmxAttribute);
+ JmxAttributeValidationException.checkNotNull(getStateful(), VALUE_IS_NOT_SET, statefulJmxAttribute);
+ JmxAttributeValidationException.checkNotNull(getSrCapable(), VALUE_IS_NOT_SET, srCapableJmxAttribute);
}
@Override
super.addTlv(builder, tlv);
final Tlvs7Builder tlvBuilder = new Tlvs7Builder();
if (builder.getTlvs() != null) {
- if (builder.getTlvs().getAugmentation(Tlvs7.class) != null) {
- final Tlvs7 t = builder.getTlvs().getAugmentation(Tlvs7.class);
- if (t.getPathSetupType() != null) {
- tlvBuilder.setPathSetupType(t.getPathSetupType());
- }
+ final Tlvs7 tlvs = builder.getTlvs().getAugmentation(Tlvs7.class);
+ if (tlvs != null && tlvs.getPathSetupType() != null) {
+ tlvBuilder.setPathSetupType(tlvs.getPathSetupType());
}
}
if (tlv instanceof PathSetupType) {
super.addTlv(builder, tlv);
final Tlvs1Builder tlvBuilder = new Tlvs1Builder();
if (builder.getTlvs() != null) {
- if (builder.getTlvs().getAugmentation(Tlvs1.class) != null) {
- final Tlvs1 t = builder.getTlvs().getAugmentation(Tlvs1.class);
- if (t.getPathSetupType() != null) {
- tlvBuilder.setPathSetupType(t.getPathSetupType());
- }
+ final Tlvs1 tlvs = builder.getTlvs().getAugmentation(Tlvs1.class);
+ if (tlvs != null && tlvs.getPathSetupType() != null) {
+ tlvBuilder.setPathSetupType(tlvs.getPathSetupType());
}
}
if (tlv instanceof PathSetupType) {
private static final int FLAGS_OFFSET = 1;
private static final int HEADER_LENGTH = FLAGS_OFFSET + 1;
private static final int MINIMAL_LENGTH = SID_LENGTH + HEADER_LENGTH;
+ private static final int SID_TYPE_BITS_OFFSET = 4;
private static final int M_FLAG_POSITION = 7;
private static final int C_FLAG_POSITION = 6;
final SrEroSubobject srEroSubobject = (SrEroSubobject) subobject.getSubobjectType();
final ByteBuf body = Unpooled.buffer(MINIMAL_LENGTH);
- writeUnsignedByte((short)(srEroSubobject.getSidType().getIntValue() << 4), body);
+ writeUnsignedByte((short)(srEroSubobject.getSidType().getIntValue() << SID_TYPE_BITS_OFFSET), body);
final Flags flags = srEroSubobject.getFlags();
final BitSet bits = new BitSet();
+ ";");
}
final SrEroTypeBuilder srEroSubobjectBuilder = new SrEroTypeBuilder();
- final int sidTypeByte = buffer.readByte() >> 4;
+ final int sidTypeByte = buffer.readByte() >> SID_TYPE_BITS_OFFSET;
final SidType sidType = SidType.forValue(sidTypeByte);
srEroSubobjectBuilder.setSidType(sidType);
}
protected static boolean isPst(final PathSetupTypeTlv tlv) {
- if (tlv != null && tlv.getPathSetupType() != null) {
- if (tlv.getPathSetupType().isPst()) {
- return true;
- }
+ if (tlv != null && tlv.getPathSetupType() != null && tlv.getPathSetupType().isPst()) {
+ return true;
}
return false;
}
objects.remove(0);
final Object obj = objects.get(0);
- if (obj != null) {
- if (obj instanceof Ero) {
- builder.setEro((Ero) obj);
- objects.remove(0);
- }
+ if (obj instanceof Ero) {
+ builder.setEro((Ero) obj);
+ objects.remove(0);
}
return builder.build();
}
final Rp rp = reply.getRp();
if (isSegmentRoutingPath(rp)) {
serializeObject(rp, buffer);
- if (reply.getResult() != null) {
- if (reply.getResult() instanceof SuccessCase) {
- final SuccessCase s = (SuccessCase) reply.getResult();
- for (final Paths p : s.getSuccess().getPaths()) {
- final Ero ero = p.getEro();
- serializeObject(ero, buffer);
- }
+ if (reply.getResult() instanceof SuccessCase) {
+ final SuccessCase s = (SuccessCase) reply.getResult();
+ for (final Paths p : s.getSuccess().getPaths()) {
+ final Ero ero = p.getEro();
+ serializeObject(ero, buffer);
}
}
} else {
if (isSegmentRoutingPath(rp)) {
objects.remove(0);
Result res = null;
- if (!objects.isEmpty()) {
- if (objects.get(0) instanceof Ero) {
- final SuccessBuilder builder = new SuccessBuilder();
- final List<Paths> paths = Lists.newArrayList();
- final PathsBuilder pBuilder = new PathsBuilder();
- while (!objects.isEmpty()) {
- final Object object = objects.get(0);
- if (object instanceof Ero) {
- final Ero ero = (Ero) object;
- final PCEPErrors error = SrEroUtil.validateSrEroSubobjects(ero);
- if (error != null) {
- errors.add(createErrorMsg(error));
- return null;
- } else {
- paths.add(pBuilder.setEro(ero).build());
- }
+ if (objects.get(0) instanceof Ero) {
+ final SuccessBuilder builder = new SuccessBuilder();
+ final List<Paths> paths = Lists.newArrayList();
+ final PathsBuilder pBuilder = new PathsBuilder();
+ while (!objects.isEmpty()) {
+ final Object object = objects.get(0);
+ if (object instanceof Ero) {
+ final Ero ero = (Ero) object;
+ final PCEPErrors error = SrEroUtil.validateSrEroSubobjects(ero);
+ if (error != null) {
+ errors.add(createErrorMsg(error));
+ return null;
+ } else {
+ paths.add(pBuilder.setEro(ero).build());
}
- objects.remove(0);
}
- builder.setPaths(paths);
- res = new SuccessCaseBuilder().setSuccess(builder.build()).build();
+ objects.remove(0);
}
+ builder.setPaths(paths);
+ res = new SuccessCaseBuilder().setSuccess(builder.build()).build();
}
return new RepliesBuilder().setRp(rp).setResult(res).build();
}