add AgentInfo and do some modify

This commit is contained in:
coderfengyun 2013-06-30 11:05:25 +08:00
parent 0e7bd6897f
commit 453bfeafeb
11 changed files with 128 additions and 67 deletions

View File

@ -1,5 +1,7 @@
package org.bench4q.master.api;
import java.util.Random;
import javax.servlet.http.HttpServletRequest;
import org.bench4q.master.api.model.OperateScriptServerResponseModel;
@ -52,40 +54,54 @@ public class RecordScriptController {
@ResponseBody
public OperateScriptServerResponseModel startScriptRecordServer()
{
OperateScriptServerResponseModel responseModel =
new OperateScriptServerResponseModel();
if(!this.CheckScope(Constant.NORAML_AUTHENTICATION))
{
responseModel.setSuccess(false);
responseModel.setFailCauseString("has no power for this!!!");
return responseModel;
return returnResponseModel(false,
"has no power for this!!!");
}
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
responseModel.setSuccess(true);
responseModel.setFailCauseString("");
return responseModel;
return returnResponseModel(true, "");
}
@RequestMapping(value = "/stopScriptRecordServer", method = RequestMethod.GET)
@ResponseBody
public OperateScriptServerResponseModel stopScriptRecordServer(@RequestParam String accessTocken)
{
OperateScriptServerResponseModel responseModel =
new OperateScriptServerResponseModel();
if (!CheckScope(Constant.NORAML_AUTHENTICATION))
{
responseModel.setSuccess(false);
responseModel.setFailCauseString("has no power for this!!!");
return responseModel;
return returnResponseModel(false, "has no power for this!!!");
}
//TODO: add stopScriptServer
responseModel.setSuccess(true);
responseModel.setFailCauseString("");
return returnResponseModel(true, "");
}
private OperateScriptServerResponseModel returnResponseModel(boolean isSuccess,
String failCauseString)
{
OperateScriptServerResponseModel responseModel =
new OperateScriptServerResponseModel();
responseModel.setSuccess(isSuccess);
responseModel.setFailCauseString(failCauseString);
return responseModel;
}
}

View File

@ -1,8 +1,8 @@
package org.bench4q.master.api.model;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import com.sun.xml.internal.txw2.annotation.XmlElement;
@XmlRootElement(name = "authorizeResponse")
public class AuthorizeResponseModel {

View File

@ -1,9 +1,8 @@
package org.bench4q.master.api.model;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import com.sun.xml.internal.txw2.annotation.XmlElement;
@XmlRootElement(name = "registerResponse")
public class RegisterResponseModel {
private boolean success;

View File

@ -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;
}
}

View File

@ -1,8 +1,13 @@
package org.bench4q.master.entity;
import java.util.Vector;
public class Constant {
public static byte NORAML_AUTHENTICATION = 0;
public static byte SUPER_AUTHENTICATION = 1;
public static Integer getPortLock = 0;
public static Vector<AgentInfo> AgentPool = new Vector<AgentInfo>();
public static Vector<Integer> ScriptPortPool = new Vector<Integer>();
}

View File

