Skip to content

Commit

Permalink
Added sessions page to Tomcat plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
davsclaus committed Mar 25, 2013
1 parent 2a7f275 commit c1537a8
Show file tree
Hide file tree
Showing 5 changed files with 194 additions and 9 deletions.
20 changes: 20 additions & 0 deletions hawtio-web/src/main/webapp/app/tomcat/html/sessions.html
@@ -0,0 +1,20 @@
<div class="row-fluid" ng-controller="Tomcat.SessionsController">

<div class="row-fluid">
<div class="pull-right">
<form class="form-inline no-bottom-margin">
<fieldset>
<div class="control-group inline-block">
<input type="text" class="search-query" placeholder="Filter..." ng-model="search">
</div>
</fieldset>
</form>
</div>
</div>

<div class="row-fluid">
<div class="gridStyle" ng-grid="gridOptions"></div>
</div>

</div>

3 changes: 3 additions & 0 deletions hawtio-web/src/main/webapp/app/tomcat/html/tomcatTabs.html
Expand Up @@ -8,6 +8,9 @@
<li ng-class='{active : isActive("#/tomcat/connectors")}'>
<a ng-href="{{link('#/tomcat/connectors')}}">Connectors</a>
</li>
<li ng-class='{active : isActive("#/tomcat/sessions")}'>
<a ng-href="{{link('#/tomcat/sessions')}}">Sessions</a>
</li>
<li ng-class='{active : isTopTabActive("tomcatTree")}'>
<a ng-href="#/jmx/attributes?tab=tomcatTree{{hash}}">JMX</a>
</li>
Expand Down
168 changes: 168 additions & 0 deletions hawtio-web/src/main/webapp/app/tomcat/js/sessions.ts
@@ -0,0 +1,168 @@
module Tomcat {

export function SessionsController($scope, $location, workspace:Workspace, jolokia) {

var stateTemplate = '<div class="ngCellText pagination-centered" title="{{row.getProperty(col.field)}}"><i class="{{row.getProperty(col.field) | tomcatIconClass}}"></i></div>';

$scope.sessions = [];
$scope.search = "";

var columnDefs: any[] = [
{
field: 'stateName',
displayName: 'State',
cellTemplate: stateTemplate,
width: 56,
minWidth: 56,
maxWidth: 56,
resizable: false
},
{
field: 'path',
displayName: 'Context-Path',
cellFilter: null,
width: "*",
resizable: true
},
{
field: 'activeSessions',
displayName: 'Active Sessions',
cellFilter: null,
width: "*",
resizable: true
},
{
field: 'expiredSessions',
displayName: 'Expired Sessions',
cellFilter: null,
width: "*",
resizable: true
},
{
field: 'rejectedSessions',
displayName: 'Rejected Sessions',
cellFilter: null,
width: "*",
resizable: true
},
{
field: 'maxActive',
displayName: 'Max Active Sessions',
cellFilter: null,
width: "*",
resizable: true
},
{
field: 'maxActiveSessions',
displayName: 'Max Active Sessions Allowed',
cellFilter: null,
width: "*",
resizable: true
},
{
field: 'maxInactiveInterval',
displayName: 'Max Inactive Interval',
cellFilter: null,
width: "*",
resizable: true
},
{
field: 'sessionCounter',
displayName: 'Session Counter',
cellFilter: null,
width: "*",
resizable: true
},
{
field: 'sessionCreateRate',
displayName: 'Session Create Rate',
cellFilter: null,
width: "*",
resizable: true
},
{
field: 'sessionExpireRate',
displayName: 'Session Expire Rate',
cellFilter: null,
width: "*",
resizable: true
}
];

$scope.gridOptions = {
data: 'sessions',
displayFooter: false,
displaySelectionCheckbox: false,
canSelectRows: false,
columnDefs: columnDefs,
filterOptions: {
filterText: 'search'
}
};

function render(response) {
response = Tomcat.filerTomcatOrCatalina(response);

$scope.sessions = [];
$scope.mbeanIndex = {};

function onAttributes(response) {
var obj = response.value;
if (obj) {
obj.mbean = response.request.mbean;
var mbean = obj.mbean;
if (mbean) {

// the context path is part of the mbean name
// grab the 2nd part of the mbean that has context=/name
var context = mbean.toString().split(",")[1];
if (context) {
// and remove the leading context=/ from the name
obj.path = context.toString().substr(9)
} else {
obj.path = "";
}

var idx = $scope.mbeanIndex[mbean];
if (angular.isDefined(idx)) {
$scope.sessions[mbean] = obj;
} else {
$scope.sessions[mbean] = $scope.sessions.length;
$scope.sessions.push(obj);
}
}
}
}

angular.forEach(response, function (value, key) {
var mbean = value;
jolokia.request({type: "read", mbean: mbean,
attribute: ["stateName", "activeSessions", "expiredSessions", "rejectedSessions", "maxActive", "maxActiveSessions",
"maxInactiveInterval", "sessionCounter", "sessionCreateRate", "sessionExpireRate"]}, onSuccess(onAttributes));
});
Core.$apply($scope);
};

// function to trigger reloading page
$scope.onLastResponse = function (response) {
$scope.onResponse(response);
// we only want to force updating the data on the last response
loadData();
};

$scope.onResponse = function (response) {
//console.log("got response: " + response);
};

$scope.$watch('workspace.tree', function () {
// if the JMX tree is reloaded its probably because a new MBean has been added or removed
// so lets reload, asynchronously just in case
setTimeout(loadData, 50);
});

function loadData() {
console.log("Loading tomcat session data...");
jolokia.search("*:type=Manager,*", onSuccess(render));
}
}
}
11 changes: 2 additions & 9 deletions hawtio-web/src/main/webapp/app/tomcat/js/tomcat.ts
Expand Up @@ -32,13 +32,6 @@ module Tomcat {
width: "*",
resizable: true
},
{
field: 'sessionTimeout',
displayName: 'Session Timeout',
cellFilter: null,
width: "*",
resizable: true
},
{
field: 'startTime',
displayName: 'Start Time',
Expand Down Expand Up @@ -89,8 +82,8 @@ module Tomcat {

angular.forEach(response, function (value, key) {
var mbean = value;
jolokia.request({type: "read", mbean: mbean, attribute: ["displayName", "path", "stateName",
"sessionTimeout", "startTime"]}, onSuccess(onAttributes));
jolokia.request({type: "read", mbean: mbean,
attribute: ["displayName", "path", "stateName", "startTime"]}, onSuccess(onAttributes));
});
Core.$apply($scope);
};
Expand Down
1 change: 1 addition & 0 deletions hawtio-web/src/main/webapp/app/tomcat/js/tomcatPlugin.ts
Expand Up @@ -6,6 +6,7 @@ module Tomcat {
when('/tomcat/server', {templateUrl: 'app/tomcat/html/server.html'}).
when('/tomcat/applications', {templateUrl: 'app/tomcat/html/applications.html'}).
when('/tomcat/connectors', {templateUrl: 'app/tomcat/html/connectors.html'}).
when('/tomcat/sessions', {templateUrl: 'app/tomcat/html/sessions.html'}).
when('/tomcat/mbeans', {templateUrl: 'app/tomcat/html/mbeans.html'});
}).
filter('tomcatIconClass', () => iconClass).
Expand Down

0 comments on commit c1537a8

Please sign in to comment.