You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sirona.apache.org by ol...@apache.org on 2014/03/11 13:03:03 UTC

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

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

URL: http://svn.apache.org/r1576300
Log:
make disruptor optional

Added:
    incubator/sirona/trunk/agent/store/cube/src/main/java/org/apache/sirona/cube/CubeDisruptorDataStoreFactory.java   (with props)
    incubator/sirona/trunk/agent/store/cube/src/main/java/org/apache/sirona/cube/DisruptorPathTrackingDataStore.java
      - copied, changed from r1576299, incubator/sirona/trunk/agent/store/cube/src/main/java/org/apache/sirona/cube/CubePathTrackingDataStore.java
Modified:
    incubator/sirona/trunk/agent/store/cube/pom.xml
    incubator/sirona/trunk/agent/store/cube/src/main/java/org/apache/sirona/cube/CubePathTrackingDataStore.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=1576300&r1=1576299&r2=1576300&view=diff
==============================================================================
--- incubator/sirona/trunk/agent/store/cube/pom.xml (original)
+++ incubator/sirona/trunk/agent/store/cube/pom.xml Tue Mar 11 12:03:03 2014
@@ -39,6 +39,7 @@
       <groupId>com.lmax</groupId>
       <artifactId>disruptor</artifactId>
       <version>3.2.0</version>
+      <optional>true</optional>
     </dependency>
 
     <dependency>

