Improve segmented journal actor metrics
[controller.git] / opendaylight / md-sal / sal-distributed-datastore / src / main / java / org / opendaylight / controller / cluster / databroker / actors / dds / SimpleDataStoreClientActor.java
1 /*
2  * Copyright (c) 2016 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 package org.opendaylight.controller.cluster.databroker.actors.dds;
9
10 import static java.util.Objects.requireNonNull;
11
12 import akka.actor.Props;
13 import org.eclipse.jdt.annotation.NonNull;
14 import org.opendaylight.controller.cluster.access.client.AbstractClientActor;
15 import org.opendaylight.controller.cluster.access.client.ClientActorContext;
16 import org.opendaylight.controller.cluster.access.concepts.FrontendIdentifier;
17 import org.opendaylight.controller.cluster.access.concepts.FrontendType;
18 import org.opendaylight.controller.cluster.access.concepts.MemberName;
19 import org.opendaylight.controller.cluster.datastore.utils.ActorUtils;
20
21 /**
22  * A {@link AbstractClientActor} which acts as the point of contact for DistributedDataStore.
23  *
24  * @author Robert Varga
25  */
26 public final class SimpleDataStoreClientActor extends AbstractDataStoreClientActor {
27     private final String shardName;
28
29     private SimpleDataStoreClientActor(final FrontendIdentifier frontendId, final ActorUtils actorUtils,
30             final String shardName) {
31         super(frontendId, actorUtils);
32         this.shardName = requireNonNull(shardName);
33     }
34
35     @Override
36     AbstractDataStoreClientBehavior initialBehavior(final ClientActorContext context, final ActorUtils actorUtils) {
37         return new SimpleDataStoreClientBehavior(context, actorUtils, shardName);
38     }
39
40     public static Props props(final @NonNull MemberName memberName, final @NonNull String storeName,
41             final ActorUtils actorUtils, final String shardName) {
42         final String name = "datastore-" + storeName;
43         final FrontendIdentifier frontendId = FrontendIdentifier.create(memberName, FrontendType.forName(name));
44         return Props.create(SimpleDataStoreClientActor.class,
45             () -> new SimpleDataStoreClientActor(frontendId, actorUtils, shardName));
46     }
47 }