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/08/20 01:48:44 UTC

svn commit: r1619010 - in /incubator/sirona/trunk/server/reporting: reporting-api/ reporting-api/src/main/java/org/apache/sirona/reporting/web/threads/ reporting-ui/src/main/webapp/ reporting-ui/src/main/webapp/js/ reporting-ui/src/main/webapp/js/app/c...

Author: olamy
Date: Tue Aug 19 23:48:43 2014
New Revision: 1619010

URL: http://svn.apache.org/r1619010
Log:
add missing license headers

Added:
    incubator/sirona/trunk/server/reporting/reporting-api/src/main/java/org/apache/sirona/reporting/web/threads/
    incubator/sirona/trunk/server/reporting/reporting-api/src/main/java/org/apache/sirona/reporting/web/threads/ThreadDump.java   (with props)
    incubator/sirona/trunk/server/reporting/reporting-api/src/main/java/org/apache/sirona/reporting/web/threads/ThreadInfo.java   (with props)
    incubator/sirona/trunk/server/reporting/reporting-api/src/main/java/org/apache/sirona/reporting/web/threads/ThreadsReports.java   (with props)
    incubator/sirona/trunk/server/reporting/reporting-ui/src/main/webapp/js/app/controllers/controllers-threads.js   (with props)
    incubator/sirona/trunk/server/reporting/reporting-ui/src/main/webapp/partials/threads.html   (with props)
Modified:
    incubator/sirona/trunk/server/reporting/reporting-api/pom.xml
    incubator/sirona/trunk/server/reporting/reporting-ui/src/main/webapp/index.html
    incubator/sirona/trunk/server/reporting/reporting-ui/src/main/webapp/js/app/services/services.js
    incubator/sirona/trunk/server/reporting/reporting-ui/src/main/webapp/js/main.js
    incubator/sirona/trunk/server/reporting/reporting-ui/src/main/webapp/js/sirona.js

Modified: incubator/sirona/trunk/server/reporting/reporting-api/pom.xml
URL: http://svn.apache.org/viewvc/incubator/sirona/trunk/server/reporting/reporting-api/pom.xml?rev=1619010&r1=1619009&r2=1619010&view=diff
==============================================================================
--- incubator/sirona/trunk/server/reporting/reporting-api/pom.xml (original)
+++ incubator/sirona/trunk/server/reporting/reporting-api/pom.xml Tue Aug 19 23:48:43 2014
@@ -41,6 +41,10 @@
       <groupId>org.apache.sirona</groupId>
       <artifactId>sirona-web</artifactId>
     </dependency>
+    <dependency>
+      <groupId>commons-codec</groupId>
+      <artifactId>commons-codec</artifactId>
+    </dependency>
   </dependencies>
 
 </project>

Added: incubator/sirona/trunk/server/reporting/reporting-api/src/main/java/org/apache/sirona/reporting/web/threads/ThreadDump.java
URL: http://svn.apache.org/viewvc/incubator/sirona/trunk/server/reporting/reporting-api/src/main/java/org/apache/sirona/reporting/web/threads/ThreadDump.java?rev=1619010&view=auto
==============================================================================
--- incubator/sirona/trunk/server/reporting/reporting-api/src/main/java/org/apache/sirona/reporting/web/threads/ThreadDump.java (added)
+++ incubator/sirona/trunk/server/reporting/reporting-api/src/main/java/org/apache/sirona/reporting/web/threads/ThreadDump.java Tue Aug 19 23:48:43 2014
@@ -0,0 +1,71 @@
+/*
+ * 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.reporting.web.threads;
+
+import java.io.Serializable;
+
+/**
+ * @since 0.3
+ */
+public class ThreadDump
+    implements Serializable
+{
+
+    private String state;
+
+    private String dump;
+
+    public ThreadDump()
+    {
+        // no op
+    }
+
+    public ThreadDump( String state, String dump )
+    {
+        this.state = state;
+        this.dump = dump;
+    }
+
+    public String getState()
+    {
+        return state;
+    }
+
+    public void setState( String state )
+    {
+        this.state = state;
+    }
+
+    public String getDump()
+    {
+        return dump;
+    }
+
+    public void setDump( String dump )
+    {
+        this.dump = dump;
+    }
+
+    @Override
+    public String toString()
+    {
+        return "ThreadDump{" +
+            "state='" + state + '\'' +
+            ", dump='" + dump + '\'' +
+            '}';
+    }
+}

