NODE_DELET_WAITING_JOBS.get(iid).add(job);
//Also delete the node so that reconciliation kicks in
deleteTheNodeOfOldConnection(iid, getNodeConnectionInfo(iid));
- HwvtepSouthboundUtil.getScheduledExecutorService().schedule(() -> {
+ HwvtepSouthboundUtil.schedule(() -> {
runPendingJobs(iid);
}, HwvtepSouthboundConstants.HWVTEP_REGISTER_CALLBACKS_WAIT_TIMEOUT, TimeUnit.SECONDS);
} else {
private synchronized void runPendingJobs(InstanceIdentifier<Node> iid) {
List<Callable<Void>> jobs = NODE_DELET_WAITING_JOBS.remove(iid);
if (jobs != null && !jobs.isEmpty()) {
- jobs.forEach((job) -> {
+ jobs.forEach(job -> {
try {
LOG.error("Node disconnected job found {} running it now ", iid);
job.call();
}
private static void connect(Collection<DataTreeModification<Node>> changes) {
- changes.forEach((change) -> {
+ changes.forEach(change -> {
InstanceIdentifier<Node> key = change.getRootPath().getRootIdentifier();
DataObjectModification<Node> mod = change.getRootNode();
Node node = getCreated(mod);
}
private static void updated(Collection<DataTreeModification<Node>> changes) {
- changes.forEach((change) -> {
+ changes.forEach(change -> {
InstanceIdentifier<Node> key = change.getRootPath().getRootIdentifier();
DataObjectModification<Node> mod = change.getRootNode();
Node node = getUpdated(mod);
}
private void disconnect(Collection<DataTreeModification<Node>> changes) {
- changes.forEach((change) -> {
+ changes.forEach(change -> {
InstanceIdentifier<Node> key = change.getRootPath().getRootIdentifier();
DataObjectModification<Node> mod = change.getRootNode();
Node node = getRemoved(mod);
public void scheduleOldConnectionNodeDelete(InstanceIdentifier<Node> iid) {
ConnectionInfo oldConnectionInfo = getNodeConnectionInfo(iid);
- HwvtepSouthboundUtil.getScheduledExecutorService().schedule(() -> {
+ HwvtepSouthboundUtil.schedule(() -> {
deleteTheNodeOfOldConnection(iid, oldConnectionInfo);
}, HwvtepSouthboundConstants.STALE_HWVTEP_CLEANUP_DELAY_SECS, TimeUnit.SECONDS);
}
int WAITING_QUEUE_CAPACITY = Integer.getInteger("hwvtep.wait.queue.capacity", 1000);
long WAITING_JOB_EXPIRY_TIME_MILLIS = Integer.getInteger(
"hwvtep.wait.job.expiry.time.millis", 90000);
- Integer STALE_HWVTEP_CLEANUP_DELAY_SECS
- = Integer.getInteger("stale.hwvtep.node.cleanup.delay.secs", 240);
- Integer HWVTEP_REGISTER_CALLBACKS_WAIT_TIMEOUT
- = Integer.getInteger("hwvtep.max.oper.wait.time.secs", 10);
+ int STALE_HWVTEP_CLEANUP_DELAY_SECS = Integer.getInteger("stale.hwvtep.node.cleanup.delay.secs", 240);
+ int HWVTEP_REGISTER_CALLBACKS_WAIT_TIMEOUT = Integer.getInteger("hwvtep.max.oper.wait.time.secs", 10);
long IN_TRANSIT_STATE_EXPIRY_TIME_MILLIS = Integer.getInteger(
"hwvtep.intransit.job.expiry.time.millis", 10000);
long IN_TRANSIT_STATE_CHECK_PERIOD_MILLIS = Integer.getInteger(
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
+import java.util.concurrent.TimeUnit;
import org.opendaylight.mdsal.binding.api.DataBroker;
import org.opendaylight.mdsal.binding.api.ReadTransaction;
import org.opendaylight.mdsal.binding.api.ReadWriteTransaction;
import org.slf4j.LoggerFactory;
public final class HwvtepSouthboundUtil {
-
private static final Logger LOG = LoggerFactory.getLogger(HwvtepSouthboundUtil.class);
+ private static final ScheduledExecutorService BACKGROUND_EXECUTOR =
+ Executors.newSingleThreadScheduledExecutor(new ThreadFactoryBuilder()
+ .setNameFormat("hwvteputil-executor-service-%d")
+ .build());
+
private static final String SCHEMA_VERSION_MISMATCH =
"{} column for {} table is not supported by this version of the {} schema: {}";
private static InstanceIdentifierCodec instanceIdentifierCodec;
- private static ScheduledExecutorService scheduledExecutorService = Executors
- .newSingleThreadScheduledExecutor(new ThreadFactoryBuilder()
- .setNameFormat("hwvteputil-executor-service-%d").build());
private HwvtepSouthboundUtil() {
// Prevent instantiating a utility class
return 0;
}
- public static ScheduledExecutorService getScheduledExecutorService() {
- return scheduledExecutorService;
+ static void schedule(final Runnable command, final int delay, TimeUnit timeUnit) {
+ BACKGROUND_EXECUTOR.schedule(command, delay, timeUnit);
}
}