Merge branch 'master' of https://github.com/lostcharlie/Bench4Q.git
This commit is contained in:
commit
12c3248170
|
@ -70,6 +70,7 @@ public class Solution {
|
||||||
new int[] { 1, 2, 2 }));
|
new int[] { 1, 2, 2 }));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
public void test1() {
|
public void test1() {
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -163,7 +163,6 @@ public class RunningAgentDB implements RunningAgentInterface {
|
||||||
return this.getTestPlanScript();
|
return this.getTestPlanScript();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public RunningAgentInterface completeWithRunningScript(
|
public RunningAgentInterface completeWithRunningScript(
|
||||||
RunningScriptInterface runningScript) {
|
RunningScriptInterface runningScript) {
|
||||||
this.setTestPlanScript((TestPlanScript) runningScript);
|
this.setTestPlanScript((TestPlanScript) runningScript);
|
||||||
|
@ -183,9 +182,7 @@ public class RunningAgentDB implements RunningAgentInterface {
|
||||||
.tryUnmarshal(RunScenarioModel.class, this.getTestPlanScript()
|
.tryUnmarshal(RunScenarioModel.class, this.getTestPlanScript()
|
||||||
.getFilteredScriptCnt());
|
.getFilteredScriptCnt());
|
||||||
runScenarioModel.setPoolSize(getLoadInUse());
|
runScenarioModel.setPoolSize(getLoadInUse());
|
||||||
ScheduleModel scheduleModel = (ScheduleModel) MarshalHelper
|
ScheduleModel scheduleModel = generateScheduleModelWithRatio();
|
||||||
.tryUnmarshal(ScheduleModel.class, this.getTestPlanScript()
|
|
||||||
.getScheduleContent());
|
|
||||||
RunScenarioResultModel runScenarioResultModel = this
|
RunScenarioResultModel runScenarioResultModel = this
|
||||||
.getAgentMessenger().submitScenrioWithParams(this.getAgent(),
|
.getAgentMessenger().submitScenrioWithParams(this.getAgent(),
|
||||||
this.getAgentRunId(), script2.loadParamFiles(),
|
this.getAgentRunId(), script2.loadParamFiles(),
|
||||||
|
@ -197,6 +194,19 @@ public class RunningAgentDB implements RunningAgentInterface {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private ScheduleModel generateScheduleModelWithRatio() {
|
||||||
|
ScheduleModel scheduleModel = (ScheduleModel) MarshalHelper
|
||||||
|
.tryUnmarshal(ScheduleModel.class, this.getTestPlanScript()
|
||||||
|
.getScheduleContent());
|
||||||
|
int totolRequireLoad = this.getTestPlanScript().getRequireLoad();
|
||||||
|
if (totolRequireLoad <= 0) {
|
||||||
|
throw new IllegalArgumentException(
|
||||||
|
"The require load can't be less than 0!!");
|
||||||
|
}
|
||||||
|
double ratio = (double) this.getLoadInUse() / (double) totolRequireLoad;
|
||||||
|
return scheduleModel.ratioIntoEffect(ratio);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @return
|
* @return
|
||||||
|
@ -230,7 +240,6 @@ public class RunningAgentDB implements RunningAgentInterface {
|
||||||
this.setHasSubstitute(true);
|
this.setHasSubstitute(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public TestBriefStatusModel briefAll() {
|
public TestBriefStatusModel briefAll() {
|
||||||
if (this.isStoped()) {
|
if (this.isStoped()) {
|
||||||
return null;
|
return null;
|
||||||
|
|
|
@ -305,7 +305,6 @@ public class TestPlanScript implements RunningScriptInterface {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
@Transient
|
@Transient
|
||||||
public Date getStartTime() {
|
public Date getStartTime() {
|
||||||
return this.getTestPlan().getCurrentStartTime();
|
return this.getTestPlan().getCurrentStartTime();
|
||||||
|
|
|
@ -204,7 +204,6 @@ public class TestPlanEngine implements TaskCompleteCallback,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void executePendingTestPlan() {
|
public void executePendingTestPlan() {
|
||||||
pickATestPlan();
|
pickATestPlan();
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,13 +0,0 @@
|
||||||
package org.bench4q.master.domain.valueobject.schedulscript;
|
|
||||||
|
|
||||||
import java.util.TimerTask;
|
|
||||||
|
|
||||||
public class WarmUpOverTask extends TimerTask {
|
|
||||||
public WarmUpOverTask() {
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
System.out.println("warm up over and start to execute!");
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -50,7 +50,6 @@ public class TestPlanLoadApplication implements Transaction {
|
||||||
this.getHighAvailableAgentPool().checkAllHeartBeat();
|
this.getHighAvailableAgentPool().checkAllHeartBeat();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public TestPlanStatus execute() throws Exception {
|
public TestPlanStatus execute() throws Exception {
|
||||||
synchronized (this.highAvailableAgentPool) {
|
synchronized (this.highAvailableAgentPool) {
|
||||||
if (!hasEnoughMaxLoad(this.getTestPlan().getRequiredLoad())) {
|
if (!hasEnoughMaxLoad(this.getTestPlan().getRequiredLoad())) {
|
||||||
|
@ -72,7 +71,6 @@ public class TestPlanLoadApplication implements Transaction {
|
||||||
return TestPlanStatus.InRunning;
|
return TestPlanStatus.InRunning;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void rollBack() {
|
public void rollBack() {
|
||||||
for (TestPlanScript testPlanScript : this.getTestPlan()
|
for (TestPlanScript testPlanScript : this.getTestPlan()
|
||||||
.getTestPlanScripts()) {
|
.getTestPlanScripts()) {
|
||||||
|
|
|
@ -67,7 +67,6 @@ public class AgentMessengerImpl implements AgentMessenger {
|
||||||
final int requiredLoad) {
|
final int requiredLoad) {
|
||||||
return this.executorService
|
return this.executorService
|
||||||
.submit(new Callable<RunScenarioResultModel>() {
|
.submit(new Callable<RunScenarioResultModel>() {
|
||||||
@Override
|
|
||||||
public RunScenarioResultModel call() throws Exception {
|
public RunScenarioResultModel call() throws Exception {
|
||||||
return bookTest(agent, requiredLoad);
|
return bookTest(agent, requiredLoad);
|
||||||
}
|
}
|
||||||
|
@ -105,7 +104,6 @@ public class AgentMessengerImpl implements AgentMessenger {
|
||||||
final ScheduleModel scheduleModel, final Date realStartDate) {
|
final ScheduleModel scheduleModel, final Date realStartDate) {
|
||||||
return this.executorService
|
return this.executorService
|
||||||
.submit(new Callable<RunScenarioResultModel>() {
|
.submit(new Callable<RunScenarioResultModel>() {
|
||||||
@Override
|
|
||||||
public RunScenarioResultModel call() throws Exception {
|
public RunScenarioResultModel call() throws Exception {
|
||||||
return submitScenrioWithParams(agent, agentRunId,
|
return submitScenrioWithParams(agent, agentRunId,
|
||||||
paramFiles, runScenarioModel, scheduleModel,
|
paramFiles, runScenarioModel, scheduleModel,
|
||||||
|
@ -139,7 +137,6 @@ public class AgentMessengerImpl implements AgentMessenger {
|
||||||
final UUID agentRunId) {
|
final UUID agentRunId) {
|
||||||
return this.executorService
|
return this.executorService
|
||||||
.submit(new Callable<RunScenarioResultModel>() {
|
.submit(new Callable<RunScenarioResultModel>() {
|
||||||
@Override
|
|
||||||
public RunScenarioResultModel call() throws Exception {
|
public RunScenarioResultModel call() throws Exception {
|
||||||
return runWithParams(agent, agentRunId);
|
return runWithParams(agent, agentRunId);
|
||||||
}
|
}
|
||||||
|
@ -175,7 +172,7 @@ public class AgentMessengerImpl implements AgentMessenger {
|
||||||
final UUID runId) {
|
final UUID runId) {
|
||||||
return this.executorService
|
return this.executorService
|
||||||
.submit(new Callable<TestBriefStatusModel>() {
|
.submit(new Callable<TestBriefStatusModel>() {
|
||||||
@Override
|
|
||||||
public TestBriefStatusModel call() throws Exception {
|
public TestBriefStatusModel call() throws Exception {
|
||||||
return scriptBriefAll(agent, runId);
|
return scriptBriefAll(agent, runId);
|
||||||
}
|
}
|
||||||
|
@ -206,7 +203,6 @@ public class AgentMessengerImpl implements AgentMessenger {
|
||||||
public Future<StopTestModel> stopAsync(final Agent agent, final UUID runId) {
|
public Future<StopTestModel> stopAsync(final Agent agent, final UUID runId) {
|
||||||
return this.executorService.submit(new Callable<StopTestModel>() {
|
return this.executorService.submit(new Callable<StopTestModel>() {
|
||||||
|
|
||||||
@Override
|
|
||||||
public StopTestModel call() throws Exception {
|
public StopTestModel call() throws Exception {
|
||||||
return stop(agent, runId);
|
return stop(agent, runId);
|
||||||
}
|
}
|
||||||
|
@ -235,7 +231,7 @@ public class AgentMessengerImpl implements AgentMessenger {
|
||||||
|
|
||||||
public Future<ServerStatusModel> getStatusAsync(final Agent agent) {
|
public Future<ServerStatusModel> getStatusAsync(final Agent agent) {
|
||||||
return this.executorService.submit(new Callable<ServerStatusModel>() {
|
return this.executorService.submit(new Callable<ServerStatusModel>() {
|
||||||
@Override
|
|
||||||
public ServerStatusModel call() throws Exception {
|
public ServerStatusModel call() throws Exception {
|
||||||
return getStatus(agent);
|
return getStatus(agent);
|
||||||
}
|
}
|
||||||
|
|
|
@ -337,7 +337,6 @@ public class HighAvailablePoolImpl extends CurrentLoadSubject implements
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public ServerStatusModel queryAgentStatus(Agent agent) {
|
public ServerStatusModel queryAgentStatus(Agent agent) {
|
||||||
return this.getAgentMessenger().getStatus(agent);
|
return this.getAgentMessenger().getStatus(agent);
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,6 +3,7 @@ package org.bench4q.master.unitTest.entity;
|
||||||
import static org.junit.Assert.*;
|
import static org.junit.Assert.*;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
|
@ -16,6 +17,7 @@ import org.bench4q.master.domain.valueobject.transaction.TransactionFactory;
|
||||||
import org.bench4q.master.domain.valueobject.transaction.impl.ScriptLoadApplication;
|
import org.bench4q.master.domain.valueobject.transaction.impl.ScriptLoadApplication;
|
||||||
import org.bench4q.master.unitTest.TestBase_MakeUpTestPlan;
|
import org.bench4q.master.unitTest.TestBase_MakeUpTestPlan;
|
||||||
import org.bench4q.share.enums.master.TestPlanStatus;
|
import org.bench4q.share.enums.master.TestPlanStatus;
|
||||||
|
import org.bench4q.share.models.agent.scriptrecord.ScheduleModel;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
|
@ -144,4 +146,21 @@ public class Test_RunningAgent extends TestBase_MakeUpTestPlan {
|
||||||
assertTrue(runningAgentDB.stop());
|
assertTrue(runningAgentDB.stop());
|
||||||
assertTrue(runningAgentDB.stop());
|
assertTrue(runningAgentDB.stop());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void test_RatioIntoEffectWithRatioHalf() {
|
||||||
|
ScheduleModel scheduleModel = new ScheduleModel();
|
||||||
|
double ratio = 0.5;
|
||||||
|
scheduleModel.getPoints().addAll(
|
||||||
|
Arrays.asList(new ScheduleModel.PointModel(0, 0),
|
||||||
|
new ScheduleModel.PointModel(30, 100)));
|
||||||
|
ScheduleModel target = scheduleModel.ratioIntoEffect(0.5);
|
||||||
|
for (int i = 0; i < scheduleModel.getPoints().size(); i++) {
|
||||||
|
assertEquals(target.getPoints().get(i).getTimeInSecond(),
|
||||||
|
scheduleModel.getPoints().get(i).getTimeInSecond());
|
||||||
|
assertEquals(
|
||||||
|
(int) (scheduleModel.getPoints().get(i).getLoad() * ratio),
|
||||||
|
target.getPoints().get(i).getLoad());
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,12 +23,10 @@ public class HighAvailableImpl implements HighAvailablePool {
|
||||||
.put(hostName, Agent.createAgentWithoutId(hostName, 6565, 500));
|
.put(hostName, Agent.createAgentWithoutId(hostName, 6565, 500));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public Map<String, Agent> getPool() {
|
public Map<String, Agent> getPool() {
|
||||||
return this.pool;
|
return this.pool;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public Long getMaxAvailableLoad() {
|
public Long getMaxAvailableLoad() {
|
||||||
Long result = 0L;
|
Long result = 0L;
|
||||||
for (Agent agent : this.pool.values()) {
|
for (Agent agent : this.pool.values()) {
|
||||||
|
@ -37,7 +35,6 @@ public class HighAvailableImpl implements HighAvailablePool {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getCurrentAvailableLoad() {
|
public int getCurrentAvailableLoad() {
|
||||||
int result = 0;
|
int result = 0;
|
||||||
for (Agent agent : this.pool.values()) {
|
for (Agent agent : this.pool.values()) {
|
||||||
|
@ -46,58 +43,48 @@ public class HighAvailableImpl implements HighAvailablePool {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void checkAllHeartBeat() {
|
public void checkAllHeartBeat() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void checkHeartBeat(Agent agent) {
|
public void checkHeartBeat(Agent agent) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void cleanUpAboutTestPlan(
|
public void cleanUpAboutTestPlan(
|
||||||
Collection<? extends RunningScriptInterface> runningScripts) {
|
Collection<? extends RunningScriptInterface> runningScripts) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public ServerStatusModel queryAgentStatus(Agent agent) {
|
public ServerStatusModel queryAgentStatus(Agent agent) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void add(Agent agent) {
|
public void add(Agent agent) {
|
||||||
// TODO Auto-generated method stub
|
// TODO Auto-generated method stub
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setObserver(CurrentLoadObserver currentLoadObserver) {
|
public void setObserver(CurrentLoadObserver currentLoadObserver) {
|
||||||
// TODO Auto-generated method stub
|
// TODO Auto-generated method stub
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public Map<UUID, RunningAgentInterface> getAgentRunBlotters() {
|
public Map<UUID, RunningAgentInterface> getAgentRunBlotters() {
|
||||||
// TODO Auto-generated method stub
|
// TODO Auto-generated method stub
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public int blotterSize() {
|
public int blotterSize() {
|
||||||
// TODO Auto-generated method stub
|
// TODO Auto-generated method stub
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void remove(Agent agent) {
|
public void remove(Agent agent) {
|
||||||
// TODO Auto-generated method stub
|
// TODO Auto-generated method stub
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<RunningAgentInterface> applyFor(int load) {
|
public List<RunningAgentInterface> applyFor(int load) {
|
||||||
// TODO Auto-generated method stub
|
// TODO Auto-generated method stub
|
||||||
return null;
|
return null;
|
||||||
|
|
|
@ -28,12 +28,12 @@ public class Mock_AgentMessenger implements AgentMessenger {
|
||||||
|
|
||||||
private UUID testId = UUID.randomUUID();
|
private UUID testId = UUID.randomUUID();
|
||||||
|
|
||||||
@Override
|
|
||||||
public RunScenarioResultModel bookTest(Agent agent, int requireLoad) {
|
public RunScenarioResultModel bookTest(Agent agent, int requireLoad) {
|
||||||
return new RunScenarioResultModel(this.testId);
|
return new RunScenarioResultModel(this.testId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public RunScenarioResultModel submitScenrioWithParams(Agent agent,
|
public RunScenarioResultModel submitScenrioWithParams(Agent agent,
|
||||||
UUID agentRunId, List<File> paramFiles,
|
UUID agentRunId, List<File> paramFiles,
|
||||||
RunScenarioModel runScenarioModel,
|
RunScenarioModel runScenarioModel,
|
||||||
|
@ -41,12 +41,12 @@ public class Mock_AgentMessenger implements AgentMessenger {
|
||||||
return new RunScenarioResultModel(this.testId);
|
return new RunScenarioResultModel(this.testId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public RunScenarioResultModel runWithParams(Agent agent, UUID agentRunId) {
|
public RunScenarioResultModel runWithParams(Agent agent, UUID agentRunId) {
|
||||||
return new RunScenarioResultModel(this.testId);
|
return new RunScenarioResultModel(this.testId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public TestBriefStatusModel scriptBriefAll(Agent agent, UUID runId) {
|
public TestBriefStatusModel scriptBriefAll(Agent agent, UUID runId) {
|
||||||
if (isDead(agent)) {
|
if (isDead(agent)) {
|
||||||
return null;
|
return null;
|
||||||
|
@ -67,7 +67,7 @@ public class Mock_AgentMessenger implements AgentMessenger {
|
||||||
return agent.getCurrentEnumStatus() == AgentStatus.BreakDown;
|
return agent.getCurrentEnumStatus() == AgentStatus.BreakDown;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public StopTestModel stop(Agent agent, UUID runId) {
|
public StopTestModel stop(Agent agent, UUID runId) {
|
||||||
// if (runId == this.testId) {
|
// if (runId == this.testId) {
|
||||||
// return new StopTestModel(true);
|
// return new StopTestModel(true);
|
||||||
|
@ -75,7 +75,7 @@ public class Mock_AgentMessenger implements AgentMessenger {
|
||||||
return new StopTestModel(true);
|
return new StopTestModel(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public ServerStatusModel getStatus(Agent agent) {
|
public ServerStatusModel getStatus(Agent agent) {
|
||||||
ServerStatusModel result = new ServerStatusModel();
|
ServerStatusModel result = new ServerStatusModel();
|
||||||
if (agent.getCurrentEnumStatus() == AgentStatus.InIdle) {
|
if (agent.getCurrentEnumStatus() == AgentStatus.InIdle) {
|
||||||
|
@ -89,7 +89,7 @@ public class Mock_AgentMessenger implements AgentMessenger {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public Future<ServerStatusModel> getStatusAsync(Agent agent) {
|
public Future<ServerStatusModel> getStatusAsync(Agent agent) {
|
||||||
return new AsyncResult<ServerStatusModel>(getStatus(agent));
|
return new AsyncResult<ServerStatusModel>(getStatus(agent));
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,7 +14,6 @@ import org.springframework.stereotype.Component;
|
||||||
@Component
|
@Component
|
||||||
public class Mock_MonitorMessenger implements MonitorMessenger {
|
public class Mock_MonitorMessenger implements MonitorMessenger {
|
||||||
|
|
||||||
@Override
|
|
||||||
public MonitorMain monitorModel(String hostName, int port) {
|
public MonitorMain monitorModel(String hostName, int port) {
|
||||||
MonitorMain result = new MonitorMain();
|
MonitorMain result = new MonitorMain();
|
||||||
result.setFinished(false);
|
result.setFinished(false);
|
||||||
|
@ -27,27 +26,22 @@ public class Mock_MonitorMessenger implements MonitorMessenger {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public PhysicalDiskModel physicalDisk(String hostName, int port) {
|
public PhysicalDiskModel physicalDisk(String hostName, int port) {
|
||||||
return monitorModel(hostName, port).getPhysicalDiskModel();
|
return monitorModel(hostName, port).getPhysicalDiskModel();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public MemoryModel memory(String hostName, int port) {
|
public MemoryModel memory(String hostName, int port) {
|
||||||
return monitorModel(hostName, port).getMemoryModel();
|
return monitorModel(hostName, port).getMemoryModel();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public ProcessorModel processor(String hostName, int port) {
|
public ProcessorModel processor(String hostName, int port) {
|
||||||
return monitorModel(hostName, port).getProcessorModel();
|
return monitorModel(hostName, port).getProcessorModel();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public NetworkInterfaceModel networkInterface(String hostName, int port) {
|
public NetworkInterfaceModel networkInterface(String hostName, int port) {
|
||||||
return monitorModel(hostName, port).getNetworkInterfaceModel();
|
return monitorModel(hostName, port).getNetworkInterfaceModel();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public ProcessModel process(String hostName, int port) {
|
public ProcessModel process(String hostName, int port) {
|
||||||
return monitorModel(hostName, port).getProcessModel();
|
return monitorModel(hostName, port).getProcessModel();
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,6 +23,16 @@ public class ScheduleModel {
|
||||||
this.points = new LinkedList<PointModel>();
|
this.points = new LinkedList<PointModel>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ScheduleModel ratioIntoEffect(double ratio) {
|
||||||
|
ScheduleModel result = new ScheduleModel();
|
||||||
|
for (PointModel old : this.getPoints()) {
|
||||||
|
result.getPoints().add(
|
||||||
|
new PointModel(old.getTimeInSecond(),
|
||||||
|
(int) (old.getLoad() * ratio)));
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
public long getExecuteRange() {
|
public long getExecuteRange() {
|
||||||
if (this.points.size() == 0) {
|
if (this.points.size() == 0) {
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
<%@ page language="java" contentType="text/html; charset=UTF-8"
|
<%@ page language="java" contentType="text/html; charset=UTF-8"
|
||||||
pageEncoding="UTF-8"%>
|
pageEncoding="UTF-8"%>
|
||||||
<html>
|
<html>
|
||||||
|
|
||||||
<head>
|
<head>
|
||||||
<%@taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
|
<%@taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
|
||||||
<meta charset="utf-8">
|
<meta charset="utf-8">
|
||||||
|
|
|
@ -325,6 +325,10 @@ function Behavior(usePlugin, containerId) {
|
||||||
"behavior_usePlugin", "batch"));
|
"behavior_usePlugin", "batch"));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.getBehaviorEditorMap = function(){
|
||||||
|
return behaviorEditorMap;
|
||||||
|
}
|
||||||
|
|
||||||
this.getPages = function() {
|
this.getPages = function() {
|
||||||
updateBehaviorEditors();
|
updateBehaviorEditors();
|
||||||
|
|
|
@ -16,24 +16,48 @@ $(function() {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
function checkPluginsInput(plugins) {
|
function checkPluginsInput(plugins, usePlugin) {
|
||||||
|
|
||||||
for (var i = 0; i < plugins.length; i++){
|
for (var i = 0; i < plugins.length; i++){
|
||||||
for (var j = 0; j < plugins[i].parameters.length; j++){
|
for (var j = 0; j < plugins[i].parameters.length; j++){
|
||||||
if (plugins[i].parameters[j].check =="false")
|
if (plugins[i].parameters[j].check =="false"){
|
||||||
return false;
|
$("#tabs").tabs("option", "active", 0 );
|
||||||
|
|
||||||
|
var usePluginEditorMap = usePlugin.getUsePluginEditorMap();
|
||||||
|
$("#pluginEditor").append(usePluginEditorMap.get(plugins[i].id));
|
||||||
|
var inputs = $("#"+ plugins[i].parameters[j].key + " input");
|
||||||
|
for (var p = 0; p < inputs.length; p++){
|
||||||
|
if ($(inputs[p]).val() == ""){
|
||||||
|
$(inputs[p]).focus();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
function checkPagesInput(pages) {
|
function checkPagesInput(pages, usePlugin) {
|
||||||
|
|
||||||
for (var i = 0;i < pages.length; i++){
|
for (var i = 0;i < pages.length; i++){
|
||||||
for (var j = 0; j < pages[i].batches.length; j++){
|
for (var j = 0; j < pages[i].batches.length; j++){
|
||||||
for (var k = 0; k < pages[i].batches[j].behaviors.length; k++){
|
for (var k = 0; k < pages[i].batches[j].behaviors.length; k++){
|
||||||
for (var q = 0; q < pages[i].batches[j].behaviors[k].parameters.length; q++){
|
for (var q = 0; q < pages[i].batches[j].behaviors[k].parameters.length; q++){
|
||||||
if (pages[i].batches[j].behaviors[k].parameters[q].check == "false"){
|
if (pages[i].batches[j].behaviors[k].parameters[q].check =="false"){
|
||||||
return false;
|
$("#tabs").tabs("option", "active", 1 );
|
||||||
}
|
var behaviorEditorMap = usePlugin.getBehaviorEditorMap();
|
||||||
|
$("#behaviorEditor").append(behaviorEditorMap.get(pages[i].batches[j].behaviors[k].id));
|
||||||
|
var inputs = $("#"+ pages[i].batches[j].behaviors[k].parameters[q].key + " input");
|
||||||
|
for (var p = 0; p < inputs.length; p++){
|
||||||
|
if ($(inputs[p]).val() == ""){
|
||||||
|
$(inputs[p]).focus();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,11 +5,12 @@ $(function() {
|
||||||
|
|
||||||
$("#submitScript").click(function() {
|
$("#submitScript").click(function() {
|
||||||
var formData = new FormData();
|
var formData = new FormData();
|
||||||
var plugins = usePlugin.getPlugins( formData );
|
var plugins = usePlugin.getPlugins(formData);
|
||||||
var pages = usePlugin.getPages();
|
var pages = usePlugin.getPages();
|
||||||
if(checkPluginsInput(plugins) && checkPagesInput(pages))
|
if(checkPluginsInput(plugins, usePlugin) && checkPagesInput(pages, usePlugin))
|
||||||
submitScript(pages, plugins, formData);
|
submitScript(pages, plugins, formData);
|
||||||
else
|
else{
|
||||||
information("Please complete the required parameters.");
|
information("Please complete the required parameters.");
|
||||||
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -39,7 +39,7 @@ $(function() {
|
||||||
var formData = new FormData();
|
var formData = new FormData();
|
||||||
var plugins = usePlugin.getPlugins(formData);
|
var plugins = usePlugin.getPlugins(formData);
|
||||||
var pages = usePlugin.getPages();
|
var pages = usePlugin.getPages();
|
||||||
if(checkPluginsInput(plugins) && checkPagesInput(pages))
|
if(checkPluginsInput(plugins, usePlugin) && checkPagesInput(pages, usePlugin))
|
||||||
updateScript(scriptId,pages,plugins,formData);
|
updateScript(scriptId,pages,plugins,formData);
|
||||||
else
|
else
|
||||||
information("Please complete the required parameters.");
|
information("Please complete the required parameters.");
|
||||||
|
|
|
@ -85,6 +85,11 @@ function UsePlugin(behaviorListContainerId) {
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
this.getUsePluginEditorMap = function() {
|
||||||
|
return usePluginEditorMap;
|
||||||
|
}
|
||||||
|
|
||||||
function getPluginList() {
|
function getPluginList() {
|
||||||
var usePlugin = this;
|
var usePlugin = this;
|
||||||
$.post("loadPluginName", {}, function(data) {
|
$.post("loadPluginName", {}, function(data) {
|
||||||
|
@ -197,6 +202,10 @@ function UsePlugin(behaviorListContainerId) {
|
||||||
return behavior.getPages();
|
return behavior.getPages();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.getBehaviorEditorMap = function(){
|
||||||
|
return behavior.getBehaviorEditorMap();
|
||||||
|
}
|
||||||
|
|
||||||
this.initPluginAndPages = function(scriptObj){
|
this.initPluginAndPages = function(scriptObj){
|
||||||
initPluginList(scriptObj.usePlugins);
|
initPluginList(scriptObj.usePlugins);
|
||||||
behavior.initBehaviorList(scriptObj.pages);
|
behavior.initBehaviorList(scriptObj.pages);
|
||||||
|
|
Loading…
Reference in New Issue