// length field can be one or two bytes (if needed)
// check the length of nlri to see how many bytes we can skip
final int length = nlri.readableBytes();
- nlri.skipBytes(length > 240 ? NLRI_LENGTH_EXTENDED : NLRI_LENGTH);
+ nlri.skipBytes(length > MAX_NLRI_LENGTH_ONE_BYTE ? NLRI_LENGTH_EXTENDED : NLRI_LENGTH);
while(nlri.isReadable()) {
final FlowspecBuilder builder = new FlowspecBuilder();
private final byte[] byteArray;
public ByteArrayWrapper(final byte[] byteArray) {
- this.byteArray = byteArray;
+ this.byteArray = byteArray == null ? null : byteArray.clone();
}
@Override
public int hashCode() {
- return Arrays.hashCode(byteArray);
+ return Arrays.hashCode(this.byteArray);
}
@Override
- public boolean equals(Object obj) {
+ public boolean equals(final Object obj) {
if (this == obj) {
return true;
}
if (!(obj instanceof ByteArrayWrapper)) {
return false;
}
- return Arrays.equals(byteArray, ((ByteArrayWrapper) obj).byteArray);
+ return Arrays.equals(this.byteArray, ((ByteArrayWrapper) obj).byteArray);
}
}
}
import com.google.common.base.Preconditions;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
-
import java.util.ArrayList;
import java.util.List;
import org.opendaylight.protocol.pcep.spi.AbstractMessageParser;
break;
case END :
break;
+ default:
+ break;
}
if (!state.equals(State.END)) {
objects.remove(0);
break;
case END :
break;
+ default:
+ break;
}
if (!state.equals(MetricPceState.END)) {
objects.remove(0);
private static final int RESERVED = 2;
private static final int FLAGS = RESERVED;
- private static final int BODY_SIZE = RESERVED + FLAGS + 5 * INT_BYTES_LENGTH;
+ private static final int COUNT_FIELDS = 5;
+ private static final int BODY_SIZE = RESERVED + FLAGS + COUNT_FIELDS * INT_BYTES_LENGTH;
private static final int E_FLAG_POSITION = 15;
@Override
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.segment.routing.rev150112.sr.subobject.nai.UnnumberedAdjacencyBuilder;
import org.opendaylight.yangtools.yang.binding.DataContainer;
-class SrSubobjectParserUtil {
+final class SrSubobjectParserUtil {
public static final int MINIMAL_LENGTH = 4;
public static final int BITSET_LENGTH = 8;
}
return new SrSubobject() {
-
@Override
public Class<? extends DataContainer> getImplementedInterface() {
return SrSubobject.class;
}
-
@Override
public SidType getSidType() {
return sidType;
}
-
@Override
public Long getSid() {
return sid;
}
-
@Override
public Nai getNai() {
return nai;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-/**
- *
- */
public abstract class AbstractInstructionExecutor implements FutureCallback<Instruction> {
+
+ private static final class InstructionCallback implements FutureCallback<OperationResult> {
+
+ private final Instruction insn;
+
+ public InstructionCallback(final Instruction insn) {
+ this.insn = insn;
+ }
+
+ @Override
+ public void onSuccess(final OperationResult result) {
+ if (result.getFailure() != null) {
+ switch (result.getFailure()) {
+ case Failed:
+ case NoAck:
+ this.insn.executionCompleted(InstructionStatus.Failed, null);
+ break;
+ case Unsent:
+ this.insn.executionCompleted(InstructionStatus.Cancelled, null);
+ break;
+ default:
+ break;
+ }
+ } else {
+ this.insn.executionCompleted(InstructionStatus.Successful, null);
+ }
+ }
+
+ @Override
+ public void onFailure(final Throwable t) {
+ this.insn.executionCompleted(InstructionStatus.Failed, null);
+ }
+ }
+
private static final Logger LOG = LoggerFactory.getLogger(AbstractInstructionExecutor.class);
private final SubmitInstructionInput input;
public static FailureCase schedule(final InstructionScheduler scheduler, final AbstractInstructionExecutor fwd) {
final ListenableFuture<Instruction> s;
-
try {
s = scheduler.scheduleInstruction(fwd.getInput());
} catch (final SchedulerException e) {
LOG.info("Instuction {} failed to schedule", e.getMessage(), e);
return new FailureCaseBuilder().setFailure(e.getFailure()).build();
}
-
Futures.addCallback(s, fwd);
return null;
}
public void onSuccess(final Instruction insn) {
if (insn.checkedExecutionStart()) {
final ListenableFuture<OperationResult> s = invokeOperation();
- Futures.addCallback(s, new FutureCallback<OperationResult>() {
- @Override
- public void onSuccess(final OperationResult result) {
- if (result.getFailure() != null) {
- switch (result.getFailure()) {
- case Failed:
- case NoAck:
- insn.executionCompleted(InstructionStatus.Failed, null);
- break;
- case Unsent:
- insn.executionCompleted(InstructionStatus.Cancelled, null);
- break;
- default:
- break;
- }
- } else {
- insn.executionCompleted(InstructionStatus.Successful, null);
- }
- }
-
- @Override
- public void onFailure(final Throwable t) {
- insn.executionCompleted(InstructionStatus.Failed, null);
- }
- });
+ Futures.addCallback(s, new InstructionCallback(insn));
}
}
// The source node has to exist
node = sourceNode(t, tii, link).get();
} catch (IllegalStateException | ReadFailedException e) {
- LOG.debug("Link or node does not exist.", e.getMessage());
+ LOG.debug("Link or node does not exist.", e);
return Futures.<OperationResult>immediateFuture(new OperationResult() {
@Override
public Class<? extends DataContainer> getImplementedInterface() {
// The source node has to exist
node = sourceNode(t, tii, link).get();
} catch (IllegalStateException | ReadFailedException e) {
- LOG.debug("Link or node does not exist.", e.getMessage());
+ LOG.debug("Link or node does not exist.", e);
return Futures.<OperationResult>immediateFuture(new OperationResult() {
@Override
public Class<? extends DataContainer> getImplementedInterface() {