2 * Copyright (c) 2016 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
8 package org.opendaylight.controller.cluster.datastore;
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;
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");
22 private static final FrontendType FRONTEND_TYPE = FrontendType.forName(ShardTransactionTest.class.getSimpleName());
24 protected static final FrontendIdentifier FRONTEND_ID = FrontendIdentifier.create(MEMBER_NAME, FRONTEND_TYPE);
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();
31 protected static void setUpStatic() {
32 HISTORY_COUNTER.set(1L);
36 protected static TransactionIdentifier nextTransactionId() {
37 return new TransactionIdentifier(HISTORY_ID, TX_COUNTER.getAndIncrement());
40 protected static LocalHistoryIdentifier nextHistoryId() {
41 return new LocalHistoryIdentifier(CLIENT_ID, HISTORY_COUNTER.incrementAndGet());