2 * Copyright (c) 2016 Ericsson India Global Services Pvt Ltd. and others. All rights reserved.
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
8 package org.opendaylight.netvirt.elan.utils;
10 import com.google.common.util.concurrent.ListenableFuture;
11 import java.util.List;
12 import java.util.concurrent.Callable;
13 import javax.inject.Inject;
14 import javax.inject.Singleton;
15 import org.opendaylight.genius.utils.clustering.EntityOwnershipUtils;
16 import org.opendaylight.genius.utils.hwvtep.HwvtepSouthboundConstants;
17 import org.opendaylight.infrautils.jobcoordinator.JobCoordinator;
20 public final class ElanClusterUtils {
21 private final EntityOwnershipUtils entityOwnershipUtils;
22 private final JobCoordinator jobCoordinator;
25 public ElanClusterUtils(EntityOwnershipUtils entityOwnershipUtils, JobCoordinator jobCoordinator) {
26 this.entityOwnershipUtils = entityOwnershipUtils;
27 this.jobCoordinator = jobCoordinator;
30 public void runOnlyInOwnerNode(String jobDesc, Runnable job) {
31 entityOwnershipUtils.runOnlyInOwnerNode(HwvtepSouthboundConstants.ELAN_ENTITY_TYPE,
32 HwvtepSouthboundConstants.ELAN_ENTITY_NAME, jobCoordinator, jobDesc, job);
35 public void runOnlyInOwnerNode(String jobKey, String jobDesc, Callable<List<ListenableFuture<Void>>> job) {
36 entityOwnershipUtils.runOnlyInOwnerNode(HwvtepSouthboundConstants.ELAN_ENTITY_TYPE,
37 HwvtepSouthboundConstants.ELAN_ENTITY_NAME, jobCoordinator, jobKey, jobDesc, job);