Bug 8163: getDataTreeChangeListenerExecutor() & DataBrokerTestModule
[controller.git] / opendaylight / md-sal / sal-binding-broker / src / test / java / org / opendaylight / controller / md / sal / binding / test / ConcurrentDataBrokerTestCustomizer.java
1 /*
2  * Copyright (c) 2017 Red Hat, 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.md.sal.binding.test;
9
10 import com.google.common.util.concurrent.ListeningExecutorService;
11 import com.google.common.util.concurrent.MoreExecutors;
12 import java.util.concurrent.Executors;
13
14 /**
15  * ConcurrentDataBrokerTestCustomizer.
16  *
17  * <p>See {@link AbstractConcurrentDataBrokerTest} and
18  * <a href="https://bugs.opendaylight.org/show_bug.cgi?id=7538">bug 7538</a> for more details & background.
19  *
20  * @author Michael Vorburger
21  */
22 public class ConcurrentDataBrokerTestCustomizer extends AbstractDataBrokerTestCustomizer {
23
24     private final ListeningExecutorService dataTreeChangeListenerExecutorSingleton;
25
26     public ConcurrentDataBrokerTestCustomizer(boolean useMTDataTreeChangeListenerExecutor) {
27         if (useMTDataTreeChangeListenerExecutor) {
28             dataTreeChangeListenerExecutorSingleton = MoreExecutors.listeningDecorator(Executors.newCachedThreadPool());
29         } else {
30             dataTreeChangeListenerExecutorSingleton = MoreExecutors.newDirectExecutorService();
31         }
32     }
33
34     @Override
35     public ListeningExecutorService getCommitCoordinatorExecutor() {
36         return MoreExecutors.listeningDecorator(Executors.newSingleThreadExecutor());
37     }
38
39     @Override
40     public ListeningExecutorService getDataTreeChangeListenerExecutor() {
41         return dataTreeChangeListenerExecutorSingleton;
42     }
43
44 }

©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.