package org.opendaylight.netvirt.bgpmanager;
import com.google.common.base.Optional;
+import com.google.common.base.Preconditions;
import com.google.common.net.InetAddresses;
import com.google.common.util.concurrent.ThreadFactoryBuilder;
import io.netty.util.concurrent.GlobalEventExecutor;
import org.apache.thrift.TApplicationException;
import org.apache.thrift.TException;
import org.apache.thrift.transport.TTransport;
-import org.opendaylight.controller.config.api.osgi.WaitingServiceTracker;
import org.opendaylight.controller.md.sal.binding.api.ClusteredDataTreeChangeListener;
import org.opendaylight.controller.md.sal.binding.api.DataBroker;
import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier.InstanceIdentifierBuilder;
import org.osgi.framework.BundleContext;
+import org.osgi.util.tracker.ServiceTracker;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
initer.countDown();
GlobalEventExecutor.INSTANCE.execute(() -> {
- final WaitingServiceTracker<IBgpManager> tracker = WaitingServiceTracker.create(
- IBgpManager.class, bundleContext);
- bgpManager = tracker.waitForService(WaitingServiceTracker.FIVE_MINUTES);
+ ServiceTracker<IBgpManager, ?> tracker = null;
+ try {
+ tracker = new ServiceTracker<>(bundleContext, IBgpManager.class, null);
+ tracker.open();
+ bgpManager = (IBgpManager) tracker.waitForService(TimeUnit.MILLISECONDS.convert(5, TimeUnit.MINUTES));
+ Preconditions.checkState(bgpManager != null, "IBgpManager service not found");
+ } catch (InterruptedException e) {
+ throw new IllegalStateException("Error retrieving IBgpManager service", e);
+ } finally {
+ if (tracker != null) {
+ tracker.close();
+ }
+ }
+
if (InetAddresses.isInetAddress(getBgpSdncMipIp())) {
InetSocketAddress bgpThriftServerSocketAddr = new InetSocketAddress(getBgpSdncMipIp(),
Integer.parseInt(updatePort));
} else {
LOG.debug("Not owner: hasOwner: {}, isOwner: {}", ownershipChange.getState().hasOwner(),
ownershipChange.getState().isOwner());
- if ((bgpThriftService != null) && (bgpThriftService.isBgpThriftServiceStarted())) {
+ if (bgpThriftService != null && bgpThriftService.isBgpThriftServiceStarted()) {
//close the bgp Thrift Update-SERVER port opened on non-Entity Owner
bgpThriftService.stop();
bgpThriftService = null;
package org.opendaylight.netvirt.fibmanager;
import com.google.common.base.Optional;
+import com.google.common.base.Preconditions;
import com.google.common.util.concurrent.FutureCallback;
import io.netty.util.concurrent.GlobalEventExecutor;
import java.math.BigInteger;
import java.util.List;
+import java.util.concurrent.TimeUnit;
import javax.inject.Inject;
import javax.inject.Singleton;
-import org.opendaylight.controller.config.api.osgi.WaitingServiceTracker;
import org.opendaylight.controller.md.sal.binding.api.WriteTransaction;
import org.opendaylight.netvirt.fibmanager.api.IFibManager;
import org.opendaylight.netvirt.fibmanager.api.RouteOrigin;
import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.RouterInterface;
import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.vrfentries.VrfEntry;
import org.osgi.framework.BundleContext;
+import org.osgi.util.tracker.ServiceTracker;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
this.interVpnLinkCache = interVpnLinkCache;
GlobalEventExecutor.INSTANCE.execute(() -> {
- final WaitingServiceTracker<IVpnManager> tracker = WaitingServiceTracker.create(
- IVpnManager.class, bundleContext);
- vpnmanager = tracker.waitForService(WaitingServiceTracker.FIVE_MINUTES);
- LOG.info("FibManagerImpl initialized. IVpnManager={}", vpnmanager);
+ ServiceTracker<IVpnManager, ?> tracker = null;
+ try {
+ tracker = new ServiceTracker<>(bundleContext, IVpnManager.class, null);
+ tracker.open();
+ vpnmanager = (IVpnManager) tracker.waitForService(TimeUnit.MILLISECONDS.convert(5, TimeUnit.MINUTES));
+ Preconditions.checkState(vpnmanager != null, "IVpnManager service not found");
+ LOG.info("FibManagerImpl initialized. IVpnManager={}", vpnmanager);
+ } catch (IllegalStateException | InterruptedException e) {
+ LOG.error("Error retrieving IVpnManager service", e);
+ } finally {
+ if (tracker != null) {
+ tracker.close();
+ }
+ }
});
}