95b17d7ff0f849881b2fa05804e6152f64f7523d
[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 @Deprecated
23 public class ConcurrentDataBrokerTestCustomizer extends AbstractDataBrokerTestCustomizer {
24
25     private final ListeningExecutorService dataTreeChangeListenerExecutorSingleton;
26
27     public ConcurrentDataBrokerTestCustomizer(boolean useMTDataTreeChangeListenerExecutor) {
28         if (useMTDataTreeChangeListenerExecutor) {
29             dataTreeChangeListenerExecutorSingleton = MoreExecutors.listeningDecorator(Executors.newCachedThreadPool());
30         } else {
31             dataTreeChangeListenerExecutorSingleton = MoreExecutors.newDirectExecutorService();
32         }
33     }
34
35     @Override
36     public ListeningExecutorService getCommitCoordinatorExecutor() {
37         return MoreExecutors.listeningDecorator(Executors.newSingleThreadExecutor());
38     }
39
40     @Override
41     public ListeningExecutorService getDataTreeChangeListenerExecutor() {
42         return dataTreeChangeListenerExecutorSingleton;
43     }
44
45 }