11857b9936fba6122bdaa82ccc8e7fbb069a1611
[controller.git] / opendaylight / md-sal / sal-akka-raft-example / src / main / java / org / opendaylight / controller / cluster / example / ClientActor.java
1 /*
2  * Copyright (c) 2014 Cisco Systems, Inc. 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
9 package org.opendaylight.controller.cluster.example;
10
11 import akka.actor.ActorRef;
12 import akka.actor.Props;
13 import akka.actor.UntypedActor;
14 import org.opendaylight.controller.cluster.example.messages.KeyValue;
15 import org.opendaylight.controller.cluster.example.messages.KeyValueSaved;
16 import org.slf4j.Logger;
17 import org.slf4j.LoggerFactory;
18
19 public class ClientActor extends UntypedActor {
20     private static final Logger LOG = LoggerFactory.getLogger(ClientActor.class);
21
22     private final ActorRef target;
23
24     public ClientActor(ActorRef target) {
25         this.target = target;
26     }
27
28     public static Props props(final ActorRef target) {
29         return Props.create(ClientActor.class, target);
30     }
31
32     @Override public void onReceive(Object message) {
33         if (message instanceof KeyValue) {
34             target.tell(message, getSelf());
35         } else if (message instanceof KeyValueSaved) {
36             LOG.info("KeyValue saved");
37         }
38     }
39 }

©2013 OpenDaylight, A Linux Foundation Collaborative Project. All Rights Reserved.
OpenDaylight is a registered trademark of The OpenDaylight Project, Inc.
Linux Foundation and OpenDaylight are registered trademarks of the Linux Foundation.
Linux is a registered trademark of Linus Torvalds.