import com.google.common.util.concurrent.FutureCallback;
import com.google.common.util.concurrent.Futures;
import com.google.common.util.concurrent.MoreExecutors;
+import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.TimeoutException;
import java.util.stream.Collectors;
import javax.annotation.Nonnull;
-import javax.annotation.Nullable;
import org.opendaylight.mdsal.eos.binding.api.EntityOwnershipChange;
import org.opendaylight.mdsal.eos.binding.api.EntityOwnershipListenerRegistration;
import org.opendaylight.mdsal.eos.binding.api.EntityOwnershipService;
@Override
public <T extends OFPManager> void addManager(final T manager) {
- if (Objects.isNull(deviceManager) && manager instanceof DeviceManager) {
+ if (deviceManager == null && manager instanceof DeviceManager) {
LOG.trace("Context chain holder: Device manager OK.");
deviceManager = (DeviceManager) manager;
- } else if (Objects.isNull(rpcManager) && manager instanceof RpcManager) {
+ } else if (rpcManager == null && manager instanceof RpcManager) {
LOG.trace("Context chain holder: RPC manager OK.");
rpcManager = (RpcManager) manager;
- } else if (Objects.isNull(statisticsManager) && manager instanceof StatisticsManager) {
+ } else if (statisticsManager == null && manager instanceof StatisticsManager) {
LOG.trace("Context chain holder: Statistics manager OK.");
statisticsManager = (StatisticsManager) manager;
- } else if (Objects.isNull(roleManager) && manager instanceof RoleManager) {
+ } else if (roleManager == null && manager instanceof RoleManager) {
LOG.trace("Context chain holder: Role manager OK.");
roleManager = (RoleManager) manager;
}
}
@Override
- public ConnectionStatus deviceConnected(final ConnectionContext connectionContext) throws Exception {
+ public ConnectionStatus deviceConnected(final ConnectionContext connectionContext) {
final DeviceInfo deviceInfo = connectionContext.getDeviceInfo();
final ContextChain contextChain = contextChainMap.get(deviceInfo);
final FeaturesReply featuresReply = connectionContext.getFeatures();
@VisibleForTesting
boolean checkAllManagers() {
- return Objects.nonNull(deviceManager) && Objects.nonNull(rpcManager) && Objects.nonNull(statisticsManager)
- && Objects.nonNull(roleManager);
+ return deviceManager != null && rpcManager != null && statisticsManager != null && roleManager != null;
}
@Override
- public void close() throws Exception {
+ public ContextChain getContextChain(final DeviceInfo deviceInfo) {
+ return contextChainMap.get(deviceInfo);
+ }
+
+ @Override
+ public void close() {
Map<DeviceInfo, ContextChain> copyOfChains = new HashMap<>(contextChainMap);
copyOfChains.keySet().forEach(this::destroyContextChain);
copyOfChains.clear();
}
@Override
+ @SuppressFBWarnings("BC_UNCONFIRMED_CAST_OF_RETURN_VALUE")
public void ownershipChanged(EntityOwnershipChange entityOwnershipChange) {
if (entityOwnershipChange.getState().hasOwner()) {
return;
}
+ // Findbugs flags a false violation for "Unchecked/unconfirmed cast" from GenericEntity to Entity hence the
+ // suppression above. The suppression is temporary until EntityOwnershipChange is modified to eliminate the
+ // violation.
final String entityName = entityOwnershipChange
.getEntity()
.getIdentifier()
.firstKeyOf(Entity.class)
.getName();
- if (Objects.nonNull(entityName)) {
+ if (entityName != null) {
LOG.debug("Entity {} has no owner", entityName);
try {
//TODO:Remove notifications
Optional.ofNullable(contextChainMap.get(deviceInfo)).ifPresent(contextChain -> {
deviceManager.sendNodeRemovedNotification(deviceInfo.getNodeInstanceIdentifier());
contextChain.close();
+ connectingDevices.remove(deviceInfo);
});
}
ContextChain contextChain) {
return new FutureCallback<ResultState>() {
@Override
- public void onSuccess(@Nullable ResultState result) {
+ public void onSuccess(ResultState result) {
if (ResultState.DONOTHING == result) {
LOG.info("Device {} connection is enabled by reconciliation framework.", deviceInfo);
contextChain.continueInitializationAfterReconciliation();
}
@Override
- public void onFailure(@Nonnull Throwable throwable) {
+ public void onFailure(Throwable throwable) {
LOG.warn("Reconciliation framework failure.");
destroyContextChain(deviceInfo);
}