You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@sirona.apache.org by Romain Manni-Bucau <rm...@gmail.com> on 2014/03/11 13:15:48 UTC

Fwd: svn commit: r1576301 - in /incubator/sirona/trunk/agent/store/cube: ./ src/main/java/org/apache/sirona/cube/

Hehe

I guess that's for me ;)

We can make it madatory if shaded if ut brings a better connectuon handling
---------- Message transféré ----------
De : <ol...@apache.org>
Date : 11 mars 2014 13:03
Objet : svn commit: r1576301 - in /incubator/sirona/trunk/agent/store/cube:
./ src/main/java/org/apache/sirona/cube/
À : <co...@sirona.incubator.apache.org>

Author: olamy
Date: Tue Mar 11 12:03:12 2014
New Revision: 1576301

URL: http://svn.apache.org/r1576301
Log:
start a cube collector using httpclient (dependency optional and not the
default one!! :P )

Added:

incubator/sirona/trunk/agent/store/cube/src/main/java/org/apache/sirona/cube/HttpClientCube.java
  (with props)

incubator/sirona/trunk/agent/store/cube/src/main/java/org/apache/sirona/cube/HttpClientCubeBuilder.java
  (with props)
Modified:
    incubator/sirona/trunk/agent/store/cube/pom.xml

incubator/sirona/trunk/agent/store/cube/src/main/java/org/apache/sirona/cube/Cube.java

incubator/sirona/trunk/agent/store/cube/src/main/java/org/apache/sirona/cube/CubeBuilder.java

incubator/sirona/trunk/agent/store/cube/src/main/java/org/apache/sirona/cube/CubePathTrackingDataStore.java

incubator/sirona/trunk/agent/store/cube/src/main/java/org/apache/sirona/cube/DisruptorPathTrackingDataStore.java

Modified: incubator/sirona/trunk/agent/store/cube/pom.xml
URL:
http://svn.apache.org/viewvc/incubator/sirona/trunk/agent/store/cube/pom.xml?rev=1576301&r1=1576300&r2=1576301&view=diff
==============================================================================
--- incubator/sirona/trunk/agent/store/cube/pom.xml (original)
+++ incubator/sirona/trunk/agent/store/cube/pom.xml Tue Mar 11 12:03:12 2014
@@ -43,6 +43,13 @@
     </dependency>

     <dependency>
+      <groupId>org.apache.httpcomponents</groupId>
+      <artifactId>httpclient</artifactId>
+      <version>4.3.3</version>
+      <optional>true</optional>
+    </dependency>
+
+    <dependency>
       <groupId>junit</groupId>
       <artifactId>junit</artifactId>
     </dependency>
@@ -94,6 +101,14 @@
                   <pattern>com.lmax</pattern>
                   <shadedPattern>org.apache.sirona.com.lmax</shadedPattern>
                 </relocation>
+                <relocation>
+                  <pattern>org.apache.http</pattern>
+
 <shadedPattern>org.apache.sirona.org.apache.http</shadedPattern>
+                </relocation>
+                <relocation>
+                  <pattern>org.apache.commons</pattern>
+
 <shadedPattern>org.apache.sirona.org.apache.commons</shadedPattern>
+                </relocation>
                 <!--
                 <relocation>
                   <pattern>org.apache.sirona</pattern>

Modified:
incubator/sirona/trunk/agent/store/cube/src/main/java/org/apache/sirona/cube/Cube.java
URL:
http://svn.apache.org/viewvc/incubator/sirona/trunk/agent/store/cube/src/main/java/org/apache/sirona/cube/Cube.java?rev=1576301&r1=1576300&r2=1576301&view=diff
==============================================================================
---
incubator/sirona/trunk/agent/store/cube/src/main/java/org/apache/sirona/cube/Cube.java
(original)
+++
incubator/sirona/trunk/agent/store/cube/src/main/java/org/apache/sirona/cube/Cube.java
Tue Mar 11 12:03:12 2014
@@ -81,14 +81,14 @@ public class Cube {
         "\"data\": %s" +
         "}";

-    private static final String POST = "POST";
-    private static final String CONTENT_TYPE = "Content-Type";
-    private static final String APPLICATION_JSON = "application/json";
-    private static final String CONTENT_LENGTH = "Content-Length";
-    private static final String GZIP_CONTENT_ENCODING = "gzip";
-    private static final String CONTENT_ENCODING = "Content-Encoding";
-    private static final String APPLICATION_JAVA_OBJECT =
"application/x-java-serialized-object";
-    private static final String X_SIRONA_CLASSNAME = "X-Sirona-ClassName";
+    protected static final String POST = "POST";
+    protected static final String CONTENT_TYPE = "Content-Type";
+    protected static final String APPLICATION_JSON = "application/json";
+    protected static final String CONTENT_LENGTH = "Content-Length";
+    protected static final String GZIP_CONTENT_ENCODING = "gzip";
+    protected static final String CONTENT_ENCODING = "Content-Encoding";
+    protected static final String APPLICATION_JAVA_OBJECT =
"application/x-java-serialized-object";
+    protected static final String X_SIRONA_CLASSNAME =
"X-Sirona-ClassName";

     private static final String JS_ISO_FORMAT = "yyyy-MM-dd'T'HH:mm:ss'Z'";
     private static final String UTC = "UTC";
@@ -132,7 +132,7 @@ public class Cube {
         }
     }

