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/02/19 05:59:45 UTC

svn commit: r1569628 - in /incubator/sirona/trunk: agent/javaagent/src/test/java/org/apache/sirona/pathtracking/ agent/javaagent/src/test/java/org/apache/sirona/pathtracking/test/ agent/javaagent/src/test/resources/pathtracking/ core/src/main/java/org/...

Author: olamy
Date: Wed Feb 19 04:59:45 2014
New Revision: 1569628

URL: http://svn.apache.org/r1569628
Log:
use an extended in memory storage to get all

Added:
    incubator/sirona/trunk/agent/javaagent/src/test/java/org/apache/sirona/pathtracking/test/
    incubator/sirona/trunk/agent/javaagent/src/test/java/org/apache/sirona/pathtracking/test/ExtDataStoreFactory.java   (with props)
    incubator/sirona/trunk/agent/javaagent/src/test/java/org/apache/sirona/pathtracking/test/ExtendedInMemoryPathTrackingDataStore.java   (with props)
    incubator/sirona/trunk/server/store/cassandra/src/test/java/org/apache/sirona/cassandra/local/ExtendedCassandraPathTrackingDataStore.java   (with props)
Modified:
    incubator/sirona/trunk/agent/javaagent/src/test/java/org/apache/sirona/pathtracking/PathTrackingInvocationListenerTest.java
    incubator/sirona/trunk/agent/javaagent/src/test/resources/pathtracking/sirona.properties
    incubator/sirona/trunk/core/src/main/java/org/apache/sirona/store/tracking/InMemoryPathTrackingDataStore.java

Modified: incubator/sirona/trunk/agent/javaagent/src/test/java/org/apache/sirona/pathtracking/PathTrackingInvocationListenerTest.java
URL: http://svn.apache.org/viewvc/incubator/sirona/trunk/agent/javaagent/src/test/java/org/apache/sirona/pathtracking/PathTrackingInvocationListenerTest.java?rev=1569628&r1=1569627&r2=1569628&view=diff
==============================================================================
--- incubator/sirona/trunk/agent/javaagent/src/test/java/org/apache/sirona/pathtracking/PathTrackingInvocationListenerTest.java (original)
+++ incubator/sirona/trunk/agent/javaagent/src/test/java/org/apache/sirona/pathtracking/PathTrackingInvocationListenerTest.java Wed Feb 19 04:59:45 2014
@@ -19,6 +19,7 @@ package org.apache.sirona.pathtracking;
 import org.apache.sirona.configuration.ioc.IoCs;
 import org.apache.sirona.javaagent.AgentArgs;
 import org.apache.sirona.javaagent.JavaAgentRunner;
+import org.apache.sirona.pathtracking.test.ExtendedInMemoryPathTrackingDataStore;
 import org.apache.sirona.store.DataStoreFactory;
 import org.apache.sirona.store.tracking.InMemoryPathTrackingDataStore;
 import org.apache.sirona.tracking.PathTrackingEntry;
@@ -50,13 +51,16 @@ public class PathTrackingInvocationListe
 
         DataStoreFactory dataStoreFactory = IoCs.findOrCreateInstance( DataStoreFactory.class );
 
-        InMemoryPathTrackingDataStore ptds =
-            InMemoryPathTrackingDataStore.class.cast( dataStoreFactory.getPathTrackingDataStore() );
+        ExtendedInMemoryPathTrackingDataStore ptds =
+            ExtendedInMemoryPathTrackingDataStore.class.cast( dataStoreFactory.getPathTrackingDataStore() );
 
         Map<String, Set<PathTrackingEntry>> all = ptds.retrieveAll();
 
         Assert.assertTrue( !all.isEmpty() );
 
+        // test only one Thread
+        Assert.assertEquals( 1, all.size() );
+
         List<PathTrackingEntry> entries = new ArrayList<PathTrackingEntry>( all.values().iterator().next() );
 
         PathTrackingEntry first = entries.get( 0 );

Added: incubator/sirona/trunk/agent/javaagent/src/test/java/org/apache/sirona/pathtracking/test/ExtDataStoreFactory.java
URL: http://svn.apache.org/viewvc/incubator/sirona/trunk/agent/javaagent/src/test/java/org/apache/sirona/pathtracking/test/ExtDataStoreFactory.java?rev=1569628&view=auto
==============================================================================
--- incubator/sirona/trunk/agent/javaagent/src/test/java/org/apache/sirona/pathtracking/test/ExtDataStoreFactory.java (added)
+++ incubator/sirona/trunk/agent/javaagent/src/test/java/org/apache/sirona/pathtracking/test/ExtDataStoreFactory.java Wed Feb 19 04:59:45 2014
@@ -0,0 +1,37 @@
+/*
+* 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.pathtracking.test;
+
+import org.apache.sirona.configuration.ioc.IoCs;
+import org.apache.sirona.store.DelegateDataStoreFactory;
+import org.apache.sirona.store.counter.InMemoryCounterDataStore;
+import org.apache.sirona.store.gauge.InMemoryGaugeDataStore;
+import org.apache.sirona.store.status.PeriodicNodeStatusDataStore;
+
+/**
+ * @author Olivier Lamy
+ */
+public class ExtDataStoreFactory extends DelegateDataStoreFactory
+{
+    public ExtDataStoreFactory() {
+        super(
+            IoCs.processInstance( new InMemoryCounterDataStore() ),
+            IoCs.processInstance(new InMemoryGaugeDataStore()),
+            IoCs.processInstance(new PeriodicNodeStatusDataStore()),
+            IoCs.processInstance( new ExtendedInMemoryPathTrackingDataStore() ));
+    }
+}