@ -10,7 +10,7 @@ import javax.persistence.Table;
@Entity
@Table(name = "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
private int id;
private int scriptId;
@ -41,7 +41,7 @@ public class Behavior {
return behaviorString;
}
public void setBehaviorString(String behaviorItring) {
this.behaviorString = behaviorItring;
public void setBehaviorString(String behaviorString) {
this.behaviorString = behaviorString;
}
}

View File

@ -41,12 +41,12 @@ public class Group {
this.forceStop = forceStop;
}
@Column(name = "loadprofile_id", nullable = false)
public int getLoadprofile_id() {
@Column(name = "loadProfileId", nullable = false)
public int getLoadprofileId() {
return loadProfileId;
}
public void setLoadprofile_id(int loadprofile_id) {
this.loadProfileId = loadprofile_id;
public void setLoadprofileId(int loadprofileId) {
this.loadProfileId = loadprofileId;
}

View File

@ -23,7 +23,7 @@ public class LoadProfile {
this.id = id;
}
@Column(name = "script_id", nullable = false)
@Column(name = "scriptId", nullable = false)
public int getScriptId() {
return scriptId;
}

View File

@ -74,104 +74,104 @@ public class Sample {
public String getParamsPassword() {
return paramsPassword;
}
public void setParamsPassword(String password) {
this.paramsPassword = password;
public void setParamsPassword(String paramsPassword) {
this.paramsPassword = paramsPassword;
}
@Column(name = "paramsParameters", nullable = false)
public String getParams_Parameters() {
public String getParamsParameters() {
return paramsParameters;
}
public void setParamsParameters(String parameters) {
this.paramsParameters = parameters;
public void setParamsParameters(String paramsParameters) {
this.paramsParameters = paramsParameters;
}
@Column(name = "paramsRealm", nullable = false)
public String getParamsRealm() {
return paramsRealm;
}
public void setParamsRealm(String realm) {
this.paramsRealm = realm;
public void setParamsRealm(String paramsRealm) {
this.paramsRealm = paramsRealm;
}
@Column(name = "paramsProxyport", nullable = false)
public String getParamsProxyport() {
return paramsProxyport;
}
public void setParamsProxyport(String proxyport) {
this.paramsProxyport = proxyport;
public void setParamsProxyport(String paramsProxyport) {
this.paramsProxyport = paramsProxyport;
}
@Column(name = "paramsCookies", nullable = false)
public String getParamsCookies() {
return paramsCookies;
}
public void setParamsCookies(String cookies) {
this.paramsCookies = cookies;
public void setParamsCookies(String paramsCookies) {
this.paramsCookies = paramsCookies;
}
@Column(name = "paramsProxypassword", nullable = false)
public String getParamsProxypassword() {
return paramsProxypassword;
}
public void setParamsProxypassword(String proxypassword) {
this.paramsProxypassword = proxypassword;
public void setParamsProxypassword(String paramsProxypassword) {
this.paramsProxypassword = paramsProxypassword;
}
@Column(name = "paramsHostauth", nullable = false)
public String getParamsHostauth() {
return paramsHostauth;
}
public void setParamsHostauth(String hostauth) {
this.paramsHostauth = hostauth;
public void setParamsHostauth(String paramsHostauth) {
this.paramsHostauth = paramsHostauth;
}
@Column(name = "paramsCookiepolicy", nullable = false)
public String getParamsCookiepolicy() {
return paramsCookiepolicy;
}
public void setParamsCookiepolicy(String cookiepolicy) {
this.paramsCookiepolicy = cookiepolicy;
public void setParamsCookiepolicy(String paramsCookiepolicy) {
this.paramsCookiepolicy = paramsCookiepolicy;
}
@Column(name = "paramsUri", nullable = false)
public String getParamsUri() {
return paramsUri;
}
public void setParamsUri(String uri) {
this.paramsUri = uri;
public void setParamsUri(String paramsUri) {
this.paramsUri = paramsUri;
}
@Column(name = "paramsUsername", nullable = false)
public String getParamsUsername() {
return paramsUsername;
}
public void setParamsUsername(String username) {
this.paramsUsername = username;
public void setParamsUsername(String paramsUsername) {
this.paramsUsername = paramsUsername;
}
@Column(name = "paramsRedirect", nullable = false)
public String getParamsRedirect() {
return paramsRedirect;
}
public void setParamsRedirect(String redirect) {
this.paramsRedirect = redirect;
public void setParamsRedirect(String paramsRedirect) {
this.paramsRedirect = paramsRedirect;
}
@Column(name = "paramsLocaladdress", nullable = false)
public String getParamsLocaladdress() {
return paramsLocaladdress;
}
public void setParamsLocaladdress(String localaddress) {
this.paramsLocaladdress = localaddress;
public void setParamsLocaladdress(String paramsLocaladdress) {
this.paramsLocaladdress = paramsLocaladdress;
}
@Column(name = "paramsProxylogin", nullable = false)
public String getParamsProxylogin() {
return paramsProxylogin;
}
public void setParamsProxylogin(String proxylogin) {
this.paramsProxylogin = proxylogin;
public void setParamsProxylogin(String paramsProxylogin) {
this.paramsProxylogin = paramsProxylogin;
}

View File

@ -1,5 +1,6 @@
package org.bench4q.master.entity.db;
import java.util.Date;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
@ -7,15 +8,13 @@ import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
import com.sun.org.apache.xerces.internal.impl.dv.xs.DateTimeDV;
@Entity
@Table(name = "Script")
public class Script {
private int id;
private String name;
private DateTimeDV createDatetime;
private Date createDatetime;
private int userId;
@Id
@ -32,15 +31,15 @@ public class Script {
public String getName() {
return name;
}
public void setName(String scriptName) {
this.name = scriptName;
public void setName(String name) {
this.name = name;
}
@Column(name = "createDatetime", nullable = false)
public DateTimeDV getCreateDatetime() {
@Column(name = "createDateTime", nullable = false)
public Date getCreateDatetime() {
return createDatetime;
}
public void setCreateDatetime(DateTimeDV createDatetime) {
public void setCreateDatetime(Date createDatetime) {
this.createDatetime = createDatetime;
}
@ -53,4 +52,5 @@ public class Script {
}
}

View File

@ -15,6 +15,13 @@
<property name="hibernate.dialect">org.hibernate.dialect.MySQLDialect </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>
</hibernate-configuration>