2 * Copyright (c) 2014 Cisco Systems, Inc. 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
9 package org.opendaylight.controller.cluster.datastore;
11 import akka.actor.ActorRef;
12 import akka.actor.ActorSystem;
13 import akka.cluster.Cluster;
14 import akka.cluster.ClusterEvent;
16 public class ClusterWrapperImpl implements ClusterWrapper {
17 private final Cluster cluster;
18 private final String currentMemberName;
20 public ClusterWrapperImpl(ActorSystem actorSystem){
21 cluster = Cluster.get(actorSystem);
22 currentMemberName = (String) cluster.getSelfRoles().toArray()[0];
26 public void subscribeToMemberEvents(ActorRef actorRef){
27 cluster.subscribe(actorRef, ClusterEvent.initialStateAsEvents(),
28 ClusterEvent.MemberEvent.class,
29 ClusterEvent.UnreachableMember.class);
32 public String getCurrentMemberName() {
33 return currentMemberName;