Propchange: incubator/sirona/trunk/server/reporting/reporting-api/src/main/java/org/apache/sirona/reporting/web/threads/ThreadDump.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/sirona/trunk/server/reporting/reporting-api/src/main/java/org/apache/sirona/reporting/web/threads/ThreadDump.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Added: incubator/sirona/trunk/server/reporting/reporting-api/src/main/java/org/apache/sirona/reporting/web/threads/ThreadInfo.java
URL: http://svn.apache.org/viewvc/incubator/sirona/trunk/server/reporting/reporting-api/src/main/java/org/apache/sirona/reporting/web/threads/ThreadInfo.java?rev=1619010&view=auto
==============================================================================
--- incubator/sirona/trunk/server/reporting/reporting-api/src/main/java/org/apache/sirona/reporting/web/threads/ThreadInfo.java (added)
+++ incubator/sirona/trunk/server/reporting/reporting-api/src/main/java/org/apache/sirona/reporting/web/threads/ThreadInfo.java Tue Aug 19 23:48:43 2014
@@ -0,0 +1,81 @@
+/*
+ * 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.reporting.web.threads;
+
+import java.io.Serializable;
+import java.util.Comparator;
+
+/**
+ * @since 0.3
+ */
+public class ThreadInfo
+    implements Serializable
+{
+
+    private String name;
+
+    private String encodedName;
+
+    public ThreadInfo()
+    {
+        // no op
+    }
+
+    public ThreadInfo( String name, String encodedName )
+    {
+        this.name = name;
+        this.encodedName = encodedName;
+    }
+
+    public String getName()
+    {
+        return name;
+    }
+
+    public void setName( String name )
+    {
+        this.name = name;
+    }
+
+    public String getEncodedName()
+    {
+        return encodedName;
+    }
+
+    public void setEncodedName( String encodedName )
+    {
+        this.encodedName = encodedName;
+    }
+
+    @Override
+    public String toString()
+    {
+        return "ThreadInfo{" +
+            "name='" + name + '\'' +
+            ", encodedName='" + encodedName + '\'' +
+            '}';
+    }
+
+    public static final Comparator COMPARATOR = new Comparator<ThreadInfo>()
+    {
+        @Override
+        public int compare( ThreadInfo threadInfo, ThreadInfo t1 )
+        {
+            return threadInfo.getName().compareTo( t1.getName() );
+        }
+    };
+}

Propchange: incubator/sirona/trunk/server/reporting/reporting-api/src/main/java/org/apache/sirona/reporting/web/threads/ThreadInfo.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/sirona/trunk/server/reporting/reporting-api/src/main/java/org/apache/sirona/reporting/web/threads/ThreadInfo.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Added: incubator/sirona/trunk/server/reporting/reporting-api/src/main/java/org/apache/sirona/reporting/web/threads/ThreadsReports.java
URL: http://svn.apache.org/viewvc/incubator/sirona/trunk/server/reporting/reporting-api/src/main/java/org/apache/sirona/reporting/web/threads/ThreadsReports.java?rev=1619010&view=auto
==============================================================================
--- incubator/sirona/trunk/server/reporting/reporting-api/src/main/java/org/apache/sirona/reporting/web/threads/ThreadsReports.java (added)
+++ incubator/sirona/trunk/server/reporting/reporting-api/src/main/java/org/apache/sirona/reporting/web/threads/ThreadsReports.java Tue Aug 19 23:48:43 2014
@@ -0,0 +1,104 @@
+/*
+ * 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.reporting.web.threads;
+
+import org.apache.commons.codec.binary.Base64;
+
+import javax.ws.rs.GET;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
+import javax.ws.rs.core.MediaType;
+import java.util.Collection;
+import java.util.Set;
+import java.util.TreeSet;
+
+/**
+ * @since 0.3
+ */
+@Path( "/threads" )
+public class ThreadsReports
+{
+
+
+    @GET
+    @Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML } )
+    public Collection<ThreadInfo> all()
+    {
+        return listThreads();
+    }
+
+    @GET
+    @Path( "/{threadName}" )
+    @Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML } )
+    public ThreadDump getThread( @PathParam( "threadName" ) String name )
+    {
+        Thread thread = findThread( name );
+        if ( thread == null )
+        {
+            return null;
+        }
+
+        return new ThreadDump( thread.getState().name(), dump( thread ) );
+
+    }
+
+    private static Thread findThread( final String name )
+    {
+        int count = Thread.activeCount();
+        final Thread[] threads = new Thread[count];
+        count = Thread.enumerate( threads );
+
+        for ( int i = 0; i < count; i++ )
+        {
+            if ( threads[i].getName().equals( name ) )
+            {
+                return threads[i];
+            }
+        }
+
+        return null;
+    }
+
+    private static String dump( final Thread thread )
+    {
+        final StackTraceElement[] stack = thread.getStackTrace();
+        final StringBuilder builder = new StringBuilder();
+        for ( final StackTraceElement element : stack )
+        {
+            builder.append( element.toString() ).append( "\n" ); // toString method is fine
+        }
+        return builder.toString();
+    }
+
+    private static Collection<ThreadInfo> listThreads()
+    {
+        final Set<ThreadInfo> out = new TreeSet<ThreadInfo>( ThreadInfo.COMPARATOR );
+        int count = Thread.activeCount();
+        final Thread[] threads = new Thread[count];
+        count = Thread.enumerate( threads );
+        for ( int i = 0; i < count; i++ )
+        {
+            final String name = threads[i].getName();
+            out.add( new ThreadInfo( name, Base64.encodeBase64URLSafeString( name.getBytes() ) ) );
+        }
+
+        return out;
+    }
+
+}