-    public void postBytes(byte[] bytes, String className)
+    public void doPostBytes( byte[] bytes, String className )
     {
         try {
             final URL url = new URL(config.getCollector());
@@ -184,7 +184,7 @@ public class Cube {
         }
     }

-    private void doPost(final String payload) {
+    protected void doPost(final String payload) {
         try {
             final URL url = new URL(config.getCollector());

@@ -403,5 +403,8 @@ public class Cube {
         return events;
     }

-
+    protected CubeBuilder getConfig()
+    {
+        return config;
+    }
 }

Modified:
incubator/sirona/trunk/agent/store/cube/src/main/java/org/apache/sirona/cube/CubeBuilder.java
URL:
http://svn.apache.org/viewvc/incubator/sirona/trunk/agent/store/cube/src/main/java/org/apache/sirona/cube/CubeBuilder.java?rev=1576301&r1=1576300&r2=1576301&view=diff
==============================================================================
---
incubator/sirona/trunk/agent/store/cube/src/main/java/org/apache/sirona/cube/CubeBuilder.java
(original)
+++
incubator/sirona/trunk/agent/store/cube/src/main/java/org/apache/sirona/cube/CubeBuilder.java
Tue Mar 11 12:03:12 2014
@@ -129,7 +129,7 @@ public class CubeBuilder {
         this.postTimeout = postTimeout;
     }

-    private TrustManager[] createTrustManager() {
+    protected TrustManager[] createTrustManager() {
         if (sslTrustStore == null) {
             return null;
         }
@@ -156,7 +156,7 @@ public class CubeBuilder {
         }
     }

-    private KeyManager[] createKeyManager() {
+    protected KeyManager[] createKeyManager() {
         if (sslKeyStore == null) {
             return null;
         }
@@ -183,6 +183,46 @@ public class CubeBuilder {
         }
     }

+    public String getSslTrustStore()
+    {
+        return sslTrustStore;
+    }
+
+    public String getSslTrustStoreType()
+    {
+        return sslTrustStoreType;
+    }
+
+    public String getSslTrustStorePassword()
+    {
+        return sslTrustStorePassword;
+    }
+
+    public String getSslTrustStoreProvider()
+    {
+        return sslTrustStoreProvider;
+    }
+
+    public String getSslKeyStore()
+    {
+        return sslKeyStore;
+    }
+
+    public String getSslKeyStoreType()
+    {
+        return sslKeyStoreType;
+    }
+
+    public String getSslKeyStorePassword()
+    {
+        return sslKeyStorePassword;
+    }
+
+    public String getSslKeyStoreProvider()
+    {
+        return sslKeyStoreProvider;
+    }
+
     @Override
     public String toString() {
         return "CubeBuilder{" + collector + '}';

Modified:
incubator/sirona/trunk/agent/store/cube/src/main/java/org/apache/sirona/cube/CubePathTrackingDataStore.java
URL:
http://svn.apache.org/viewvc/incubator/sirona/trunk/agent/store/cube/src/main/java/org/apache/sirona/cube/CubePathTrackingDataStore.java?rev=1576301&r1=1576300&r2=1576301&view=diff
==============================================================================
---
incubator/sirona/trunk/agent/store/cube/src/main/java/org/apache/sirona/cube/CubePathTrackingDataStore.java
(original)
+++
incubator/sirona/trunk/agent/store/cube/src/main/java/org/apache/sirona/cube/CubePathTrackingDataStore.java
Tue Mar 11 12:03:12 2014
@@ -65,7 +65,7 @@ public class CubePathTrackingDataStore
     @Override
     public void store( final PathTrackingEntry pathTrackingEntry )
     {
-        CUBE.postBytes( SerializeUtils.serialize( pathTrackingEntry ),
PathTrackingEntry.class.getName() );
+        CUBE.doPostBytes( SerializeUtils.serialize( pathTrackingEntry ),
PathTrackingEntry.class.getName() );
     }

     @Override
@@ -80,7 +80,7 @@ public class CubePathTrackingDataStore
                 {
                     if ( !pointer.isFree() )
                     {
-                        CUBE.postBytes( readBytes( pointer ),
PathTrackingEntry.class.getName() );
+                        CUBE.doPostBytes( readBytes( pointer ),
PathTrackingEntry.class.getName() );
                         pointer.freeMemory();
                     }
                 }

Modified:
incubator/sirona/trunk/agent/store/cube/src/main/java/org/apache/sirona/cube/DisruptorPathTrackingDataStore.java
URL:
http://svn.apache.org/viewvc/incubator/sirona/trunk/agent/store/cube/src/main/java/org/apache/sirona/cube/DisruptorPathTrackingDataStore.java?rev=1576301&r1=1576300&r2=1576301&view=diff
==============================================================================
---
incubator/sirona/trunk/agent/store/cube/src/main/java/org/apache/sirona/cube/DisruptorPathTrackingDataStore.java
(original)
+++
incubator/sirona/trunk/agent/store/cube/src/main/java/org/apache/sirona/cube/DisruptorPathTrackingDataStore.java
Tue Mar 11 12:03:12 2014
@@ -89,7 +89,7 @@ public class DisruptorPathTrackingDataSt
             public void onEvent( final PathTrackingEntry entry, final long
sequence, final boolean endOfBatch )
                 throws Exception
             {
-                CUBE.postBytes( SerializeUtils.serialize( entry ),
PathTrackingEntry.class.getName() );
+                CUBE.doPostBytes( SerializeUtils.serialize( entry ),
PathTrackingEntry.class.getName() );
             }
         };

@@ -131,7 +131,7 @@ public class DisruptorPathTrackingDataSt
                 {
                     if ( !pointer.isFree() )
                     {
-                        CUBE.postBytes( readBytes( pointer ),
PathTrackingEntry.class.getName() );
+                        CUBE.doPostBytes( readBytes( pointer ),
PathTrackingEntry.class.getName() );
                         pointer.freeMemory();
                     }
                 }

Added:
incubator/sirona/trunk/agent/store/cube/src/main/java/org/apache/sirona/cube/HttpClientCube.java
URL:
http://svn.apache.org/viewvc/incubator/sirona/trunk/agent/store/cube/src/main/java/org/apache/sirona/cube/HttpClientCube.java?rev=1576301&view=auto
==============================================================================
---
incubator/sirona/trunk/agent/store/cube/src/main/java/org/apache/sirona/cube/HttpClientCube.java
(added)
+++
incubator/sirona/trunk/agent/store/cube/src/main/java/org/apache/sirona/cube/HttpClientCube.java
Tue Mar 11 12:03:12 2014
@@ -0,0 +1,101 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.sirona.cube;
+
+import org.apache.http.client.HttpClient;
+import org.apache.http.client.methods.HttpPost;
+import org.apache.http.conn.ssl.SSLContexts;
+import org.apache.http.entity.ByteArrayEntity;
+import org.apache.http.impl.client.HttpClientBuilder;
+import org.apache.http.impl.client.HttpClients;
+import org.apache.http.impl.conn.PoolingHttpClientConnectionManager;
+
+import java.io.IOException;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+/**
+ * @author Olivier Lamy
+ */
+public class HttpClientCube
+    extends Cube
+{
+
+    private static final Logger LOGGER =
Logger.getLogger(HttpClientCube.class.getName());
+
+    private HttpClient httpclient;
+
+    public HttpClientCube( CubeBuilder cubeBuilder )
+    {
+        super( cubeBuilder );
+        try
+        {
+            HttpClientBuilder builder = HttpClientBuilder.create();
+
+            PoolingHttpClientConnectionManager connectionManager = new
PoolingHttpClientConnectionManager();
+
+            builder.setConnectionManager( connectionManager );
+
+            httpclient = builder.build();
+
+
+        }
+        catch ( Exception e )
+        {
+            e.printStackTrace();
+        }
+    }
+
+
+    @Override
+    public void doPostBytes( final byte[] bytes, final String className )
+    {
+
+        try
+        {
+            final URI uri = new URI(getConfig().getCollector());
+
+            HttpPost httpPost = new HttpPost( uri );
+            httpPost.setEntity( new ByteArrayEntity( bytes ) );
+            httpPost.setHeader( CONTENT_TYPE, APPLICATION_JAVA_OBJECT );
+            httpPost.setHeader( X_SIRONA_CLASSNAME, className );
+
+            httpclient.execute( httpPost );
+        }
+        catch ( URISyntaxException e )
+        {
+            if (LOGGER.isLoggable( Level.FINE ) )
+            {
+                LOGGER.log(Level.FINE, "Can't post data to collector:" +
e.getMessage(),e);
+            } else
+            {
+                LOGGER.log( Level.WARNING, "Can't post data to collector:
" + e.getMessage() );
+            }
+        } catch ( IOException e)
+        {
+            if (LOGGER.isLoggable( Level.FINE ) )
+            {
+                LOGGER.log(Level.FINE, "Can't post data to collector:" +
e.getMessage(),e);
+            } else
+            {
+                LOGGER.log( Level.WARNING, "Can't post data to collector:
" + e.getMessage() );
+            }
+        }
+    }
+}

Propchange:
incubator/sirona/trunk/agent/store/cube/src/main/java/org/apache/sirona/cube/HttpClientCube.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange:
incubator/sirona/trunk/agent/store/cube/src/main/java/org/apache/sirona/cube/HttpClientCube.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Added:
incubator/sirona/trunk/agent/store/cube/src/main/java/org/apache/sirona/cube/HttpClientCubeBuilder.java
URL:
http://svn.apache.org/viewvc/incubator/sirona/trunk/agent/store/cube/src/main/java/org/apache/sirona/cube/HttpClientCubeBuilder.java?rev=1576301&view=auto
==============================================================================
---
incubator/sirona/trunk/agent/store/cube/src/main/java/org/apache/sirona/cube/HttpClientCubeBuilder.java
(added)
+++
incubator/sirona/trunk/agent/store/cube/src/main/java/org/apache/sirona/cube/HttpClientCubeBuilder.java
Tue Mar 11 12:03:12 2014
@@ -0,0 +1,33 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.sirona.cube;
+
+import org.apache.sirona.configuration.ioc.AutoSet;
+
+/**
+ * @author Olivier Lamy
+ */
+@AutoSet
+public class HttpClientCubeBuilder
+    extends CubeBuilder
+{
+    @Override
+    public synchronized Cube build()
+    {
+        return new HttpClientCube( this );
+    }
+}

Propchange:
incubator/sirona/trunk/agent/store/cube/src/main/java/org/apache/sirona/cube/HttpClientCubeBuilder.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange:
incubator/sirona/trunk/agent/store/cube/src/main/java/org/apache/sirona/cube/HttpClientCubeBuilder.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Re: svn commit: r1576301 - in /incubator/sirona/trunk/agent/store/cube: ./ src/main/java/org/apache/sirona/cube/

Posted by Romain Manni-Bucau <rm...@gmail.com>.
So go for it but ensure whatever the way it is deployed it will not
conflict with apps (so shade relocation)
Le 11 mars 2014 23:17, "Olivier Lamy" <ol...@apache.org> a écrit :

> On 11 March 2014 23:15, Romain Manni-Bucau <rm...@gmail.com> wrote:
>
> > Hehe
> >
> > I guess that's for me ;)
> >
> > We can make it madatory if shaded if ut brings a better connectuon
> handling
> >
>
> I will do more testing today but the connection handling is the main reason
> I want to use that rather than the pure jdk api.
>
>
> > ---------- Message transféré ----------
> > De : <ol...@apache.org>
> > Date : 11 mars 2014 13:03
> > Objet : svn commit: r1576301 - in
> /incubator/sirona/trunk/agent/store/cube:
> > ./ src/main/java/org/apache/sirona/cube/
> > À : <co...@sirona.incubator.apache.org>
> >
> > Author: olamy
> > Date: Tue Mar 11 12:03:12 2014
> > New Revision: 1576301
> >
> > URL: http://svn.apache.org/r1576301
> > Log:
> > start a cube collector using httpclient (dependency optional and not the
> > default one!! :P )
> >
> > Added:
> >
> >
> >
> incubator/sirona/trunk/agent/store/cube/src/main/java/org/apache/sirona/cube/HttpClientCube.java
> >   (with props)
> >
> >
> >
> incubator/sirona/trunk/agent/store/cube/src/main/java/org/apache/sirona/cube/HttpClientCubeBuilder.java
> >   (with props)
> > Modified:
> >     incubator/sirona/trunk/agent/store/cube/pom.xml
> >
> >
> >
> incubator/sirona/trunk/agent/store/cube/src/main/java/org/apache/sirona/cube/Cube.java
> >
> >
> >
> incubator/sirona/trunk/agent/store/cube/src/main/java/org/apache/sirona/cube/CubeBuilder.java
> >
> >
> >
> incubator/sirona/trunk/agent/store/cube/src/main/java/org/apache/sirona/cube/CubePathTrackingDataStore.java
> >
> >
> >
> incubator/sirona/trunk/agent/store/cube/src/main/java/org/apache/sirona/cube/DisruptorPathTrackingDataStore.java
> >
> > Modified: incubator/sirona/trunk/agent/store/cube/pom.xml
> > URL:
> >
> >
> http://svn.apache.org/viewvc/incubator/sirona/trunk/agent/store/cube/pom.xml?rev=1576301&r1=1576300&r2=1576301&view=diff
> >
> >
> ==============================================================================
> > --- incubator/sirona/trunk/agent/store/cube/pom.xml (original)
> > +++ incubator/sirona/trunk/agent/store/cube/pom.xml Tue Mar 11 12:03:12
> > 2014
> > @@ -43,6 +43,13 @@
> >      </dependency>
> >
> >      <dependency>
> > +      <groupId>org.apache.httpcomponents</groupId>
> > +      <artifactId>httpclient</artifactId>
> > +      <version>4.3.3</version>
> > +      <optional>true</optional>
> > +    </dependency>
> > +
> > +    <dependency>
> >        <groupId>junit</groupId>
> >        <artifactId>junit</artifactId>
> >      </dependency>
> > @@ -94,6 +101,14 @@
> >                    <pattern>com.lmax</pattern>
> >
> >  <shadedPattern>org.apache.sirona.com.lmax</shadedPattern>
> >                  </relocation>
> > +                <relocation>
> > +                  <pattern>org.apache.http</pattern>
> > +
> >  <shadedPattern>org.apache.sirona.org.apache.http</shadedPattern>
> > +                </relocation>
> > +                <relocation>
> > +                  <pattern>org.apache.commons</pattern>
> > +
> >  <shadedPattern>org.apache.sirona.org.apache.commons</shadedPattern>
> > +                </relocation>
> >                  <!--
> >                  <relocation>
> >                    <pattern>org.apache.sirona</pattern>
> >
> > Modified:
> >
> >
> incubator/sirona/trunk/agent/store/cube/src/main/java/org/apache/sirona/cube/Cube.java
> > URL:
> >
> >
> http://svn.apache.org/viewvc/incubator/sirona/trunk/agent/store/cube/src/main/java/org/apache/sirona/cube/Cube.java?rev=1576301&r1=1576300&r2=1576301&view=diff
> >
> >
> ==============================================================================
> > ---
> >
> >
> incubator/sirona/trunk/agent/store/cube/src/main/java/org/apache/sirona/cube/Cube.java
> > (original)
> > +++
> >
> >
> incubator/sirona/trunk/agent/store/cube/src/main/java/org/apache/sirona/cube/Cube.java
> > Tue Mar 11 12:03:12 2014
> > @@ -81,14 +81,14 @@ public class Cube {
> >          "\"data\": %s" +
> >          "}";
> >
> > -    private static final String POST = "POST";
> > -    private static final String CONTENT_TYPE = "Content-Type";
> > -    private static final String APPLICATION_JSON = "application/json";
> > -    private static final String CONTENT_LENGTH = "Content-Length";
> > -    private static final String GZIP_CONTENT_ENCODING = "gzip";
> > -    private static final String CONTENT_ENCODING = "Content-Encoding";
> > -    private static final String APPLICATION_JAVA_OBJECT =
> > "application/x-java-serialized-object";
> > -    private static final String X_SIRONA_CLASSNAME =
> "X-Sirona-ClassName";
> > +    protected static final String POST = "POST";
> > +    protected static final String CONTENT_TYPE = "Content-Type";
> > +    protected static final String APPLICATION_JSON = "application/json";
> > +    protected static final String CONTENT_LENGTH = "Content-Length";
> > +    protected static final String GZIP_CONTENT_ENCODING = "gzip";
> > +    protected static final String CONTENT_ENCODING = "Content-Encoding";
> > +    protected static final String APPLICATION_JAVA_OBJECT =
> > "application/x-java-serialized-object";
> > +    protected static final String X_SIRONA_CLASSNAME =
> > "X-Sirona-ClassName";
> >
> >      private static final String JS_ISO_FORMAT =
> > "yyyy-MM-dd'T'HH:mm:ss'Z'";
> >      private static final String UTC = "UTC";
> > @@ -132,7 +132,7 @@ public class Cube {
> >          }
> >      }
> >
> > -    public void postBytes(byte[] bytes, String className)
> > +    public void doPostBytes( byte[] bytes, String className )
> >      {
> >          try {
> >              final URL url = new URL(config.getCollector());
> > @@ -184,7 +184,7 @@ public class Cube {
> >          }
> >      }
> >
> > -    private void doPost(final String payload) {
> > +    protected void doPost(final String payload) {
> >          try {
> >              final URL url = new URL(config.getCollector());
> >
> > @@ -403,5 +403,8 @@ public class Cube {
> >          return events;
> >      }
> >
> > -
> > +    protected CubeBuilder getConfig()
> > +    {
> > +        return config;
> > +    }
> >  }
> >
> > Modified:
> >
> >
> incubator/sirona/trunk/agent/store/cube/src/main/java/org/apache/sirona/cube/CubeBuilder.java
> > URL:
> >
> >
> http://svn.apache.org/viewvc/incubator/sirona/trunk/agent/store/cube/src/main/java/org/apache/sirona/cube/CubeBuilder.java?rev=1576301&r1=1576300&r2=1576301&view=diff
> >
> >
> ==============================================================================
> > ---
> >
> >
> incubator/sirona/trunk/agent/store/cube/src/main/java/org/apache/sirona/cube/CubeBuilder.java
> > (original)
> > +++
> >
> >
> incubator/sirona/trunk/agent/store/cube/src/main/java/org/apache/sirona/cube/CubeBuilder.java
> > Tue Mar 11 12:03:12 2014
> > @@ -129,7 +129,7 @@ public class CubeBuilder {
> >          this.postTimeout = postTimeout;
> >      }
> >
> > -    private TrustManager[] createTrustManager() {
> > +    protected TrustManager[] createTrustManager() {
> >          if (sslTrustStore == null) {
> >              return null;
> >          }
> > @@ -156,7 +156,7 @@ public class CubeBuilder {
> >          }
> >      }
> >
> > -    private KeyManager[] createKeyManager() {
> > +    protected KeyManager[] createKeyManager() {
> >          if (sslKeyStore == null) {
> >              return null;
> >          }
> > @@ -183,6 +183,46 @@ public class CubeBuilder {
> >          }
> >      }
> >
> > +    public String getSslTrustStore()
> > +    {
> > +        return sslTrustStore;
> > +    }
> > +
> > +    public String getSslTrustStoreType()
> > +    {
> > +        return sslTrustStoreType;
> > +    }
> > +
> > +    public String getSslTrustStorePassword()
> > +    {
> > +        return sslTrustStorePassword;
> > +    }
> > +
> > +    public String getSslTrustStoreProvider()
> > +    {
> > +        return sslTrustStoreProvider;
> > +    }
> > +
> > +    public String getSslKeyStore()
> > +    {
> > +        return sslKeyStore;
> > +    }
> > +
> > +    public String getSslKeyStoreType()
> > +    {
> > +        return sslKeyStoreType;
> > +    }
> > +
> > +    public String getSslKeyStorePassword()
> > +    {
> > +        return sslKeyStorePassword;
> > +    }
> > +
> > +    public String getSslKeyStoreProvider()
> > +    {
> > +        return sslKeyStoreProvider;
> > +    }
> > +
> >      @Override
> >      public String toString() {
> >          return "CubeBuilder{" + collector + '}';
> >
> > Modified:
> >
> >
> incubator/sirona/trunk/agent/store/cube/src/main/java/org/apache/sirona/cube/CubePathTrackingDataStore.java
> > URL:
> >
> >
> http://svn.apache.org/viewvc/incubator/sirona/trunk/agent/store/cube/src/main/java/org/apache/sirona/cube/CubePathTrackingDataStore.java?rev=1576301&r1=1576300&r2=1576301&view=diff
> >
> >
> ==============================================================================
> > ---
> >
> >
> incubator/sirona/trunk/agent/store/cube/src/main/java/org/apache/sirona/cube/CubePathTrackingDataStore.java
> > (original)
> > +++
> >
> >
> incubator/sirona/trunk/agent/store/cube/src/main/java/org/apache/sirona/cube/CubePathTrackingDataStore.java
> > Tue Mar 11 12:03:12 2014
> > @@ -65,7 +65,7 @@ public class CubePathTrackingDataStore
> >      @Override
> >      public void store( final PathTrackingEntry pathTrackingEntry )
> >      {
> > -        CUBE.postBytes( SerializeUtils.serialize( pathTrackingEntry ),
> > PathTrackingEntry.class.getName() );
> > +        CUBE.doPostBytes( SerializeUtils.serialize( pathTrackingEntry ),
> > PathTrackingEntry.class.getName() );
> >      }
> >
> >      @Override
> > @@ -80,7 +80,7 @@ public class CubePathTrackingDataStore
> >                  {
> >                      if ( !pointer.isFree() )
> >                      {
> > -                        CUBE.postBytes( readBytes( pointer ),
> > PathTrackingEntry.class.getName() );
> > +                        CUBE.doPostBytes( readBytes( pointer ),
> > PathTrackingEntry.class.getName() );
> >                          pointer.freeMemory();
> >                      }
> >                  }
> >
> > Modified:
> >
> >
> incubator/sirona/trunk/agent/store/cube/src/main/java/org/apache/sirona/cube/DisruptorPathTrackingDataStore.java
> > URL:
> >
> >
> http://svn.apache.org/viewvc/incubator/sirona/trunk/agent/store/cube/src/main/java/org/apache/sirona/cube/DisruptorPathTrackingDataStore.java?rev=1576301&r1=1576300&r2=1576301&view=diff
> >
> >
> ==============================================================================
> > ---
> >
> >
> incubator/sirona/trunk/agent/store/cube/src/main/java/org/apache/sirona/cube/DisruptorPathTrackingDataStore.java
> > (original)
> > +++
> >
> >
> incubator/sirona/trunk/agent/store/cube/src/main/java/org/apache/sirona/cube/DisruptorPathTrackingDataStore.java
> > Tue Mar 11 12:03:12 2014
> > @@ -89,7 +89,7 @@ public class DisruptorPathTrackingDataSt
> >              public void onEvent( final PathTrackingEntry entry, final
> long
> > sequence, final boolean endOfBatch )
> >                  throws Exception
> >              {
> > -                CUBE.postBytes( SerializeUtils.serialize( entry ),
> > PathTrackingEntry.class.getName() );
> > +                CUBE.doPostBytes( SerializeUtils.serialize( entry ),
> > PathTrackingEntry.class.getName() );
> >              }
> >          };
> >
> > @@ -131,7 +131,7 @@ public class DisruptorPathTrackingDataSt
> >                  {
> >                      if ( !pointer.isFree() )
> >                      {
> > -                        CUBE.postBytes( readBytes( pointer ),
> > PathTrackingEntry.class.getName() );
> > +                        CUBE.doPostBytes( readBytes( pointer ),
> > PathTrackingEntry.class.getName() );
> >                          pointer.freeMemory();
> >                      }
> >                  }
> >
> > Added:
> >
> >
> incubator/sirona/trunk/agent/store/cube/src/main/java/org/apache/sirona/cube/HttpClientCube.java
> > URL:
> >
> >
> http://svn.apache.org/viewvc/incubator/sirona/trunk/agent/store/cube/src/main/java/org/apache/sirona/cube/HttpClientCube.java?rev=1576301&view=auto
> >
> >
> ==============================================================================
> > ---
> >
> >
> incubator/sirona/trunk/agent/store/cube/src/main/java/org/apache/sirona/cube/HttpClientCube.java
> > (added)
> > +++
> >
> >
> incubator/sirona/trunk/agent/store/cube/src/main/java/org/apache/sirona/cube/HttpClientCube.java
> > Tue Mar 11 12:03:12 2014
> > @@ -0,0 +1,101 @@
> > +/*
> > + * Licensed to the Apache Software Foundation (ASF) under one or more
> > + * contributor license agreements.  See the NOTICE file distributed with
> > + * this work for additional information regarding copyright ownership.
> > + * The ASF licenses this file to You under the Apache License, Version
> 2.0
> > + * (the "License"); you may not use this file except in compliance with
> > + * the License.  You may obtain a copy of the License at
> > + *
> > + *      http://www.apache.org/licenses/LICENSE-2.0
> > + *
> > + * Unless required by applicable law or agreed to in writing, software
> > + * distributed under the License is distributed on an "AS IS" BASIS,
> > + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
> > implied.
> > + * See the License for the specific language governing permissions and
> > + * limitations under the License.
> > + */
> > +package org.apache.sirona.cube;
> > +
> > +import org.apache.http.client.HttpClient;
> > +import org.apache.http.client.methods.HttpPost;
> > +import org.apache.http.conn.ssl.SSLContexts;
> > +import org.apache.http.entity.ByteArrayEntity;
> > +import org.apache.http.impl.client.HttpClientBuilder;
> > +import org.apache.http.impl.client.HttpClients;
> > +import org.apache.http.impl.conn.PoolingHttpClientConnectionManager;
> > +
> > +import java.io.IOException;
> > +import java.net.URI;
> > +import java.net.URISyntaxException;
> > +import java.util.logging.Level;
> > +import java.util.logging.Logger;
> > +
> > +/**
> > + * @author Olivier Lamy
> > + */
> > +public class HttpClientCube
> > +    extends Cube
> > +{
> > +
> > +    private static final Logger LOGGER =
> > Logger.getLogger(HttpClientCube.class.getName());
> > +
> > +    private HttpClient httpclient;
> > +
> > +    public HttpClientCube( CubeBuilder cubeBuilder )
> > +    {
> > +        super( cubeBuilder );
> > +        try
> > +        {
> > +            HttpClientBuilder builder = HttpClientBuilder.create();
> > +
> > +            PoolingHttpClientConnectionManager connectionManager = new
> > PoolingHttpClientConnectionManager();
> > +
> > +            builder.setConnectionManager( connectionManager );
> > +
> > +            httpclient = builder.build();
> > +
> > +
> > +        }
> > +        catch ( Exception e )
> > +        {
> > +            e.printStackTrace();
> > +        }
> > +    }
> > +
> > +
> > +    @Override
> > +    public void doPostBytes( final byte[] bytes, final String className
> )
> > +    {
> > +
> > +        try
> > +        {
> > +            final URI uri = new URI(getConfig().getCollector());
> > +
> > +            HttpPost httpPost = new HttpPost( uri );
> > +            httpPost.setEntity( new ByteArrayEntity( bytes ) );
> > +            httpPost.setHeader( CONTENT_TYPE, APPLICATION_JAVA_OBJECT );
> > +            httpPost.setHeader( X_SIRONA_CLASSNAME, className );
> > +
> > +            httpclient.execute( httpPost );
> > +        }
> > +        catch ( URISyntaxException e )
> > +        {
> > +            if (LOGGER.isLoggable( Level.FINE ) )
> > +            {
> > +                LOGGER.log(Level.FINE, "Can't post data to collector:" +
> > e.getMessage(),e);
> > +            } else
> > +            {
> > +                LOGGER.log( Level.WARNING, "Can't post data to
> collector:
> > " + e.getMessage() );
> > +            }
> > +        } catch ( IOException e)
> > +        {
> > +            if (LOGGER.isLoggable( Level.FINE ) )
> > +            {
> > +                LOGGER.log(Level.FINE, "Can't post data to collector:" +
> > e.getMessage(),e);
> > +            } else
> > +            {
> > +                LOGGER.log( Level.WARNING, "Can't post data to
> collector:
> > " + e.getMessage() );
> > +            }
> > +        }
> > +    }
> > +}
> >
> > Propchange:
> >
> >
> incubator/sirona/trunk/agent/store/cube/src/main/java/org/apache/sirona/cube/HttpClientCube.java
> >
> >
> ------------------------------------------------------------------------------
> >     svn:eol-style = native
> >
> > Propchange:
> >
> >
> incubator/sirona/trunk/agent/store/cube/src/main/java/org/apache/sirona/cube/HttpClientCube.java
> >
> >
> ------------------------------------------------------------------------------
> >     svn:keywords = Author Date Id Revision
> >
> > Added:
> >
> >
> incubator/sirona/trunk/agent/store/cube/src/main/java/org/apache/sirona/cube/HttpClientCubeBuilder.java
> > URL:
> >
> >
> http://svn.apache.org/viewvc/incubator/sirona/trunk/agent/store/cube/src/main/java/org/apache/sirona/cube/HttpClientCubeBuilder.java?rev=1576301&view=auto
> >
> >
> ==============================================================================
> > ---
> >
> >
> incubator/sirona/trunk/agent/store/cube/src/main/java/org/apache/sirona/cube/HttpClientCubeBuilder.java
> > (added)
> > +++
> >
> >
> incubator/sirona/trunk/agent/store/cube/src/main/java/org/apache/sirona/cube/HttpClientCubeBuilder.java
> > Tue Mar 11 12:03:12 2014
> > @@ -0,0 +1,33 @@
> > +/*
> > + * Licensed to the Apache Software Foundation (ASF) under one or more
> > + * contributor license agreements.  See the NOTICE file distributed with
> > + * this work for additional information regarding copyright ownership.
> > + * The ASF licenses this file to You under the Apache License, Version
> 2.0
> > + * (the "License"); you may not use this file except in compliance with
> > + * the License.  You may obtain a copy of the License at
> > + *
> > + *      http://www.apache.org/licenses/LICENSE-2.0
> > + *
> > + * Unless required by applicable law or agreed to in writing, software
> > + * distributed under the License is distributed on an "AS IS" BASIS,
> > + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
> > implied.
> > + * See the License for the specific language governing permissions and
> > + * limitations under the License.
> > + */
> > +package org.apache.sirona.cube;
> > +
> > +import org.apache.sirona.configuration.ioc.AutoSet;
> > +
> > +/**
> > + * @author Olivier Lamy
> > + */
> > +@AutoSet
> > +public class HttpClientCubeBuilder
> > +    extends CubeBuilder
> > +{
> > +    @Override
> > +    public synchronized Cube build()
> > +    {
> > +        return new HttpClientCube( this );
> > +    }
> > +}
> >
> > Propchange:
> >
> >
> incubator/sirona/trunk/agent/store/cube/src/main/java/org/apache/sirona/cube/HttpClientCubeBuilder.java
> >
> >
> ------------------------------------------------------------------------------
> >     svn:eol-style = native
> >
> > Propchange:
> >
> >
> incubator/sirona/trunk/agent/store/cube/src/main/java/org/apache/sirona/cube/HttpClientCubeBuilder.java
> >
> >
> ------------------------------------------------------------------------------
> >     svn:keywords = Author Date Id Revision
> >
>
>
>
> --
> Olivier Lamy
> Ecetera: http://ecetera.com.au
> http://twitter.com/olamy | http://linkedin.com/in/olamy
>

Re: svn commit: r1576301 - in /incubator/sirona/trunk/agent/store/cube: ./ src/main/java/org/apache/sirona/cube/

Posted by Olivier Lamy <ol...@apache.org>.
On 11 March 2014 23:15, Romain Manni-Bucau <rm...@gmail.com> wrote:

> Hehe
>
> I guess that's for me ;)
>
> We can make it madatory if shaded if ut brings a better connectuon handling
>

I will do more testing today but the connection handling is the main reason
I want to use that rather than the pure jdk api.


> ---------- Message transféré ----------
> De : <ol...@apache.org>
> Date : 11 mars 2014 13:03
> Objet : svn commit: r1576301 - in /incubator/sirona/trunk/agent/store/cube:
> ./ src/main/java/org/apache/sirona/cube/
> À : <co...@sirona.incubator.apache.org>
>
> Author: olamy
> Date: Tue Mar 11 12:03:12 2014
> New Revision: 1576301
>
> URL: http://svn.apache.org/r1576301
> Log:
> start a cube collector using httpclient (dependency optional and not the
> default one!! :P )
>
> Added:
>
>
> incubator/sirona/trunk/agent/store/cube/src/main/java/org/apache/sirona/cube/HttpClientCube.java
>   (with props)
>
>
> incubator/sirona/trunk/agent/store/cube/src/main/java/org/apache/sirona/cube/HttpClientCubeBuilder.java
>   (with props)
> Modified:
>     incubator/sirona/trunk/agent/store/cube/pom.xml
>
>
> incubator/sirona/trunk/agent/store/cube/src/main/java/org/apache/sirona/cube/Cube.java
>
>
> incubator/sirona/trunk/agent/store/cube/src/main/java/org/apache/sirona/cube/CubeBuilder.java
>
>
> incubator/sirona/trunk/agent/store/cube/src/main/java/org/apache/sirona/cube/CubePathTrackingDataStore.java
>
>
> incubator/sirona/trunk/agent/store/cube/src/main/java/org/apache/sirona/cube/DisruptorPathTrackingDataStore.java
>
> Modified: incubator/sirona/trunk/agent/store/cube/pom.xml
> URL:
>
> http://svn.apache.org/viewvc/incubator/sirona/trunk/agent/store/cube/pom.xml?rev=1576301&r1=1576300&r2=1576301&view=diff
>
> ==============================================================================
> --- incubator/sirona/trunk/agent/store/cube/pom.xml (original)
> +++ incubator/sirona/trunk/agent/store/cube/pom.xml Tue Mar 11 12:03:12
> 2014
> @@ -43,6 +43,13 @@
>      </dependency>
>
>      <dependency>
> +      <groupId>org.apache.httpcomponents</groupId>
> +      <artifactId>httpclient</artifactId>
> +      <version>4.3.3</version>
> +      <optional>true</optional>
> +    </dependency>
> +
> +    <dependency>
>        <groupId>junit</groupId>
>        <artifactId>junit</artifactId>
>      </dependency>
> @@ -94,6 +101,14 @@
>                    <pattern>com.lmax</pattern>
>
>  <shadedPattern>org.apache.sirona.com.lmax</shadedPattern>
>                  </relocation>
> +                <relocation>
> +                  <pattern>org.apache.http</pattern>
> +
>  <shadedPattern>org.apache.sirona.org.apache.http</shadedPattern>
> +                </relocation>
> +                <relocation>
> +                  <pattern>org.apache.commons</pattern>
> +
>  <shadedPattern>org.apache.sirona.org.apache.commons</shadedPattern>
> +                </relocation>
>                  <!--
>                  <relocation>
>                    <pattern>org.apache.sirona</pattern>
>
> Modified:
>
> incubator/sirona/trunk/agent/store/cube/src/main/java/org/apache/sirona/cube/Cube.java
> URL:
>
> http://svn.apache.org/viewvc/incubator/sirona/trunk/agent/store/cube/src/main/java/org/apache/sirona/cube/Cube.java?rev=1576301&r1=1576300&r2=1576301&view=diff
>
> ==============================================================================
> ---
>
> incubator/sirona/trunk/agent/store/cube/src/main/java/org/apache/sirona/cube/Cube.java
> (original)
> +++
>
> incubator/sirona/trunk/agent/store/cube/src/main/java/org/apache/sirona/cube/Cube.java
> Tue Mar 11 12:03:12 2014
> @@ -81,14 +81,14 @@ public class Cube {
>          "\"data\": %s" +
>          "}";
>
> -    private static final String POST = "POST";
> -    private static final String CONTENT_TYPE = "Content-Type";
> -    private static final String APPLICATION_JSON = "application/json";
> -    private static final String CONTENT_LENGTH = "Content-Length";
> -    private static final String GZIP_CONTENT_ENCODING = "gzip";
> -    private static final String CONTENT_ENCODING = "Content-Encoding";
> -    private static final String APPLICATION_JAVA_OBJECT =
> "application/x-java-serialized-object";
> -    private static final String X_SIRONA_CLASSNAME = "X-Sirona-ClassName";
> +    protected static final String POST = "POST";
> +    protected static final String CONTENT_TYPE = "Content-Type";
> +    protected static final String APPLICATION_JSON = "application/json";
> +    protected static final String CONTENT_LENGTH = "Content-Length";
> +    protected static final String GZIP_CONTENT_ENCODING = "gzip";
> +    protected static final String CONTENT_ENCODING = "Content-Encoding";
> +    protected static final String APPLICATION_JAVA_OBJECT =
> "application/x-java-serialized-object";
> +    protected static final String X_SIRONA_CLASSNAME =
> "X-Sirona-ClassName";
>
>      private static final String JS_ISO_FORMAT =
> "yyyy-MM-dd'T'HH:mm:ss'Z'";
>      private static final String UTC = "UTC";
> @@ -132,7 +132,7 @@ public class Cube {
>          }
>      }
>
> -    public void postBytes(byte[] bytes, String className)
> +    public void doPostBytes( byte[] bytes, String className )
>      {
>          try {
>              final URL url = new URL(config.getCollector());
> @@ -184,7 +184,7 @@ public class Cube {
>          }
>      }
>
> -    private void doPost(final String payload) {
> +    protected void doPost(final String payload) {
>          try {
>              final URL url = new URL(config.getCollector());
>
> @@ -403,5 +403,8 @@ public class Cube {
>          return events;
>      }
>
> -
> +    protected CubeBuilder getConfig()
> +    {
> +        return config;
> +    }
>  }
>
> Modified:
>
> incubator/sirona/trunk/agent/store/cube/src/main/java/org/apache/sirona/cube/CubeBuilder.java
> URL:
>
> http://svn.apache.org/viewvc/incubator/sirona/trunk/agent/store/cube/src/main/java/org/apache/sirona/cube/CubeBuilder.java?rev=1576301&r1=1576300&r2=1576301&view=diff
>
> ==============================================================================
> ---
>
> incubator/sirona/trunk/agent/store/cube/src/main/java/org/apache/sirona/cube/CubeBuilder.java
> (original)
> +++
>
> incubator/sirona/trunk/agent/store/cube/src/main/java/org/apache/sirona/cube/CubeBuilder.java
> Tue Mar 11 12:03:12 2014
> @@ -129,7 +129,7 @@ public class CubeBuilder {
>          this.postTimeout = postTimeout;
>      }
>
> -    private TrustManager[] createTrustManager() {
> +    protected TrustManager[] createTrustManager() {
>          if (sslTrustStore == null) {
>              return null;
>          }
> @@ -156,7 +156,7 @@ public class CubeBuilder {
>          }
>      }
>
> -    private KeyManager[] createKeyManager() {
> +    protected KeyManager[] createKeyManager() {
>          if (sslKeyStore == null) {
>              return null;
>          }
> @@ -183,6 +183,46 @@ public class CubeBuilder {
>          }
>      }
>
> +    public String getSslTrustStore()
> +    {
> +        return sslTrustStore;
> +    }
> +
> +    public String getSslTrustStoreType()
> +    {
> +        return sslTrustStoreType;
> +    }
> +
> +    public String getSslTrustStorePassword()
> +    {
> +        return sslTrustStorePassword;
> +    }
> +
> +    public String getSslTrustStoreProvider()
> +    {
> +        return sslTrustStoreProvider;
> +    }
> +
> +    public String getSslKeyStore()
> +    {
> +        return sslKeyStore;
> +    }
> +
> +    public String getSslKeyStoreType()
> +    {
> +        return sslKeyStoreType;
> +    }
> +
> +    public String getSslKeyStorePassword()
> +    {
> +        return sslKeyStorePassword;
> +    }
> +
> +    public String getSslKeyStoreProvider()
> +    {
> +        return sslKeyStoreProvider;
> +    }
> +
>      @Override
>      public String toString() {
>          return "CubeBuilder{" + collector + '}';
>
> Modified:
>
> incubator/sirona/trunk/agent/store/cube/src/main/java/org/apache/sirona/cube/CubePathTrackingDataStore.java
> URL:
>
> http://svn.apache.org/viewvc/incubator/sirona/trunk/agent/store/cube/src/main/java/org/apache/sirona/cube/CubePathTrackingDataStore.java?rev=1576301&r1=1576300&r2=1576301&view=diff
>
> ==============================================================================
> ---
>
> incubator/sirona/trunk/agent/store/cube/src/main/java/org/apache/sirona/cube/CubePathTrackingDataStore.java
> (original)
> +++
>
> incubator/sirona/trunk/agent/store/cube/src/main/java/org/apache/sirona/cube/CubePathTrackingDataStore.java
> Tue Mar 11 12:03:12 2014
> @@ -65,7 +65,7 @@ public class CubePathTrackingDataStore
>      @Override
>      public void store( final PathTrackingEntry pathTrackingEntry )
>      {
> -        CUBE.postBytes( SerializeUtils.serialize( pathTrackingEntry ),
> PathTrackingEntry.class.getName() );
> +        CUBE.doPostBytes( SerializeUtils.serialize( pathTrackingEntry ),
> PathTrackingEntry.class.getName() );
>      }
>
>      @Override
> @@ -80,7 +80,7 @@ public class CubePathTrackingDataStore
>                  {
>                      if ( !pointer.isFree() )
>                      {
> -                        CUBE.postBytes( readBytes( pointer ),
> PathTrackingEntry.class.getName() );
> +                        CUBE.doPostBytes( readBytes( pointer ),
> PathTrackingEntry.class.getName() );
>                          pointer.freeMemory();
>                      }
>                  }
>
> Modified:
>
> incubator/sirona/trunk/agent/store/cube/src/main/java/org/apache/sirona/cube/DisruptorPathTrackingDataStore.java
> URL:
>
> http://svn.apache.org/viewvc/incubator/sirona/trunk/agent/store/cube/src/main/java/org/apache/sirona/cube/DisruptorPathTrackingDataStore.java?rev=1576301&r1=1576300&r2=1576301&view=diff
>
> ==============================================================================
> ---
>
> incubator/sirona/trunk/agent/store/cube/src/main/java/org/apache/sirona/cube/DisruptorPathTrackingDataStore.java
> (original)
> +++
>
> incubator/sirona/trunk/agent/store/cube/src/main/java/org/apache/sirona/cube/DisruptorPathTrackingDataStore.java
> Tue Mar 11 12:03:12 2014
> @@ -89,7 +89,7 @@ public class DisruptorPathTrackingDataSt
>              public void onEvent( final PathTrackingEntry entry, final long
> sequence, final boolean endOfBatch )
>                  throws Exception
>              {
> -                CUBE.postBytes( SerializeUtils.serialize( entry ),
> PathTrackingEntry.class.getName() );
> +                CUBE.doPostBytes( SerializeUtils.serialize( entry ),
> PathTrackingEntry.class.getName() );
>              }
>          };
>
> @@ -131,7 +131,7 @@ public class DisruptorPathTrackingDataSt
>                  {
>                      if ( !pointer.isFree() )
>                      {
> -                        CUBE.postBytes( readBytes( pointer ),
> PathTrackingEntry.class.getName() );
> +                        CUBE.doPostBytes( readBytes( pointer ),
> PathTrackingEntry.class.getName() );
>                          pointer.freeMemory();
>                      }
>                  }
>
> Added:
>
> incubator/sirona/trunk/agent/store/cube/src/main/java/org/apache/sirona/cube/HttpClientCube.java
> URL:
>
> http://svn.apache.org/viewvc/incubator/sirona/trunk/agent/store/cube/src/main/java/org/apache/sirona/cube/HttpClientCube.java?rev=1576301&view=auto
>
> ==============================================================================
> ---
>
> incubator/sirona/trunk/agent/store/cube/src/main/java/org/apache/sirona/cube/HttpClientCube.java
> (added)
> +++
>
> incubator/sirona/trunk/agent/store/cube/src/main/java/org/apache/sirona/cube/HttpClientCube.java
> Tue Mar 11 12:03:12 2014
> @@ -0,0 +1,101 @@
> +/*
> + * Licensed to the Apache Software Foundation (ASF) under one or more
> + * contributor license agreements.  See the NOTICE file distributed with
> + * this work for additional information regarding copyright ownership.
> + * The ASF licenses this file to You under the Apache License, Version 2.0
> + * (the "License"); you may not use this file except in compliance with
> + * the License.  You may obtain a copy of the License at
> + *
> + *      http://www.apache.org/licenses/LICENSE-2.0
> + *
> + * Unless required by applicable law or agreed to in writing, software
> + * distributed under the License is distributed on an "AS IS" BASIS,
> + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
> implied.
> + * See the License for the specific language governing permissions and
> + * limitations under the License.
> + */
> +package org.apache.sirona.cube;
> +
> +import org.apache.http.client.HttpClient;
> +import org.apache.http.client.methods.HttpPost;
> +import org.apache.http.conn.ssl.SSLContexts;
> +import org.apache.http.entity.ByteArrayEntity;
> +import org.apache.http.impl.client.HttpClientBuilder;
> +import org.apache.http.impl.client.HttpClients;
> +import org.apache.http.impl.conn.PoolingHttpClientConnectionManager;
> +
> +import java.io.IOException;
> +import java.net.URI;
> +import java.net.URISyntaxException;
> +import java.util.logging.Level;
> +import java.util.logging.Logger;
> +
> +/**
> + * @author Olivier Lamy
> + */
> +public class HttpClientCube
> +    extends Cube
> +{
> +
> +    private static final Logger LOGGER =
> Logger.getLogger(HttpClientCube.class.getName());
> +
> +    private HttpClient httpclient;
> +
> +    public HttpClientCube( CubeBuilder cubeBuilder )
> +    {
> +        super( cubeBuilder );
> +        try
> +        {
> +            HttpClientBuilder builder = HttpClientBuilder.create();
> +
> +            PoolingHttpClientConnectionManager connectionManager = new
> PoolingHttpClientConnectionManager();
> +
> +            builder.setConnectionManager( connectionManager );
> +
> +            httpclient = builder.build();
> +
> +
> +        }
> +        catch ( Exception e )
> +        {
> +            e.printStackTrace();
> +        }
> +    }
> +
> +
> +    @Override
> +    public void doPostBytes( final byte[] bytes, final String className )
> +    {
> +
> +        try
> +        {
> +            final URI uri = new URI(getConfig().getCollector());
> +
> +            HttpPost httpPost = new HttpPost( uri );
> +            httpPost.setEntity( new ByteArrayEntity( bytes ) );
> +            httpPost.setHeader( CONTENT_TYPE, APPLICATION_JAVA_OBJECT );
> +            httpPost.setHeader( X_SIRONA_CLASSNAME, className );
> +
> +            httpclient.execute( httpPost );
> +        }
> +        catch ( URISyntaxException e )
> +        {
> +            if (LOGGER.isLoggable( Level.FINE ) )
> +            {
> +                LOGGER.log(Level.FINE, "Can't post data to collector:" +
> e.getMessage(),e);
> +            } else
> +            {
> +                LOGGER.log( Level.WARNING, "Can't post data to collector:
> " + e.getMessage() );
> +            }
> +        } catch ( IOException e)
> +        {
> +            if (LOGGER.isLoggable( Level.FINE ) )
> +            {
> +                LOGGER.log(Level.FINE, "Can't post data to collector:" +
> e.getMessage(),e);
> +            } else
> +            {
> +                LOGGER.log( Level.WARNING, "Can't post data to collector:
> " + e.getMessage() );
> +            }
> +        }
> +    }
> +}
>
> Propchange:
>
> incubator/sirona/trunk/agent/store/cube/src/main/java/org/apache/sirona/cube/HttpClientCube.java
>
> ------------------------------------------------------------------------------
>     svn:eol-style = native
>
> Propchange:
>
> incubator/sirona/trunk/agent/store/cube/src/main/java/org/apache/sirona/cube/HttpClientCube.java
>
> ------------------------------------------------------------------------------
>     svn:keywords = Author Date Id Revision
>
> Added:
>
> incubator/sirona/trunk/agent/store/cube/src/main/java/org/apache/sirona/cube/HttpClientCubeBuilder.java
> URL:
>
> http://svn.apache.org/viewvc/incubator/sirona/trunk/agent/store/cube/src/main/java/org/apache/sirona/cube/HttpClientCubeBuilder.java?rev=1576301&view=auto
>
> ==============================================================================
> ---
>
> incubator/sirona/trunk/agent/store/cube/src/main/java/org/apache/sirona/cube/HttpClientCubeBuilder.java
> (added)
> +++
>
> incubator/sirona/trunk/agent/store/cube/src/main/java/org/apache/sirona/cube/HttpClientCubeBuilder.java
> Tue Mar 11 12:03:12 2014
> @@ -0,0 +1,33 @@
> +/*
> + * Licensed to the Apache Software Foundation (ASF) under one or more
> + * contributor license agreements.  See the NOTICE file distributed with
> + * this work for additional information regarding copyright ownership.
> + * The ASF licenses this file to You under the Apache License, Version 2.0
> + * (the "License"); you may not use this file except in compliance with
> + * the License.  You may obtain a copy of the License at
> + *
> + *      http://www.apache.org/licenses/LICENSE-2.0
> + *
> + * Unless required by applicable law or agreed to in writing, software
> + * distributed under the License is distributed on an "AS IS" BASIS,
> + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
> implied.
> + * See the License for the specific language governing permissions and
> + * limitations under the License.
> + */
> +package org.apache.sirona.cube;
> +
> +import org.apache.sirona.configuration.ioc.AutoSet;
> +
> +/**
> + * @author Olivier Lamy
> + */
> +@AutoSet
> +public class HttpClientCubeBuilder
> +    extends CubeBuilder
> +{
> +    @Override
> +    public synchronized Cube build()
> +    {
> +        return new HttpClientCube( this );
> +    }
> +}
>
> Propchange:
>
> incubator/sirona/trunk/agent/store/cube/src/main/java/org/apache/sirona/cube/HttpClientCubeBuilder.java
>
> ------------------------------------------------------------------------------
>     svn:eol-style = native
>
> Propchange:
>
> incubator/sirona/trunk/agent/store/cube/src/main/java/org/apache/sirona/cube/HttpClientCubeBuilder.java
>
> ------------------------------------------------------------------------------
>     svn:keywords = Author Date Id Revision
>



-- 
Olivier Lamy
Ecetera: http://ecetera.com.au
http://twitter.com/olamy | http://linkedin.com/in/olamy