Skip to content

Commit dc15111

Browse files
committed
AutoScaling without NetScaler
1 parent bd238ce commit dc15111

25 files changed

Lines changed: 2195 additions & 103 deletions

api/src/com/cloud/network/as/AutoScaleCounter.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ public static class AutoScaleCounterType {
2727

2828
public static final AutoScaleCounterType Snmp = new AutoScaleCounterType("snmp");
2929
public static final AutoScaleCounterType Netscaler = new AutoScaleCounterType("netscaler");
30+
public static final AutoScaleCounterType Cpu = new AutoScaleCounterType("cpu");
31+
public static final AutoScaleCounterType Memory = new AutoScaleCounterType("memory");
3032

3133
public AutoScaleCounterType(String name) {
3234
_name = name;

api/src/com/cloud/network/as/AutoScalePolicy.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717

1818
package com.cloud.network.as;
1919

20+
import java.util.Date;
21+
2022
import org.apache.cloudstack.acl.ControlledEntity;
2123
import org.apache.cloudstack.api.InternalIdentity;
2224

@@ -30,6 +32,8 @@ public interface AutoScalePolicy extends ControlledEntity, InternalIdentity {
3032
public int getDuration();
3133

3234
public int getQuietTime();
35+
36+
public Date getLastQuiteTime();
3337

3438
public String getAction();
3539

api/src/com/cloud/network/as/AutoScaleVmGroup.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717

1818
package com.cloud.network.as;
1919

20+
import java.util.Date;
21+
2022
import org.apache.cloudstack.acl.ControlledEntity;
2123
import org.apache.cloudstack.api.InternalIdentity;
2224

@@ -45,6 +47,8 @@ public interface AutoScaleVmGroup extends ControlledEntity, InternalIdentity {
4547

4648
int getInterval();
4749

50+
Date getLastInterval();
51+
4852
String getState();
4953

5054
String getUuid();

api/src/com/cloud/network/as/Counter.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,16 @@
2323
public interface Counter extends InternalIdentity, Identity {
2424

2525
public static enum Source {
26-
netscaler, snmp
26+
netscaler,
27+
snmp,
28+
cpu,
29+
memory
2730
}
2831

2932
String getName();
3033

3134
String getValue();
3235

3336
Source getSource();
37+
3438
}

client/tomcatconf/applicationContext.xml.in

Lines changed: 956 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
package com.cloud.agent.api;
2+
3+
public class PerformanceMonitorAnswer extends Answer {
4+
public PerformanceMonitorAnswer() {
5+
}
6+
7+
public PerformanceMonitorAnswer(PerformanceMonitorCommand cmd,
8+
boolean result, String details) {
9+
super(cmd, result, details);
10+
}
11+
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
package com.cloud.agent.api;
2+
3+
import java.util.HashMap;
4+
import java.util.Map;
5+
6+
public class PerformanceMonitorCommand extends Command {
7+
8+
Map<String, String> params = new HashMap<String, String>();
9+
10+
public PerformanceMonitorCommand() {
11+
}
12+
13+
public PerformanceMonitorCommand(Map<String, String> params, int wait) {
14+
setWait(wait);
15+
this.params = params;
16+
}
17+
18+
@Override
19+
public boolean executeInSequence() {
20+
return false;
21+
}
22+
23+
public Map<String, String> getParams() {
24+
return params;
25+
}
26+
27+
public void setParams(Map<String, String> params) {
28+
this.params = params;
29+
}
30+
}

engine/schema/src/com/cloud/network/as/AutoScalePolicyVO.java

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@
2727
import javax.persistence.Inheritance;
2828
import javax.persistence.InheritanceType;
2929
import javax.persistence.Table;
30+
import javax.persistence.Temporal;
31+
import javax.persistence.TemporalType;
3032

3133
import org.apache.cloudstack.api.InternalIdentity;
3234

@@ -57,6 +59,10 @@ public class AutoScalePolicyVO implements AutoScalePolicy, InternalIdentity {
5759
@Column(name = "quiet_time", updatable = true, nullable = false)
5860
private int quietTime;
5961

62+
@Column(name = "last_quiet_time", updatable = true)
63+
@Temporal(value = TemporalType.TIMESTAMP)
64+
private Date lastQuiteTime;
65+
6066
@Column(name = "action", updatable = false, nullable = false)
6167
private String action;
6268

@@ -69,12 +75,14 @@ public class AutoScalePolicyVO implements AutoScalePolicy, InternalIdentity {
6975
public AutoScalePolicyVO() {
7076
}
7177

72-
public AutoScalePolicyVO(long domainId, long accountId, int duration, int quietTime, String action) {
78+
public AutoScalePolicyVO(long domainId, long accountId, int duration,
79+
int quietTime, Date lastQuiteTime, String action) {
7380
this.uuid = UUID.randomUUID().toString();
7481
this.domainId = domainId;
7582
this.accountId = accountId;
7683
this.duration = duration;
7784
this.quietTime = quietTime;
85+
this.lastQuiteTime = lastQuiteTime;
7886
this.action = action;
7987
}
8088

@@ -113,6 +121,11 @@ public int getQuietTime() {
113121
return quietTime;
114122
}
115123

124+
@Override
125+
public Date getLastQuiteTime() {
126+
return lastQuiteTime;
127+
}
128+
116129
@Override
117130
public String getAction() {
118131
return action;
@@ -133,4 +146,8 @@ public void setDuration(Integer duration) {
133146
public void setQuietTime(Integer quietTime) {
134147
this.quietTime = quietTime;
135148
}
149+
150+
public void setLastQuiteTime(Date lastQuiteTime) {
151+
this.lastQuiteTime = lastQuiteTime;
152+
}
136153
}

engine/schema/src/com/cloud/network/as/AutoScaleVmGroupVO.java

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@
2727
import javax.persistence.Inheritance;
2828
import javax.persistence.InheritanceType;
2929
import javax.persistence.Table;
30+
import javax.persistence.Temporal;
31+
import javax.persistence.TemporalType;
3032

3133
import org.apache.cloudstack.api.InternalIdentity;
3234

@@ -69,6 +71,10 @@ public class AutoScaleVmGroupVO implements AutoScaleVmGroup, InternalIdentity {
6971
@Column(name = "interval")
7072
private int interval;
7173

74+
@Column(name = "last_interval", updatable = true)
75+
@Temporal(value = TemporalType.TIMESTAMP)
76+
private Date lastInterval;
77+
7278
@Column(name = "profile_id")
7379
private long profileId;
7480

@@ -84,8 +90,10 @@ public class AutoScaleVmGroupVO implements AutoScaleVmGroup, InternalIdentity {
8490
public AutoScaleVmGroupVO() {
8591
}
8692

87-
public AutoScaleVmGroupVO(long lbRuleId, long zoneId, long domainId, long accountId, int minMembers, int maxMembers, int memberPort, int interval, long profileId,
88-
String state) {
93+
public AutoScaleVmGroupVO(long lbRuleId, long zoneId, long domainId,
94+
long accountId, int minMembers, int maxMembers, int memberPort,
95+
int interval, Date lastInterval, long profileId, String state) {
96+
8997
this.uuid = UUID.randomUUID().toString();
9098
this.loadBalancerId = lbRuleId;
9199
this.minMembers = minMembers;
@@ -97,6 +105,7 @@ public AutoScaleVmGroupVO(long lbRuleId, long zoneId, long domainId, long accoun
97105
this.zoneId = zoneId;
98106
this.state = state;
99107
this.interval = interval;
108+
this.lastInterval = lastInterval;
100109
}
101110

102111
@Override
@@ -148,6 +157,11 @@ public int getInterval() {
148157
return interval;
149158
}
150159

160+
@Override
161+
public Date getLastInterval() {
162+
return lastInterval;
163+
}
164+
151165
@Override
152166
public long getProfileId() {
153167
return profileId;
@@ -182,6 +196,10 @@ public void setInterval(Integer interval) {
182196
this.interval = interval;
183197
}
184198

199+
public void setLastInterval(Date lastInterval) {
200+
this.lastInterval = lastInterval;
201+
}
202+
185203
public void setLoadBalancerId(Long loadBalancerId) {
186204
this.loadBalancerId = loadBalancerId;
187205
}
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
package com.cloud.network.as;
2+
3+
import javax.persistence.Column;
4+
import javax.persistence.Entity;
5+
import javax.persistence.GeneratedValue;
6+
import javax.persistence.GenerationType;
7+
import javax.persistence.Id;
8+
import javax.persistence.Table;
9+
10+
import org.apache.cloudstack.api.InternalIdentity;
11+
12+
@Entity
13+
@Table(name = ("autoscale_vmgroup_vm_map"))
14+
public class AutoScaleVmGroupVmMapVO implements InternalIdentity {
15+
@Id
16+
@GeneratedValue(strategy = GenerationType.IDENTITY)
17+
@Column(name = "id")
18+
private long id;
19+
20+
@Column(name = "vmgroup_id")
21+
private long vmGroupId;
22+
23+
@Column(name = "instance_id")
24+
private long instanceId;
25+
26+
public AutoScaleVmGroupVmMapVO() {
27+
}
28+
29+
public AutoScaleVmGroupVmMapVO(long vmGroupId, long instanceId) {
30+
this.vmGroupId = vmGroupId;
31+
this.instanceId = instanceId;
32+
}
33+
34+
public long getId() {
35+
return id;
36+
}
37+
38+
public long getVmGroupId() {
39+
return vmGroupId;
40+
}
41+
42+
public long getInstanceId() {
43+
return instanceId;
44+
}
45+
46+
}

0 commit comments

Comments
 (0)