Added: incubator/sirona/trunk/agent/store/cube/src/main/java/org/apache/sirona/cube/CubeDisruptorDataStoreFactory.java
URL: http://svn.apache.org/viewvc/incubator/sirona/trunk/agent/store/cube/src/main/java/org/apache/sirona/cube/CubeDisruptorDataStoreFactory.java?rev=1576300&view=auto
==============================================================================
--- incubator/sirona/trunk/agent/store/cube/src/main/java/org/apache/sirona/cube/CubeDisruptorDataStoreFactory.java (added)
+++ incubator/sirona/trunk/agent/store/cube/src/main/java/org/apache/sirona/cube/CubeDisruptorDataStoreFactory.java Tue Mar 11 12:03:03 2014
@@ -0,0 +1,31 @@
+/*
+ * 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.IoCs;
+import org.apache.sirona.store.DelegateDataStoreFactory;
+
+public class CubeDisruptorDataStoreFactory
+    extends DelegateDataStoreFactory {
+    public CubeDisruptorDataStoreFactory() {
+        super(
+            IoCs.processInstance(new CubeCounterDataStore()),
+            IoCs.processInstance(new CubeGaugeDataStore()),
+            IoCs.processInstance(new CubeNodeStatusDataStore()),
+            IoCs.processInstance(new DisruptorPathTrackingDataStore()));
+    }
+}

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

Propchange: incubator/sirona/trunk/agent/store/cube/src/main/java/org/apache/sirona/cube/CubeDisruptorDataStoreFactory.java
------------------------------------------------------------------------------
    svn:executable = *

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

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=1576300&r1=1576299&r2=1576300&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:03 2014
@@ -17,13 +17,6 @@
 
 package org.apache.sirona.cube;
 
-import com.lmax.disruptor.BusySpinWaitStrategy;
-import com.lmax.disruptor.EventFactory;
-import com.lmax.disruptor.EventHandler;
-import com.lmax.disruptor.EventTranslator;
-import com.lmax.disruptor.RingBuffer;
-import com.lmax.disruptor.dsl.Disruptor;
-import com.lmax.disruptor.dsl.ProducerType;
 import org.apache.sirona.configuration.Configuration;
 import org.apache.sirona.configuration.ioc.Destroying;
 import org.apache.sirona.configuration.ioc.IoCs;
@@ -53,12 +46,8 @@ public class CubePathTrackingDataStore
     private static boolean USE_SINGLE_STORE = Boolean.parseBoolean(
         Configuration.getProperty( Configuration.CONFIG_PROPERTY_PREFIX + "pathtracking.singlestore", "false" ) );
 
-    private static final boolean USE_DISRUPTOR = Boolean.parseBoolean(
-        Configuration.getProperty( Configuration.CONFIG_PROPERTY_PREFIX + "pathtracking.usedisruptor", "true" ) );
-
     protected static ExecutorService executorService;
 
-    private static RingBuffer<PathTrackingEntry> RINGBUFFER;
 
     static
     {
@@ -71,67 +60,12 @@ public class CubePathTrackingDataStore
 
         }
 
-        if ( USE_DISRUPTOR )
-        {
-            ExecutorService exec = Executors.newCachedThreadPool();
-
-            // FIXME make configurable: ring buffer size and WaitStrategy
-
-            Disruptor<PathTrackingEntry> disruptor =
-                new Disruptor<PathTrackingEntry>( new EventFactory<PathTrackingEntry>()
-                {
-                    @Override
-                    public PathTrackingEntry newInstance()
-                    {
-                        return new PathTrackingEntry();
-                    }
-                }, 2048, exec, ProducerType.SINGLE, new BusySpinWaitStrategy()
-                );
-
-            final EventHandler<PathTrackingEntry> handler = new EventHandler<PathTrackingEntry>()
-            {
-                // event will eventually be recycled by the Disruptor after it wraps
-                public void onEvent( final PathTrackingEntry entry, final long sequence, final boolean endOfBatch )
-                    throws Exception
-                {
-                    CUBE.postBytes( SerializeUtils.serialize( entry ), PathTrackingEntry.class.getName() );
-                }
-            };
-
-            disruptor.handleEventsWith( handler );
-
-            RINGBUFFER = disruptor.start();
-        }
     }
 
     @Override
     public void store( final PathTrackingEntry pathTrackingEntry )
     {
-        if ( USE_DISRUPTOR )
-        {
-
-            RINGBUFFER.publishEvent( new EventTranslator<PathTrackingEntry>()
-            {
-                @Override
-                public void translateTo( PathTrackingEntry event, long sequence )
-                {
-                    event.setClassName( pathTrackingEntry.getClassName() );
-                    event.setExecutionTime( pathTrackingEntry.getExecutionTime() );
-                    event.setLevel( pathTrackingEntry.getLevel() );
-                    event.setMethodName( pathTrackingEntry.getMethodName() );
-                    event.setNodeId( pathTrackingEntry.getNodeId() );
-                    event.setStartTime( pathTrackingEntry.getStartTime() );
-                    event.setTrackingId( pathTrackingEntry.getTrackingId() );
-                }
-            } );
-
-
-        }
-        else
-        {
-            CUBE.postBytes( SerializeUtils.serialize( pathTrackingEntry ), PathTrackingEntry.class.getName() );
-        }
-
+        CUBE.postBytes( SerializeUtils.serialize( pathTrackingEntry ), PathTrackingEntry.class.getName() );
     }
 
     @Override

Copied: incubator/sirona/trunk/agent/store/cube/src/main/java/org/apache/sirona/cube/DisruptorPathTrackingDataStore.java (from r1576299, 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/DisruptorPathTrackingDataStore.java?p2=incubator/sirona/trunk/agent/store/cube/src/main/java/org/apache/sirona/cube/DisruptorPathTrackingDataStore.java&p1=incubator/sirona/trunk/agent/store/cube/src/main/java/org/apache/sirona/cube/CubePathTrackingDataStore.java&r1=1576299&r2=1576300&rev=1576300&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/DisruptorPathTrackingDataStore.java Tue Mar 11 12:03:03 2014
@@ -17,11 +17,11 @@
 
 package org.apache.sirona.cube;
 
-import com.lmax.disruptor.BusySpinWaitStrategy;
 import com.lmax.disruptor.EventFactory;
 import com.lmax.disruptor.EventHandler;
 import com.lmax.disruptor.EventTranslator;
 import com.lmax.disruptor.RingBuffer;
+import com.lmax.disruptor.SleepingWaitStrategy;
 import com.lmax.disruptor.dsl.Disruptor;
 import com.lmax.disruptor.dsl.ProducerType;
 import org.apache.sirona.configuration.Configuration;
@@ -40,7 +40,7 @@ import java.util.concurrent.Executors;
 /**
  *
  */
-public class CubePathTrackingDataStore
+public class DisruptorPathTrackingDataStore
     extends BatchPathTrackingDataStore
     implements CollectorPathTrackingDataStore
 {
@@ -53,8 +53,6 @@ public class CubePathTrackingDataStore
     private static boolean USE_SINGLE_STORE = Boolean.parseBoolean(
         Configuration.getProperty( Configuration.CONFIG_PROPERTY_PREFIX + "pathtracking.singlestore", "false" ) );
 
-    private static final boolean USE_DISRUPTOR = Boolean.parseBoolean(
-        Configuration.getProperty( Configuration.CONFIG_PROPERTY_PREFIX + "pathtracking.usedisruptor", "true" ) );
 
     protected static ExecutorService executorService;
 
@@ -71,67 +69,54 @@ public class CubePathTrackingDataStore
 
         }
 