Propchange: incubator/sirona/trunk/agent/javaagent/src/test/java/org/apache/sirona/pathtracking/test/ExtDataStoreFactory.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/sirona/trunk/agent/javaagent/src/test/java/org/apache/sirona/pathtracking/test/ExtDataStoreFactory.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Added: incubator/sirona/trunk/agent/javaagent/src/test/java/org/apache/sirona/pathtracking/test/ExtendedInMemoryPathTrackingDataStore.java
URL: http://svn.apache.org/viewvc/incubator/sirona/trunk/agent/javaagent/src/test/java/org/apache/sirona/pathtracking/test/ExtendedInMemoryPathTrackingDataStore.java?rev=1569628&view=auto
==============================================================================
--- incubator/sirona/trunk/agent/javaagent/src/test/java/org/apache/sirona/pathtracking/test/ExtendedInMemoryPathTrackingDataStore.java (added)
+++ incubator/sirona/trunk/agent/javaagent/src/test/java/org/apache/sirona/pathtracking/test/ExtendedInMemoryPathTrackingDataStore.java Wed Feb 19 04:59:45 2014
@@ -0,0 +1,38 @@
+/*
+* 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.pathtracking.test;
+
+import org.apache.sirona.store.tracking.InMemoryPathTrackingDataStore;
+import org.apache.sirona.tracking.PathTrackingEntry;
+
+import java.util.Map;
+import java.util.Set;
+
+/**
+ * @author Olivier Lamy
+ */
+public class ExtendedInMemoryPathTrackingDataStore
+    extends InMemoryPathTrackingDataStore
+{
+    /**
+     * testing purpose
+     */
+    public Map<String, Set<PathTrackingEntry>> retrieveAll()
+    {
+        return this.getPathTrackingEntries();
+    }
+}

Propchange: incubator/sirona/trunk/agent/javaagent/src/test/java/org/apache/sirona/pathtracking/test/ExtendedInMemoryPathTrackingDataStore.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/sirona/trunk/agent/javaagent/src/test/java/org/apache/sirona/pathtracking/test/ExtendedInMemoryPathTrackingDataStore.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Modified: incubator/sirona/trunk/agent/javaagent/src/test/resources/pathtracking/sirona.properties
URL: http://svn.apache.org/viewvc/incubator/sirona/trunk/agent/javaagent/src/test/resources/pathtracking/sirona.properties?rev=1569628&r1=1569627&r2=1569628&view=diff
==============================================================================
--- incubator/sirona/trunk/agent/javaagent/src/test/resources/pathtracking/sirona.properties (original)
+++ incubator/sirona/trunk/agent/javaagent/src/test/resources/pathtracking/sirona.properties Wed Feb 19 04:59:45 2014
@@ -24,6 +24,7 @@ org.apache.sirona.javaagent.listener.Cou
   prefix:com.apple
 
 
+org.apache.sirona.store.DataStoreFactory = org.apache.sirona.pathtracking.test.ExtDataStoreFactory
 org.apache.sirona.javaagent.path.tracking.activate=true
 
 

Modified: incubator/sirona/trunk/core/src/main/java/org/apache/sirona/store/tracking/InMemoryPathTrackingDataStore.java
URL: http://svn.apache.org/viewvc/incubator/sirona/trunk/core/src/main/java/org/apache/sirona/store/tracking/InMemoryPathTrackingDataStore.java?rev=1569628&r1=1569627&r2=1569628&view=diff
==============================================================================
--- incubator/sirona/trunk/core/src/main/java/org/apache/sirona/store/tracking/InMemoryPathTrackingDataStore.java (original)
+++ incubator/sirona/trunk/core/src/main/java/org/apache/sirona/store/tracking/InMemoryPathTrackingDataStore.java Wed Feb 19 04:59:45 2014
@@ -85,14 +85,8 @@ public class InMemoryPathTrackingDataSto
         return trackingIds;
     }
 
-    /**
-     * <b>use with CAUTION as can return a lot of data</b>
-     * <p>This method is use for testing purpose</p>
-     *
-     * @return {@link List} containing all {@link PathTrackingEntry}
-     */
-    public Map<String, Set<PathTrackingEntry>> retrieveAll()
+    protected ConcurrentMap<String, Set<PathTrackingEntry>> getPathTrackingEntries()
     {
-        return this.pathTrackingEntries;
+        return pathTrackingEntries;
     }
 }

