Merge Bench4Q-Master
|
@ -1,8 +1,8 @@
|
|||
<html>
|
||||
<head>
|
||||
<title>frame1</title>
|
||||
</head>
|
||||
<body>
|
||||
<img alt="No this picture" src="images/4.jpg">
|
||||
</body>
|
||||
<html>
|
||||
<head>
|
||||
<title>frame1</title>
|
||||
</head>
|
||||
<body>
|
||||
<img alt="No this picture" src="images/4.jpg">
|
||||
</body>
|
||||
</html>
|
|
@ -1,16 +1,16 @@
|
|||
<html>
|
||||
<head>
|
||||
<title>Bench4Q Test Case</title>
|
||||
<link href="style/bootstrap-cerulean.css" />
|
||||
<link href="style/bootstrap-classic.css" />
|
||||
<link href="style/bootstrap-cerulean.css" />
|
||||
</head>
|
||||
<body>
|
||||
<iframe src=""></iframe>
|
||||
<img src="images/1.jpg" alt="No this one" />
|
||||
<img src="images/2.jpg" alt="No this one" />
|
||||
<img src="images/3.jpg" alt="No this one" />
|
||||
<script src="script/agentTable.js" type="text/javascript"></script>
|
||||
<script src="script/base.js" type="text/javascript"></script>
|
||||
</body>
|
||||
<html>
|
||||
<head>
|
||||
<title>Bench4Q Test Case</title>
|
||||
<link href="style/bootstrap-cerulean.css" />
|
||||
<link href="style/bootstrap-classic.css" />
|
||||
<link href="style/bootstrap-cerulean.css" />
|
||||
</head>
|
||||
<body>
|
||||
<iframe src=""></iframe>
|
||||
<img src="images/1.jpg" alt="No this one" />
|
||||
<img src="images/2.jpg" alt="No this one" />
|
||||
<img src="images/3.jpg" alt="No this one" />
|
||||
<script src="script/agentTable.js" type="text/javascript"></script>
|
||||
<script src="script/base.js" type="text/javascript"></script>
|
||||
</body>
|
||||
</html>
|
Before Width: | Height: | Size: 20 KiB After Width: | Height: | Size: 20 KiB |
Before Width: | Height: | Size: 16 KiB After Width: | Height: | Size: 16 KiB |
Before Width: | Height: | Size: 19 KiB After Width: | Height: | Size: 19 KiB |
Before Width: | Height: | Size: 22 KiB After Width: | Height: | Size: 22 KiB |
Before Width: | Height: | Size: 22 KiB After Width: | Height: | Size: 22 KiB |
Before Width: | Height: | Size: 22 KiB After Width: | Height: | Size: 22 KiB |
|
@ -1,94 +1,94 @@
|
|||
var table= $('#agents');
|
||||
$('.datatable').dataTable({
|
||||
"sDom": "<'row-fluid'<'span6'l><'span6'f>>t<'row-fluid'<'span12 center'p>>",
|
||||
"sPaginationType": "bootstrap",
|
||||
"oLanguage": {
|
||||
"sLengthMenu": "_MENU_ records per page"
|
||||
}
|
||||
} );
|
||||
|
||||
|
||||
$('.btn-setting').click(function(e){
|
||||
e.preventDefault();
|
||||
$("#agentParam").modal('show');
|
||||
});
|
||||
$(document).ready(function() {
|
||||
loadAgents(table);
|
||||
|
||||
});
|
||||
function cancel(){
|
||||
$("#agentParam").modal('hide');
|
||||
}
|
||||
function loadAgents() {
|
||||
table.dataTable().fnClearTable();
|
||||
$.post("loadAgents", {}, function(data) {
|
||||
if (data!=null) {
|
||||
for (var i = 0; i<data.list.length; i++)
|
||||
addAgentTableRow(table, data.list[i]);
|
||||
}
|
||||
},"json");
|
||||
|
||||
$('.btn-info').click(function() {
|
||||
deleteAgent(this);
|
||||
});
|
||||
}
|
||||
|
||||
function addAgentTableRow(table, data) {
|
||||
var status = "NA";
|
||||
switch (data.currentStatus) {
|
||||
case 1:
|
||||
status = "Idle";
|
||||
break;
|
||||
case 2:
|
||||
status = "Running";
|
||||
break;
|
||||
case 3:
|
||||
status = "BackUp";
|
||||
break;
|
||||
case 4:
|
||||
status = "BreakDown";
|
||||
break;
|
||||
default:
|
||||
status = "NA";
|
||||
break;
|
||||
}
|
||||
table.dataTable().fnAddData(
|
||||
[ data.hostName, data.id, data.port, status, data.maxLoad,
|
||||
data.remainLoad, deleteButton ]);
|
||||
|
||||
}
|
||||
|
||||
function getAgentId(obj) {
|
||||
var row = obj.parentNode.parentNode;
|
||||
var tbody = row.parentNode;
|
||||
var id = $(tbody).children("tr").eq(row.rowIndex - 1).children("td").eq(1)
|
||||
.text();
|
||||
return id;
|
||||
}
|
||||
|
||||
function deletetablerow(obj) {
|
||||
id=getAgentId(obj);
|
||||
table=obj.pratent.parent;
|
||||
$.post("removeAgentFromPool", {
|
||||
id : id,
|
||||
}, function(data) {
|
||||
if (data)
|
||||
$(table).dataTable().fnDeleteRow(row.rowIndex - 1);
|
||||
else{}
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
function addAgentToDB() {
|
||||
$.post("addAgentToPool", {
|
||||
hostName : $("#hostName").val(),
|
||||
port : $("#port").val(),
|
||||
maxLoad : $("#maxLoad").val(),
|
||||
remainLoad : $("#remainLoad").val()
|
||||
}, function(data) {
|
||||
if (data) {
|
||||
loadAgents();
|
||||
}
|
||||
});
|
||||
}
|
||||
var table= $('#agents');
|
||||
$('.datatable').dataTable({
|
||||
"sDom": "<'row-fluid'<'span6'l><'span6'f>>t<'row-fluid'<'span12 center'p>>",
|
||||
"sPaginationType": "bootstrap",
|
||||
"oLanguage": {
|
||||
"sLengthMenu": "_MENU_ records per page"
|
||||
}
|
||||
} );
|
||||
|
||||
|
||||
$('.btn-setting').click(function(e){
|
||||
e.preventDefault();
|
||||
$("#agentParam").modal('show');
|
||||
});
|
||||
$(document).ready(function() {
|
||||
loadAgents(table);
|
||||
|
||||
});
|
||||
function cancel(){
|
||||
$("#agentParam").modal('hide');
|
||||
}
|
||||
function loadAgents() {
|
||||
table.dataTable().fnClearTable();
|
||||
$.post("loadAgents", {}, function(data) {
|
||||
if (data!=null) {
|
||||
for (var i = 0; i<data.list.length; i++)
|
||||
addAgentTableRow(table, data.list[i]);
|
||||
}
|
||||
},"json");
|
||||
|
||||
$('.btn-info').click(function() {
|
||||
deleteAgent(this);
|
||||
});
|
||||
}
|
||||
|
||||
function addAgentTableRow(table, data) {
|
||||
var status = "NA";
|
||||
switch (data.currentStatus) {
|
||||
case 1:
|
||||
status = "Idle";
|
||||
break;
|
||||
case 2:
|
||||
status = "Running";
|
||||
break;
|
||||
case 3:
|
||||
status = "BackUp";
|
||||
break;
|
||||
case 4:
|
||||
status = "BreakDown";
|
||||
break;
|
||||
default:
|
||||
status = "NA";
|
||||
break;
|
||||
}
|
||||
table.dataTable().fnAddData(
|
||||
[ data.hostName, data.id, data.port, status, data.maxLoad,
|
||||
data.remainLoad, deleteButton ]);
|
||||
|
||||
}
|
||||
|
||||
function getAgentId(obj) {
|
||||
var row = obj.parentNode.parentNode;
|
||||
var tbody = row.parentNode;
|
||||
var id = $(tbody).children("tr").eq(row.rowIndex - 1).children("td").eq(1)
|
||||
.text();
|
||||
return id;
|
||||
}
|
||||
|
||||
function deletetablerow(obj) {
|
||||
id=getAgentId(obj);
|
||||
table=obj.pratent.parent;
|
||||
$.post("removeAgentFromPool", {
|
||||
id : id,
|
||||
}, function(data) {
|
||||
if (data)
|
||||
$(table).dataTable().fnDeleteRow(row.rowIndex - 1);
|
||||
else{}
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
function addAgentToDB() {
|
||||
$.post("addAgentToPool", {
|
||||
hostName : $("#hostName").val(),
|
||||
port : $("#port").val(),
|
||||
maxLoad : $("#maxLoad").val(),
|
||||
remainLoad : $("#remainLoad").val()
|
||||
}, function(data) {
|
||||
if (data) {
|
||||
loadAgents();
|
||||
}
|
||||
});
|
||||
}
|
|
@ -1,143 +1,143 @@
|
|||
|
||||
/*var viewButton = "<a class='btn btn-success' href='#' ><i class='icon-zoom-in icon-white'></i>View</a>"+" ";
|
||||
var editButton = "<a class='btn btn-success' href='#' ><i class='icon-edit icon-white'></i>Edit</a>"+" ";
|
||||
var deleteButton = "<a class='btn btn-info' href='#'><i class='icon-trash icon-white'></i>Delete</a>";*/
|
||||
|
||||
$(document).ready(function(){
|
||||
//highlight current / active link
|
||||
$('ul.main-menu li a').each(function(){
|
||||
if($($(this))[0].href==String(window.location))
|
||||
$(this).parent().addClass('active');
|
||||
});
|
||||
//animating menus on hover
|
||||
$('ul.main-menu li:not(.nav-header)').hover(function(){
|
||||
$(this).animate({'margin-left':'+=5'},300);
|
||||
},
|
||||
function(){
|
||||
$(this).animate({'margin-left':'-=5'},300);
|
||||
});
|
||||
docReady();
|
||||
loadProperties();
|
||||
});
|
||||
|
||||
|
||||
function docReady(){
|
||||
//makes elements soratble, elements that sort need to have id attribute to save the result
|
||||
$('.sortable').sortable({
|
||||
revert:true,
|
||||
cancel:'.btn,.box-content,.nav-header',
|
||||
update:function(event,ui){
|
||||
//line below gives the ids of elements, you can make ajax call here to save it to the database
|
||||
//console.log($(this).sortable('toArray'));
|
||||
}
|
||||
});
|
||||
$('.btn-close').click(function(e){
|
||||
e.preventDefault();
|
||||
$(this).parent().parent().parent().fadeOut();
|
||||
});
|
||||
$('.btn-minimize').click(function(e){
|
||||
e.preventDefault();
|
||||
var $target = $(this).parent().parent().next('.box-content');
|
||||
if($target.is(':visible')) $('i',$(this)).removeClass('icon-chevron-up').addClass('icon-chevron-down');
|
||||
else $('i',$(this)).removeClass('icon-chevron-down').addClass('icon-chevron-up');
|
||||
$target.slideToggle();
|
||||
});
|
||||
/*$('.btn-setting').click(function(e){
|
||||
e.preventDefault();
|
||||
$('#myModal').modal('show');
|
||||
});*/
|
||||
}
|
||||
$.fn.dataTableExt.oApi.fnPagingInfo = function ( oSettings )
|
||||
{
|
||||
return {
|
||||
"iStart": oSettings._iDisplayStart,
|
||||
"iEnd": oSettings.fnDisplayEnd(),
|
||||
"iLength": oSettings._iDisplayLength,
|
||||
"iTotal": oSettings.fnRecordsTotal(),
|
||||
"iFilteredTotal": oSettings.fnRecordsDisplay(),
|
||||
"iPage": Math.ceil( oSettings._iDisplayStart / oSettings._iDisplayLength ),
|
||||
"iTotalPages": Math.ceil( oSettings.fnRecordsDisplay() / oSettings._iDisplayLength )
|
||||
};
|
||||
};
|
||||
$.extend( $.fn.dataTableExt.oPagination, {
|
||||
"bootstrap": {
|
||||
"fnInit": function( oSettings, nPaging, fnDraw ) {
|
||||
var oLang = oSettings.oLanguage.oPaginate;
|
||||
var fnClickHandler = function ( e ) {
|
||||
e.preventDefault();
|
||||
if ( oSettings.oApi._fnPageChange(oSettings, e.data.action) ) {
|
||||
fnDraw( oSettings );
|
||||
}
|
||||
};
|
||||
|
||||
$(nPaging).addClass('pagination').append(
|
||||
'<ul>'+
|
||||
'<li class="prev disabled"><a href="#">← '+oLang.sPrevious+'</a></li>'+
|
||||
'<li class="next disabled"><a href="#">'+oLang.sNext+' → </a></li>'+
|
||||
'</ul>'
|
||||
);
|
||||
var els = $('a', nPaging);
|
||||
$(els[0]).bind( 'click.DT', { action: "previous" }, fnClickHandler );
|
||||
$(els[1]).bind( 'click.DT', { action: "next" }, fnClickHandler );
|
||||
},
|
||||
|
||||
"fnUpdate": function ( oSettings, fnDraw ) {
|
||||
var iListLength = 5;
|
||||
var oPaging = oSettings.oInstance.fnPagingInfo();
|
||||
var an = oSettings.aanFeatures.p;
|
||||
var i, j, sClass, iStart, iEnd, iHalf=Math.floor(iListLength/2);
|
||||
|
||||
if ( oPaging.iTotalPages < iListLength) {
|
||||
iStart = 1;
|
||||
iEnd = oPaging.iTotalPages;
|
||||
}
|
||||
else if ( oPaging.iPage <= iHalf ) {
|
||||
iStart = 1;
|
||||
iEnd = iListLength;
|
||||
} else if ( oPaging.iPage >= (oPaging.iTotalPages-iHalf) ) {
|
||||
iStart = oPaging.iTotalPages - iListLength + 1;
|
||||
iEnd = oPaging.iTotalPages;
|
||||
} else {
|
||||
iStart = oPaging.iPage - iHalf + 1;
|
||||
iEnd = iStart + iListLength - 1;
|
||||
}
|
||||
|
||||
for ( i=0, iLen=an.length ; i<iLen ; i++ ) {
|
||||
// remove the middle elements
|
||||
$('li:gt(0)', an[i]).filter(':not(:last)').remove();
|
||||
|
||||
// add the new list items and their event handlers
|
||||
for ( j=iStart ; j<=iEnd ; j++ ) {
|
||||
sClass = (j==oPaging.iPage+1) ? 'class="active"' : '';
|
||||
$('<li '+sClass+'><a href="#">'+j+'</a></li>')
|
||||
.insertBefore( $('li:last', an[i])[0] )
|
||||
.bind('click', function (e) {
|
||||
e.preventDefault();
|
||||
oSettings._iDisplayStart = (parseInt($('a', this).text(),10)-1) * oPaging.iLength;
|
||||
fnDraw( oSettings );
|
||||
} );
|
||||
}
|
||||
|
||||
// add / remove disabled classes from the static elements
|
||||
if ( oPaging.iPage === 0 ) {
|
||||
$('li:first', an[i]).addClass('disabled');
|
||||
} else {
|
||||
$('li:first', an[i]).removeClass('disabled');
|
||||
}
|
||||
|
||||
if ( oPaging.iPage === oPaging.iTotalPages-1 || oPaging.iTotalPages === 0 ) {
|
||||
$('li:last', an[i]).addClass('disabled');
|
||||
} else {
|
||||
$('li:last', an[i]).removeClass('disabled');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
function loadProperties(){
|
||||
jQuery.i18n.properties({// 加载资浏览器语言对应的资源文件
|
||||
name:'i18n', // 资源文件名称
|
||||
path:'i18n/', // 资源文件路径
|
||||
mode:'map', // 用 Map 的方式使用资源文件中的值
|
||||
} );
|
||||
}
|
||||
|
||||
/*var viewButton = "<a class='btn btn-success' href='#' ><i class='icon-zoom-in icon-white'></i>View</a>"+" ";
|
||||
var editButton = "<a class='btn btn-success' href='#' ><i class='icon-edit icon-white'></i>Edit</a>"+" ";
|
||||
var deleteButton = "<a class='btn btn-info' href='#'><i class='icon-trash icon-white'></i>Delete</a>";*/
|
||||
|
||||
$(document).ready(function(){
|
||||
//highlight current / active link
|
||||
$('ul.main-menu li a').each(function(){
|
||||
if($($(this))[0].href==String(window.location))
|
||||
$(this).parent().addClass('active');
|
||||
});
|
||||
//animating menus on hover
|
||||
$('ul.main-menu li:not(.nav-header)').hover(function(){
|
||||
$(this).animate({'margin-left':'+=5'},300);
|
||||
},
|
||||
function(){
|
||||
$(this).animate({'margin-left':'-=5'},300);
|
||||
});
|
||||
docReady();
|
||||
loadProperties();
|
||||
});
|
||||
|
||||
|
||||
function docReady(){
|
||||
//makes elements soratble, elements that sort need to have id attribute to save the result
|
||||
$('.sortable').sortable({
|
||||
revert:true,
|
||||
cancel:'.btn,.box-content,.nav-header',
|
||||
update:function(event,ui){
|
||||
//line below gives the ids of elements, you can make ajax call here to save it to the database
|
||||
//console.log($(this).sortable('toArray'));
|
||||
}
|
||||
});
|
||||
$('.btn-close').click(function(e){
|
||||
e.preventDefault();
|
||||
$(this).parent().parent().parent().fadeOut();
|
||||
});
|
||||
$('.btn-minimize').click(function(e){
|
||||
e.preventDefault();
|
||||
var $target = $(this).parent().parent().next('.box-content');
|
||||
if($target.is(':visible')) $('i',$(this)).removeClass('icon-chevron-up').addClass('icon-chevron-down');
|
||||
else $('i',$(this)).removeClass('icon-chevron-down').addClass('icon-chevron-up');
|
||||
$target.slideToggle();
|
||||
});
|
||||
/*$('.btn-setting').click(function(e){
|
||||
e.preventDefault();
|
||||
$('#myModal').modal('show');
|
||||
});*/
|
||||
}
|
||||
$.fn.dataTableExt.oApi.fnPagingInfo = function ( oSettings )
|
||||
{
|
||||
return {
|
||||
"iStart": oSettings._iDisplayStart,
|
||||
"iEnd": oSettings.fnDisplayEnd(),
|
||||
"iLength": oSettings._iDisplayLength,
|
||||
"iTotal": oSettings.fnRecordsTotal(),
|
||||
"iFilteredTotal": oSettings.fnRecordsDisplay(),
|
||||
"iPage": Math.ceil( oSettings._iDisplayStart / oSettings._iDisplayLength ),
|
||||
"iTotalPages": Math.ceil( oSettings.fnRecordsDisplay() / oSettings._iDisplayLength )
|
||||
};
|
||||
};
|
||||
$.extend( $.fn.dataTableExt.oPagination, {
|
||||
"bootstrap": {
|
||||
"fnInit": function( oSettings, nPaging, fnDraw ) {
|
||||
var oLang = oSettings.oLanguage.oPaginate;
|
||||
var fnClickHandler = function ( e ) {
|
||||
e.preventDefault();
|
||||
if ( oSettings.oApi._fnPageChange(oSettings, e.data.action) ) {
|
||||
fnDraw( oSettings );
|
||||
}
|
||||
};
|
||||
|
||||
$(nPaging).addClass('pagination').append(
|
||||
'<ul>'+
|
||||
'<li class="prev disabled"><a href="#">← '+oLang.sPrevious+'</a></li>'+
|
||||
'<li class="next disabled"><a href="#">'+oLang.sNext+' → </a></li>'+
|
||||
'</ul>'
|
||||
);
|
||||
var els = $('a', nPaging);
|
||||
$(els[0]).bind( 'click.DT', { action: "previous" }, fnClickHandler );
|
||||
$(els[1]).bind( 'click.DT', { action: "next" }, fnClickHandler );
|
||||
},
|
||||
|
||||
"fnUpdate": function ( oSettings, fnDraw ) {
|
||||
var iListLength = 5;
|
||||
var oPaging = oSettings.oInstance.fnPagingInfo();
|
||||
var an = oSettings.aanFeatures.p;
|
||||
var i, j, sClass, iStart, iEnd, iHalf=Math.floor(iListLength/2);
|
||||
|
||||
if ( oPaging.iTotalPages < iListLength) {
|
||||
iStart = 1;
|
||||
iEnd = oPaging.iTotalPages;
|
||||
}
|
||||
else if ( oPaging.iPage <= iHalf ) {
|
||||
iStart = 1;
|
||||
iEnd = iListLength;
|
||||
} else if ( oPaging.iPage >= (oPaging.iTotalPages-iHalf) ) {
|
||||
iStart = oPaging.iTotalPages - iListLength + 1;
|
||||
iEnd = oPaging.iTotalPages;
|
||||
} else {
|
||||
iStart = oPaging.iPage - iHalf + 1;
|
||||
iEnd = iStart + iListLength - 1;
|
||||
}
|
||||
|
||||
for ( i=0, iLen=an.length ; i<iLen ; i++ ) {
|
||||
// remove the middle elements
|
||||
$('li:gt(0)', an[i]).filter(':not(:last)').remove();
|
||||
|
||||
// add the new list items and their event handlers
|
||||
for ( j=iStart ; j<=iEnd ; j++ ) {
|
||||
sClass = (j==oPaging.iPage+1) ? 'class="active"' : '';
|
||||
$('<li '+sClass+'><a href="#">'+j+'</a></li>')
|
||||
.insertBefore( $('li:last', an[i])[0] )
|
||||
.bind('click', function (e) {
|
||||
e.preventDefault();
|
||||
oSettings._iDisplayStart = (parseInt($('a', this).text(),10)-1) * oPaging.iLength;
|
||||
fnDraw( oSettings );
|
||||
} );
|
||||
}
|
||||
|
||||
// add / remove disabled classes from the static elements
|
||||
if ( oPaging.iPage === 0 ) {
|
||||
$('li:first', an[i]).addClass('disabled');
|
||||
} else {
|
||||
$('li:first', an[i]).removeClass('disabled');
|
||||
}
|
||||
|
||||
if ( oPaging.iPage === oPaging.iTotalPages-1 || oPaging.iTotalPages === 0 ) {
|
||||
$('li:last', an[i]).addClass('disabled');
|
||||
} else {
|
||||
$('li:last', an[i]).removeClass('disabled');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
function loadProperties(){
|
||||
jQuery.i18n.properties({// 加载资浏览器语言对应的资源文件
|
||||
name:'i18n', // 资源文件名称
|
||||
path:'i18n/', // 资源文件路径
|
||||
mode:'map', // 用 Map 的方式使用资源文件中的值
|
||||
} );
|
||||
}
|
|
@ -1,17 +1,17 @@
|
|||
<html>
|
||||
<head>
|
||||
<title>Bench4Q Test Case</title>
|
||||
<link href="style/bootstrap-cerulean.css" />
|
||||
<link href="style/bootstrap-classic.css" />
|
||||
<link href="style/bootstrap-cerulean.css" />
|
||||
</head>
|
||||
<body>
|
||||
<img src="images/1.jpg" alt="No this one" />
|
||||
<img src="images/2.jpg" alt="No this one" />
|
||||
<img src="images/3.jpg" alt="No this one" />
|
||||
|
||||
<script src="script/agentTable.js" type="text/javascript"></script>
|
||||
<script src="script/base.js" type="text/javascript"></script>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Bench4Q Test Case</title>
|
||||
<link href="style/bootstrap-cerulean.css" />
|
||||
<link href="style/bootstrap-classic.css" />
|
||||
<link href="style/bootstrap-cerulean.css" />
|
||||
</head>
|
||||
<body>
|
||||
<img src="images/1.jpg" alt="No this one" />
|
||||
<img src="images/2.jpg" alt="No this one" />
|
||||
<img src="images/3.jpg" alt="No this one" />
|
||||
|
||||
<script src="script/agentTable.js" type="text/javascript"></script>
|
||||
<script src="script/base.js" type="text/javascript"></script>
|
||||
</body>
|
||||
|
||||
</html>
|
|
@ -1,16 +1,16 @@
|
|||
HTTP/1.1 200 OK
|
||||
Content-Type: text/html; charset=utf-8
|
||||
Server: Microsoft-IIS/7.0
|
||||
CachedXSLT: true
|
||||
X-AspNet-Version: 2.0.50727
|
||||
X-Powered-By: ASP.NET
|
||||
Vary: Accept-Encoding
|
||||
Cache-Control: private, max-age=31
|
||||
Date: Tue, 10 Dec 2013 08:40:29 GMT
|
||||
Content-Length: 26
|
||||
Connection: keep-alive
|
||||
Set-Cookie: agentscape-tag-devtype=desktop; Path=/
|
||||
Set-Cookie: agentscape-proc=noop; Path=/
|
||||
x-agentscape-info: c=1.0-r9869; v=3; fp=f844b0e65e9b5458; ts=1333395837
|
||||
|
||||
HTTP/1.1 200 OK
|
||||
Content-Type: text/html; charset=utf-8
|
||||
Server: Microsoft-IIS/7.0
|
||||
CachedXSLT: true
|
||||
X-AspNet-Version: 2.0.50727
|
||||
X-Powered-By: ASP.NET
|
||||
Vary: Accept-Encoding
|
||||
Cache-Control: private, max-age=31
|
||||
Date: Tue, 10 Dec 2013 08:40:29 GMT
|
||||
Content-Length: 26
|
||||
Connection: keep-alive
|
||||
Set-Cookie: agentscape-tag-devtype=desktop; Path=/
|
||||
Set-Cookie: agentscape-proc=noop; Path=/
|
||||
x-agentscape-info: c=1.0-r9869; v=3; fp=f844b0e65e9b5458; ts=1333395837
|
||||
|
||||
<html><body></body></html>
|
|
@ -1,16 +1,16 @@
|
|||
HTTP/1.1 200 OK
|
||||
Content-Type: text/plain; charset=utf-8
|
||||
Server: Microsoft-IIS/7.0
|
||||
CachedXSLT: true
|
||||
X-AspNet-Version: 2.0.50727
|
||||
X-Powered-By: ASP.NET
|
||||
Vary: Accept-Encoding
|
||||
Cache-Control: private, max-age=31
|
||||
Date: Tue, 10 Dec 2013 08:40:29 GMT
|
||||
Content-Length: 6
|
||||
Connection: keep-alive
|
||||
Set-Cookie: agentscape-tag-devtype=desktop; Path=/
|
||||
Set-Cookie: agentscape-proc=noop; Path=/
|
||||
x-agentscape-info: c=1.0-r9869; v=3; fp=f844b0e65e9b5458; ts=1333395837
|
||||
|
||||
HTTP/1.1 200 OK
|
||||
Content-Type: text/plain; charset=utf-8
|
||||
Server: Microsoft-IIS/7.0
|
||||
CachedXSLT: true
|
||||
X-AspNet-Version: 2.0.50727
|
||||
X-Powered-By: ASP.NET
|
||||
Vary: Accept-Encoding
|
||||
Cache-Control: private, max-age=31
|
||||
Date: Tue, 10 Dec 2013 08:40:29 GMT
|
||||
Content-Length: 6
|
||||
Connection: keep-alive
|
||||
Set-Cookie: agentscape-tag-devtype=desktop; Path=/
|
||||
Set-Cookie: agentscape-proc=noop; Path=/
|
||||
x-agentscape-info: c=1.0-r9869; v=3; fp=f844b0e65e9b5458; ts=1333395837
|
||||
|
||||
adnddm
|
|
@ -1,15 +1,15 @@
|
|||
GET /phoenix.zhtml?c=188488&p=irol-homeprofile HTTP/1.1
|
||||
Host: ir.baidu.com
|
||||
Connection: keep-alive
|
||||
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8
|
||||
User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/31.0.1650.63 Safari/537.36
|
||||
Referer: http://www.baidu.com/
|
||||
Accept-Encoding: gzip,deflate,sdch
|
||||
IF-MODIFIED-SINCE: Mon, 22 Mar 2010 14:14:40 GMT; old-content-length=200
|
||||
AUTHORIZATION: bearer
|
||||
Accept-Language: zh-CN,zh;q=0.8
|
||||
Content-Type: multipart
|
||||
Content-Length: 100
|
||||
Pragma: No-Cache
|
||||
Cookie: BAIDUID=993724E1CAB01EE3D0C0AFAA99796E6A:FG=1; H_PS_PSSID=4381_1463_4212_4264_4451
|
||||
|
||||
GET /phoenix.zhtml?c=188488&p=irol-homeprofile HTTP/1.1
|
||||
Host: ir.baidu.com
|
||||
Connection: keep-alive
|
||||
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8
|
||||
User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/31.0.1650.63 Safari/537.36
|
||||
Referer: http://www.baidu.com/
|
||||
Accept-Encoding: gzip,deflate,sdch
|
||||
IF-MODIFIED-SINCE: Mon, 22 Mar 2010 14:14:40 GMT; old-content-length=200
|
||||
AUTHORIZATION: bearer
|
||||
Accept-Language: zh-CN,zh;q=0.8
|
||||
Content-Type: multipart
|
||||
Content-Length: 100
|
||||
Pragma: No-Cache
|
||||
Cookie: BAIDUID=993724E1CAB01EE3D0C0AFAA99796E6A:FG=1; H_PS_PSSID=4381_1463_4212_4264_4451
|
||||
|
|
@ -1,10 +1,10 @@
|
|||
GET / HTTP/1.1
|
||||
Host: www.baidu.com
|
||||
Connection: keep-alive
|
||||
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8
|
||||
User-Agent: Mozilla/5.0 (Windows NT 6.2; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/31.0.1650.63 Safari/537.36
|
||||
DNT: 1
|
||||
Accept-Encoding: gzip,deflate,sdch
|
||||
Accept-Language: en,zh-CN;q=0.8,zh;q=0.6
|
||||
Cookie: BAIDUID=1D43A956BCED0A81B8340058134CD2F6:FG=1; BDUSS=EJMRWZ2eklMaERoQ344em5RZ2EyTVh0UjRDcWpiRmhnMjRlLTZnR3NZajBOS0JTQVFBQUFBJCQAAAAAAAAAAAEAAAA2JuwxZmVuZ3l1bjIwMTIzOQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAPSneFL0p3hSN; Hm_lvt_9f14aaa038bbba8b12ec2a4a3e51d254=1384429678; H_PS_PSSID=3784_4199_1432_4421_4414_4211_4264_4450_4503; BDRCVFR[feWj1Vr5u3D]=I67x6TjHwwYf0
|
||||
|
||||
GET / HTTP/1.1
|
||||
Host: www.baidu.com
|
||||
Connection: keep-alive
|
||||
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8
|
||||
User-Agent: Mozilla/5.0 (Windows NT 6.2; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/31.0.1650.63 Safari/537.36
|
||||
DNT: 1
|
||||
Accept-Encoding: gzip,deflate,sdch
|
||||
Accept-Language: en,zh-CN;q=0.8,zh;q=0.6
|
||||
Cookie: BAIDUID=1D43A956BCED0A81B8340058134CD2F6:FG=1; BDUSS=EJMRWZ2eklMaERoQ344em5RZ2EyTVh0UjRDcWpiRmhnMjRlLTZnR3NZajBOS0JTQVFBQUFBJCQAAAAAAAAAAAEAAAA2JuwxZmVuZ3l1bjIwMTIzOQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAPSneFL0p3hSN; Hm_lvt_9f14aaa038bbba8b12ec2a4a3e51d254=1384429678; H_PS_PSSID=3784_4199_1432_4421_4414_4211_4264_4450_4503; BDRCVFR[feWj1Vr5u3D]=I67x6TjHwwYf0
|
||||
|
|
@ -1,16 +1,16 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
||||
<agentBriefStatusModel>
|
||||
<failCountFromBegin>0</failCountFromBegin>
|
||||
<failCountThisTime>0</failCountThisTime>
|
||||
<failThroughputThisTime>0</failThroughputThisTime>
|
||||
<maxResponseTime>1203</maxResponseTime>
|
||||
<minResponseTime>0</minResponseTime>
|
||||
<successCountFromBegin>28205</successCountFromBegin>
|
||||
<successCountThisTime>1774</successCountThisTime>
|
||||
<successThroughputThisTime>559</successThroughputThisTime>
|
||||
<timeFrame>3172</timeFrame>
|
||||
<totalResponseTimeThisTime>22154</totalResponseTimeThisTime>
|
||||
<totalSqureResponseTimeThisTime>5245392
|
||||
</totalSqureResponseTimeThisTime>
|
||||
<vUserCount>40</vUserCount>
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
||||
<agentBriefStatusModel>
|
||||
<failCountFromBegin>0</failCountFromBegin>
|
||||
<failCountThisTime>0</failCountThisTime>
|
||||
<failThroughputThisTime>0</failThroughputThisTime>
|
||||
<maxResponseTime>1203</maxResponseTime>
|
||||
<minResponseTime>0</minResponseTime>
|
||||
<successCountFromBegin>28205</successCountFromBegin>
|
||||
<successCountThisTime>1774</successCountThisTime>
|
||||
<successThroughputThisTime>559</successThroughputThisTime>
|
||||
<timeFrame>3172</timeFrame>
|
||||
<totalResponseTimeThisTime>22154</totalResponseTimeThisTime>
|
||||
<totalSqureResponseTimeThisTime>5245392
|
||||
</totalSqureResponseTimeThisTime>
|
||||
<vUserCount>40</vUserCount>
|
||||
</agentBriefStatusModel>
|
|
@ -1,26 +1,26 @@
|
|||
HTTP/1.1 200 OK
|
||||
Server: Apache-Coyote/1.1
|
||||
Accept-Ranges: bytes
|
||||
ETag: W/"532-1386125334307"
|
||||
Last-Modified: Wed, 04 Dec 2013 02:48:54 GMT
|
||||
Content-Type: text/html
|
||||
Content-Length: 532
|
||||
Date: Mon, 09 Dec 2013 07:03:15 GMT
|
||||
|
||||
<html>
|
||||
<head>
|
||||
<title>Bench4Q Test Case</title>
|
||||
<link href="style/bootstrap-cerulean.css" />
|
||||
<link href="style/bootstrap-classic.css" />
|
||||
<link href="style/bootstrap-cerulean.css" />
|
||||
</head>
|
||||
<body>
|
||||
<img src="images/1.jpg" alt="No this one" />
|
||||
<img src="images/2.jpg" alt="No this one" />
|
||||
<img src="images/3.jpg" alt="No this one" />
|
||||
|
||||
<script src="script/agentTable.js" type="text/javascript"></script>
|
||||
<script src="script/base.js" type="text/javascript"></script>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
HTTP/1.1 200 OK
|
||||
Server: Apache-Coyote/1.1
|
||||
Accept-Ranges: bytes
|
||||
ETag: W/"532-1386125334307"
|
||||
Last-Modified: Wed, 04 Dec 2013 02:48:54 GMT
|
||||
Content-Type: text/html
|
||||
Content-Length: 532
|
||||
Date: Mon, 09 Dec 2013 07:03:15 GMT
|
||||
|
||||
<html>
|
||||
<head>
|
||||
<title>Bench4Q Test Case</title>
|
||||
<link href="style/bootstrap-cerulean.css" />
|
||||
<link href="style/bootstrap-classic.css" />
|
||||
<link href="style/bootstrap-cerulean.css" />
|
||||
</head>
|
||||
<body>
|
||||
<img src="images/1.jpg" alt="No this one" />
|
||||
<img src="images/2.jpg" alt="No this one" />
|
||||
<img src="images/3.jpg" alt="No this one" />
|
||||
|
||||
<script src="script/agentTable.js" type="text/javascript"></script>
|
||||
<script src="script/base.js" type="text/javascript"></script>
|
||||
</body>
|
||||
|
||||
</html>
|
|
@ -1,25 +1,25 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<assembly
|
||||
xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0 http://maven.apache.org/xsd/assembly-1.1.0.xsd">
|
||||
<id>publish</id>
|
||||
<formats>
|
||||
<format>tar.gz</format>
|
||||
</formats>
|
||||
<includeBaseDirectory>false</includeBaseDirectory>
|
||||
<dependencySets>
|
||||
<dependencySet>
|
||||
<outputDirectory>lib</outputDirectory>
|
||||
<useProjectArtifact>false</useProjectArtifact>
|
||||
<unpack>false</unpack>
|
||||
<scope>runtime</scope>
|
||||
</dependencySet>
|
||||
</dependencySets>
|
||||
<files>
|
||||
<file>
|
||||
<source>target/bench4q-master.jar</source>
|
||||
<outputDirectory>/</outputDirectory>
|
||||
</file>
|
||||
</files>
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<assembly
|
||||
xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0 http://maven.apache.org/xsd/assembly-1.1.0.xsd">
|
||||
<id>publish</id>
|
||||
<formats>
|
||||
<format>tar.gz</format>
|
||||
</formats>
|
||||
<includeBaseDirectory>false</includeBaseDirectory>
|
||||
<dependencySets>
|
||||
<dependencySet>
|
||||
<outputDirectory>lib</outputDirectory>
|
||||
<useProjectArtifact>false</useProjectArtifact>
|
||||
<unpack>false</unpack>
|
||||
<scope>runtime</scope>
|
||||
</dependencySet>
|
||||
</dependencySets>
|
||||
<files>
|
||||
<file>
|
||||
<source>target/bench4q-master.jar</source>
|
||||
<outputDirectory>/</outputDirectory>
|
||||
</file>
|
||||
</files>
|
||||
</assembly>
|
|
@ -1,167 +1,167 @@
|
|||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>org.bench4q</groupId>
|
||||
<artifactId>bench4q-master</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<name>Bench4Q Master</name>
|
||||
<description>Bench4Q Master</description>
|
||||
<organization>
|
||||
<name>TCSE, ISCAS</name>
|
||||
</organization>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<version>4.11</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework</groupId>
|
||||
<artifactId>spring-webmvc</artifactId>
|
||||
<version>3.2.5.RELEASE</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.codehaus.jackson</groupId>
|
||||
<artifactId>jackson-mapper-asl</artifactId>
|
||||
<version>1.9.12</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.hibernate</groupId>
|
||||
<artifactId>hibernate-core</artifactId>
|
||||
<version>4.3.0.Beta3</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.hibernate.javax.persistence</groupId>
|
||||
<artifactId>hibernate-jpa-2.1-api</artifactId>
|
||||
<version>1.0.0.Draft-16</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>mysql</groupId>
|
||||
<artifactId>mysql-connector-java</artifactId>
|
||||
<version>5.1.25</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>log4j</groupId>
|
||||
<artifactId>log4j</artifactId>
|
||||
<version>1.2.17</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>commons-httpclient</groupId>
|
||||
<artifactId>commons-httpclient</artifactId>
|
||||
<version>3.1</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.python</groupId>
|
||||
<artifactId>jython</artifactId>
|
||||
<version>2.7-b1</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework</groupId>
|
||||
<artifactId>spring-test</artifactId>
|
||||
<version>3.2.5.RELEASE</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.quartz-scheduler</groupId>
|
||||
<artifactId>quartz</artifactId>
|
||||
<version>1.8.5</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework</groupId>
|
||||
<artifactId>spring-core</artifactId>
|
||||
<version>3.2.5.RELEASE</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-simple</artifactId>
|
||||
<version>1.7.5</version>
|
||||
</dependency>
|
||||
<!-- this is used to create chart for report -->
|
||||
<dependency>
|
||||
<groupId>jfree</groupId>
|
||||
<artifactId>jfreechart</artifactId>
|
||||
<version>1.0.13</version>
|
||||
</dependency>
|
||||
<!-- this is used to create a pdf report -->
|
||||
<dependency>
|
||||
<groupId>org.eclipse.birt.runtime.3_7_1</groupId>
|
||||
<artifactId>com.lowagie.text</artifactId>
|
||||
<version>2.1.7</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.portals.jetspeed-2</groupId>
|
||||
<artifactId>jetspeed-fileutils-maven-plugin</artifactId>
|
||||
<version>2.2.2</version>
|
||||
<type>maven-plugin</type>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.bench4q</groupId>
|
||||
<artifactId>bench4q-share</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.eclipse.jetty</groupId>
|
||||
<artifactId>jetty-servlet</artifactId>
|
||||
<version>9.1.0.RC2</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.eclipse.jetty</groupId>
|
||||
<artifactId>jetty-server</artifactId>
|
||||
<version>9.1.0.RC2</version>
|
||||
</dependency>
|
||||
<!-- this is used to parse html dom tree -->
|
||||
<dependency>
|
||||
<groupId>org.jsoup</groupId>
|
||||
<artifactId>jsoup</artifactId>
|
||||
<version>1.7.3</version>
|
||||
</dependency>
|
||||
<!-- this is used to parse http request and response -->
|
||||
<dependency>
|
||||
<groupId>org.apache.httpcomponents</groupId>
|
||||
<artifactId>httpcore-nio</artifactId>
|
||||
<version>4.3</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<artifactId>maven-jar-plugin</artifactId>
|
||||
<configuration>
|
||||
<archive>
|
||||
<manifest>
|
||||
<mainClass>org.bench4q.master.Main</mainClass>
|
||||
<addClasspath>true</addClasspath>
|
||||
<classpathPrefix>lib/</classpathPrefix>
|
||||
</manifest>
|
||||
</archive>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<artifactId>maven-assembly-plugin</artifactId>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>make-zip</id>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>single</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<descriptors>
|
||||
<descriptor>descriptor.xml</descriptor>
|
||||
</descriptors>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-surefire-plugin</artifactId>
|
||||
<configuration>
|
||||
<skip>true</skip>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
<finalName>bench4q-master</finalName>
|
||||
</build>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>org.bench4q</groupId>
|
||||
<artifactId>bench4q-master</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<name>Bench4Q Master</name>
|
||||
<description>Bench4Q Master</description>
|
||||
<organization>
|
||||
<name>TCSE, ISCAS</name>
|
||||
</organization>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<version>4.11</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework</groupId>
|
||||
<artifactId>spring-webmvc</artifactId>
|
||||
<version>3.2.5.RELEASE</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.codehaus.jackson</groupId>
|
||||
<artifactId>jackson-mapper-asl</artifactId>
|
||||
<version>1.9.12</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.hibernate</groupId>
|
||||
<artifactId>hibernate-core</artifactId>
|
||||
<version>4.3.0.Beta3</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.hibernate.javax.persistence</groupId>
|
||||
<artifactId>hibernate-jpa-2.1-api</artifactId>
|
||||
<version>1.0.0.Draft-16</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>mysql</groupId>
|
||||
<artifactId>mysql-connector-java</artifactId>
|
||||
<version>5.1.25</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>log4j</groupId>
|
||||
<artifactId>log4j</artifactId>
|
||||
<version>1.2.17</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>commons-httpclient</groupId>
|
||||
<artifactId>commons-httpclient</artifactId>
|
||||
<version>3.1</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.python</groupId>
|
||||
<artifactId>jython</artifactId>
|
||||
<version>2.7-b1</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework</groupId>
|
||||
<artifactId>spring-test</artifactId>
|
||||
<version>3.2.5.RELEASE</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.quartz-scheduler</groupId>
|
||||
<artifactId>quartz</artifactId>
|
||||
<version>1.8.5</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework</groupId>
|
||||
<artifactId>spring-core</artifactId>
|
||||
<version>3.2.5.RELEASE</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-simple</artifactId>
|
||||
<version>1.7.5</version>
|
||||
</dependency>
|
||||
<!-- this is used to create chart for report -->
|
||||
<dependency>
|
||||
<groupId>jfree</groupId>
|
||||
<artifactId>jfreechart</artifactId>
|
||||
<version>1.0.13</version>
|
||||
</dependency>
|
||||
<!-- this is used to create a pdf report -->
|
||||
<dependency>
|
||||
<groupId>org.eclipse.birt.runtime.3_7_1</groupId>
|
||||
<artifactId>com.lowagie.text</artifactId>
|
||||
<version>2.1.7</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.portals.jetspeed-2</groupId>
|
||||
<artifactId>jetspeed-fileutils-maven-plugin</artifactId>
|
||||
<version>2.2.2</version>
|
||||
<type>maven-plugin</type>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.bench4q</groupId>
|
||||
<artifactId>bench4q-share</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.eclipse.jetty</groupId>
|
||||
<artifactId>jetty-servlet</artifactId>
|
||||
<version>9.1.0.RC2</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.eclipse.jetty</groupId>
|
||||
<artifactId>jetty-server</artifactId>
|
||||
<version>9.1.0.RC2</version>
|
||||
</dependency>
|
||||
<!-- this is used to parse html dom tree -->
|
||||
<dependency>
|
||||
<groupId>org.jsoup</groupId>
|
||||
<artifactId>jsoup</artifactId>
|
||||
<version>1.7.3</version>
|
||||
</dependency>
|
||||
<!-- this is used to parse http request and response -->
|
||||
<dependency>
|
||||
<groupId>org.apache.httpcomponents</groupId>
|
||||
<artifactId>httpcore-nio</artifactId>
|
||||
<version>4.3</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<artifactId>maven-jar-plugin</artifactId>
|
||||
<configuration>
|
||||
<archive>
|
||||
<manifest>
|
||||
<mainClass>org.bench4q.master.Main</mainClass>
|
||||
<addClasspath>true</addClasspath>
|
||||
<classpathPrefix>lib/</classpathPrefix>
|
||||
</manifest>
|
||||
</archive>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<artifactId>maven-assembly-plugin</artifactId>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>make-zip</id>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>single</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<descriptors>
|
||||
<descriptor>descriptor.xml</descriptor>
|
||||
</descriptors>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-surefire-plugin</artifactId>
|
||||
<configuration>
|
||||
<skip>true</skip>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
<finalName>bench4q-master</finalName>
|
||||
</build>
|
||||
</project>
|
|
@ -1,57 +1,57 @@
|
|||
package org.bench4q.master;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.util.Properties;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author coderfengyun
|
||||
*
|
||||
*/
|
||||
public class Main {
|
||||
private static Logger logger = Logger.getLogger(Main.class);
|
||||
public static int Min_Sample_Cycle_InSecond = 10;
|
||||
public static int MAX_FAIL_TIMES = 10;
|
||||
public static int MIN_EXECUTE_INTERVAL_IN_SECONDS = 600;
|
||||
public static int PICK_CYCLE_IN_SECONDS = 60;
|
||||
|
||||
public static void main(String[] args) {
|
||||
try {
|
||||
MasterServer masterServer = new MasterServer(getPortToServe());
|
||||
masterServer.start();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
public static int getPortToServe() {
|
||||
int portToUse = 0;
|
||||
Properties prop = new Properties();
|
||||
String configFile = "";
|
||||
try {
|
||||
InputStream inputStream = Main.class.getClassLoader()
|
||||
.getResourceAsStream(
|
||||
"org/bench4q/master/config/ServerPort.properties");
|
||||
prop.load(inputStream);
|
||||
portToUse = Integer.parseInt(prop.getProperty("portToServe"));
|
||||
MAX_FAIL_TIMES = Integer.parseInt(prop.getProperty("maxFailTime"));
|
||||
MIN_EXECUTE_INTERVAL_IN_SECONDS = Integer.parseInt(prop
|
||||
.getProperty("minExcuteIntervalInSeconds"));
|
||||
PICK_CYCLE_IN_SECONDS = Integer.parseInt(prop
|
||||
.getProperty("pickTestPlanCycleInSeconds"));
|
||||
Min_Sample_Cycle_InSecond = Integer.parseInt(prop
|
||||
.getProperty("minSampleCycleInSeconds"));
|
||||
} catch (Exception e) {
|
||||
portToUse = 8080;
|
||||
MAX_FAIL_TIMES = 10;
|
||||
MIN_EXECUTE_INTERVAL_IN_SECONDS = 600;
|
||||
PICK_CYCLE_IN_SECONDS = 60;
|
||||
Min_Sample_Cycle_InSecond = 10;
|
||||
logger.error("There is no config file for port to serve! where path is "
|
||||
+ configFile);
|
||||
}
|
||||
return portToUse;
|
||||
}
|
||||
}
|
||||
package org.bench4q.master;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.util.Properties;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author coderfengyun
|
||||
*
|
||||
*/
|
||||
public class Main {
|
||||
private static Logger logger = Logger.getLogger(Main.class);
|
||||
public static int Min_Sample_Cycle_InSecond = 10;
|
||||
public static int MAX_FAIL_TIMES = 10;
|
||||
public static int MIN_EXECUTE_INTERVAL_IN_SECONDS = 600;
|
||||
public static int PICK_CYCLE_IN_SECONDS = 60;
|
||||
|
||||
public static void main(String[] args) {
|
||||
try {
|
||||
MasterServer masterServer = new MasterServer(getPortToServe());
|
||||
masterServer.start();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
public static int getPortToServe() {
|
||||
int portToUse = 0;
|
||||
Properties prop = new Properties();
|
||||
String configFile = "";
|
||||
try {
|
||||
InputStream inputStream = Main.class.getClassLoader()
|
||||
.getResourceAsStream(
|
||||
"org/bench4q/master/config/ServerPort.properties");
|
||||
prop.load(inputStream);
|
||||
portToUse = Integer.parseInt(prop.getProperty("portToServe"));
|
||||
MAX_FAIL_TIMES = Integer.parseInt(prop.getProperty("maxFailTime"));
|
||||
MIN_EXECUTE_INTERVAL_IN_SECONDS = Integer.parseInt(prop
|
||||
.getProperty("minExcuteIntervalInSeconds"));
|
||||
PICK_CYCLE_IN_SECONDS = Integer.parseInt(prop
|
||||
.getProperty("pickTestPlanCycleInSeconds"));
|
||||
Min_Sample_Cycle_InSecond = Integer.parseInt(prop
|
||||
.getProperty("minSampleCycleInSeconds"));
|
||||
} catch (Exception e) {
|
||||
portToUse = 8080;
|
||||
MAX_FAIL_TIMES = 10;
|
||||
MIN_EXECUTE_INTERVAL_IN_SECONDS = 600;
|
||||
PICK_CYCLE_IN_SECONDS = 60;
|
||||
Min_Sample_Cycle_InSecond = 10;
|
||||
logger.error("There is no config file for port to serve! where path is "
|
||||
+ configFile);
|
||||
}
|
||||
return portToUse;
|
||||
}
|
||||
}
|
|
@ -1,75 +1,75 @@
|
|||
package org.bench4q.master;
|
||||
|
||||
import org.eclipse.jetty.server.Connector;
|
||||
import org.eclipse.jetty.server.Server;
|
||||
import org.eclipse.jetty.servlet.ServletContextHandler;
|
||||
import org.eclipse.jetty.servlet.ServletHolder;
|
||||
import org.springframework.web.servlet.DispatcherServlet;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author coderfengyun
|
||||
*
|
||||
*/
|
||||
public class MasterServer {
|
||||
private Server server;
|
||||
private int port;
|
||||
|
||||
private Server getServer() {
|
||||
return server;
|
||||
}
|
||||
|
||||
private void setServer(Server server) {
|
||||
this.server = server;
|
||||
}
|
||||
|
||||
private int getPort() {
|
||||
return port;
|
||||
}
|
||||
|
||||
private void setPort(int port) {
|
||||
this.port = port;
|
||||
}
|
||||
|
||||
public MasterServer(int port) {
|
||||
this.setPort(port);
|
||||
}
|
||||
|
||||
public boolean start() {
|
||||
try {
|
||||
this.setServer(new Server(this.getPort()));
|
||||
ServletContextHandler servletContextHandler = new ServletContextHandler();
|
||||
ServletHolder servletHolder = servletContextHandler.addServlet(
|
||||
DispatcherServlet.class, "/");
|
||||
servletHolder
|
||||
.setInitParameter("contextConfigLocation",
|
||||
"classpath*:/org/bench4q/master/config/application-context.xml");
|
||||
servletHolder.setInitOrder(1);
|
||||
this.getServer().setHandler(servletContextHandler);
|
||||
this.getServer().start();
|
||||
return true;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public boolean stop() {
|
||||
try {
|
||||
if (this.getServer() != null) {
|
||||
for (Connector connector : this.getServer().getConnectors()) {
|
||||
if (connector != null) {
|
||||
connector.shutdown();
|
||||
}
|
||||
}
|
||||
this.getServer().stop();
|
||||
}
|
||||
return true;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return false;
|
||||
} finally {
|
||||
this.setServer(null);
|
||||
}
|
||||
}
|
||||
}
|
||||
package org.bench4q.master;
|
||||
|
||||
import org.eclipse.jetty.server.Connector;
|
||||
import org.eclipse.jetty.server.Server;
|
||||
import org.eclipse.jetty.servlet.ServletContextHandler;
|
||||
import org.eclipse.jetty.servlet.ServletHolder;
|
||||
import org.springframework.web.servlet.DispatcherServlet;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author coderfengyun
|
||||
*
|
||||
*/
|
||||
public class MasterServer {
|
||||
private Server server;
|
||||
private int port;
|
||||
|
||||
private Server getServer() {
|
||||
return server;
|
||||
}
|
||||
|
||||
private void setServer(Server server) {
|
||||
this.server = server;
|
||||
}
|
||||
|
||||
private int getPort() {
|
||||
return port;
|
||||
}
|
||||
|
||||
private void setPort(int port) {
|
||||
this.port = port;
|
||||
}
|
||||
|
||||
public MasterServer(int port) {
|
||||
this.setPort(port);
|
||||
}
|
||||
|
||||
public boolean start() {
|
||||
try {
|
||||
this.setServer(new Server(this.getPort()));
|
||||
ServletContextHandler servletContextHandler = new ServletContextHandler();
|
||||
ServletHolder servletHolder = servletContextHandler.addServlet(
|
||||
DispatcherServlet.class, "/");
|
||||
servletHolder
|
||||
.setInitParameter("contextConfigLocation",
|
||||
"classpath*:/org/bench4q/master/config/application-context.xml");
|
||||
servletHolder.setInitOrder(1);
|
||||
this.getServer().setHandler(servletContextHandler);
|
||||
this.getServer().start();
|
||||
return true;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public boolean stop() {
|
||||
try {
|
||||
if (this.getServer() != null) {
|
||||
for (Connector connector : this.getServer().getConnectors()) {
|
||||
if (connector != null) {
|
||||
connector.shutdown();
|
||||
}
|
||||
}
|
||||
this.getServer().stop();
|
||||
}
|
||||
return true;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return false;
|
||||
} finally {
|
||||
this.setServer(null);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,62 +1,62 @@
|
|||
package org.bench4q.master;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.bench4q.share.models.master.plugin.MethodModel;
|
||||
import org.bench4q.share.models.master.plugin.MethodParamModel;
|
||||
import org.bench4q.share.models.master.plugin.ParamTypeEnum;
|
||||
import org.bench4q.share.models.master.plugin.PluginModel;
|
||||
import org.bench4q.share.models.master.plugin.MethodParamPropertyModel;
|
||||
|
||||
;
|
||||
|
||||
public class TestPlunginHelper {
|
||||
|
||||
public static PluginModel createOnePlugin() {
|
||||
PluginModel plugin = new PluginModel();
|
||||
MethodModel method = new MethodModel();
|
||||
MethodParamModel methodParamModelUrl = new MethodParamModel();
|
||||
methodParamModelUrl.setLable("input url");
|
||||
methodParamModelUrl.setName("url");
|
||||
methodParamModelUrl.setMethodParamProperties(generatePropertyForField());
|
||||
methodParamModelUrl.setParamType(ParamTypeEnum.Field);
|
||||
|
||||
MethodParamModel methodParamsParamModel = new MethodParamModel();
|
||||
methodParamsParamModel.setName("queryparams");
|
||||
methodParamsParamModel.setLable("key=value");
|
||||
methodParamsParamModel.setMethodParamProperties(generatePropertyForMulti());
|
||||
methodParamsParamModel.setParamType(ParamTypeEnum.MultiField);
|
||||
Set<MethodParamModel> methodParams = new HashSet<MethodParamModel>();
|
||||
methodParams.add(methodParamModelUrl);
|
||||
methodParams.add(methodParamsParamModel);
|
||||
method.setName("get");
|
||||
method.setMethodParams(methodParams);
|
||||
|
||||
Set<MethodModel> methods = new HashSet<MethodModel>();
|
||||
methods.add(method);
|
||||
plugin.setMethods(methods);
|
||||
plugin.setName("http" + UUID.randomUUID());
|
||||
return plugin;
|
||||
|
||||
}
|
||||
private static Set<MethodParamPropertyModel> generatePropertyForField() {
|
||||
Set<MethodParamPropertyModel> metList = new HashSet<MethodParamPropertyModel>();
|
||||
MethodParamPropertyModel methodParamPropertyModel = new MethodParamPropertyModel();
|
||||
methodParamPropertyModel.setKey("size");
|
||||
methodParamPropertyModel.setValue("20");
|
||||
metList.add(methodParamPropertyModel);
|
||||
return metList;
|
||||
|
||||
}
|
||||
private static Set<MethodParamPropertyModel> generatePropertyForMulti() {
|
||||
Set<MethodParamPropertyModel> metList = new HashSet<MethodParamPropertyModel>();
|
||||
MethodParamPropertyModel methodParamPropertyModel = new MethodParamPropertyModel();
|
||||
methodParamPropertyModel.setKey("size");
|
||||
methodParamPropertyModel.setValue("20");
|
||||
metList.add(methodParamPropertyModel);
|
||||
return metList;
|
||||
|
||||
}
|
||||
}
|
||||
package org.bench4q.master;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.bench4q.share.models.master.plugin.MethodModel;
|
||||
import org.bench4q.share.models.master.plugin.MethodParamModel;
|
||||
import org.bench4q.share.models.master.plugin.ParamTypeEnum;
|
||||
import org.bench4q.share.models.master.plugin.PluginModel;
|
||||
import org.bench4q.share.models.master.plugin.MethodParamPropertyModel;
|
||||
|
||||
;
|
||||
|
||||
public class TestPlunginHelper {
|
||||
|
||||
public static PluginModel createOnePlugin() {
|
||||
PluginModel plugin = new PluginModel();
|
||||
MethodModel method = new MethodModel();
|
||||
MethodParamModel methodParamModelUrl = new MethodParamModel();
|
||||
methodParamModelUrl.setLable("input url");
|
||||
methodParamModelUrl.setName("url");
|
||||
methodParamModelUrl.setMethodParamProperties(generatePropertyForField());
|
||||
methodParamModelUrl.setParamType(ParamTypeEnum.Field);
|
||||
|
||||
MethodParamModel methodParamsParamModel = new MethodParamModel();
|
||||
methodParamsParamModel.setName("queryparams");
|
||||
methodParamsParamModel.setLable("key=value");
|
||||
methodParamsParamModel.setMethodParamProperties(generatePropertyForMulti());
|
||||
methodParamsParamModel.setParamType(ParamTypeEnum.MultiField);
|
||||
Set<MethodParamModel> methodParams = new HashSet<MethodParamModel>();
|
||||
methodParams.add(methodParamModelUrl);
|
||||
methodParams.add(methodParamsParamModel);
|
||||
method.setName("get");
|
||||
method.setMethodParams(methodParams);
|
||||
|
||||
Set<MethodModel> methods = new HashSet<MethodModel>();
|
||||
methods.add(method);
|
||||
plugin.setMethods(methods);
|
||||
plugin.setName("http" + UUID.randomUUID());
|
||||
return plugin;
|
||||
|
||||
}
|
||||
private static Set<MethodParamPropertyModel> generatePropertyForField() {
|
||||
Set<MethodParamPropertyModel> metList = new HashSet<MethodParamPropertyModel>();
|
||||
MethodParamPropertyModel methodParamPropertyModel = new MethodParamPropertyModel();
|
||||
methodParamPropertyModel.setKey("size");
|
||||
methodParamPropertyModel.setValue("20");
|
||||
metList.add(methodParamPropertyModel);
|
||||
return metList;
|
||||
|
||||
}
|
||||
private static Set<MethodParamPropertyModel> generatePropertyForMulti() {
|
||||
Set<MethodParamPropertyModel> metList = new HashSet<MethodParamPropertyModel>();
|
||||
MethodParamPropertyModel methodParamPropertyModel = new MethodParamPropertyModel();
|
||||
methodParamPropertyModel.setKey("size");
|
||||
methodParamPropertyModel.setValue("20");
|
||||
metList.add(methodParamPropertyModel);
|
||||
return metList;
|
||||
|
||||
}
|
||||
}
|
|
@ -1,128 +1,128 @@
|
|||
package org.bench4q.master.api;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
import org.bench4q.master.TestPlunginHelper;
|
||||
import org.bench4q.master.domain.service.PluginService;
|
||||
import org.bench4q.master.domain.service.UserService;
|
||||
import org.bench4q.master.exception.Bench4QException;
|
||||
import org.bench4q.master.exception.ExceptionLog;
|
||||
import org.bench4q.share.models.master.plugin.PluginGUI;
|
||||
import org.bench4q.share.models.master.plugin.PluginModel;
|
||||
import org.bench4q.share.models.master.plugin.PluginResponseModel;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
|
||||
@Controller
|
||||
@RequestMapping("/plugin")
|
||||
public class PluginController extends BaseController {
|
||||
private Logger logger = Logger.getLogger(PluginController.class);
|
||||
private PluginService pluginService;
|
||||
|
||||
public PluginService getPluginService() {
|
||||
return pluginService;
|
||||
}
|
||||
|
||||
@Autowired
|
||||
public void setPluginService(PluginService pluginService) {
|
||||
this.pluginService = pluginService;
|
||||
}
|
||||
|
||||
@RequestMapping("/add")
|
||||
@ResponseBody
|
||||
public void addPluginToDataBase() throws Bench4QException{
|
||||
PluginModel pluginModel=TestPlunginHelper.createOnePlugin();
|
||||
this.getPluginService().addPlugin(pluginModel);
|
||||
}
|
||||
@RequestMapping("/loadPluginList")
|
||||
@ResponseBody
|
||||
public PluginResponseModel loadPluginList() throws Bench4QException {
|
||||
if (!this.checkScope(UserService.NORAML_AUTHENTICATION)) {
|
||||
throw new Bench4QException(400 + "", "not permitted",
|
||||
"/loadPluginList");
|
||||
}
|
||||
PluginResponseModel pluginResponseModel = new PluginResponseModel();
|
||||
pluginResponseModel.setPluginList(this.getPluginService()
|
||||
.getPluginNameList());
|
||||
|
||||
pluginResponseModel.setSuccess(true);
|
||||
return pluginResponseModel;
|
||||
}
|
||||
|
||||
@RequestMapping(value = "loadMethodList/{pluginName}", method = {
|
||||
RequestMethod.GET, RequestMethod.POST })
|
||||
@ResponseBody
|
||||
public PluginResponseModel getMethodList(
|
||||
@PathVariable("pluginName") String pluginName)
|
||||
throws Bench4QException {
|
||||
if (!this.checkScope(UserService.NORAML_AUTHENTICATION)) {
|
||||
throw new Bench4QException(400 + "", "not permitted",
|
||||
"/loadMethodList/{pluginName}");
|
||||
}
|
||||
try {
|
||||
PluginResponseModel pluginResponseModel = new PluginResponseModel();
|
||||
pluginResponseModel.setMethodList(this.getPluginService()
|
||||
.getMethodNameInPlugin(pluginName));
|
||||
pluginResponseModel.setSuccess(true);
|
||||
return pluginResponseModel;
|
||||
} catch (Exception e) {
|
||||
logger.error(ExceptionLog.getStackTrace(e));
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@RequestMapping(value = "loadMethodParams/{pluginName}/{methodName}", method = {
|
||||
RequestMethod.GET, RequestMethod.POST })
|
||||
@ResponseBody
|
||||
public PluginResponseModel getMethodParams(
|
||||
@PathVariable("pluginName") String pluginName,
|
||||
@PathVariable("methodName") String methodName)
|
||||
throws Bench4QException {
|
||||
if (!this.checkScope(UserService.SUPER_AUTHENTICATION)) {
|
||||
throw new Bench4QException(400 + "", "not permitted",
|
||||
"loadMethodParams/{pluginName}/{methodName}");
|
||||
}
|
||||
PluginResponseModel pluginResponseModel = new PluginResponseModel();
|
||||
pluginResponseModel.setMethosMethodParamModels(this.getPluginService()
|
||||
.getMethodParamModelsInPlugin(pluginName, methodName));
|
||||
pluginResponseModel.setSuccess(true);
|
||||
return pluginResponseModel;
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/addPlugin", method = { RequestMethod.PUT })
|
||||
@ResponseBody
|
||||
public PluginResponseModel addPlugin(@RequestBody PluginGUI pluginGUI)
|
||||
throws Bench4QException {
|
||||
if (!this.checkScope(UserService.SUPER_AUTHENTICATION)) {
|
||||
throw new Bench4QException(400 + "", "not permitted",
|
||||
"loadMethodParams/{pluginName}/{methodName}");
|
||||
}
|
||||
PluginResponseModel pluginResponseModel = new PluginResponseModel();
|
||||
pluginResponseModel.setSuccess(this.getPluginService().addPlugin(
|
||||
pluginGUI.getPlugin()));
|
||||
return pluginResponseModel;
|
||||
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/deletePlugin/{pluginName}", method = {
|
||||
RequestMethod.GET, RequestMethod.POST })
|
||||
@ResponseBody
|
||||
public PluginResponseModel deletePlugin(
|
||||
@PathVariable("pluginName") String pluginName)
|
||||
throws Bench4QException {
|
||||
if (!this.checkScope(UserService.SUPER_AUTHENTICATION)) {
|
||||
throw new Bench4QException(400 + "", "not permitted",
|
||||
"loadMethodParams/{pluginName}/{methodName}");
|
||||
}
|
||||
PluginResponseModel pluginResponseModel = new PluginResponseModel();
|
||||
pluginResponseModel.setSuccess(this.getPluginService().deletePlugin(
|
||||
pluginName));
|
||||
return pluginResponseModel;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
package org.bench4q.master.api;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
import org.bench4q.master.TestPlunginHelper;
|
||||
import org.bench4q.master.domain.service.PluginService;
|
||||
import org.bench4q.master.domain.service.UserService;
|
||||
import org.bench4q.master.exception.Bench4QException;
|
||||
import org.bench4q.master.exception.ExceptionLog;
|
||||
import org.bench4q.share.models.master.plugin.PluginGUI;
|
||||
import org.bench4q.share.models.master.plugin.PluginModel;
|
||||
import org.bench4q.share.models.master.plugin.PluginResponseModel;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
|
||||
@Controller
|
||||
@RequestMapping("/plugin")
|
||||
public class PluginController extends BaseController {
|
||||
private Logger logger = Logger.getLogger(PluginController.class);
|
||||
private PluginService pluginService;
|
||||
|
||||
public PluginService getPluginService() {
|
||||
return pluginService;
|
||||
}
|
||||
|
||||
@Autowired
|
||||
public void setPluginService(PluginService pluginService) {
|
||||
this.pluginService = pluginService;
|
||||
}
|
||||
|
||||
@RequestMapping("/add")
|
||||
@ResponseBody
|
||||
public void addPluginToDataBase() throws Bench4QException{
|
||||
PluginModel pluginModel=TestPlunginHelper.createOnePlugin();
|
||||
this.getPluginService().addPlugin(pluginModel);
|
||||
}
|
||||
@RequestMapping("/loadPluginList")
|
||||
@ResponseBody
|
||||
public PluginResponseModel loadPluginList() throws Bench4QException {
|
||||
if (!this.checkScope(UserService.NORAML_AUTHENTICATION)) {
|
||||
throw new Bench4QException(400 + "", "not permitted",
|
||||
"/loadPluginList");
|
||||
}
|
||||
PluginResponseModel pluginResponseModel = new PluginResponseModel();
|
||||
pluginResponseModel.setPluginList(this.getPluginService()
|
||||
.getPluginNameList());
|
||||
|
||||
pluginResponseModel.setSuccess(true);
|
||||
return pluginResponseModel;
|
||||
}
|
||||
|
||||
@RequestMapping(value = "loadMethodList/{pluginName}", method = {
|
||||
RequestMethod.GET, RequestMethod.POST })
|
||||
@ResponseBody
|
||||
public PluginResponseModel getMethodList(
|
||||
@PathVariable("pluginName") String pluginName)
|
||||
throws Bench4QException {
|
||||
if (!this.checkScope(UserService.NORAML_AUTHENTICATION)) {
|
||||
throw new Bench4QException(400 + "", "not permitted",
|
||||
"/loadMethodList/{pluginName}");
|
||||
}
|
||||
try {
|
||||
PluginResponseModel pluginResponseModel = new PluginResponseModel();
|
||||
pluginResponseModel.setMethodList(this.getPluginService()
|
||||
.getMethodNameInPlugin(pluginName));
|
||||
pluginResponseModel.setSuccess(true);
|
||||
return pluginResponseModel;
|
||||
} catch (Exception e) {
|
||||
logger.error(ExceptionLog.getStackTrace(e));
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@RequestMapping(value = "loadMethodParams/{pluginName}/{methodName}", method = {
|
||||
RequestMethod.GET, RequestMethod.POST })
|
||||
@ResponseBody
|
||||
public PluginResponseModel getMethodParams(
|
||||
@PathVariable("pluginName") String pluginName,
|
||||
@PathVariable("methodName") String methodName)
|
||||
throws Bench4QException {
|
||||
if (!this.checkScope(UserService.SUPER_AUTHENTICATION)) {
|
||||
throw new Bench4QException(400 + "", "not permitted",
|
||||
"loadMethodParams/{pluginName}/{methodName}");
|
||||
}
|
||||
PluginResponseModel pluginResponseModel = new PluginResponseModel();
|
||||
pluginResponseModel.setMethosMethodParamModels(this.getPluginService()
|
||||
.getMethodParamModelsInPlugin(pluginName, methodName));
|
||||
pluginResponseModel.setSuccess(true);
|
||||
return pluginResponseModel;
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/addPlugin", method = { RequestMethod.PUT })
|
||||
@ResponseBody
|
||||
public PluginResponseModel addPlugin(@RequestBody PluginGUI pluginGUI)
|
||||
throws Bench4QException {
|
||||
if (!this.checkScope(UserService.SUPER_AUTHENTICATION)) {
|
||||
throw new Bench4QException(400 + "", "not permitted",
|
||||
"loadMethodParams/{pluginName}/{methodName}");
|
||||
}
|
||||
PluginResponseModel pluginResponseModel = new PluginResponseModel();
|
||||
pluginResponseModel.setSuccess(this.getPluginService().addPlugin(
|
||||
pluginGUI.getPlugin()));
|
||||
return pluginResponseModel;
|
||||
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/deletePlugin/{pluginName}", method = {
|
||||
RequestMethod.GET, RequestMethod.POST })
|
||||
@ResponseBody
|
||||
public PluginResponseModel deletePlugin(
|
||||
@PathVariable("pluginName") String pluginName)
|
||||
throws Bench4QException {
|
||||
if (!this.checkScope(UserService.SUPER_AUTHENTICATION)) {
|
||||
throw new Bench4QException(400 + "", "not permitted",
|
||||
"loadMethodParams/{pluginName}/{methodName}");
|
||||
}
|
||||
PluginResponseModel pluginResponseModel = new PluginResponseModel();
|
||||
pluginResponseModel.setSuccess(this.getPluginService().deletePlugin(
|
||||
pluginName));
|
||||
return pluginResponseModel;
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -1,60 +1,60 @@
|
|||
package org.bench4q.master.domain.entity.plugin;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.GenerationType;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.JoinColumn;
|
||||
import javax.persistence.ManyToOne;
|
||||
import javax.persistence.Table;
|
||||
|
||||
@Entity
|
||||
@Table(name = "methodParamProperty")
|
||||
public class MethodParamProperty {
|
||||
|
||||
private int id;
|
||||
private String key;
|
||||
private String value;
|
||||
private MethodParam methodParam;
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
@Column(name = "id", nullable = false)
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(int id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
@Column(name = "key")
|
||||
public String getKey() {
|
||||
return key;
|
||||
}
|
||||
|
||||
public void setKey(String key) {
|
||||
this.key = key;
|
||||
}
|
||||
|
||||
@Column(name = "value")
|
||||
public String getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public void setValue(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
@ManyToOne
|
||||
@JoinColumn(name = "methodParamId")
|
||||
public MethodParam getMethodParam() {
|
||||
return methodParam;
|
||||
}
|
||||
|
||||
public void setMethodParam(MethodParam methodParam) {
|
||||
this.methodParam = methodParam;
|
||||
}
|
||||
|
||||
}
|
||||
package org.bench4q.master.domain.entity.plugin;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.GenerationType;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.JoinColumn;
|
||||
import javax.persistence.ManyToOne;
|
||||
import javax.persistence.Table;
|
||||
|
||||
@Entity
|
||||
@Table(name = "methodParamProperty")
|
||||
public class MethodParamProperty {
|
||||
|
||||
private int id;
|
||||
private String key;
|
||||
private String value;
|
||||
private MethodParam methodParam;
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
@Column(name = "id", nullable = false)
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(int id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
@Column(name = "key")
|
||||
public String getKey() {
|
||||
return key;
|
||||
}
|
||||
|
||||
public void setKey(String key) {
|
||||
this.key = key;
|
||||
}
|
||||
|
||||
@Column(name = "value")
|
||||
public String getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public void setValue(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
@ManyToOne
|
||||
@JoinColumn(name = "methodParamId")
|
||||
public MethodParam getMethodParam() {
|
||||
return methodParam;
|
||||
}
|
||||
|
||||
public void setMethodParam(MethodParam methodParam) {
|
||||
this.methodParam = methodParam;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,41 +1,41 @@
|
|||
package org.bench4q.master.domain.entity.plugin;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.EnumType;
|
||||
import javax.persistence.Enumerated;
|
||||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.GenerationType;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Table;
|
||||
|
||||
import org.bench4q.share.models.master.plugin.ParamTypeEnum;
|
||||
|
||||
@Entity
|
||||
@Table(name = "paramType")
|
||||
public class ParamType {
|
||||
private int id;
|
||||
private ParamTypeEnum type;
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
@Column(name = "id", nullable = false)
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(int id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
@Enumerated(EnumType.STRING)
|
||||
@Column(columnDefinition = "ENUM('Field', 'MultiField', 'Table','CheckBox')")
|
||||
public ParamTypeEnum getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(ParamTypeEnum type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
}
|
||||
package org.bench4q.master.domain.entity.plugin;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.EnumType;
|
||||
import javax.persistence.Enumerated;
|
||||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.GenerationType;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Table;
|
||||
|
||||
import org.bench4q.share.models.master.plugin.ParamTypeEnum;
|
||||
|
||||
@Entity
|
||||
@Table(name = "paramType")
|
||||
public class ParamType {
|
||||
private int id;
|
||||
private ParamTypeEnum type;
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
@Column(name = "id", nullable = false)
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(int id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
@Enumerated(EnumType.STRING)
|
||||
@Column(columnDefinition = "ENUM('Field', 'MultiField', 'Table','CheckBox')")
|
||||
public ParamTypeEnum getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(ParamTypeEnum type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,137 +1,137 @@
|
|||
package org.bench4q.master.domain.factory;
|
||||
|
||||
import java.util.HashSet;
|
||||
|
||||
import org.bench4q.master.domain.entity.plugin.Method;
|
||||
import org.bench4q.master.domain.entity.plugin.MethodParam;
|
||||
import org.bench4q.master.domain.entity.plugin.MethodParamProperty;
|
||||
import org.bench4q.master.domain.entity.plugin.ParamType;
|
||||
import org.bench4q.master.domain.entity.plugin.Plugin;
|
||||
import org.bench4q.master.domain.repository.PluginRepository;
|
||||
import org.bench4q.share.models.master.plugin.MethodModel;
|
||||
import org.bench4q.share.models.master.plugin.MethodParamModel;
|
||||
import org.bench4q.share.models.master.plugin.MethodParamPropertyModel;
|
||||
import org.bench4q.share.models.master.plugin.ParamTypeEnum;
|
||||
import org.bench4q.share.models.master.plugin.PluginModel;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
@Component
|
||||
public class PluginFactory {
|
||||
|
||||
private PluginRepository pluginRepository;
|
||||
|
||||
public PluginRepository getPluginRepository() {
|
||||
return pluginRepository;
|
||||
}
|
||||
|
||||
@Autowired
|
||||
public void setPluginRepository(PluginRepository pluginRepository) {
|
||||
this.pluginRepository = pluginRepository;
|
||||
}
|
||||
|
||||
public Plugin createPluginEntity(PluginModel pluginModel) {
|
||||
Plugin plugin = new Plugin();
|
||||
plugin.setPluginMethods(new HashSet<Method>());
|
||||
if (pluginModel.getMethods() != null) {
|
||||
for (MethodModel methodModel : pluginModel.getMethods()) {
|
||||
plugin.getPluginMethods().add(
|
||||
createMethodEntity(methodModel, plugin));
|
||||
}
|
||||
}
|
||||
|
||||
plugin.setName(pluginModel.getName());
|
||||
return plugin;
|
||||
|
||||
}
|
||||
|
||||
private Method createMethodEntity(MethodModel methodModel, Plugin plugin) {
|
||||
Method method = new Method();
|
||||
method.setMethodParams(new HashSet<MethodParam>());
|
||||
method.setName(methodModel.getName());
|
||||
if (methodModel.getMethodParams() != null) {
|
||||
for (MethodParamModel methodParamModel : methodModel
|
||||
.getMethodParams()) {
|
||||
method.getMethodParams().add(
|
||||
createMethodParamEntity(methodParamModel, method));
|
||||
}
|
||||
}
|
||||
method.setPlugin(plugin);
|
||||
|
||||
return method;
|
||||
}
|
||||
|
||||
private MethodParam createMethodParamEntity(
|
||||
MethodParamModel methodParamModel, Method method) {
|
||||
MethodParam methodParam = new MethodParam();
|
||||
methodParam.setLable(methodParamModel.getLable());
|
||||
methodParam.setName(methodParamModel.getName());
|
||||
methodParam.setMethod(method);
|
||||
methodParam.setParamType(createPraParamTypeWithOutId(methodParamModel
|
||||
.getParamType()));
|
||||
if (methodParamModel.getMethodParamProperties() != null) {
|
||||
methodParam
|
||||
.setMethodParamProperties(new HashSet<MethodParamProperty>());
|
||||
for (MethodParamPropertyModel methodParamPropertyModel : methodParamModel
|
||||
.getMethodParamProperties()) {
|
||||
methodParam.getMethodParamProperties().add(
|
||||
createMethodParamPropertyWithOutId(
|
||||
methodParamPropertyModel, methodParam));
|
||||
}
|
||||
}
|
||||
return methodParam;
|
||||
}
|
||||
|
||||
private ParamType createPraParamTypeWithOutId(ParamTypeEnum paramTypeEnum) {
|
||||
return this.getPluginRepository().getParamTypeByType(paramTypeEnum);
|
||||
}
|
||||
|
||||
private MethodParamProperty createMethodParamPropertyWithOutId(
|
||||
MethodParamPropertyModel methodParamPropertyModel,
|
||||
MethodParam methodParam) {
|
||||
MethodParamProperty methodParamProperty = new MethodParamProperty();
|
||||
methodParamProperty.setKey(methodParamPropertyModel.getKey());
|
||||
methodParamProperty.setValue(methodParamPropertyModel.getValue());
|
||||
methodParamProperty.setMethodParam(methodParam);
|
||||
return methodParamProperty;
|
||||
}
|
||||
|
||||
public static MethodModel extractMethodModel(Method method) {
|
||||
MethodModel methodModel = new MethodModel();
|
||||
methodModel.setName(method.getName());
|
||||
if (method.getMethodParams() != null) {
|
||||
methodModel.setMethodParams(new HashSet<MethodParamModel>());
|
||||
for (MethodParam methodParam : method.getMethodParams()) {
|
||||
methodModel.getMethodParams().add(
|
||||
extractMethodParamModel(methodParam));
|
||||
}
|
||||
}
|
||||
return methodModel;
|
||||
}
|
||||
|
||||
private static MethodParamModel extractMethodParamModel(
|
||||
MethodParam methodParam) {
|
||||
MethodParamModel methodParamModel = new MethodParamModel();
|
||||
methodParamModel.setLable(methodParam.getLable());
|
||||
methodParamModel.setName(methodParam.getName());
|
||||
methodParamModel.setParamType(methodParam.getParamType().getType());
|
||||
if (methodParam.getMethodParamProperties() != null) {
|
||||
methodParamModel
|
||||
.setMethodParamProperties(new HashSet<MethodParamPropertyModel>());
|
||||
for (MethodParamProperty methodParamProperty : methodParam
|
||||
.getMethodParamProperties()) {
|
||||
methodParamModel.getMethodParamProperties().add(
|
||||
extractMethodParamPropertyModel(methodParamProperty));
|
||||
}
|
||||
}
|
||||
return methodParamModel;
|
||||
}
|
||||
|
||||
private static MethodParamPropertyModel extractMethodParamPropertyModel(
|
||||
MethodParamProperty methodParamProperty) {
|
||||
MethodParamPropertyModel methodParamPropertyModel = new MethodParamPropertyModel();
|
||||
methodParamPropertyModel.setKey(methodParamProperty.getKey());
|
||||
methodParamPropertyModel.setValue(methodParamProperty.getValue());
|
||||
return methodParamPropertyModel;
|
||||
}
|
||||
|
||||
}
|
||||
package org.bench4q.master.domain.factory;
|
||||
|
||||
import java.util.HashSet;
|
||||
|
||||
import org.bench4q.master.domain.entity.plugin.Method;
|
||||
import org.bench4q.master.domain.entity.plugin.MethodParam;
|
||||
import org.bench4q.master.domain.entity.plugin.MethodParamProperty;
|
||||
import org.bench4q.master.domain.entity.plugin.ParamType;
|
||||
import org.bench4q.master.domain.entity.plugin.Plugin;
|
||||
import org.bench4q.master.domain.repository.PluginRepository;
|
||||
import org.bench4q.share.models.master.plugin.MethodModel;
|
||||
import org.bench4q.share.models.master.plugin.MethodParamModel;
|
||||
import org.bench4q.share.models.master.plugin.MethodParamPropertyModel;
|
||||
import org.bench4q.share.models.master.plugin.ParamTypeEnum;
|
||||
import org.bench4q.share.models.master.plugin.PluginModel;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
@Component
|
||||
public class PluginFactory {
|
||||
|
||||
private PluginRepository pluginRepository;
|
||||
|
||||
public PluginRepository getPluginRepository() {
|
||||
return pluginRepository;
|
||||
}
|
||||
|
||||
@Autowired
|
||||
public void setPluginRepository(PluginRepository pluginRepository) {
|
||||
this.pluginRepository = pluginRepository;
|
||||
}
|
||||
|
||||
public Plugin createPluginEntity(PluginModel pluginModel) {
|
||||
Plugin plugin = new Plugin();
|
||||
plugin.setPluginMethods(new HashSet<Method>());
|
||||
if (pluginModel.getMethods() != null) {
|
||||
for (MethodModel methodModel : pluginModel.getMethods()) {
|
||||
plugin.getPluginMethods().add(
|
||||
createMethodEntity(methodModel, plugin));
|
||||
}
|
||||
}
|
||||
|
||||
plugin.setName(pluginModel.getName());
|
||||
return plugin;
|
||||
|
||||
}
|
||||
|
||||
private Method createMethodEntity(MethodModel methodModel, Plugin plugin) {
|
||||
Method method = new Method();
|
||||
method.setMethodParams(new HashSet<MethodParam>());
|
||||
method.setName(methodModel.getName());
|
||||
if (methodModel.getMethodParams() != null) {
|
||||
for (MethodParamModel methodParamModel : methodModel
|
||||
.getMethodParams()) {
|
||||
method.getMethodParams().add(
|
||||
createMethodParamEntity(methodParamModel, method));
|
||||
}
|
||||
}
|
||||
method.setPlugin(plugin);
|
||||
|
||||
return method;
|
||||
}
|
||||
|
||||
private MethodParam createMethodParamEntity(
|
||||
MethodParamModel methodParamModel, Method method) {
|
||||
MethodParam methodParam = new MethodParam();
|
||||
methodParam.setLable(methodParamModel.getLable());
|
||||
methodParam.setName(methodParamModel.getName());
|
||||
methodParam.setMethod(method);
|
||||
methodParam.setParamType(createPraParamTypeWithOutId(methodParamModel
|
||||
.getParamType()));
|
||||
if (methodParamModel.getMethodParamProperties() != null) {
|
||||
methodParam
|
||||
.setMethodParamProperties(new HashSet<MethodParamProperty>());
|
||||
for (MethodParamPropertyModel methodParamPropertyModel : methodParamModel
|
||||
.getMethodParamProperties()) {
|
||||
methodParam.getMethodParamProperties().add(
|
||||
createMethodParamPropertyWithOutId(
|
||||
methodParamPropertyModel, methodParam));
|
||||
}
|
||||
}
|
||||
return methodParam;
|
||||
}
|
||||
|
||||
private ParamType createPraParamTypeWithOutId(ParamTypeEnum paramTypeEnum) {
|
||||
return this.getPluginRepository().getParamTypeByType(paramTypeEnum);
|
||||
}
|
||||
|
||||
private MethodParamProperty createMethodParamPropertyWithOutId(
|
||||
MethodParamPropertyModel methodParamPropertyModel,
|
||||
MethodParam methodParam) {
|
||||
MethodParamProperty methodParamProperty = new MethodParamProperty();
|
||||
methodParamProperty.setKey(methodParamPropertyModel.getKey());
|
||||
methodParamProperty.setValue(methodParamPropertyModel.getValue());
|
||||
methodParamProperty.setMethodParam(methodParam);
|
||||
return methodParamProperty;
|
||||
}
|
||||
|
||||
public static MethodModel extractMethodModel(Method method) {
|
||||
MethodModel methodModel = new MethodModel();
|
||||
methodModel.setName(method.getName());
|
||||
if (method.getMethodParams() != null) {
|
||||
methodModel.setMethodParams(new HashSet<MethodParamModel>());
|
||||
for (MethodParam methodParam : method.getMethodParams()) {
|
||||
methodModel.getMethodParams().add(
|
||||
extractMethodParamModel(methodParam));
|
||||
}
|
||||
}
|
||||
return methodModel;
|
||||
}
|
||||
|
||||
private static MethodParamModel extractMethodParamModel(
|
||||
MethodParam methodParam) {
|
||||
MethodParamModel methodParamModel = new MethodParamModel();
|
||||
methodParamModel.setLable(methodParam.getLable());
|
||||
methodParamModel.setName(methodParam.getName());
|
||||
methodParamModel.setParamType(methodParam.getParamType().getType());
|
||||
if (methodParam.getMethodParamProperties() != null) {
|
||||
methodParamModel
|
||||
.setMethodParamProperties(new HashSet<MethodParamPropertyModel>());
|
||||
for (MethodParamProperty methodParamProperty : methodParam
|
||||
.getMethodParamProperties()) {
|
||||
methodParamModel.getMethodParamProperties().add(
|
||||
extractMethodParamPropertyModel(methodParamProperty));
|
||||
}
|
||||
}
|
||||
return methodParamModel;
|
||||
}
|
||||
|
||||
private static MethodParamPropertyModel extractMethodParamPropertyModel(
|
||||
MethodParamProperty methodParamProperty) {
|
||||
MethodParamPropertyModel methodParamPropertyModel = new MethodParamPropertyModel();
|
||||
methodParamPropertyModel.setKey(methodParamProperty.getKey());
|
||||
methodParamPropertyModel.setValue(methodParamProperty.getValue());
|
||||
return methodParamPropertyModel;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,14 +1,14 @@
|
|||
package org.bench4q.master.domain.repository;
|
||||
|
||||
import org.bench4q.master.exception.ExceptionUtils.EntityUniqueAlReadyExistException;
|
||||
|
||||
public class MonitorRepository extends AbstractRepositoty {
|
||||
|
||||
@Override
|
||||
protected void guardOtherUniqueConditionForEntity(
|
||||
String uniquePropertyName, String value)
|
||||
throws EntityUniqueAlReadyExistException {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
}
|
||||
package org.bench4q.master.domain.repository;
|
||||
|
||||
import org.bench4q.master.exception.ExceptionUtils.EntityUniqueAlReadyExistException;
|
||||
|
||||
public class MonitorRepository extends AbstractRepositoty {
|
||||
|
||||
@Override
|
||||
protected void guardOtherUniqueConditionForEntity(
|
||||
String uniquePropertyName, String value)
|
||||
throws EntityUniqueAlReadyExistException {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
}
|
|
@ -1,129 +1,129 @@
|
|||
package org.bench4q.master.domain.service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
import org.bench4q.master.domain.entity.plugin.MethodParam;
|
||||
import org.bench4q.master.domain.entity.plugin.Plugin;
|
||||
import org.bench4q.master.domain.repository.PluginRepository;
|
||||
import org.bench4q.master.exception.Bench4QException;
|
||||
import org.bench4q.master.domain.entity.plugin.Method;
|
||||
import org.bench4q.master.domain.factory.PluginFactory;
|
||||
import org.bench4q.share.models.master.plugin.MethodParamModel;
|
||||
import org.bench4q.share.models.master.plugin.PluginModel;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component
|
||||
public class PluginService {
|
||||
private Set<Plugin> plugins;
|
||||
private List<String> pluginNameList;
|
||||
private PluginRepository pluginRepository;
|
||||
private PluginFactory pluginFactory;
|
||||
private Logger logger = Logger.getLogger(PluginService.class);
|
||||
|
||||
public PluginRepository getPluginRepository() {
|
||||
return pluginRepository;
|
||||
}
|
||||
|
||||
@Autowired
|
||||
public void setPluginRepository(PluginRepository pluginRepository) {
|
||||
this.pluginRepository = pluginRepository;
|
||||
}
|
||||
|
||||
public PluginFactory getPluginFactory() {
|
||||
return pluginFactory;
|
||||
}
|
||||
|
||||
@Autowired
|
||||
public void setPluginFactory(PluginFactory pluginFactory) {
|
||||
this.pluginFactory = pluginFactory;
|
||||
}
|
||||
|
||||
private Set<Plugin> getPlugins() throws Bench4QException {
|
||||
List<Plugin> loadPluginList = this.getPluginRepository().loadPlugins();
|
||||
if (loadPluginList != null) {
|
||||
this.plugins = new HashSet<Plugin>();
|
||||
for (Plugin plugin : loadPluginList) {
|
||||
this.plugins.add(plugin);
|
||||
}
|
||||
}
|
||||
|
||||
return this.plugins;
|
||||
}
|
||||
|
||||
public boolean addPlugin(PluginModel pluginModel) throws Bench4QException {
|
||||
return this.getPluginRepository().attatch(
|
||||
this.getPluginFactory().createPluginEntity(pluginModel));
|
||||
}
|
||||
|
||||
public boolean deletePlugin(String pluginName) throws Bench4QException {
|
||||
return this.getPluginRepository().detach(pluginName);
|
||||
}
|
||||
|
||||
private Plugin getPluginByName(String pluginName) {
|
||||
return this.getPluginRepository().getPlugin(pluginName);
|
||||
}
|
||||
|
||||
public List<String> getPluginNameList() throws Bench4QException {
|
||||
this.pluginNameList = new ArrayList<String>();
|
||||
this.getPlugins();
|
||||
if (this.plugins != null) {
|
||||
for (Plugin plugin : this.plugins) {
|
||||
this.pluginNameList.add(plugin.getName());
|
||||
}
|
||||
}
|
||||
return this.pluginNameList;
|
||||
}
|
||||
|
||||
public List<String> getMethodNameInPlugin(String pluginName) {
|
||||
List<String> methodNameList = new ArrayList<String>();
|
||||
Set<Method> methods = this.getPluginByName(pluginName)
|
||||
.getPluginMethods();
|
||||
|
||||
if (methods != null) {
|
||||
for (Method method : methods) {
|
||||
methodNameList.add(method.getName());
|
||||
}
|
||||
}
|
||||
return methodNameList;
|
||||
}
|
||||
|
||||
private Method getMethodInPlugin(String pluginName, String methodName)
|
||||
throws Bench4QException {
|
||||
Set<Method> methods = this.getMethodInPlugin(pluginName);
|
||||
if (methods != null) {
|
||||
for (Method method : methods) {
|
||||
if (method.getName().equals(methodName))
|
||||
return method;
|
||||
}
|
||||
}
|
||||
logger.info("method is empty");
|
||||
|
||||
throw new Bench4QException("", "no such method:" + methodName
|
||||
+ "in plugin:" + pluginName, "");
|
||||
|
||||
}
|
||||
|
||||
public Set<MethodParamModel> getMethodParamModelsInPlugin(
|
||||
String pluginName, String methodName) throws Bench4QException {
|
||||
return PluginFactory.extractMethodModel(
|
||||
this.getMethodInPlugin(pluginName, methodName))
|
||||
.getMethodParams();
|
||||
}
|
||||
|
||||
private Set<Method> getMethodInPlugin(String pluginName) {
|
||||
|
||||
return this.getPluginByName(pluginName).getPluginMethods();
|
||||
}
|
||||
|
||||
public Set<MethodParam> getMethodParams(String pluginName, String methodName)
|
||||
throws Bench4QException {
|
||||
Method method = this.getMethodInPlugin(pluginName, methodName);
|
||||
return method.getMethodParams();
|
||||
}
|
||||
|
||||
}
|
||||
package org.bench4q.master.domain.service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
import org.bench4q.master.domain.entity.plugin.MethodParam;
|
||||
import org.bench4q.master.domain.entity.plugin.Plugin;
|
||||
import org.bench4q.master.domain.repository.PluginRepository;
|
||||
import org.bench4q.master.exception.Bench4QException;
|
||||
import org.bench4q.master.domain.entity.plugin.Method;
|
||||
import org.bench4q.master.domain.factory.PluginFactory;
|
||||
import org.bench4q.share.models.master.plugin.MethodParamModel;
|
||||
import org.bench4q.share.models.master.plugin.PluginModel;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component
|
||||
public class PluginService {
|
||||
private Set<Plugin> plugins;
|
||||
private List<String> pluginNameList;
|
||||
private PluginRepository pluginRepository;
|
||||
private PluginFactory pluginFactory;
|
||||
private Logger logger = Logger.getLogger(PluginService.class);
|
||||
|
||||
public PluginRepository getPluginRepository() {
|
||||
return pluginRepository;
|
||||
}
|
||||
|
||||
@Autowired
|
||||
public void setPluginRepository(PluginRepository pluginRepository) {
|
||||
this.pluginRepository = pluginRepository;
|
||||
}
|
||||
|
||||
public PluginFactory getPluginFactory() {
|
||||
return pluginFactory;
|
||||
}
|
||||
|
||||
@Autowired
|
||||
public void setPluginFactory(PluginFactory pluginFactory) {
|
||||
this.pluginFactory = pluginFactory;
|
||||
}
|
||||
|
||||
private Set<Plugin> getPlugins() throws Bench4QException {
|
||||
List<Plugin> loadPluginList = this.getPluginRepository().loadPlugins();
|
||||
if (loadPluginList != null) {
|
||||
this.plugins = new HashSet<Plugin>();
|
||||
for (Plugin plugin : loadPluginList) {
|
||||
this.plugins.add(plugin);
|
||||
}
|
||||
}
|
||||
|
||||
return this.plugins;
|
||||
}
|
||||
|
||||
public boolean addPlugin(PluginModel pluginModel) throws Bench4QException {
|
||||
return this.getPluginRepository().attatch(
|
||||
this.getPluginFactory().createPluginEntity(pluginModel));
|
||||
}
|
||||
|
||||
public boolean deletePlugin(String pluginName) throws Bench4QException {
|
||||
return this.getPluginRepository().detach(pluginName);
|
||||
}
|
||||
|
||||
private Plugin getPluginByName(String pluginName) {
|
||||
return this.getPluginRepository().getPlugin(pluginName);
|
||||
}
|
||||
|
||||
public List<String> getPluginNameList() throws Bench4QException {
|
||||
this.pluginNameList = new ArrayList<String>();
|
||||
this.getPlugins();
|
||||
if (this.plugins != null) {
|
||||
for (Plugin plugin : this.plugins) {
|
||||
this.pluginNameList.add(plugin.getName());
|
||||
}
|
||||
}
|
||||
return this.pluginNameList;
|
||||
}
|
||||
|
||||
public List<String> getMethodNameInPlugin(String pluginName) {
|
||||
List<String> methodNameList = new ArrayList<String>();
|
||||
Set<Method> methods = this.getPluginByName(pluginName)
|
||||
.getPluginMethods();
|
||||
|
||||
if (methods != null) {
|
||||
for (Method method : methods) {
|
||||
methodNameList.add(method.getName());
|
||||
}
|
||||
}
|
||||
return methodNameList;
|
||||
}
|
||||
|
||||
private Method getMethodInPlugin(String pluginName, String methodName)
|
||||
throws Bench4QException {
|
||||
Set<Method> methods = this.getMethodInPlugin(pluginName);
|
||||
if (methods != null) {
|
||||
for (Method method : methods) {
|
||||
if (method.getName().equals(methodName))
|
||||
return method;
|
||||
}
|
||||
}
|
||||
logger.info("method is empty");
|
||||
|
||||
throw new Bench4QException("", "no such method:" + methodName
|
||||
+ "in plugin:" + pluginName, "");
|
||||
|
||||
}
|
||||
|
||||
public Set<MethodParamModel> getMethodParamModelsInPlugin(
|
||||
String pluginName, String methodName) throws Bench4QException {
|
||||
return PluginFactory.extractMethodModel(
|
||||
this.getMethodInPlugin(pluginName, methodName))
|
||||
.getMethodParams();
|
||||
}
|
||||
|
||||
private Set<Method> getMethodInPlugin(String pluginName) {
|
||||
|
||||
return this.getPluginByName(pluginName).getPluginMethods();
|
||||
}
|
||||
|
||||
public Set<MethodParam> getMethodParams(String pluginName, String methodName)
|
||||
throws Bench4QException {
|
||||
Method method = this.getMethodInPlugin(pluginName, methodName);
|
||||
return method.getMethodParams();
|
||||
}
|
||||
|
||||
}
|
|
@ -1,126 +1,126 @@
|
|||
package org.bench4q.master.domain.testplan;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.Date;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Observable;
|
||||
import java.util.Observer;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
import javax.xml.bind.JAXBException;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
import org.bench4q.master.domain.entity.Monitor;
|
||||
import org.bench4q.master.domain.entity.MonitorResult;
|
||||
import org.bench4q.master.domain.entity.TestPlan;
|
||||
import org.bench4q.master.domain.repository.TestPlanRepository;
|
||||
import org.bench4q.master.helper.SessionHelper;
|
||||
import org.bench4q.share.helper.MarshalHelper;
|
||||
import org.bench4q.share.models.master.statistics.SampleModel;
|
||||
import org.bench4q.share.models.monitor.MonitorMain;
|
||||
import org.hibernate.Session;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component
|
||||
public class TestMoniorResultSave implements Observer {
|
||||
private Logger logger = Logger.getLogger(TestMoniorResultSave.class);
|
||||
private SessionHelper sessionHelper;
|
||||
private TestPlanRepository testPlanRepository;
|
||||
|
||||
public SessionHelper getSessionHelper() {
|
||||
return sessionHelper;
|
||||
}
|
||||
|
||||
@Autowired
|
||||
public void setSessionHelper(SessionHelper sessionHelper) {
|
||||
this.sessionHelper = sessionHelper;
|
||||
}
|
||||
|
||||
private TestPlanRepository getTestPlanRepository() {
|
||||
return testPlanRepository;
|
||||
}
|
||||
|
||||
@Autowired
|
||||
private void setTestPlanRepository(TestPlanRepository testPlanRepository) {
|
||||
this.testPlanRepository = testPlanRepository;
|
||||
}
|
||||
|
||||
public void update(Observable o, Object arg) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
Monitor monitor = (Monitor) o;
|
||||
logger.info("enter monitor update:" + monitor.getHostName());
|
||||
this.saveMonitorResult(
|
||||
UUID.fromString(monitor.getTestPlan().getTestPlanRunId()),
|
||||
(MonitorMain) arg, ((SampleModel) arg).getSamplingTime(),
|
||||
monitor);
|
||||
}
|
||||
|
||||
public boolean saveMonitorResult(UUID testPlanRunId, MonitorMain mainModel,
|
||||
Date createDatetime, Monitor monitor) {
|
||||
Session session = this.getSessionHelper().openSession();
|
||||
try {
|
||||
TestPlan testPlan = this.getTestPlanRepository().doGetTestPlanBy(
|
||||
session, testPlanRunId);
|
||||
if (testPlan == null) {
|
||||
return false;
|
||||
}
|
||||
monitor = testPlan.extractSpecifiedMonitor(monitor.getHostName());
|
||||
Set<MonitorResult> monitorResultToAdd = monitor.getResults();
|
||||
List<MonitorResult> monitorResults = this
|
||||
.extractMonitorResultFromMonitorModel(mainModel, testPlan,
|
||||
monitor, createDatetime);
|
||||
if (monitorResults == null)
|
||||
return false;
|
||||
if (monitorResults.size() == 0) {
|
||||
System.out.println("size is 0 ");
|
||||
return false;
|
||||
}
|
||||
|
||||
for (MonitorResult monitorResult : monitorResults) {
|
||||
if (session == null)
|
||||
return false;
|
||||
monitorResultToAdd.add(monitorResult);
|
||||
}
|
||||
logger.info("monitor ressult size:" + monitorResultToAdd.size());
|
||||
return this.getTestPlanRepository().doUpdateEntity(session,
|
||||
testPlan);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return false;
|
||||
} finally {
|
||||
if (session.isConnected()) {
|
||||
session.close();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private List<MonitorResult> extractMonitorResultFromMonitorModel(
|
||||
MonitorMain monitorMain, TestPlan testPlan, Monitor monitor,
|
||||
Date createDatetime) throws IllegalArgumentException,
|
||||
IllegalAccessException, JAXBException {
|
||||
|
||||
List<MonitorResult> monitorResults = new LinkedList<MonitorResult>();
|
||||
|
||||
Field[] fields = monitorMain.getClass().getDeclaredFields();
|
||||
|
||||
for (int i = 0; i < fields.length; i++) {
|
||||
MonitorResult monitorResult = new MonitorResult();
|
||||
monitorResult.setTestPlanDB(testPlan);
|
||||
monitorResult.setMonitor(monitor);
|
||||
monitorResult.setCreateDatetime(createDatetime);
|
||||
monitorResult.setHostNameUnderMonitor(monitor.getHostName());
|
||||
fields[i].setAccessible(true);
|
||||
monitorResult.setType(fields[i].getName());
|
||||
monitorResult.setContent(MarshalHelper.marshal(fields[i].getType(),
|
||||
fields[i].get(monitorMain)));
|
||||
monitorResults.add(monitorResult);
|
||||
}
|
||||
return monitorResults;
|
||||
|
||||
}
|
||||
}
|
||||
package org.bench4q.master.domain.testplan;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.Date;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Observable;
|
||||
import java.util.Observer;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
import javax.xml.bind.JAXBException;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
import org.bench4q.master.domain.entity.Monitor;
|
||||
import org.bench4q.master.domain.entity.MonitorResult;
|
||||
import org.bench4q.master.domain.entity.TestPlan;
|
||||
import org.bench4q.master.domain.repository.TestPlanRepository;
|
||||
import org.bench4q.master.helper.SessionHelper;
|
||||
import org.bench4q.share.helper.MarshalHelper;
|
||||
import org.bench4q.share.models.master.statistics.SampleModel;
|
||||
import org.bench4q.share.models.monitor.MonitorMain;
|
||||
import org.hibernate.Session;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component
|
||||
public class TestMoniorResultSave implements Observer {
|
||||
private Logger logger = Logger.getLogger(TestMoniorResultSave.class);
|
||||
private SessionHelper sessionHelper;
|
||||
private TestPlanRepository testPlanRepository;
|
||||
|
||||
public SessionHelper getSessionHelper() {
|
||||
return sessionHelper;
|
||||
}
|
||||
|
||||
@Autowired
|
||||
public void setSessionHelper(SessionHelper sessionHelper) {
|
||||
this.sessionHelper = sessionHelper;
|
||||
}
|
||||
|
||||
private TestPlanRepository getTestPlanRepository() {
|
||||
return testPlanRepository;
|
||||
}
|
||||
|
||||
@Autowired
|
||||
private void setTestPlanRepository(TestPlanRepository testPlanRepository) {
|
||||
this.testPlanRepository = testPlanRepository;
|
||||
}
|
||||
|
||||
public void update(Observable o, Object arg) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
Monitor monitor = (Monitor) o;
|
||||
logger.info("enter monitor update:" + monitor.getHostName());
|
||||
this.saveMonitorResult(
|
||||
UUID.fromString(monitor.getTestPlan().getTestPlanRunId()),
|
||||
(MonitorMain) arg, ((SampleModel) arg).getSamplingTime(),
|
||||
monitor);
|
||||
}
|
||||
|
||||
public boolean saveMonitorResult(UUID testPlanRunId, MonitorMain mainModel,
|
||||
Date createDatetime, Monitor monitor) {
|
||||
Session session = this.getSessionHelper().openSession();
|
||||
try {
|
||||
TestPlan testPlan = this.getTestPlanRepository().doGetTestPlanBy(
|
||||
session, testPlanRunId);
|
||||
if (testPlan == null) {
|
||||
return false;
|
||||
}
|
||||
monitor = testPlan.extractSpecifiedMonitor(monitor.getHostName());
|
||||
Set<MonitorResult> monitorResultToAdd = monitor.getResults();
|
||||
List<MonitorResult> monitorResults = this
|
||||
.extractMonitorResultFromMonitorModel(mainModel, testPlan,
|
||||
monitor, createDatetime);
|
||||
if (monitorResults == null)
|
||||
return false;
|
||||
if (monitorResults.size() == 0) {
|
||||
System.out.println("size is 0 ");
|
||||
return false;
|
||||
}
|
||||
|
||||
for (MonitorResult monitorResult : monitorResults) {
|
||||
if (session == null)
|
||||
return false;
|
||||
monitorResultToAdd.add(monitorResult);
|
||||
}
|
||||
logger.info("monitor ressult size:" + monitorResultToAdd.size());
|
||||
return this.getTestPlanRepository().doUpdateEntity(session,
|
||||
testPlan);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return false;
|
||||
} finally {
|
||||
if (session.isConnected()) {
|
||||
session.close();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private List<MonitorResult> extractMonitorResultFromMonitorModel(
|
||||
MonitorMain monitorMain, TestPlan testPlan, Monitor monitor,
|
||||
Date createDatetime) throws IllegalArgumentException,
|
||||
IllegalAccessException, JAXBException {
|
||||
|
||||
List<MonitorResult> monitorResults = new LinkedList<MonitorResult>();
|
||||
|
||||
Field[] fields = monitorMain.getClass().getDeclaredFields();
|
||||
|
||||
for (int i = 0; i < fields.length; i++) {
|
||||
MonitorResult monitorResult = new MonitorResult();
|
||||
monitorResult.setTestPlanDB(testPlan);
|
||||
monitorResult.setMonitor(monitor);
|
||||
monitorResult.setCreateDatetime(createDatetime);
|
||||
monitorResult.setHostNameUnderMonitor(monitor.getHostName());
|
||||
fields[i].setAccessible(true);
|
||||
monitorResult.setType(fields[i].getName());
|
||||
monitorResult.setContent(MarshalHelper.marshal(fields[i].getType(),
|
||||
fields[i].get(monitorMain)));
|
||||
monitorResults.add(monitorResult);
|
||||
}
|
||||
return monitorResults;
|
||||
|
||||
}
|
||||
}
|
|
@ -1,25 +1,25 @@
|
|||
package org.bench4q.master.domain.testplan;
|
||||
|
||||
|
||||
import org.bench4q.master.infrastructure.communication.MonitorMessenger;
|
||||
import org.bench4q.share.models.monitor.MonitorMain;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component
|
||||
public class TestMonitorSampler {
|
||||
|
||||
private MonitorMessenger monitorMessenger;
|
||||
|
||||
@Autowired
|
||||
private void setMonitorMessenger(MonitorMessenger monitorMessenger) {
|
||||
this.monitorMessenger = monitorMessenger;
|
||||
}
|
||||
|
||||
public MonitorMain getMonitorResult( String hostName,
|
||||
int port) {
|
||||
return this.monitorMessenger
|
||||
.monitorModel(hostName, port);
|
||||
}
|
||||
|
||||
}
|
||||
package org.bench4q.master.domain.testplan;
|
||||
|
||||
|
||||
import org.bench4q.master.infrastructure.communication.MonitorMessenger;
|
||||
import org.bench4q.share.models.monitor.MonitorMain;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component
|
||||
public class TestMonitorSampler {
|
||||
|
||||
private MonitorMessenger monitorMessenger;
|
||||
|
||||
@Autowired
|
||||
private void setMonitorMessenger(MonitorMessenger monitorMessenger) {
|
||||
this.monitorMessenger = monitorMessenger;
|
||||
}
|
||||
|
||||
public MonitorMain getMonitorResult( String hostName,
|
||||
int port) {
|
||||
return this.monitorMessenger
|
||||
.monitorModel(hostName, port);
|
||||
}
|
||||
|
||||
}
|
|
@ -1,47 +1,47 @@
|
|||
package org.bench4q.master.exception;
|
||||
|
||||
/**
|
||||
* To deal with the response of each function of TestPlanController
|
||||
*
|
||||
* @author coderfengyun
|
||||
*
|
||||
*/
|
||||
public class Bench4QException extends Exception {
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = 7450550491330737876L;
|
||||
private String code;
|
||||
private String message;
|
||||
private String resource;
|
||||
|
||||
public String getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
public void setCode(String code) {
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
public String getMessage() {
|
||||
return message;
|
||||
}
|
||||
|
||||
public void setMessage(String message) {
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
public String getResource() {
|
||||
return resource;
|
||||
}
|
||||
|
||||
public void setResource(String resource) {
|
||||
this.resource = resource;
|
||||
}
|
||||
|
||||
public Bench4QException(String code, String message, String resource) {
|
||||
this.setCode(code);
|
||||
this.setMessage(message);
|
||||
this.setResource(resource);
|
||||
}
|
||||
}
|
||||
package org.bench4q.master.exception;
|
||||
|
||||
/**
|
||||
* To deal with the response of each function of TestPlanController
|
||||
*
|
||||
* @author coderfengyun
|
||||
*
|
||||
*/
|
||||
public class Bench4QException extends Exception {
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = 7450550491330737876L;
|
||||
private String code;
|
||||
private String message;
|
||||
private String resource;
|
||||
|
||||
public String getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
public void setCode(String code) {
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
public String getMessage() {
|
||||
return message;
|
||||
}
|
||||
|
||||
public void setMessage(String message) {
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
public String getResource() {
|
||||
return resource;
|
||||
}
|
||||
|
||||
public void setResource(String resource) {
|
||||
this.resource = resource;
|
||||
}
|
||||
|
||||
public Bench4QException(String code, String message, String resource) {
|
||||
this.setCode(code);
|
||||
this.setMessage(message);
|
||||
this.setResource(resource);
|
||||
}
|
||||
}
|
|
@ -1,19 +1,19 @@
|
|||
package org.bench4q.master.exception;
|
||||
|
||||
import org.bench4q.share.models.ErrorResponseModel;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.web.bind.annotation.ExceptionHandler;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
import org.springframework.web.bind.annotation.ResponseStatus;
|
||||
|
||||
@Component
|
||||
public class Bench4QExceptionSweeper {
|
||||
@ExceptionHandler(Bench4QException.class)
|
||||
@ResponseStatus(value = HttpStatus.BAD_REQUEST)
|
||||
@ResponseBody
|
||||
public ErrorResponseModel handleException(Bench4QException e) {
|
||||
return ErrorResponseModel.buildErrorResponse(e.getCode(),
|
||||
e.getMessage(), e.getResource());
|
||||
}
|
||||
}
|
||||
package org.bench4q.master.exception;
|
||||
|
||||
import org.bench4q.share.models.ErrorResponseModel;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.web.bind.annotation.ExceptionHandler;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
import org.springframework.web.bind.annotation.ResponseStatus;
|
||||
|
||||
@Component
|
||||
public class Bench4QExceptionSweeper {
|
||||
@ExceptionHandler(Bench4QException.class)
|
||||
@ResponseStatus(value = HttpStatus.BAD_REQUEST)
|
||||
@ResponseBody
|
||||
public ErrorResponseModel handleException(Bench4QException e) {
|
||||
return ErrorResponseModel.buildErrorResponse(e.getCode(),
|
||||
e.getMessage(), e.getResource());
|
||||
}
|
||||
}
|
|
@ -1,13 +1,13 @@
|
|||
package org.bench4q.master.exception;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.PrintStream;
|
||||
|
||||
public class ExceptionLog {
|
||||
public static ByteArrayOutputStream getStackTrace(Throwable e) {
|
||||
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
|
||||
PrintStream printStream = new PrintStream(outputStream);
|
||||
e.printStackTrace(printStream);
|
||||
return outputStream;
|
||||
}
|
||||
}
|
||||
package org.bench4q.master.exception;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.PrintStream;
|
||||
|
||||
public class ExceptionLog {
|
||||
public static ByteArrayOutputStream getStackTrace(Throwable e) {
|
||||
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
|
||||
PrintStream printStream = new PrintStream(outputStream);
|
||||
e.printStackTrace(printStream);
|
||||
return outputStream;
|
||||
}
|
||||
}
|
|
@ -1,26 +1,26 @@
|
|||
package org.bench4q.master.helper;
|
||||
|
||||
import org.springframework.beans.BeansException;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.context.ApplicationContextAware;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component
|
||||
public class ApplicationContextHelper implements ApplicationContextAware {
|
||||
|
||||
private static ApplicationContext context;
|
||||
|
||||
public static ApplicationContext getContext() {
|
||||
return context;
|
||||
}
|
||||
|
||||
private void setContext(ApplicationContext context) {
|
||||
ApplicationContextHelper.context = context;
|
||||
}
|
||||
|
||||
public void setApplicationContext(ApplicationContext applicationContext)
|
||||
throws BeansException {
|
||||
this.setContext(applicationContext);
|
||||
}
|
||||
|
||||
}
|
||||
package org.bench4q.master.helper;
|
||||
|
||||
import org.springframework.beans.BeansException;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.context.ApplicationContextAware;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component
|
||||
public class ApplicationContextHelper implements ApplicationContextAware {
|
||||
|
||||
private static ApplicationContext context;
|
||||
|
||||
public static ApplicationContext getContext() {
|
||||
return context;
|
||||
}
|
||||
|
||||
private void setContext(ApplicationContext context) {
|
||||
ApplicationContextHelper.context = context;
|
||||
}
|
||||
|
||||
public void setApplicationContext(ApplicationContext applicationContext)
|
||||
throws BeansException {
|
||||
this.setContext(applicationContext);
|
||||
}
|
||||
|
||||
}
|