-        if ( USE_DISRUPTOR )
-        {
-            ExecutorService exec = Executors.newCachedThreadPool();
+        ExecutorService exec = Executors.newCachedThreadPool();
 
-            // FIXME make configurable: ring buffer size and WaitStrategy
+        // FIXME make configurable: ring buffer size and WaitStrategy
 
-            Disruptor<PathTrackingEntry> disruptor =
-                new Disruptor<PathTrackingEntry>( new EventFactory<PathTrackingEntry>()
-                {
-                    @Override
-                    public PathTrackingEntry newInstance()
-                    {
-                        return new PathTrackingEntry();
-                    }
-                }, 2048, exec, ProducerType.SINGLE, new BusySpinWaitStrategy()
-                );
+        Disruptor<PathTrackingEntry> disruptor = new Disruptor<PathTrackingEntry>( new EventFactory<PathTrackingEntry>()
+        {
+            @Override
+            public PathTrackingEntry newInstance()
+            {
+                return new PathTrackingEntry();
+            }
+        }, 2048, exec, ProducerType.SINGLE, new SleepingWaitStrategy()
+        );
 
-            final EventHandler<PathTrackingEntry> handler = new EventHandler<PathTrackingEntry>()
+        final EventHandler<PathTrackingEntry> handler = new EventHandler<PathTrackingEntry>()
+        {
+            // event will eventually be recycled by the Disruptor after it wraps
+            public void onEvent( final PathTrackingEntry entry, final long sequence, final boolean endOfBatch )
+                throws Exception
             {
-                // event will eventually be recycled by the Disruptor after it wraps
-                public void onEvent( final PathTrackingEntry entry, final long sequence, final boolean endOfBatch )
-                    throws Exception
-                {
-                    CUBE.postBytes( SerializeUtils.serialize( entry ), PathTrackingEntry.class.getName() );
-                }
-            };
+                CUBE.postBytes( SerializeUtils.serialize( entry ), PathTrackingEntry.class.getName() );
+            }
+        };
 
-            disruptor.handleEventsWith( handler );
+        disruptor.handleEventsWith( handler );
+
+        RINGBUFFER = disruptor.start();
 
-            RINGBUFFER = disruptor.start();
-        }
     }
 
     @Override
     public void store( final PathTrackingEntry pathTrackingEntry )
     {
-        if ( USE_DISRUPTOR )
-        {
-
-            RINGBUFFER.publishEvent( new EventTranslator<PathTrackingEntry>()
-            {
-                @Override
-                public void translateTo( PathTrackingEntry event, long sequence )
-                {
-                    event.setClassName( pathTrackingEntry.getClassName() );
-                    event.setExecutionTime( pathTrackingEntry.getExecutionTime() );
-                    event.setLevel( pathTrackingEntry.getLevel() );
-                    event.setMethodName( pathTrackingEntry.getMethodName() );
-                    event.setNodeId( pathTrackingEntry.getNodeId() );
-                    event.setStartTime( pathTrackingEntry.getStartTime() );
-                    event.setTrackingId( pathTrackingEntry.getTrackingId() );
-                }
-            } );
 
-
-        }
-        else
+        RINGBUFFER.publishEvent( new EventTranslator<PathTrackingEntry>()
         {
-            CUBE.postBytes( SerializeUtils.serialize( pathTrackingEntry ), PathTrackingEntry.class.getName() );
-        }
-
+            @Override
+            public void translateTo( PathTrackingEntry event, long sequence )
+            {
+                event.setClassName( pathTrackingEntry.getClassName() );
+                event.setExecutionTime( pathTrackingEntry.getExecutionTime() );
+                event.setLevel( pathTrackingEntry.getLevel() );
+                event.setMethodName( pathTrackingEntry.getMethodName() );
+                event.setNodeId( pathTrackingEntry.getNodeId() );
+                event.setStartTime( pathTrackingEntry.getStartTime() );
+                event.setTrackingId( pathTrackingEntry.getTrackingId() );
+            }
+        } );
     }
 
     @Override