Search in sources :

Example 1 with DeleteLogicalSwitchJob

use of org.opendaylight.netvirt.elan.l2gw.jobs.DeleteLogicalSwitchJob in project netvirt by opendaylight.

the class ElanL2GatewayUtils method scheduleDeleteLogicalSwitch.

public void scheduleDeleteLogicalSwitch(final NodeId hwvtepNodeId, final String lsName, final boolean clearUcast) {
    final Pair<NodeId, String> nodeIdLogicalSwitchNamePair = new ImmutablePair<>(hwvtepNodeId, lsName);
    logicalSwitchDeletedTasks.computeIfAbsent(nodeIdLogicalSwitchNamePair, (key) -> {
        return scheduler.getScheduledExecutorService().schedule(() -> {
            DeleteLogicalSwitchJob deleteLsJob = new DeleteLogicalSwitchJob(broker, ElanL2GatewayUtils.this, hwvtepNodeId, lsName, clearUcast);
            jobCoordinator.enqueueJob(deleteLsJob.getJobKey(), deleteLsJob, SystemPropertyReader.getDataStoreJobCoordinatorMaxRetries());
            deleteJobs.put(nodeIdLogicalSwitchNamePair, deleteLsJob);
            logicalSwitchDeletedTasks.remove(nodeIdLogicalSwitchNamePair);
        }, getLogicalSwitchDeleteDelaySecs(), TimeUnit.SECONDS);
    });
}
Also used : ImmutablePair(org.apache.commons.lang3.tuple.ImmutablePair) DeleteLogicalSwitchJob(org.opendaylight.netvirt.elan.l2gw.jobs.DeleteLogicalSwitchJob) NodeId(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId)

Example 2 with DeleteLogicalSwitchJob

use of org.opendaylight.netvirt.elan.l2gw.jobs.DeleteLogicalSwitchJob in project netvirt by opendaylight.

the class ElanL2GatewayUtils method cancelDeleteLogicalSwitch.

public void cancelDeleteLogicalSwitch(final NodeId hwvtepNodeId, final String lsName) {
    Pair<NodeId, String> nodeIdLogicalSwitchNamePair = new ImmutablePair<>(hwvtepNodeId, lsName);
    ScheduledFuture logicalSwitchDeleteTask = logicalSwitchDeletedTasks.remove(nodeIdLogicalSwitchNamePair);
    if (logicalSwitchDeleteTask != null) {
        LOG.debug("Delete logical switch {} action on node {} cancelled", lsName, hwvtepNodeId);
        logicalSwitchDeleteTask.cancel(true);
        DeleteLogicalSwitchJob deleteLogicalSwitchJob = deleteJobs.remove(nodeIdLogicalSwitchNamePair);
        if (deleteLogicalSwitchJob != null) {
            deleteLogicalSwitchJob.cancel();
        }
    }
}
Also used : ImmutablePair(org.apache.commons.lang3.tuple.ImmutablePair) DeleteLogicalSwitchJob(org.opendaylight.netvirt.elan.l2gw.jobs.DeleteLogicalSwitchJob) NodeId(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId) ScheduledFuture(java.util.concurrent.ScheduledFuture)

Aggregations

ImmutablePair (org.apache.commons.lang3.tuple.ImmutablePair)2 DeleteLogicalSwitchJob (org.opendaylight.netvirt.elan.l2gw.jobs.DeleteLogicalSwitchJob)2 NodeId (org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId)2 ScheduledFuture (java.util.concurrent.ScheduledFuture)1