Added: incubator/sirona/trunk/server/store/cassandra/src/test/java/org/apache/sirona/cassandra/local/ExtendedCassandraPathTrackingDataStore.java
URL: http://svn.apache.org/viewvc/incubator/sirona/trunk/server/store/cassandra/src/test/java/org/apache/sirona/cassandra/local/ExtendedCassandraPathTrackingDataStore.java?rev=1569628&view=auto
==============================================================================
--- incubator/sirona/trunk/server/store/cassandra/src/test/java/org/apache/sirona/cassandra/local/ExtendedCassandraPathTrackingDataStore.java (added)
+++ incubator/sirona/trunk/server/store/cassandra/src/test/java/org/apache/sirona/cassandra/local/ExtendedCassandraPathTrackingDataStore.java Wed Feb 19 04:59:45 2014
@@ -0,0 +1,89 @@
+package org.apache.sirona.cassandra.local;
+
+import me.prettyprint.cassandra.serializers.StringSerializer;
+import me.prettyprint.hector.api.beans.ColumnSlice;
+import me.prettyprint.hector.api.beans.OrderedRows;
+import me.prettyprint.hector.api.beans.Row;
+import me.prettyprint.hector.api.factory.HFactory;
+import me.prettyprint.hector.api.query.QueryResult;
+import org.apache.sirona.cassandra.DynamicDelegatedSerializer;
+import org.apache.sirona.cassandra.pathtracking.CassandraPathTrackingDataStore;
+import org.apache.sirona.tracking.PathTrackingEntry;
+
+import java.util.Map;
+import java.util.Set;
+import java.util.TreeMap;
+import java.util.TreeSet;
+
+/**
+ * @author Olivier Lamy
+ */
+public class ExtendedCassandraPathTrackingDataStore
+    extends CassandraPathTrackingDataStore
+{
+
+    /**
+     * <b>use with CAUTION as can return a lot of data</b>
+     * <p>This method is use for testing purpose</p>
+     *
+     * @return {@link java.util.List} containing all {@link org.apache.sirona.tracking.PathTrackingEntry}
+     */
+    public Map<String, Set<PathTrackingEntry>> retrieveAll()
+    {
+        final QueryResult<OrderedRows<String, String, String>> cResult = //
+            HFactory.createRangeSlicesQuery( getKeyspace(), //
+                                             StringSerializer.get(), //
+                                             StringSerializer.get(), //
+                                             StringSerializer.get() ) //
+                .setColumnFamily( getFamily() ) //
+                .setRange( null, null, false, Integer.MAX_VALUE ) //
+                .execute();
+
+        Map<String, Set<PathTrackingEntry>> entries = new TreeMap<String, Set<PathTrackingEntry>>();
+
+        final DynamicDelegatedSerializer<Object> serializer = new DynamicDelegatedSerializer<Object>();
+
+        for ( Row<String, String, String> row : cResult.get().getList() )
+        {
+            ColumnSlice<String, String> columnSlice = row.getColumnSlice();
+            String trackingId = columnSlice.getColumnByName( "trackingId" ).getValue();
+            String nodeId = columnSlice.getColumnByName( "nodeId" ).getValue();
+            String className = columnSlice.getColumnByName( "className" ).getValue();
+            String methodName = columnSlice.getColumnByName( "methodName" ).getValue();
+
+            long startTime = Long.parseLong( columnSlice.getColumnByName( "startTime" ).getValue() );
+            //getOrDefault( serializer, //
+            //              columnSlice.getColumnByName( "startTime" ), //
+            //              LongSerializer.get() ).longValue();
+
+            long executionTime = Long.parseLong( columnSlice.getColumnByName( "executionTime" ).getValue() );
+            //getOrDefault( serializer, //
+            //            columnSlice.getColumnByName( "executionTime" ), //
+            //               LongSerializer.get() ).longValue();
+
+            int level = Integer.parseInt( columnSlice.getColumnByName( "level" ).getValue() );
+            //getOrDefault( serializer, //
+            //          columnSlice.getColumnByName( "level" ), //
+            //          LongSerializer.get() ).intValue();
+
+            Set<PathTrackingEntry> pathTrackingEntries = entries.get( trackingId );
+            if ( pathTrackingEntries == null )
+            {
+                pathTrackingEntries = new TreeSet<PathTrackingEntry>();
+            }
+            pathTrackingEntries.add( new PathTrackingEntry( trackingId, //
+                                                            nodeId, //
+                                                            className, //
+                                                            methodName, //
+                                                            startTime, //
+                                                            executionTime, //
+                                                            level ) );
+
+            entries.put( trackingId, pathTrackingEntries );
+
+        }
+
+        return entries;
+    }
+
+}

Propchange: incubator/sirona/trunk/server/store/cassandra/src/test/java/org/apache/sirona/cassandra/local/ExtendedCassandraPathTrackingDataStore.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/sirona/trunk/server/store/cassandra/src/test/java/org/apache/sirona/cassandra/local/ExtendedCassandraPathTrackingDataStore.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision