/*
 * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
 *
 * This program and the accompanying materials are made available under the
 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
 * and is available at http://www.eclipse.org/legal/epl-v10.html
 */
package org.opendaylight.controller.md.sal.dom.store.benchmark;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.TimeUnit;
import org.opendaylight.controller.md.sal.dom.store.impl.InMemoryDOMDataStore;
import org.opendaylight.yangtools.util.concurrent.SpecialExecutors;
import org.openjdk.jmh.annotations.Level;
import org.openjdk.jmh.annotations.Setup;
import org.openjdk.jmh.annotations.TearDown;
import org.openjdk.jmh.annotations.Fork;
import org.openjdk.jmh.annotations.Scope;
import org.openjdk.jmh.annotations.State;
import org.openjdk.jmh.annotations.BenchmarkMode;
import org.openjdk.jmh.annotations.Mode;
import org.openjdk.jmh.annotations.OutputTimeUnit;

/**
 * Benchmark for testing of performance of write operations for InMemoryDataStore. The instance
 * of benchmark creates InMemoryDataStore with Data Change Listener Executor Service as BlockingBoundedFastThreadPool
 * and DOM Store Executor Service as Blocking Bounded Fast Thread Pool.
 *
 * @see org.opendaylight.yangtools.util.concurrent.SpecialExecutors
 * @see org.opendaylight.controller.md.sal.dom.store.benchmark.AbstractInMemoryDatastoreWriteTransactionBenchmark
 *
 * @author Lukas Sedlak <lsedlak@cisco.com>
 */
@State(Scope.Thread)
@BenchmarkMode(Mode.AverageTime)
@OutputTimeUnit(TimeUnit.MILLISECONDS)
@Fork(1)
public class InMemoryDataStoreWithExecutorServiceBenchmark extends AbstractInMemoryDatastoreWriteTransactionBenchmark  {

    private static final int MAX_DATA_CHANGE_EXECUTOR_POOL_SIZE = 20;
    private static final int MAX_DATA_CHANGE_EXECUTOR_QUEUE_SIZE = 1000;
    private static final int MAX_DATA_STORE_EXECUTOR_QUEUE_SIZE = 5000;

    @Setup(Level.Trial)
    public void setUp() throws Exception {
        final String name = "DS_BENCHMARK";
        final ExecutorService dataChangeListenerExecutor = SpecialExecutors.newBlockingBoundedFastThreadPool(
            MAX_DATA_CHANGE_EXECUTOR_POOL_SIZE, MAX_DATA_CHANGE_EXECUTOR_QUEUE_SIZE, name + "-DCL");

        final ExecutorService domStoreExecutor = SpecialExecutors.newBoundedSingleThreadExecutor(
            MAX_DATA_STORE_EXECUTOR_QUEUE_SIZE, "DOMStore-" + name );

        domStore = new InMemoryDOMDataStore(name, domStoreExecutor,
            dataChangeListenerExecutor);
        schemaContext = BenchmarkModel.createTestContext();
        domStore.onGlobalContextUpdated(schemaContext);
        initTestNode();
    }

    @TearDown
    public void tearDown() {
        schemaContext = null;
        domStore = null;
    }
}

@@ -366,16 +366,139 @@
 hmark;%0A%0A
+import com.google.common.util.concurrent.ListeningExecutorService;%0Aimport com.google.common.util.concurrent.MoreExecutors;%0A
 import j
@@ -754,21 +754,29 @@
 tations.
-Level
+BenchmarkMode
 ;%0Aimport
@@ -804,21 +804,20 @@
 tations.
-Setup
+Fork
 ;%0Aimport
@@ -845,24 +845,21 @@
 tations.
-TearDown
+Level
 ;%0Aimport
@@ -879,36 +879,36 @@
 jmh.annotations.
-Fork
+Mode
 ;%0Aimport org.ope
@@ -928,21 +928,30 @@
 tations.
-Scope
+OutputTimeUnit
 ;%0Aimport
@@ -980,19 +980,19 @@
 ations.S
-tat
+cop
 e;%0Aimpor
@@ -1017,37 +1017,29 @@
 annotations.
-BenchmarkMode
+Setup
 ;%0Aimport org
@@ -1055,35 +1055,36 @@
 jmh.annotations.
-Mod
+Stat
 e;%0Aimport org.op
@@ -1105,30 +1105,24 @@
 tations.
-OutputTimeUnit
+TearDown
 ;%0A%0A/**%0A 
@@ -2082,16 +2082,30 @@
  5000;%0A%0A
+    @Override%0A
     @Set
@@ -2425,32 +2425,41 @@
 %0A%0A        final 
+Listening
 ExecutorService 
@@ -2469,32 +2469,65 @@
 StoreExecutor = 
+MoreExecutors.listeningDecorator(
 SpecialExecutors
@@ -2626,16 +2626,17 @@
  + name 
+)
 );%0A%0A    
@@ -2887,16 +2887,30 @@
 %0A    %7D%0A%0A
+    @Override%0A
     @Tea

fix benchmark compilation