Initial code drop of yang model driven configuration system
[controller.git] / opendaylight / config / config-manager / src / test / java / org / opendaylight / controller / config / manager / testingservices / parallelapsp / TestingParallelAPSPImpl.java
1 /*
2  * Copyright (c) 2013 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.config.manager.testingservices.parallelapsp;
9
10 import static com.google.common.base.Preconditions.checkArgument;
11
12 import java.io.Closeable;
13 import java.io.IOException;
14
15 import javax.annotation.concurrent.NotThreadSafe;
16
17 import org.opendaylight.controller.config.manager.testingservices.threadpool.TestingThreadPoolIfc;
18
19 import com.google.common.base.Strings;
20
21 @NotThreadSafe
22 public class TestingParallelAPSPImpl implements TestingAPSP, Closeable {
23     public static final int MINIMAL_NUMBER_OF_THREADS = 10;
24     private TestingThreadPoolIfc threadPool;
25     private String someParam;
26
27     public TestingParallelAPSPImpl(TestingThreadPoolIfc threadPool,
28             String someParam) {
29         checkArgument(
30                 threadPool.getMaxNumberOfThreads() >= MINIMAL_NUMBER_OF_THREADS,
31                 "Parameter 'threadPool' has not enough threads");
32         checkArgument(Strings.isNullOrEmpty(someParam) == false,
33                 "Parameter 'someParam' is blank");
34         this.threadPool = threadPool;
35         this.someParam = someParam;
36     }
37
38     @Override
39     public int getMaxNumberOfThreads() {
40         return threadPool.getMaxNumberOfThreads();
41     }
42
43     @Override
44     public void close() throws IOException {
45
46     }
47
48     TestingThreadPoolIfc getThreadPool() {
49         return threadPool;
50     }
51
52     void setSomeParam(String s) {
53         checkArgument(Strings.isNullOrEmpty(someParam) == false,
54                 "Parameter 'someParam' is blank");
55         this.someParam = s;
56     }
57
58     public String getSomeParam() {
59         return someParam;
60     }
61
62 }