add AgentInfo and do some modify
This commit is contained in:
parent
0e7bd6897f
commit
453bfeafeb
|
@ -1,5 +1,7 @@
|
||||||
package org.bench4q.master.api;
|
package org.bench4q.master.api;
|
||||||
|
|
||||||
|
import java.util.Random;
|
||||||
|
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
|
||||||
import org.bench4q.master.api.model.OperateScriptServerResponseModel;
|
import org.bench4q.master.api.model.OperateScriptServerResponseModel;
|
||||||
|
@ -52,40 +54,54 @@ public class RecordScriptController {
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public OperateScriptServerResponseModel startScriptRecordServer()
|
public OperateScriptServerResponseModel startScriptRecordServer()
|
||||||
{
|
{
|
||||||
OperateScriptServerResponseModel responseModel =
|
|
||||||
new OperateScriptServerResponseModel();
|
|
||||||
|
|
||||||
if(!this.CheckScope(Constant.NORAML_AUTHENTICATION))
|
if(!this.CheckScope(Constant.NORAML_AUTHENTICATION))
|
||||||
{
|
{
|
||||||
|
return returnResponseModel(false,
|
||||||
responseModel.setSuccess(false);
|
"has no power for this!!!");
|
||||||
responseModel.setFailCauseString("has no power for this!!!");
|
}
|
||||||
return responseModel;
|
if(this.getRequest().getSession().getAttribute("ScriptWizard") != null)
|
||||||
|
{
|
||||||
|
return returnResponseModel(false,
|
||||||
|
"A Script Recording is in Process, please wait");
|
||||||
|
}
|
||||||
|
//TODO: add startScriptRecordServer
|
||||||
|
synchronized (Constant.getPortLock)
|
||||||
|
{
|
||||||
|
int portNum = Constant.ScriptPortPool.size();
|
||||||
|
if(portNum == 0)
|
||||||
|
{
|
||||||
|
return returnResponseModel(false,
|
||||||
|
"Script Record port not enough, please wait for a while!");
|
||||||
|
}
|
||||||
|
Random rand = new Random();
|
||||||
|
int ran = rand.nextInt(portNum);
|
||||||
|
@SuppressWarnings("unused")
|
||||||
|
int portForUse = Constant.ScriptPortPool.get(ran);
|
||||||
|
Constant.ScriptPortPool.remove(ran);
|
||||||
}
|
}
|
||||||
|
|
||||||
//TODO: add startScriptRecordServer
|
return returnResponseModel(true, "");
|
||||||
|
|
||||||
responseModel.setSuccess(true);
|
|
||||||
responseModel.setFailCauseString("");
|
|
||||||
return responseModel;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequestMapping(value = "/stopScriptRecordServer", method = RequestMethod.GET)
|
@RequestMapping(value = "/stopScriptRecordServer", method = RequestMethod.GET)
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public OperateScriptServerResponseModel stopScriptRecordServer(@RequestParam String accessTocken)
|
public OperateScriptServerResponseModel stopScriptRecordServer(@RequestParam String accessTocken)
|
||||||
{
|
{
|
||||||
OperateScriptServerResponseModel responseModel =
|
|
||||||
new OperateScriptServerResponseModel();
|
|
||||||
if (!CheckScope(Constant.NORAML_AUTHENTICATION))
|
if (!CheckScope(Constant.NORAML_AUTHENTICATION))
|
||||||
{
|
{
|
||||||
responseModel.setSuccess(false);
|
return returnResponseModel(false, "has no power for this!!!");
|
||||||
responseModel.setFailCauseString("has no power for this!!!");
|
|
||||||
return responseModel;
|
|
||||||
}
|
}
|
||||||
//TODO: add stopScriptServer
|
//TODO: add stopScriptServer
|
||||||
|
return returnResponseModel(true, "");
|
||||||
|
}
|
||||||
|
|
||||||
responseModel.setSuccess(true);
|
private OperateScriptServerResponseModel returnResponseModel(boolean isSuccess,
|
||||||
responseModel.setFailCauseString("");
|
String failCauseString)
|
||||||
|
{
|
||||||
|
OperateScriptServerResponseModel responseModel =
|
||||||
|
new OperateScriptServerResponseModel();
|
||||||
|
responseModel.setSuccess(isSuccess);
|
||||||
|
responseModel.setFailCauseString(failCauseString);
|
||||||
return responseModel;
|
return responseModel;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
package org.bench4q.master.api.model;
|
package org.bench4q.master.api.model;
|
||||||
|
|
||||||
|
import javax.xml.bind.annotation.XmlElement;
|
||||||
import javax.xml.bind.annotation.XmlRootElement;
|
import javax.xml.bind.annotation.XmlRootElement;
|
||||||
|
|
||||||
import com.sun.xml.internal.txw2.annotation.XmlElement;
|
|
||||||
|
|
||||||
@XmlRootElement(name = "authorizeResponse")
|
@XmlRootElement(name = "authorizeResponse")
|
||||||
public class AuthorizeResponseModel {
|
public class AuthorizeResponseModel {
|
||||||
|
|
|
@ -1,9 +1,8 @@
|
||||||
package org.bench4q.master.api.model;
|
package org.bench4q.master.api.model;
|
||||||
|
|
||||||
|
import javax.xml.bind.annotation.XmlElement;
|
||||||
import javax.xml.bind.annotation.XmlRootElement;
|
import javax.xml.bind.annotation.XmlRootElement;
|
||||||
|
|
||||||
import com.sun.xml.internal.txw2.annotation.XmlElement;
|
|
||||||
|
|
||||||
@XmlRootElement(name = "registerResponse")
|
@XmlRootElement(name = "registerResponse")
|
||||||
public class RegisterResponseModel {
|
public class RegisterResponseModel {
|
||||||
private boolean success;
|
private boolean success;
|
||||||
|
|
|
@ -0,0 +1,34 @@
|
||||||
|
package org.bench4q.master.entity;
|
||||||
|
|
||||||
|
public class AgentInfo {
|
||||||
|
private String ipAdress;
|
||||||
|
private int port;
|
||||||
|
private int MaxLoad;
|
||||||
|
private int RemainLoad;
|
||||||
|
|
||||||
|
public String getIpAdress() {
|
||||||
|
return ipAdress;
|
||||||
|
}
|
||||||
|
public void setIpAdress(String ipAdress) {
|
||||||
|
this.ipAdress = ipAdress;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getPort() {
|
||||||
|
return port;
|
||||||
|
}
|
||||||
|
public void setPort(int port) {
|
||||||
|
this.port = port;
|
||||||
|
}
|
||||||
|
public int getMaxLoad() {
|
||||||
|
return MaxLoad;
|
||||||
|
}
|
||||||
|
public void setMaxLoad(int maxLoad) {
|
||||||
|
MaxLoad = maxLoad;
|
||||||
|
}
|
||||||
|
public int getRemainLoad() {
|
||||||
|
return RemainLoad;
|
||||||
|
}
|
||||||
|
public void setRemainLoad(int remainLoad) {
|
||||||
|
RemainLoad = remainLoad;
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,8 +1,13 @@
|
||||||
package org.bench4q.master.entity;
|
package org.bench4q.master.entity;
|
||||||
|
|
||||||
|
import java.util.Vector;
|
||||||
|
|
||||||
public class Constant {
|
public class Constant {
|
||||||
public static byte NORAML_AUTHENTICATION = 0;
|
public static byte NORAML_AUTHENTICATION = 0;
|
||||||
public static byte SUPER_AUTHENTICATION = 1;
|
public static byte SUPER_AUTHENTICATION = 1;
|
||||||
|
|
||||||
public static Integer getPortLock = 0;
|
public static Integer getPortLock = 0;
|
||||||
|
public static Vector<AgentInfo> AgentPool = new Vector<AgentInfo>();
|
||||||
|
public static Vector<Integer> ScriptPortPool = new Vector<Integer>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -10,7 +10,7 @@ import javax.persistence.Table;
|
||||||
@Entity
|
@Entity
|
||||||
@Table(name = "behavior")
|
@Table(name = "behavior")
|
||||||
public class Behavior {
|
public class Behavior {
|
||||||
// id is the identifier only in database, in fact, behaviorstring is the
|
// id is the identifier only in database, in fact, behaviorString is the
|
||||||
// identifier in the dtd
|
// identifier in the dtd
|
||||||
private int id;
|
private int id;
|
||||||
private int scriptId;
|
private int scriptId;
|
||||||
|
@ -41,7 +41,7 @@ public class Behavior {
|
||||||
return behaviorString;
|
return behaviorString;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setBehaviorString(String behaviorItring) {
|
public void setBehaviorString(String behaviorString) {
|
||||||
this.behaviorString = behaviorItring;
|
this.behaviorString = behaviorString;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,12 +41,12 @@ public class Group {
|
||||||
this.forceStop = forceStop;
|
this.forceStop = forceStop;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Column(name = "loadprofile_id", nullable = false)
|
@Column(name = "loadProfileId", nullable = false)
|
||||||
public int getLoadprofile_id() {
|
public int getLoadprofileId() {
|
||||||
return loadProfileId;
|
return loadProfileId;
|
||||||
}
|
}
|
||||||
public void setLoadprofile_id(int loadprofile_id) {
|
public void setLoadprofileId(int loadprofileId) {
|
||||||
this.loadProfileId = loadprofile_id;
|
this.loadProfileId = loadprofileId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -23,7 +23,7 @@ public class LoadProfile {
|
||||||
this.id = id;
|
this.id = id;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Column(name = "script_id", nullable = false)
|
@Column(name = "scriptId", nullable = false)
|
||||||
public int getScriptId() {
|
public int getScriptId() {
|
||||||
return scriptId;
|
return scriptId;
|
||||||
}
|
}
|
||||||
|
|
|
@ -74,104 +74,104 @@ public class Sample {
|
||||||
public String getParamsPassword() {
|
public String getParamsPassword() {
|
||||||
return paramsPassword;
|
return paramsPassword;
|
||||||
}
|
}
|
||||||
public void setParamsPassword(String password) {
|
public void setParamsPassword(String paramsPassword) {
|
||||||
this.paramsPassword = password;
|
this.paramsPassword = paramsPassword;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Column(name = "paramsParameters", nullable = false)
|
@Column(name = "paramsParameters", nullable = false)
|
||||||
public String getParams_Parameters() {
|
public String getParamsParameters() {
|
||||||
return paramsParameters;
|
return paramsParameters;
|
||||||
}
|
}
|
||||||
public void setParamsParameters(String parameters) {
|
public void setParamsParameters(String paramsParameters) {
|
||||||
this.paramsParameters = parameters;
|
this.paramsParameters = paramsParameters;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Column(name = "paramsRealm", nullable = false)
|
@Column(name = "paramsRealm", nullable = false)
|
||||||
public String getParamsRealm() {
|
public String getParamsRealm() {
|
||||||
return paramsRealm;
|
return paramsRealm;
|
||||||
}
|
}
|
||||||
public void setParamsRealm(String realm) {
|
public void setParamsRealm(String paramsRealm) {
|
||||||
this.paramsRealm = realm;
|
this.paramsRealm = paramsRealm;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Column(name = "paramsProxyport", nullable = false)
|
@Column(name = "paramsProxyport", nullable = false)
|
||||||
public String getParamsProxyport() {
|
public String getParamsProxyport() {
|
||||||
return paramsProxyport;
|
return paramsProxyport;
|
||||||
}
|
}
|
||||||
public void setParamsProxyport(String proxyport) {
|
public void setParamsProxyport(String paramsProxyport) {
|
||||||
this.paramsProxyport = proxyport;
|
this.paramsProxyport = paramsProxyport;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Column(name = "paramsCookies", nullable = false)
|
@Column(name = "paramsCookies", nullable = false)
|
||||||
public String getParamsCookies() {
|
public String getParamsCookies() {
|
||||||
return paramsCookies;
|
return paramsCookies;
|
||||||
}
|
}
|
||||||
public void setParamsCookies(String cookies) {
|
public void setParamsCookies(String paramsCookies) {
|
||||||
this.paramsCookies = cookies;
|
this.paramsCookies = paramsCookies;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Column(name = "paramsProxypassword", nullable = false)
|
@Column(name = "paramsProxypassword", nullable = false)
|
||||||
public String getParamsProxypassword() {
|
public String getParamsProxypassword() {
|
||||||
return paramsProxypassword;
|
return paramsProxypassword;
|
||||||
}
|
}
|
||||||
public void setParamsProxypassword(String proxypassword) {
|
public void setParamsProxypassword(String paramsProxypassword) {
|
||||||
this.paramsProxypassword = proxypassword;
|
this.paramsProxypassword = paramsProxypassword;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Column(name = "paramsHostauth", nullable = false)
|
@Column(name = "paramsHostauth", nullable = false)
|
||||||
public String getParamsHostauth() {
|
public String getParamsHostauth() {
|
||||||
return paramsHostauth;
|
return paramsHostauth;
|
||||||
}
|
}
|
||||||
public void setParamsHostauth(String hostauth) {
|
public void setParamsHostauth(String paramsHostauth) {
|
||||||
this.paramsHostauth = hostauth;
|
this.paramsHostauth = paramsHostauth;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Column(name = "paramsCookiepolicy", nullable = false)
|
@Column(name = "paramsCookiepolicy", nullable = false)
|
||||||
public String getParamsCookiepolicy() {
|
public String getParamsCookiepolicy() {
|
||||||
return paramsCookiepolicy;
|
return paramsCookiepolicy;
|
||||||
}
|
}
|
||||||
public void setParamsCookiepolicy(String cookiepolicy) {
|
public void setParamsCookiepolicy(String paramsCookiepolicy) {
|
||||||
this.paramsCookiepolicy = cookiepolicy;
|
this.paramsCookiepolicy = paramsCookiepolicy;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Column(name = "paramsUri", nullable = false)
|
@Column(name = "paramsUri", nullable = false)
|
||||||
public String getParamsUri() {
|
public String getParamsUri() {
|
||||||
return paramsUri;
|
return paramsUri;
|
||||||
}
|
}
|
||||||
public void setParamsUri(String uri) {
|
public void setParamsUri(String paramsUri) {
|
||||||
this.paramsUri = uri;
|
this.paramsUri = paramsUri;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Column(name = "paramsUsername", nullable = false)
|
@Column(name = "paramsUsername", nullable = false)
|
||||||
public String getParamsUsername() {
|
public String getParamsUsername() {
|
||||||
return paramsUsername;
|
return paramsUsername;
|
||||||
}
|
}
|
||||||
public void setParamsUsername(String username) {
|
public void setParamsUsername(String paramsUsername) {
|
||||||
this.paramsUsername = username;
|
this.paramsUsername = paramsUsername;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Column(name = "paramsRedirect", nullable = false)
|
@Column(name = "paramsRedirect", nullable = false)
|
||||||
public String getParamsRedirect() {
|
public String getParamsRedirect() {
|
||||||
return paramsRedirect;
|
return paramsRedirect;
|
||||||
}
|
}
|
||||||
public void setParamsRedirect(String redirect) {
|
public void setParamsRedirect(String paramsRedirect) {
|
||||||
this.paramsRedirect = redirect;
|
this.paramsRedirect = paramsRedirect;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Column(name = "paramsLocaladdress", nullable = false)
|
@Column(name = "paramsLocaladdress", nullable = false)
|
||||||
public String getParamsLocaladdress() {
|
public String getParamsLocaladdress() {
|
||||||
return paramsLocaladdress;
|
return paramsLocaladdress;
|
||||||
}
|
}
|
||||||
public void setParamsLocaladdress(String localaddress) {
|
public void setParamsLocaladdress(String paramsLocaladdress) {
|
||||||
this.paramsLocaladdress = localaddress;
|
this.paramsLocaladdress = paramsLocaladdress;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Column(name = "paramsProxylogin", nullable = false)
|
@Column(name = "paramsProxylogin", nullable = false)
|
||||||
public String getParamsProxylogin() {
|
public String getParamsProxylogin() {
|
||||||
return paramsProxylogin;
|
return paramsProxylogin;
|
||||||
}
|
}
|
||||||
public void setParamsProxylogin(String proxylogin) {
|
public void setParamsProxylogin(String paramsProxylogin) {
|
||||||
this.paramsProxylogin = proxylogin;
|
this.paramsProxylogin = paramsProxylogin;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package org.bench4q.master.entity.db;
|
package org.bench4q.master.entity.db;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
import javax.persistence.Column;
|
import javax.persistence.Column;
|
||||||
import javax.persistence.Entity;
|
import javax.persistence.Entity;
|
||||||
import javax.persistence.GeneratedValue;
|
import javax.persistence.GeneratedValue;
|
||||||
|
@ -7,15 +8,13 @@ import javax.persistence.GenerationType;
|
||||||
import javax.persistence.Id;
|
import javax.persistence.Id;
|
||||||
import javax.persistence.Table;
|
import javax.persistence.Table;
|
||||||
|
|
||||||
import com.sun.org.apache.xerces.internal.impl.dv.xs.DateTimeDV;
|
|
||||||
|
|
||||||
@Entity
|
@Entity
|
||||||
@Table(name = "Script")
|
@Table(name = "Script")
|
||||||
public class Script {
|
public class Script {
|
||||||
|
|
||||||
private int id;
|
private int id;
|
||||||
private String name;
|
private String name;
|
||||||
private DateTimeDV createDatetime;
|
private Date createDatetime;
|
||||||
private int userId;
|
private int userId;
|
||||||
|
|
||||||
@Id
|
@Id
|
||||||
|
@ -32,15 +31,15 @@ public class Script {
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
public void setName(String scriptName) {
|
public void setName(String name) {
|
||||||
this.name = scriptName;
|
this.name = name;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Column(name = "createDatetime", nullable = false)
|
@Column(name = "createDateTime", nullable = false)
|
||||||
public DateTimeDV getCreateDatetime() {
|
public Date getCreateDatetime() {
|
||||||
return createDatetime;
|
return createDatetime;
|
||||||
}
|
}
|
||||||
public void setCreateDatetime(DateTimeDV createDatetime) {
|
public void setCreateDatetime(Date createDatetime) {
|
||||||
this.createDatetime = createDatetime;
|
this.createDatetime = createDatetime;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -53,4 +52,5 @@ public class Script {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,6 +15,13 @@
|
||||||
<property name="hibernate.dialect">org.hibernate.dialect.MySQLDialect </property>
|
<property name="hibernate.dialect">org.hibernate.dialect.MySQLDialect </property>
|
||||||
<property name="hibernate.hbm2ddl.auto">update</property>
|
<property name="hibernate.hbm2ddl.auto">update</property>
|
||||||
|
|
||||||
<mapping class="org.bench4q.master.entity.User" />
|
<mapping class="org.bench4q.master.entity.db.User" />
|
||||||
|
<mapping class="org.bench4q.master.entity.db.Script" />
|
||||||
|
<mapping class="org.bench4q.master.entity.db.Behavior" />
|
||||||
|
<mapping class="org.bench4q.master.entity.db.Group" />
|
||||||
|
<mapping class="org.bench4q.master.entity.db.LoadProfile" />
|
||||||
|
<mapping class="org.bench4q.master.entity.db.Plugin" />
|
||||||
|
<mapping class="org.bench4q.master.entity.db.Sample" />
|
||||||
|
<mapping class="org.bench4q.master.entity.db.Timer" />
|
||||||
</session-factory>
|
</session-factory>
|
||||||
</hibernate-configuration>
|
</hibernate-configuration>
|
Loading…
Reference in New Issue