Propchange: incubator/sirona/trunk/server/reporting/reporting-api/src/main/java/org/apache/sirona/reporting/web/threads/ThreadsReports.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/sirona/trunk/server/reporting/reporting-api/src/main/java/org/apache/sirona/reporting/web/threads/ThreadsReports.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Modified: incubator/sirona/trunk/server/reporting/reporting-ui/src/main/webapp/index.html
URL: http://svn.apache.org/viewvc/incubator/sirona/trunk/server/reporting/reporting-ui/src/main/webapp/index.html?rev=1619010&r1=1619009&r2=1619010&view=diff
==============================================================================
--- incubator/sirona/trunk/server/reporting/reporting-ui/src/main/webapp/index.html (original)
+++ incubator/sirona/trunk/server/reporting/reporting-ui/src/main/webapp/index.html Tue Aug 19 23:48:43 2014
@@ -59,13 +59,15 @@
           <!-- FIXME this need to be generated/dynamic -->
           <ul class="nav navbar-nav side-nav" id="plugins">
             <li class="active">
-            <li>
               <a href="#home">Home</a>
             </li>
-            <li class="active">
             <li>
               <a href="#jvm">JVM</a>
             </li>
+            <li>
+              <a href="#threads">Threads</a>
+            </li>
+
           </ul>
 
           <ul class="nav navbar-nav navbar-right navbar-user">

Added: incubator/sirona/trunk/server/reporting/reporting-ui/src/main/webapp/js/app/controllers/controllers-threads.js
URL: http://svn.apache.org/viewvc/incubator/sirona/trunk/server/reporting/reporting-ui/src/main/webapp/js/app/controllers/controllers-threads.js?rev=1619010&view=auto
==============================================================================
--- incubator/sirona/trunk/server/reporting/reporting-ui/src/main/webapp/js/app/controllers/controllers-threads.js (added)
+++ incubator/sirona/trunk/server/reporting/reporting-ui/src/main/webapp/js/app/controllers/controllers-threads.js Tue Aug 19 23:48:43 2014
@@ -0,0 +1,44 @@
+/*
+ * 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.
+ */
+'use strict';
+
+/* Controllers */
+define(['jquery','angular','bootstrap','services','morris','ui-bootstrap','datetimepicker'], function (){
+
+
+  var jvmControllers = angular.module('threadsControllers', ['sironaJvmServices','ui.bootstrap','ui.bootstrap.datetimepicker']);
+
+  jvmControllers.controller( 'ThreadsHomeCtrl', ['$scope','threads',
+    function ( $scope,threads){
+
+      $scope.data={};
+      console.log("ThreadsHomeCtrl");
+
+      threads.query().$promise.then(function(result){
+        $scope.data.threadInfos=result;
+
+      });
+
+  }]);
+
+
+});
+
+
+
+
+

Propchange: incubator/sirona/trunk/server/reporting/reporting-ui/src/main/webapp/js/app/controllers/controllers-threads.js
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/sirona/trunk/server/reporting/reporting-ui/src/main/webapp/js/app/controllers/controllers-threads.js
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Modified: incubator/sirona/trunk/server/reporting/reporting-ui/src/main/webapp/js/app/services/services.js
URL: http://svn.apache.org/viewvc/incubator/sirona/trunk/server/reporting/reporting-ui/src/main/webapp/js/app/services/services.js?rev=1619010&r1=1619009&r2=1619010&view=diff
==============================================================================
--- incubator/sirona/trunk/server/reporting/reporting-ui/src/main/webapp/js/app/services/services.js (original)
+++ incubator/sirona/trunk/server/reporting/reporting-ui/src/main/webapp/js/app/services/services.js Tue Aug 19 23:48:43 2014
@@ -68,4 +68,13 @@ define(['angular','angular-resource'], f
     }
   ]);
 
