X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;ds=sidebyside;f=benchmark%2Fntfbenchmark%2Fsrc%2Fmain%2Fjava%2Fntfbenchmark%2Fimpl%2FNtfbenchmarkProvider.java;h=c11f676dafd1cf9412236ea836340d53d9df601a;hb=4eafc030622cc6dc155c452b6c6547eac7b5b616;hp=c36267e4b3bae8663ec67407476983b5ae4aaf85;hpb=4cc30565511b55b07f079930932430c340df0ce5;p=controller.git diff --git a/benchmark/ntfbenchmark/src/main/java/ntfbenchmark/impl/NtfbenchmarkProvider.java b/benchmark/ntfbenchmark/src/main/java/ntfbenchmark/impl/NtfbenchmarkProvider.java index c36267e4b3..c11f676daf 100644 --- a/benchmark/ntfbenchmark/src/main/java/ntfbenchmark/impl/NtfbenchmarkProvider.java +++ b/benchmark/ntfbenchmark/src/main/java/ntfbenchmark/impl/NtfbenchmarkProvider.java @@ -5,26 +5,23 @@ * 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 ntfbenchmark.impl; +import com.google.common.util.concurrent.ListenableFuture; import java.util.ArrayList; import java.util.List; import java.util.concurrent.ExecutionException; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; -import java.util.concurrent.Future; import java.util.concurrent.TimeUnit; - import org.opendaylight.controller.md.sal.binding.api.NotificationPublishService; import org.opendaylight.controller.md.sal.binding.api.NotificationService; -import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ProviderContext; -import org.opendaylight.controller.sal.binding.api.BindingAwareProvider; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ntfbenchmark.rev150105.NtfbenchmarkService; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ntfbenchmark.rev150105.StartTestInput; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ntfbenchmark.rev150105.StartTestInput.ProducerType; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ntfbenchmark.rev150105.StartTestOutput; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ntfbenchmark.rev150105.StartTestOutputBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ntfbenchmark.rev150105.TestStatusInput; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ntfbenchmark.rev150105.TestStatusOutput; import org.opendaylight.yangtools.concepts.ListenerRegistration; import org.opendaylight.yangtools.yang.common.RpcResult; @@ -32,33 +29,31 @@ import org.opendaylight.yangtools.yang.common.RpcResultBuilder; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -public class NtfbenchmarkProvider implements BindingAwareProvider, AutoCloseable, NtfbenchmarkService { - +public class NtfbenchmarkProvider implements AutoCloseable, NtfbenchmarkService { private static final Logger LOG = LoggerFactory.getLogger(NtfbenchmarkProvider.class); - private NotificationService listenService; - private NotificationPublishService publishService; - private static final int testTimeout = 5; + private static final int TEST_TIMEOUT = 5; - public NtfbenchmarkProvider(NotificationService listenServiceDependency, - NotificationPublishService publishServiceDependency) { + private final NotificationService listenService; + private final NotificationPublishService publishService; + + public NtfbenchmarkProvider(final NotificationService listenServiceDependency, + final NotificationPublishService publishServiceDependency) { LOG.debug("NtfbenchmarkProvider Constructor"); listenService = listenServiceDependency; publishService = publishServiceDependency; } - @Override - public void onSessionInitiated(final ProviderContext session) { - LOG.debug("NtfbenchmarkProvider Session Initiated"); - session.addRpcImplementation(NtfbenchmarkService.class, this); + public void init() { + LOG.info("NtfbenchmarkProvider initiated"); } @Override - public void close() throws Exception { - LOG.debug("NtfbenchmarkProvider Closed"); + public void close() { + LOG.info("NtfbenchmarkProvider closed"); } @Override - public Future> startTest(final StartTestInput input) { + public ListenableFuture> startTest(final StartTestInput input) { final int producerCount = input.getProducers().intValue(); final int listenerCount = input.getListeners().intValue(); final int iterations = input.getIterations().intValue(); @@ -92,12 +87,12 @@ public class NtfbenchmarkProvider implements BindingAwareProvider, AutoCloseable } executor.shutdown(); try { - executor.awaitTermination(testTimeout, TimeUnit.MINUTES); + executor.awaitTermination(TEST_TIMEOUT, TimeUnit.MINUTES); for (ListenerRegistration listenerRegistration : listeners) { listenerRegistration.getInstance().getAllDone().get(); } } catch (final InterruptedException | ExecutionException e) { - LOG.error("Out of time: test did not finish within the {} min deadline ", testTimeout); + LOG.error("Out of time: test did not finish within the {} min deadline ", TEST_TIMEOUT); } final long producerEndTime = System.nanoTime(); @@ -128,8 +123,8 @@ public class NtfbenchmarkProvider implements BindingAwareProvider, AutoCloseable .setListenerOk(allListeners) .setProducerOk(allProducersOk) .setProducerError(allProducersError) - .setProducerRate(((allProducersOk + allProducersError) * 1000000000) / producerElapsedTime) - .setListenerRate((allListeners * 1000000000) / listenerElapsedTime) + .setProducerRate((allProducersOk + allProducersError) * 1000000000 / producerElapsedTime) + .setListenerRate(allListeners * 1000000000 / listenerElapsedTime) .build(); return RpcResultBuilder.success(output).buildFuture(); } finally { @@ -140,7 +135,7 @@ public class NtfbenchmarkProvider implements BindingAwareProvider, AutoCloseable } @Override - public Future> testStatus() { + public ListenableFuture> testStatus(final TestStatusInput input) { // TODO Auto-generated method stub return null; }