Bulk merge of l2gw changes
[netvirt.git] / elanmanager / impl / src / main / java / org / opendaylight / netvirt / elan / l2gw / jobs / McastUpdateJobUtil.java
1 /*
2  * Copyright (c) 2020 Ericsson India Global Services Pvt Ltd. and others.  All rights reserved.
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6  * and is available at http://www.eclipse.org/legal/epl-v10.html
7  */
8 package org.opendaylight.netvirt.elan.l2gw.jobs;
9
10 import javax.inject.Inject;
11 import javax.inject.Singleton;
12 import org.opendaylight.infrautils.jobcoordinator.JobCoordinator;
13 import org.opendaylight.netvirt.elan.l2gw.utils.ElanL2GatewayMulticastUtils;
14 import org.opendaylight.netvirt.elan.utils.ElanClusterUtils;
15 import org.opendaylight.netvirt.elan.utils.Scheduler;
16 import org.opendaylight.netvirt.elanmanager.utils.ElanL2GwCacheUtils;
17
18 @Singleton
19 public class McastUpdateJobUtil {
20     ElanL2GatewayMulticastUtils mcastUtils;
21     ElanClusterUtils elanClusterUtils;
22     Scheduler scheduler;
23     JobCoordinator jobCoordinator;
24
25     @Inject
26     public McastUpdateJobUtil(ElanL2GatewayMulticastUtils mcastUtils, ElanClusterUtils elanClusterUtils,
27                               Scheduler scheduler, JobCoordinator jobCoordinator) {
28         this.mcastUtils = mcastUtils;
29         this.elanClusterUtils = elanClusterUtils;
30         this.scheduler = scheduler;
31         this.jobCoordinator = jobCoordinator;
32     }
33
34     public void updateAllMcasts(String elanName) {
35         ElanL2GwCacheUtils.getInvolvedL2GwDevices(elanName).keySet().forEach(nodeId -> {
36             new McastUpdateJob(elanName, nodeId, true, mcastUtils,
37                     elanClusterUtils, scheduler, jobCoordinator).submit();
38         });
39     }
40
41     public void removeMcastForNode(String elanName, String nodeId) {
42         new McastUpdateJob(elanName, nodeId, false, mcastUtils,
43                 elanClusterUtils, scheduler, jobCoordinator).submit();
44     }
45
46     public void updateMcastForNode(String elanName, String nodeId) {
47         new McastUpdateJob(elanName, nodeId, true, mcastUtils,
48                 elanClusterUtils, scheduler, jobCoordinator).submit();
49     }
50 }