+
+  sironaServices.factory('threads', ['$resource',
+    function($resource){
+      return $resource('restServices/sironaServices/threads',
+                       {},
+                       {query: {method:'GET', params:{},isArray:true}});
+    }
+  ]);
+
 });
\ No newline at end of file

Modified: incubator/sirona/trunk/server/reporting/reporting-ui/src/main/webapp/js/main.js
URL: http://svn.apache.org/viewvc/incubator/sirona/trunk/server/reporting/reporting-ui/src/main/webapp/js/main.js?rev=1619010&r1=1619009&r2=1619010&view=diff
==============================================================================
--- incubator/sirona/trunk/server/reporting/reporting-ui/src/main/webapp/js/main.js (original)
+++ incubator/sirona/trunk/server/reporting/reporting-ui/src/main/webapp/js/main.js Tue Aug 19 23:48:43 2014
@@ -36,6 +36,7 @@ require.config({
     'bootstrap' : 'bootstrap.3.2.0.min',
     'controllers': 'app/controllers/controllers',
     'controllers-jvm': 'app/controllers/controllers-jvm',
+    'controllers-threads': 'app/controllers/controllers-threads',
     'services': 'app/services/services',
     'sirona': 'sirona',
     'morris': 'plugins/morris/morris-0.5.0.min',

Modified: incubator/sirona/trunk/server/reporting/reporting-ui/src/main/webapp/js/sirona.js
URL: http://svn.apache.org/viewvc/incubator/sirona/trunk/server/reporting/reporting-ui/src/main/webapp/js/sirona.js?rev=1619010&r1=1619009&r2=1619010&view=diff
==============================================================================
--- incubator/sirona/trunk/server/reporting/reporting-ui/src/main/webapp/js/sirona.js (original)
+++ incubator/sirona/trunk/server/reporting/reporting-ui/src/main/webapp/js/sirona.js Tue Aug 19 23:48:43 2014
@@ -17,13 +17,14 @@
 
 'use strict';
 
-define(['jquery','controllers','controllers-jvm', 'angular-route', 'bootstrap','datetimepicker'],
+define(['jquery','controllers','controllers-jvm','controllers-threads','angular-route','bootstrap','datetimepicker'],
        function (jquery,controllers) {
 
   var sirona = angular.module('sirona', [
     'ngRoute',
     'homeControllers',
-    'jvmControllers'
+    'jvmControllers',
+    'threadsControllers'
   ]);
 
   sirona.config(['$routeProvider','$logProvider',
@@ -35,13 +36,19 @@ define(['jquery','controllers','controll
                 templateUrl: 'partials/home.html',
                 controller: 'HomeCtrl'
              }
-         ).
-         when('/jvm',
+        ).
+        when('/jvm',
               {
                 templateUrl: 'partials/jvm.html',
                 controller: 'JvmHomeCtrl'
               }
-         ).
+        ).
+        when('/threads',
+             {
+               templateUrl: 'partials/threads.html',
+               controller: 'ThreadsHomeCtrl'
+             }
+        ).
         otherwise({
           redirectTo: '/home'
         });

Added: incubator/sirona/trunk/server/reporting/reporting-ui/src/main/webapp/partials/threads.html
URL: http://svn.apache.org/viewvc/incubator/sirona/trunk/server/reporting/reporting-ui/src/main/webapp/partials/threads.html?rev=1619010&view=auto
==============================================================================
--- incubator/sirona/trunk/server/reporting/reporting-ui/src/main/webapp/partials/threads.html (added)
+++ incubator/sirona/trunk/server/reporting/reporting-ui/src/main/webapp/partials/threads.html Tue Aug 19 23:48:43 2014
@@ -0,0 +1,28 @@
+<!--
+  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.
+-->
+<div class="row">
+  <div class="col-lg-2" style="word-break: break-all; word-wrap: break-word;">
+    <ul>
+      <li ng-repeat="threadInfo in data.threadInfos">
+        {{threadInfo.name}}
+      </li>
+    </ul>
+  </div>
+  <div class="col-lg-10">
+    content
+  </div>
+</div>
\ No newline at end of file

Propchange: incubator/sirona/trunk/server/reporting/reporting-ui/src/main/webapp/partials/threads.html
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/sirona/trunk/server/reporting/reporting-ui/src/main/webapp/partials/threads.html
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision