2 * Copyright (c) 2017 Red Hat, 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.mdsal.binding.dom.adapter.test;
10 import com.google.common.util.concurrent.ListeningExecutorService;
11 import com.google.common.util.concurrent.MoreExecutors;
12 import java.util.concurrent.Executors;
15 * AbstractDataBrokerTestCustomizer implementation that uses a single-threaded executor for commits.
17 * @author Michael Vorburger
19 public class ConcurrentDataBrokerTestCustomizer extends AbstractDataBrokerTestCustomizer {
21 private final ListeningExecutorService dataTreeChangeListenerExecutorSingleton;
23 public ConcurrentDataBrokerTestCustomizer(boolean useMTDataTreeChangeListenerExecutor) {
24 if (useMTDataTreeChangeListenerExecutor) {
25 dataTreeChangeListenerExecutorSingleton = MoreExecutors.listeningDecorator(Executors.newCachedThreadPool());
27 dataTreeChangeListenerExecutorSingleton = MoreExecutors.newDirectExecutorService();
32 public ListeningExecutorService getCommitCoordinatorExecutor() {
33 return MoreExecutors.listeningDecorator(Executors.newSingleThreadExecutor());
37 public ListeningExecutorService getDataTreeChangeListenerExecutor() {
38 return dataTreeChangeListenerExecutorSingleton;