import com.google.common.util.concurrent.JdkFutureAdapters;
import com.google.common.util.concurrent.ListenableFuture;
import com.google.common.util.concurrent.MoreExecutors;
-
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Collections;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.atomic.AtomicLong;
-
+import javax.annotation.PostConstruct;
+import javax.annotation.PreDestroy;
+import javax.inject.Inject;
+import javax.inject.Singleton;
+import org.apache.aries.blueprint.annotation.service.Reference;
import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.RoutedRpcRegistration;
import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry;
import org.opendaylight.openflowplugin.api.OFConstants;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+@Singleton
public class ArbitratorReconciliationManagerImpl implements ArbitratorReconcileService,
ReconciliationNotificationListener, AutoCloseable {
private final ExecutorService executor = Executors.newFixedThreadPool(THREAD_POOL_SIZE);
private final Map<BigInteger, BundleDetails> bundleIdMap = new ConcurrentHashMap<>();
- public ArbitratorReconciliationManagerImpl(final RpcProviderRegistry rpcRegistry,
- final ReconciliationManager reconciliationManager, final UpgradeState upgradeState) {
+ @Inject
+ public ArbitratorReconciliationManagerImpl(@Reference RpcProviderRegistry rpcRegistry,
+ @Reference ReconciliationManager reconciliationManager, @Reference UpgradeState upgradeState) {
Preconditions.checkArgument(rpcRegistry != null, "RpcConsumerRegistry cannot be null !");
this.reconciliationManager = Preconditions.checkNotNull(reconciliationManager,
"ReconciliationManager cannot be null!");
this.upgradeState = Preconditions.checkNotNull(upgradeState, "UpgradeState cannot be null!");
}
+ @PostConstruct
public void start() {
registration = reconciliationManager.registerService(this);
LOG.info("ArbitratorReconciliationManager has started successfully.");
}
@Override
+ @PreDestroy
public void close() throws Exception {
executor.shutdown();
if (registration != null) {
MoreExecutors.directExecutor());
}
}
- return RpcResultBuilder.success((new CommitActiveBundleOutputBuilder()
- .setResult(null).build()))
+ return RpcResultBuilder.success(new CommitActiveBundleOutputBuilder()
+ .setResult(null).build())
.withRpcErrors(Collections.singleton(RpcResultBuilder.newError(RpcError.ErrorType.APPLICATION,
null, "No active bundle found for the node" + nodeId.toString()))).buildFuture();
}
//This blocking call is used to prevent the applications from pushing flows and groups via the default
// pipeline when the commit bundle is ongoing.
bundleDetails.getResult().get();
- return RpcResultBuilder.success((new GetActiveBundleOutputBuilder()
- .setResult(bundleDetails.getBundleId()).build())).buildFuture();
+ return RpcResultBuilder.success(new GetActiveBundleOutputBuilder()
+ .setResult(bundleDetails.getBundleId()).build()).buildFuture();
} catch (InterruptedException | ExecutionException | NullPointerException e) {
return RpcResultBuilder.<GetActiveBundleOutput>failed()
.withRpcErrors(Collections.singleton(RpcResultBuilder.newError(RpcError.ErrorType.APPLICATION,
null, e.getMessage()))).buildFuture();
}
}
- return RpcResultBuilder.success((new GetActiveBundleOutputBuilder()
- .setResult(null).build())).buildFuture();
+ return RpcResultBuilder.success(new GetActiveBundleOutputBuilder()
+ .setResult(null).build()).buildFuture();
}
@Override
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
- xmlns:cm="http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.1.0"
- xmlns:odl="http://opendaylight.org/xmlns/blueprint/v1.0.0"
- odl:use-default-for-reference-types="true">
-
- <reference id="rpcRegistry" interface="org.opendaylight.controller.sal.binding.api.RpcProviderRegistry"/>
- <reference id="reconciliationservice" interface="org.opendaylight.openflowplugin.applications.reconciliation.ReconciliationManager"/>
- <reference id="upgradeState" interface="org.opendaylight.serviceutils.upgrade.UpgradeState"/>
-
- <bean id="arbitratorReconciliationManager"
- class="org.opendaylight.openflowplugin.applications.arbitratorreconciliation.impl.ArbitratorReconciliationManagerImpl"
- init-method="start" destroy-method="close">
- <argument ref="rpcRegistry"/>
- <argument ref="reconciliationservice"/>
- <argument ref="upgradeState"/>
- </bean>
-
-</blueprint>