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.vpnservice.utils.clustering;
10 import com.google.common.base.Optional;
11 import org.opendaylight.controller.md.sal.common.api.clustering.EntityOwnershipService;
12 import org.opendaylight.controller.md.sal.common.api.clustering.Entity;
13 import org.opendaylight.controller.md.sal.common.api.clustering.EntityOwnershipState;
14 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
16 public class ClusteringUtils {
18 public static boolean isNodeEntityOwner(EntityOwnershipService entityOwnershipService, String entityType,
20 Entity entity = new Entity(entityType, nodeId);
21 Optional<EntityOwnershipState> entityState = entityOwnershipService.getOwnershipState(entity);
22 if (entityState.isPresent()) {
23 return entityState.get().isOwner();
28 public static boolean isNodeEntityOwner(EntityOwnershipService entityOwnershipService, String entityType,
29 YangInstanceIdentifier nodeId) {
30 Entity entity = new Entity(entityType, nodeId);
31 Optional<EntityOwnershipState> entityState = entityOwnershipService.getOwnershipState(entity);
32 if (entityState.isPresent()) {
33 return entityState.get().isOwner();