private static final class Holder {
private static final BGPExtensionProviderContext INSTANCE;
+ private Holder() {
+ }
+
static {
try {
INSTANCE = create();
final BGPExtensionProviderContext ctx = new SimpleBGPExtensionProviderContext();
final ServiceLoader<BGPExtensionProviderActivator> loader = ServiceLoader.load(BGPExtensionProviderActivator.class);
- for (BGPExtensionProviderActivator a : loader) {
+ for (final BGPExtensionProviderActivator a : loader) {
a.start(ctx);
}
@Override
public PathAttributes parseAttributes(final ByteBuf buffer) throws BGPDocumentedException, BGPParsingException {
- final TreeMap<Integer, RawAttribute> attributes = new TreeMap<>();
+ final Map<Integer, RawAttribute> attributes = new TreeMap<>();
while (buffer.isReadable()) {
addAttribute(buffer, attributes);
}
@Override
public void serializeAttribute(final DataObject attribute,final ByteBuf byteAggregator) {
- for (AttributeSerializer serializer : this.roSerializers.get()) {
+ for (final AttributeSerializer serializer : this.roSerializers.get()) {
serializer.serializeAttribute(attribute, byteAggregator);
}
}
private final MD5ChannelFactory<?> cf;
private final BGPHandlerFactory hf;
private KeyMapping keys;
+ private static final String NEGOTIATOR = "negotiator";
public BGPDispatcherImpl(final MessageRegistry messageRegistry, final EventLoopGroup bossGroup, final EventLoopGroup workerGroup) {
this(messageRegistry, bossGroup, workerGroup, null, null);
@Override
public void initializeChannel(final SocketChannel ch, final Promise<BGPSessionImpl> promise) {
ch.pipeline().addLast(BGPDispatcherImpl.this.hf.getDecoders());
- ch.pipeline().addLast("negotiator", snf.getSessionNegotiator(null, ch, promise));
+ ch.pipeline().addLast(NEGOTIATOR, snf.getSessionNegotiator(null, ch, promise));
ch.pipeline().addLast(BGPDispatcherImpl.this.hf.getEncoders());
}
});
@Override
public void initializeChannel(final SocketChannel ch, final Promise<BGPSessionImpl> promise) {
ch.pipeline().addLast(BGPDispatcherImpl.this.hf.getDecoders());
- ch.pipeline().addLast("negotiator", snf.getSessionNegotiator(null, ch, promise));
+ ch.pipeline().addLast(NEGOTIATOR, snf.getSessionNegotiator(null, ch, promise));
ch.pipeline().addLast(BGPDispatcherImpl.this.hf.getEncoders());
}
});
@Override
public void initializeChannel(final SocketChannel ch, final Promise<BGPSessionImpl> promise) {
ch.pipeline().addLast(BGPDispatcherImpl.this.hf.getDecoders());
- ch.pipeline().addLast("negotiator", snf.getSessionNegotiator(null, ch, promise));
+ ch.pipeline().addLast(NEGOTIATOR, snf.getSessionNegotiator(null, ch, promise));
ch.pipeline().addLast(BGPDispatcherImpl.this.hf.getEncoders());
}
});
}
@Override
- public synchronized final void onLocRIBChange(final ReadWriteTransaction trans,
+ public final synchronized void onLocRIBChange(final ReadWriteTransaction trans,
final AsyncDataChangeEvent<InstanceIdentifier<?>, DataObject> event) {
LOG.debug("Received data change {} event with transaction {}", event, trans.getIdentifier());
if (this.closed) {
}
@Override
- public synchronized final void close() throws TransactionCommitFailedException {
+ public final synchronized void close() throws TransactionCommitFailedException {
LOG.info("Shutting down builder for {}", getInstanceIdentifier());
final WriteTransaction trans = this.chain.newWriteOnlyTransaction();
trans.delete(LogicalDatastoreType.OPERATIONAL, getInstanceIdentifier());
final Pcupd updMsg = (Pcupd) message;
final Updates updates = updMsg.getPcupdMessage().getUpdates().get(0);
final long srpId = updates.getSrp().getOperationId().getValue();
- if (pcError) {
+ if (this.pcError) {
session.sendMessage(MsgBuilderUtil.createErrorMsg(getRandomError(), srpId));
} else {
final Tlvs tlvs = createLspTlvs(updates.getLsp().getPlspId().getValue(), false,
.getIpPrefix().getIpPrefix().getIpv4Prefix().getValue();
try {
return InetAddress.getByName(prefix.substring(0, prefix.indexOf('/')));
- } catch (UnknownHostException e) {
- LOG.warn("Unknown host name {}", prefix);
+ } catch (final UnknownHostException e) {
+ LOG.warn("Unknown host name {}.", prefix, e);
}
}
return this.address;
}
- private Random rnd = new Random();
+ private final Random rnd = new Random();
private PCEPErrors getRandomError() {
- return PCEPErrors.values()[rnd.nextInt(PCEPErrors.values().length)];
+ return PCEPErrors.values()[this.rnd.nextInt(PCEPErrors.values().length)];
}
}
@Override
public boolean canReuseInstance(final AbstractSimplePCEPExtensionProviderContextModule oldModule) {
return oldModule.getInstance().getClass().equals(ReusablePCEPExtensionProviderContext.class);
- };
+ }
@Override
public java.lang.AutoCloseable reuseInstance(final java.lang.AutoCloseable oldInstance) {
private static final class Holder {
private static final PCEPExtensionProviderContext INSTANCE;
+ private Holder() {
+ }
+
static {
try {
INSTANCE = create();
final InstanceIdentifier<Link> lii = NodeChangedListener.linkIdentifier(tii, ab.getNode(), ab.getName());
try {
Preconditions.checkState(! t.read(LogicalDatastoreType.OPERATIONAL, lii).checkedGet().isPresent());
- } catch (ReadFailedException e) {
+ } catch (final ReadFailedException e) {
throw new IllegalStateException("Failed to ensure link existence.", e);
}
args.setEro(buildEro(input.getExplicitHops()));
args.setLspa(new LspaBuilder(input).build());
- AdministrativeStatus adminStatus = input.getAugmentation(PcepCreateP2pTunnelInput1.class).getAdministrativeStatus();
+ final AdministrativeStatus adminStatus = input.getAugmentation(PcepCreateP2pTunnelInput1.class).getAdministrativeStatus();
if (adminStatus != null) {
args.addAugmentation(Arguments2.class, new Arguments2Builder().setLsp(new LspBuilder().setAdministrative((adminStatus == AdministrativeStatus.Active) ? true : false).build()).build());
}
// 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());
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());
return Futures.<OperationResult>immediateFuture(new OperationResult() {
@Override
public Class<? extends DataContainer> getImplementedInterface() {
args.setEro(buildEro(input.getExplicitHops()));
args.setLspa(new LspaBuilder(input).build());
- AdministrativeStatus adminStatus = input.getAugmentation(PcepUpdateTunnelInput1.class).getAdministrativeStatus();
+ final AdministrativeStatus adminStatus = input.getAugmentation(PcepUpdateTunnelInput1.class).getAdministrativeStatus();
if (adminStatus != null) {
args.addAugmentation(Arguments3.class, new Arguments3Builder().setLsp(new LspBuilder().setAdministrative((adminStatus == AdministrativeStatus.Active) ? true : false).build()).build());
}
import java.nio.charset.Charset;
import java.util.Arrays;
import java.util.BitSet;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
* Util class for methods working with byte array.
*/
public final class ByteArray {
+ private static final Logger LOG = LoggerFactory.getLogger(ByteArray.class);
+
private ByteArray() {
throw new UnsupportedOperationException();
}
try {
return Charset.forName("UTF-8").newDecoder().decode(ByteBuffer.wrap(bytes)).toString();
} catch (final CharacterCodingException e) {
+ LOG.debug("Could not apply UTF-8 encoding.", e);
return Arrays.toString(bytes);
}
}
public final class NoopReferenceCache implements ReferenceCache {
private static final class Holder {
static final NoopReferenceCache INSTANCE = new NoopReferenceCache();
+
+ private Holder() {
+ }
}
private NoopReferenceCache() {