BUG-2138: Create DistributedShardFrontend
[controller.git] / opendaylight / md-sal / sal-distributed-datastore / src / test / java / org / opendaylight / controller / cluster / datastore / AbstractTest.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.datastore;
9
10 import java.util.concurrent.atomic.AtomicLong;
11 import org.opendaylight.controller.cluster.access.concepts.ClientIdentifier;
12 import org.opendaylight.controller.cluster.access.concepts.FrontendIdentifier;
13 import org.opendaylight.controller.cluster.access.concepts.FrontendType;
14 import org.opendaylight.controller.cluster.access.concepts.LocalHistoryIdentifier;
15 import org.opendaylight.controller.cluster.access.concepts.MemberName;
16 import org.opendaylight.controller.cluster.access.concepts.TransactionIdentifier;
17
18 public abstract class AbstractTest {
19     protected static final MemberName MEMBER_NAME = MemberName.forName("member-1");
20     protected static final MemberName MEMBER_2_NAME = MemberName.forName("member-2");
21
22     private static final FrontendType FRONTEND_TYPE = FrontendType.forName(ShardTransactionTest.class.getSimpleName());
23
24     protected static final FrontendIdentifier FRONTEND_ID = FrontendIdentifier.create(MEMBER_NAME, FRONTEND_TYPE);
25
26     private static final ClientIdentifier CLIENT_ID = ClientIdentifier.create(FRONTEND_ID, 0);
27     private static final LocalHistoryIdentifier HISTORY_ID = new LocalHistoryIdentifier(CLIENT_ID, 0);
28     private static final AtomicLong HISTORY_COUNTER = new AtomicLong();
29     private static final AtomicLong TX_COUNTER = new AtomicLong();
30
31     protected static void setUpStatic() {
32         HISTORY_COUNTER.set(1L);
33         TX_COUNTER.set(1L);
34     }
35
36     protected static TransactionIdentifier nextTransactionId() {
37         return new TransactionIdentifier(HISTORY_ID, TX_COUNTER.getAndIncrement());
38     }
39
40     protected static LocalHistoryIdentifier nextHistoryId() {
41         return new LocalHistoryIdentifier(CLIENT_ID, HISTORY_COUNTER.incrementAndGet());
42     }
43 }