diff options
author | Jan Srnicek <jsrnicek@cisco.com> | 2017-10-04 09:55:39 +0200 |
---|---|---|
committer | Jan Srnicek <jsrnicek@cisco.com> | 2017-10-04 07:57:11 +0000 |
commit | d893224d0a3727d66253031ebb892c287df0ed8a (patch) | |
tree | b0c8814a8bc210a59b392d379fe0b34089671001 | |
parent | ca983b9d748fd38e66f854a5d984d216958b1713 (diff) |
HONEYCOMB-401 - Fix compilation issues for benchmark
Change-Id: I93df9e6b65273c82da308a194f4fe6488c6ce5e1
Signed-off-by: Jan Srnicek <jsrnicek@cisco.com>
8 files changed, 72 insertions, 73 deletions
diff --git a/infra/it/benchmark/src/main/java/io/fd/honeycomb/benchmark/data/DataBrokerConfigWriteBenchmark.java b/infra/it/benchmark/src/main/java/io/fd/honeycomb/benchmark/data/DataBrokerConfigWriteBenchmark.java index 6d76ad2d3..d37148936 100644 --- a/infra/it/benchmark/src/main/java/io/fd/honeycomb/benchmark/data/DataBrokerConfigWriteBenchmark.java +++ b/infra/it/benchmark/src/main/java/io/fd/honeycomb/benchmark/data/DataBrokerConfigWriteBenchmark.java @@ -16,27 +16,19 @@ package io.fd.honeycomb.benchmark.data; -import com.google.inject.AbstractModule; -import com.google.inject.Guice; -import com.google.inject.Injector; -import com.google.inject.Key; -import com.google.inject.Module; +import com.google.inject.*; import com.google.inject.multibindings.Multibinder; import com.google.inject.name.Names; import io.fd.honeycomb.benchmark.util.DataProvider; import io.fd.honeycomb.benchmark.util.DataSubmitter; import io.fd.honeycomb.benchmark.util.FileManager; import io.fd.honeycomb.benchmark.util.NoopWriter; +import io.fd.honeycomb.infra.distro.activation.ActivationConfig; +import io.fd.honeycomb.infra.distro.activation.ActiveModules; import io.fd.honeycomb.infra.distro.cfgattrs.HoneycombConfiguration; import io.fd.honeycomb.infra.distro.data.ConfigAndOperationalPipelineModule; import io.fd.honeycomb.translate.write.WriterFactory; import io.fd.honeycomb.translate.write.registry.ModifiableWriterRegistryBuilder; -import java.io.IOException; -import java.nio.file.Paths; -import java.util.ArrayList; -import java.util.List; -import java.util.Optional; -import java.util.concurrent.ExecutionException; import org.opendaylight.controller.md.sal.binding.api.DataBroker; import org.opendaylight.controller.md.sal.binding.api.WriteTransaction; import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; @@ -46,22 +38,20 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.hc.test. import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.hc.test.rev150105.container.with.list.list.in.container.ContainerInList; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.hc.test.rev150105.container.with.list.list.in.container.container.in.list.NestedList; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; -import org.openjdk.jmh.annotations.Benchmark; -import org.openjdk.jmh.annotations.BenchmarkMode; -import org.openjdk.jmh.annotations.Fork; -import org.openjdk.jmh.annotations.Level; -import org.openjdk.jmh.annotations.Measurement; -import org.openjdk.jmh.annotations.Mode; -import org.openjdk.jmh.annotations.Param; +import org.openjdk.jmh.annotations.*; import org.openjdk.jmh.annotations.Scope; -import org.openjdk.jmh.annotations.Setup; -import org.openjdk.jmh.annotations.State; -import org.openjdk.jmh.annotations.TearDown; -import org.openjdk.jmh.annotations.Timeout; -import org.openjdk.jmh.annotations.Warmup; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import java.io.IOException; +import java.nio.file.Paths; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.Optional; +import java.util.concurrent.ExecutionException; +import java.util.stream.Collectors; + /** * Measures the performance of CONFIG writes into BA DataBroker, backed by HC infrastructure and then NOOP writers. */ @@ -162,6 +152,8 @@ public class DataBrokerConfigWriteBenchmark extends AbstractModule implements Fi try { instance = getHoneycombConfiguration(persistence); bind(HoneycombConfiguration.class).toInstance(instance); + bind(ActivationConfig.class).toInstance(getActivationConfig()); + bind(ActiveModules.class).toInstance(new ActiveModules(Arrays.stream(modules).map(Module::getClass).collect(Collectors.toSet()))); } catch (IOException e) { throw new RuntimeException("Unable to prepare configuration", e); } @@ -196,4 +188,10 @@ public class DataBrokerConfigWriteBenchmark extends AbstractModule implements Fi instance.peristContextPath = FileManager.INSTANCE.createTempFile("context").toString(); return instance; } + + private static ActivationConfig getActivationConfig(){ + final ActivationConfig activationConfig = new ActivationConfig(); + activationConfig.yangModulesIndexPath = "yang-mapping"; + return activationConfig; + } } diff --git a/infra/it/benchmark/src/main/java/io/fd/honeycomb/benchmark/data/DataBrokerOperReadBenchmark.java b/infra/it/benchmark/src/main/java/io/fd/honeycomb/benchmark/data/DataBrokerOperReadBenchmark.java index 86ded0f66..bdb398b86 100644 --- a/infra/it/benchmark/src/main/java/io/fd/honeycomb/benchmark/data/DataBrokerOperReadBenchmark.java +++ b/infra/it/benchmark/src/main/java/io/fd/honeycomb/benchmark/data/DataBrokerOperReadBenchmark.java @@ -16,27 +16,19 @@ package io.fd.honeycomb.benchmark.data; -import com.google.inject.AbstractModule; -import com.google.inject.Guice; -import com.google.inject.Injector; -import com.google.inject.Key; -import com.google.inject.Module; +import com.google.inject.*; import com.google.inject.multibindings.Multibinder; import com.google.inject.name.Names; import io.fd.honeycomb.benchmark.util.DataProvider; import io.fd.honeycomb.benchmark.util.FileManager; import io.fd.honeycomb.benchmark.util.StaticReader; +import io.fd.honeycomb.infra.distro.activation.ActivationConfig; +import io.fd.honeycomb.infra.distro.activation.ActiveModules; import io.fd.honeycomb.infra.distro.cfgattrs.HoneycombConfiguration; import io.fd.honeycomb.infra.distro.data.ConfigAndOperationalPipelineModule; import io.fd.honeycomb.translate.read.Reader; import io.fd.honeycomb.translate.read.ReaderFactory; import io.fd.honeycomb.translate.read.registry.ModifiableReaderRegistryBuilder; -import java.io.IOException; -import java.nio.file.Paths; -import java.util.ArrayList; -import java.util.List; -import java.util.Optional; -import java.util.concurrent.ExecutionException; import org.opendaylight.controller.md.sal.binding.api.DataBroker; import org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction; import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; @@ -45,22 +37,20 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.hc.test. import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.hc.test.rev150105.SimpleContainer; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.hc.test.rev150105.container.with.list.ListInContainer; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; -import org.openjdk.jmh.annotations.Benchmark; -import org.openjdk.jmh.annotations.BenchmarkMode; -import org.openjdk.jmh.annotations.Fork; -import org.openjdk.jmh.annotations.Level; -import org.openjdk.jmh.annotations.Measurement; -import org.openjdk.jmh.annotations.Mode; -import org.openjdk.jmh.annotations.Param; +import org.openjdk.jmh.annotations.*; import org.openjdk.jmh.annotations.Scope; -import org.openjdk.jmh.annotations.Setup; -import org.openjdk.jmh.annotations.State; -import org.openjdk.jmh.annotations.TearDown; -import org.openjdk.jmh.annotations.Timeout; -import org.openjdk.jmh.annotations.Warmup; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import java.io.IOException; +import java.nio.file.Paths; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.Optional; +import java.util.concurrent.ExecutionException; +import java.util.stream.Collectors; + /** * Measures the performance of CONFIG writes into BA DataBroker, backed by HC infrastructure and then NOOP writers. */ @@ -142,6 +132,8 @@ public class DataBrokerOperReadBenchmark extends AbstractModule implements FileM try { instance = getHoneycombConfiguration(persistence); bind(HoneycombConfiguration.class).toInstance(instance); + bind(ActivationConfig.class).toInstance(getActivationConfig()); + bind(ActiveModules.class).toInstance(new ActiveModules(Arrays.stream(modules).map(Module::getClass).collect(Collectors.toSet()))); } catch (IOException e) { throw new RuntimeException("Unable to prepare configuration", e); } @@ -189,4 +181,10 @@ public class DataBrokerOperReadBenchmark extends AbstractModule implements FileM instance.peristContextPath = FileManager.INSTANCE.createTempFile("context").toString(); return instance; } + + private static ActivationConfig getActivationConfig(){ + final ActivationConfig activationConfig = new ActivationConfig(); + activationConfig.yangModulesIndexPath = "yang-mapping"; + return activationConfig; + } } diff --git a/infra/it/benchmark/src/main/java/io/fd/honeycomb/benchmark/util/NoopWriter.java b/infra/it/benchmark/src/main/java/io/fd/honeycomb/benchmark/util/NoopWriter.java index f61bd1b5d..c42474754 100644 --- a/infra/it/benchmark/src/main/java/io/fd/honeycomb/benchmark/util/NoopWriter.java +++ b/infra/it/benchmark/src/main/java/io/fd/honeycomb/benchmark/util/NoopWriter.java @@ -19,11 +19,12 @@ package io.fd.honeycomb.benchmark.util; import io.fd.honeycomb.translate.write.WriteContext; import io.fd.honeycomb.translate.write.WriteFailedException; import io.fd.honeycomb.translate.write.Writer; +import org.opendaylight.yangtools.yang.binding.DataObject; +import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; + import javax.annotation.Nonnull; import javax.annotation.Nullable; import javax.annotation.concurrent.NotThreadSafe; -import org.opendaylight.yangtools.yang.binding.DataObject; -import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; /** * Noop writer suitable for lists as well. @@ -39,7 +40,7 @@ public final class NoopWriter<T extends DataObject> implements Writer<T> { } @Override - public void update(@Nonnull final InstanceIdentifier<? extends DataObject> id, + public void processModification(@Nonnull final InstanceIdentifier<? extends DataObject> id, @Nullable final DataObject dataBefore, @Nullable final DataObject dataAfter, @Nonnull final WriteContext ctx) throws WriteFailedException { @@ -60,4 +61,9 @@ public final class NoopWriter<T extends DataObject> implements Writer<T> { ", counter=" + counter + '}'; } + + @Override + public boolean supportsDirectUpdate() { + return true; + } } diff --git a/infra/it/benchmark/src/main/resources/yang-mapping/yang-index b/infra/it/benchmark/src/main/resources/yang-mapping/yang-index new file mode 100644 index 000000000..78acc66c1 --- /dev/null +++ b/infra/it/benchmark/src/main/resources/yang-mapping/yang-index @@ -0,0 +1 @@ +GUICE_MODULE:io.fd.honeycomb.infra.distro.schema.SchemaModule|YANG_MODULES:org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.hc.test.rev150105.$YangModelBindingProvider diff --git a/infra/it/memory-benchmark/src/main/java/io/fd/honeycomb/benchmark/memory/write/NoopWriter.java b/infra/it/memory-benchmark/src/main/java/io/fd/honeycomb/benchmark/memory/write/NoopWriter.java index 000a176df..dafca09a9 100644 --- a/infra/it/memory-benchmark/src/main/java/io/fd/honeycomb/benchmark/memory/write/NoopWriter.java +++ b/infra/it/memory-benchmark/src/main/java/io/fd/honeycomb/benchmark/memory/write/NoopWriter.java @@ -33,13 +33,18 @@ public final class NoopWriter<T extends DataObject> implements Writer<T> { } @Override - public void update(@Nonnull final InstanceIdentifier<? extends DataObject> id, + public void processModification(@Nonnull final InstanceIdentifier<? extends DataObject> id, @Nullable final DataObject dataBefore, @Nullable final DataObject dataAfter, @Nonnull final WriteContext ctx) throws WriteFailedException { // NOOP } + @Override + public boolean supportsDirectUpdate() { + return true; + } + @Nonnull @Override public InstanceIdentifier<T> getManagedDataObjectType() { diff --git a/infra/minimal-distribution-core/src/main/java/io/fd/honeycomb/infra/distro/activation/ActivationConfig.java b/infra/minimal-distribution-core/src/main/java/io/fd/honeycomb/infra/distro/activation/ActivationConfig.java index a17f5d632..ecda4ae72 100644 --- a/infra/minimal-distribution-core/src/main/java/io/fd/honeycomb/infra/distro/activation/ActivationConfig.java +++ b/infra/minimal-distribution-core/src/main/java/io/fd/honeycomb/infra/distro/activation/ActivationConfig.java @@ -16,19 +16,20 @@ package io.fd.honeycomb.infra.distro.activation; -import java.util.Optional; import net.jmob.guice.conf.core.BindConfig; import net.jmob.guice.conf.core.InjectConfig; import net.jmob.guice.conf.core.Syntax; +import java.util.Optional; + @BindConfig(value = "activation", syntax = Syntax.JSON) public class ActivationConfig { @InjectConfig("modules-resource-path") - private String modulesResourcePath; + public String modulesResourcePath; @InjectConfig("yang-modules-index-path") - private String yangModulesIndexPath; + public String yangModulesIndexPath; public String getModulesResourcePath() { return Optional.ofNullable(modulesResourcePath).orElse("../modules/"); diff --git a/infra/minimal-distribution-core/src/main/java/io/fd/honeycomb/infra/distro/activation/ActiveModules.java b/infra/minimal-distribution-core/src/main/java/io/fd/honeycomb/infra/distro/activation/ActiveModules.java index f729f00b9..601e9b686 100644 --- a/infra/minimal-distribution-core/src/main/java/io/fd/honeycomb/infra/distro/activation/ActiveModules.java +++ b/infra/minimal-distribution-core/src/main/java/io/fd/honeycomb/infra/distro/activation/ActiveModules.java @@ -16,12 +16,13 @@ package io.fd.honeycomb.infra.distro.activation; -import static java.lang.String.format; - import com.google.inject.Module; + import java.util.Set; import java.util.stream.Collectors; +import static java.lang.String.format; + /** * Provides static set of active activeModulesClasses */ diff --git a/infra/minimal-distribution-core/src/main/java/io/fd/honeycomb/infra/distro/schema/YangModulesProvider.java b/infra/minimal-distribution-core/src/main/java/io/fd/honeycomb/infra/distro/schema/YangModulesProvider.java index f6d8ea0c1..b60df1ad6 100644 --- a/infra/minimal-distribution-core/src/main/java/io/fd/honeycomb/infra/distro/schema/YangModulesProvider.java +++ b/infra/minimal-distribution-core/src/main/java/io/fd/honeycomb/infra/distro/schema/YangModulesProvider.java @@ -17,21 +17,18 @@ package io.fd.honeycomb.infra.distro.schema; -import static java.lang.String.format; - -import com.google.common.base.Charsets; -import com.google.common.io.Resources; import com.google.inject.Inject; import com.google.inject.Provider; import io.fd.honeycomb.infra.distro.activation.ActivationConfig; import io.fd.honeycomb.infra.distro.activation.ActiveModules; -import java.io.IOException; -import java.net.URL; +import org.opendaylight.yangtools.yang.binding.YangModelBindingProvider; + +import javax.annotation.Nonnull; import java.util.Collection; import java.util.Set; import java.util.stream.Collectors; -import javax.annotation.Nonnull; -import org.opendaylight.yangtools.yang.binding.YangModelBindingProvider; + +import static java.lang.String.format; /** * Loads active yang modules @@ -59,10 +56,10 @@ public class YangModulesProvider implements Provider<YangModulesProvider.YangMod .collect(Collectors.toSet())); } - static class YangModules { + public static class YangModules { private final Set<Class<? extends YangModelBindingProvider>> yangBindings; - YangModules(final Set<Class<? extends YangModelBindingProvider>> yangBindings) { + public YangModules(final Set<Class<? extends YangModelBindingProvider>> yangBindings) { this.yangBindings = yangBindings; } @@ -86,12 +83,4 @@ public class YangModulesProvider implements Provider<YangModulesProvider.YangMod throw new IllegalArgumentException("Unable to load class: " + className, e); } } - - static String urlToString(@Nonnull final URL url) { - try { - return Resources.toString(url, Charsets.UTF_8); - } catch (IOException e) { - throw new IllegalArgumentException("Unable to read resource from: " + url, e); - } - } } |