camel-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Grzegorz Grzybek <gr.grzy...@gmail.com>
Subject Re: [1/3] camel git commit: [CAMEL-11427] Provide camel-leveldb-java feature that uses non-native leveldb library
Date Tue, 27 Jun 2017 06:14:25 GMT
Hello

I changed logging - debug information when implementation is found instead
of warn information when it's not found.

regards
Grzegorz Grzybek

2017-06-20 12:49 GMT+02:00 Claus Ibsen <claus.ibsen@gmail.com>:

> Hi
>
> I think the log.warn you do should be improved a bit, since you will
> get this on first attempt to load the driver and if its not on the
> classpath. So maybe ignore it totally, or change the logging level to
> debug etc.
>
> On Tue, Jun 20, 2017 at 9:51 AM,  <ggrzybek@apache.org> wrote:
> > Repository: camel
> > Updated Branches:
> >   refs/heads/camel-2.18.x 653c8262f -> 2ba4c00ca
> >   refs/heads/camel-2.19.x 3d33970af -> 5e6794310
> >   refs/heads/master 1f8ef53d6 -> 75498ab1e
> >
> >
> > [CAMEL-11427] Provide camel-leveldb-java feature that uses non-native
> leveldb library
> >
> >
> > Project: http://git-wip-us.apache.org/repos/asf/camel/repo
> > Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/75498ab1
> > Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/75498ab1
> > Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/75498ab1
> >
> > Branch: refs/heads/master
> > Commit: 75498ab1ef70bb3694b84647f2e9d23d43268f9b
> > Parents: 1f8ef53
> > Author: Grzegorz Grzybek <gr.grzybek@gmail.com>
> > Authored: Tue Jun 20 09:48:48 2017 +0200
> > Committer: Grzegorz Grzybek <gr.grzybek@gmail.com>
> > Committed: Tue Jun 20 09:48:48 2017 +0200
> >
> > ----------------------------------------------------------------------
> >  components/camel-leveldb/pom.xml                | 12 ++++++++++++
> >  .../leveldb/LevelDBAggregationRepository.java   | 14 ++++++++++++--
> >  .../camel/component/leveldb/LevelDBFile.java    | 20
> ++++++++++++++++++--
> >  parent/pom.xml                                  |  2 ++
> >  .../features/src/main/resources/features.xml    |  7 +++++++
> >  5 files changed, 51 insertions(+), 4 deletions(-)
> > ----------------------------------------------------------------------
> >
> >
> > http://git-wip-us.apache.org/repos/asf/camel/blob/75498ab1/
> components/camel-leveldb/pom.xml
> > ----------------------------------------------------------------------
> > diff --git a/components/camel-leveldb/pom.xml
> b/components/camel-leveldb/pom.xml
> > index 9281c1f..afe82d3 100644
> > --- a/components/camel-leveldb/pom.xml
> > +++ b/components/camel-leveldb/pom.xml
> > @@ -38,6 +38,13 @@
> >          <title>LevelDB</title>
> >
> >          <camel.osgi.export.pkg>org.apache.camel.component.
> leveldb.*</camel.osgi.export.pkg>
> > +        <camel.osgi.import.pkg>
> > +            *,
> > +            org.fusesource.leveldbjni;resolution:=optional,
> > +            org.iq80.leveldb;resolution:=optional,
> > +            org.iq80.leveldb.impl;resolution:=optional
> > +        </camel.osgi.import.pkg>
> > +        <leveldb-version>0.9</leveldb-version>
> >      </properties>
> >
> >      <dependencies>
> > @@ -53,6 +60,11 @@
> >              <version>${leveldbjni-version}</version>
> >          </dependency>
> >          <dependency>
> > +            <groupId>org.iq80.leveldb</groupId>
> > +            <artifactId>leveldb</artifactId>
> > +            <version>${leveldb-version}</version>
> > +        </dependency>
> > +        <dependency>
> >              <groupId>org.fusesource.hawtbuf</groupId>
> >              <artifactId>hawtbuf</artifactId>
> >              <version>${hawtbuf-version}</version>
> >
> > http://git-wip-us.apache.org/repos/asf/camel/blob/75498ab1/
> components/camel-leveldb/src/main/java/org/apache/camel/component/leveldb/
> LevelDBAggregationRepository.java
> > ----------------------------------------------------------------------
> > diff --git a/components/camel-leveldb/src/main/java/org/apache/
> camel/component/leveldb/LevelDBAggregationRepository.java
> b/components/camel-leveldb/src/main/java/org/apache/
> camel/component/leveldb/LevelDBAggregationRepository.java
> > index 2c8bf5d..eea1ad2 100644
> > --- a/components/camel-leveldb/src/main/java/org/apache/
> camel/component/leveldb/LevelDBAggregationRepository.java
> > +++ b/components/camel-leveldb/src/main/java/org/apache/
> camel/component/leveldb/LevelDBAggregationRepository.java
> > @@ -36,8 +36,6 @@ import org.iq80.leveldb.WriteBatch;
> >  import org.slf4j.Logger;
> >  import org.slf4j.LoggerFactory;
> >
> > -import static org.fusesource.leveldbjni.JniDBFactory.asString;
> > -
> >  /**
> >   * An instance of {@link org.apache.camel.spi.AggregationRepository}
> which is backed by a {@link LevelDBFile}.
> >   */
> > @@ -441,4 +439,16 @@ public class LevelDBAggregationRepository extends
> ServiceSupport implements Reco
> >          }
> >      }
> >
> > +    public static String asString(byte[] value) {
> > +        if (value == null) {
> > +            return null;
> > +        } else {
> > +            try {
> > +                return new String(value, "UTF-8");
> > +            } catch (UnsupportedEncodingException var2) {
> > +                throw new RuntimeException(var2);
> > +            }
> > +        }
> > +    }
> > +
> >  }
> >
> > http://git-wip-us.apache.org/repos/asf/camel/blob/75498ab1/
> components/camel-leveldb/src/main/java/org/apache/camel/
> component/leveldb/LevelDBFile.java
> > ----------------------------------------------------------------------
> > diff --git a/components/camel-leveldb/src/main/java/org/apache/
> camel/component/leveldb/LevelDBFile.java b/components/camel-leveldb/
> src/main/java/org/apache/camel/component/leveldb/LevelDBFile.java
> > index 05fbf62..6a86a73 100644
> > --- a/components/camel-leveldb/src/main/java/org/apache/
> camel/component/leveldb/LevelDBFile.java
> > +++ b/components/camel-leveldb/src/main/java/org/apache/
> camel/component/leveldb/LevelDBFile.java
> > @@ -23,13 +23,12 @@ import org.apache.camel.Service;
> >  import org.apache.camel.util.IOHelper;
> >  import org.iq80.leveldb.CompressionType;
> >  import org.iq80.leveldb.DB;
> > +import org.iq80.leveldb.DBFactory;
> >  import org.iq80.leveldb.Options;
> >  import org.iq80.leveldb.WriteOptions;
> >  import org.slf4j.Logger;
> >  import org.slf4j.LoggerFactory;
> >
> > -import static org.fusesource.leveldbjni.JniDBFactory.factory;
> > -
> >  /**
> >   * Manages access to a shared <a href="https://github.com/
> fusesource/leveldbjni/">LevelDB</a> file.
> >   * <p/>
> > @@ -172,12 +171,29 @@ public class LevelDBFile implements Service {
> >          options.createIfMissing(true);
> >          try {
> >              getFile().getParentFile().mkdirs();
> > +            DBFactory factory = getFactory();
> >              db = factory.open(getFile(), options);
> >          } catch (IOException ioe) {
> >              throw new RuntimeException("Error opening LevelDB with file
> " + getFile(), ioe);
> >          }
> >      }
> >
> > +    private DBFactory getFactory() {
> > +        String[] classNames = new String[] {
> > +                "org.fusesource.leveldbjni.JniDBFactory",
> > +                "org.iq80.leveldb.impl.Iq80DBFactory"
> > +        };
> > +        for (String cn : classNames) {
> > +            try {
> > +                Class<?> clz = getClass().getClassLoader().
> loadClass(cn);
> > +                return (DBFactory) clz.newInstance();
> > +            } catch (Exception e) {
> > +                LOG.warn(e.getMessage(), e);
> > +            }
> > +        }
> > +        throw new IllegalStateException("Can't find implementation of
> org.iq80.leveldb.DBFactory");
> > +    }
> > +
> >      public void stop() {
> >          File file = getFile();
> >
> >
> > http://git-wip-us.apache.org/repos/asf/camel/blob/75498ab1/
> parent/pom.xml
> > ----------------------------------------------------------------------
> > diff --git a/parent/pom.xml b/parent/pom.xml
> > index a2196c7..f85c43f 100644
> > --- a/parent/pom.xml
> > +++ b/parent/pom.xml
> > @@ -427,6 +427,8 @@
> >      <kubernetes-model-version>1.0.74</kubernetes-model-version>
> >      <kxml2-bundle-version>2.3.0_3</kxml2-bundle-version>
> >      <leveldbjni-version>1.8</leveldbjni-version>
> > +    <leveldb-api-version>0.9</leveldb-api-version>
> > +    <leveldb-version>0.9</leveldb-version>
> >      <libphonenumber-version>8.5.0</libphonenumber-version>
> >      <libphonenumber-bundle-version>8.5.0_1</
> libphonenumber-bundle-version>
> >      <!-- virtual dependency only used by Eclipse m2e -->
> >
> > http://git-wip-us.apache.org/repos/asf/camel/blob/75498ab1/
> platforms/karaf/features/src/main/resources/features.xml
> > ----------------------------------------------------------------------
> > diff --git a/platforms/karaf/features/src/main/resources/features.xml
> b/platforms/karaf/features/src/main/resources/features.xml
> > index d7c7064..fcb9ee8 100644
> > --- a/platforms/karaf/features/src/main/resources/features.xml
> > +++ b/platforms/karaf/features/src/main/resources/features.xml
> > @@ -1270,6 +1270,13 @@
> >      <bundle dependency='true'>mvn:org.fusesource.hawtbuf/hawtbuf/${
> hawtbuf-version}</bundle>
> >      <bundle>mvn:org.apache.camel/camel-leveldb/${project.
> version}</bundle>
> >    </feature>
> > +  <feature name='camel-leveldb-java' version='${project.version}'
> resolver='(obr)' start-level='50'>
> > +    <feature version='${project.version}'>camel-core</feature>
> > +    <bundle dependency='true'>wrap:mvn:org.iq80.leveldb/leveldb-api/$
> {leveldb-api-version}$Bundle-Version=${leveldb-api-version}
> &amp;Export-Package=*;-noimport:=true;version="${
> leveldb-api-version}"</bundle>
> > +    <bundle dependency='true'>wrap:mvn:org.iq80.leveldb/leveldb/${
> leveldb-version}$Bundle-Version=${leveldb-version}&amp;Export-Package=*;-
> noimport:=true;version="${leveldb-version}"</bundle>
> > +    <bundle dependency='true'>mvn:org.fusesource.hawtbuf/hawtbuf/${
> hawtbuf-version}</bundle>
> > +    <bundle>mvn:org.apache.camel/camel-leveldb/${project.
> version}</bundle>
> > +  </feature>
> >    <feature name='camel-lucene' version='${project.version}'
> resolver='(obr)' start-level='50'>
> >      <feature version='${project.version}'>camel-core</feature>
> >      <bundle dependency='true'>mvn:org.apache.servicemix.bundles/org.
> apache.servicemix.bundles.lucene/${lucene-bundle-version}</bundle>
> >
>
>
>
> --
> Claus Ibsen
> -----------------
> http://davsclaus.com @davsclaus
> Camel in Action 2: https://www.manning.com/ibsen2
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message