Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Latest changes in scaling framework for SEEP #31

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 11 additions & 13 deletions seep-system/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,21 +26,11 @@
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.17</version>
</dependency>
<!-- Object serialisation -->
<dependency>
<groupId>com.esotericsoftware.kryo</groupId>
<artifactId>kryo</artifactId>
<version>2.22</version>
<version>2.20</version>
</dependency>

<!-- Instrumentation of JVM to obtain various metrics -->
Expand All @@ -66,6 +56,8 @@
<artifactId>fastutil</artifactId>
<version>6.5.9</version>
</dependency>

<!-- Other dependencies -->
<dependency>
<groupId>joda-time</groupId>
<artifactId>joda-time</artifactId>
Expand All @@ -76,7 +68,13 @@
<artifactId>commons-collections4</artifactId>
<version>4.0</version>
</dependency>

<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.2.1</version>
</dependency>

<!-- Jetty -->
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-server</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,6 @@ public interface Factory<T> {

T create();

T create(Object...args);

}
Original file line number Diff line number Diff line change
Expand Up @@ -54,4 +54,9 @@ public MonitorMaster create() {
= new SeepInfrastructureAdaptor(infrastructure);
return new MonitorMaster(adaptor, rules, masterPort);
}

@Override
public MonitorMaster create(Object... args) {
return create();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,23 @@
******************************************************************************/
package uk.ac.imperial.lsds.seep.infrastructure.monitor.policy;

import uk.ac.imperial.lsds.seep.infrastructure.monitor.Builder;
import java.util.ArrayList;
import java.util.List;
import uk.ac.imperial.lsds.seep.infrastructure.monitor.Builder;
import uk.ac.imperial.lsds.seep.infrastructure.monitor.policy.action.Action;
import uk.ac.imperial.lsds.seep.infrastructure.monitor.policy.action.ScaleInAction;
import uk.ac.imperial.lsds.seep.infrastructure.monitor.policy.action.ScaleOutAction;
import uk.ac.imperial.lsds.seep.infrastructure.monitor.policy.metric.MetricName;
import uk.ac.imperial.lsds.seep.infrastructure.monitor.policy.operator.Operator;
import uk.ac.imperial.lsds.seep.infrastructure.monitor.policy.scale.factor.ScaleFactor;
import uk.ac.imperial.lsds.seep.infrastructure.monitor.policy.scale.constraint.ScaleConstraint;
import uk.ac.imperial.lsds.seep.infrastructure.monitor.policy.scale.factor.ScaleFactor;
import uk.ac.imperial.lsds.seep.infrastructure.monitor.policy.syntax.ActionSyntax;
import uk.ac.imperial.lsds.seep.infrastructure.monitor.policy.syntax.GuardTimeThresholdSyntax;
import uk.ac.imperial.lsds.seep.infrastructure.monitor.policy.syntax.MetricSyntax;
import uk.ac.imperial.lsds.seep.infrastructure.monitor.policy.syntax.MetricThresholdSyntax;
import uk.ac.imperial.lsds.seep.infrastructure.monitor.policy.syntax.ScaleConstraintSyntax;
import uk.ac.imperial.lsds.seep.infrastructure.monitor.policy.syntax.ScaleFactorSyntax;
import uk.ac.imperial.lsds.seep.infrastructure.monitor.policy.syntax.TimeThresholdSyntax;
import uk.ac.imperial.lsds.seep.infrastructure.monitor.policy.threshold.MetricThreshold;
import uk.ac.imperial.lsds.seep.infrastructure.monitor.policy.threshold.TimeThreshold;
import uk.ac.imperial.lsds.seep.infrastructure.monitor.policy.trigger.ActionTrigger;
Expand All @@ -28,7 +35,9 @@
*
* @author mrouaux
*/
public class PolicyRuleBuilder implements Builder<PolicyRule> {
public class PolicyRuleBuilder implements Builder<PolicyRule>,
ActionSyntax, MetricSyntax, MetricThresholdSyntax, TimeThresholdSyntax,
ScaleConstraintSyntax, ScaleFactorSyntax, GuardTimeThresholdSyntax {

/**
* Listener to notify others when the builder creates a new PolicyRule instance.
Expand Down Expand Up @@ -102,48 +111,57 @@ public interface PolicyRuleBuilderListener {
this.scaleConstraint = null;
}

@Override
public PolicyRuleBuilder scaleIn(final Operator operator) {
this.action = new ScaleInAction();
this.operator = operator;
return this;
}

@Override
public PolicyRuleBuilder scaleOut(final Operator operator) {
this.action = new ScaleOutAction();
this.operator = operator;
return this;
}

@Override
public PolicyRuleBuilder by(final ScaleFactor scaleFactor) {
this.scaleFactor = scaleFactor;
return this;
}

@Override
public PolicyRuleBuilder butNeverBelow(final ScaleConstraint scaleConstraint) {
this.scaleConstraint = scaleConstraint;
return this;
}

@Override
public PolicyRuleBuilder butNeverAbove(final ScaleConstraint scaleConstraint) {
this.scaleConstraint = scaleConstraint;
return this;
}

@Override
public PolicyRuleBuilder when(MetricName metricName) {
this.triggerMetricName = metricName;
return this;
}

@Override
public PolicyRuleBuilder and(MetricName metricName) {
this.triggerMetricName = metricName;
return this;
}

@Override
public PolicyRuleBuilder is(MetricThreshold metricThreshold) {
this.triggerMetricThreshold = metricThreshold;
return this;
}

@Override
public PolicyRuleBuilder forAtLeast(TimeThreshold timeThreshold) {
this.triggerTimeThreshold = timeThreshold;

Expand All @@ -158,11 +176,13 @@ public PolicyRuleBuilder forAtLeast(TimeThreshold timeThreshold) {
return this;
}

@Override
public PolicyRuleBuilder withNoScaleInSince(TimeThreshold scaleGuardTime) {
this.scaleGuardTime = scaleGuardTime;
return this;
}

@Override
public PolicyRuleBuilder withNoScaleOutSince(TimeThreshold scaleGuardTime) {
this.scaleGuardTime = scaleGuardTime;
return this;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,9 @@ private void pruneOldReadings(Period maximumAge) {
// works based on the assumption that metrics readings are offered
// with always increasing timestamps.
if(readingAge.toStandardSeconds()
.isLessThan(maximumAge.toStandardSeconds())) {
.isLessThan(maximumAge.toStandardSeconds())
|| readingAge.toStandardSeconds()
.equals(maximumAge.toStandardSeconds())) {
done = true;
} else {
pastReadings.poll();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package uk.ac.imperial.lsds.seep.infrastructure.monitor.policy.syntax;

import uk.ac.imperial.lsds.seep.infrastructure.monitor.policy.operator.Operator;

/**
*
* @author martinrouaux
*/
public interface ActionSyntax {

ActionSyntax scaleIn(final Operator operator);

ActionSyntax scaleOut(final Operator operator);

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package uk.ac.imperial.lsds.seep.infrastructure.monitor.policy.syntax;

import uk.ac.imperial.lsds.seep.infrastructure.monitor.policy.threshold.TimeThreshold;

/**
*
* @author martinrouaux
*/
public interface GuardTimeThresholdSyntax {

GuardTimeThresholdSyntax withNoScaleInSince(TimeThreshold scaleGuardTime);

GuardTimeThresholdSyntax withNoScaleOutSince(TimeThreshold scaleGuardTime);

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package uk.ac.imperial.lsds.seep.infrastructure.monitor.policy.syntax;

import uk.ac.imperial.lsds.seep.infrastructure.monitor.policy.metric.MetricName;

/**
*
* @author martinrouaux
*/
public interface MetricSyntax {

MetricSyntax when(MetricName metricName);

MetricSyntax and(MetricName metricName);

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package uk.ac.imperial.lsds.seep.infrastructure.monitor.policy.syntax;

import uk.ac.imperial.lsds.seep.infrastructure.monitor.policy.threshold.MetricThreshold;

/**
*
* @author martinrouaux
*/
public interface MetricThresholdSyntax {

MetricThresholdSyntax is(MetricThreshold metricThreshold);

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package uk.ac.imperial.lsds.seep.infrastructure.monitor.policy.syntax;

import uk.ac.imperial.lsds.seep.infrastructure.monitor.policy.scale.constraint.ScaleConstraint;

/**
*
* @author martinrouaux
*/
public interface ScaleConstraintSyntax {

ScaleConstraintSyntax butNeverBelow(final ScaleConstraint scaleConstraint);

ScaleConstraintSyntax butNeverAbove(final ScaleConstraint scaleConstraint);

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package uk.ac.imperial.lsds.seep.infrastructure.monitor.policy.syntax;

import uk.ac.imperial.lsds.seep.infrastructure.monitor.policy.scale.factor.ScaleFactor;

/**
*
* @author martinrouaux
*/
public interface ScaleFactorSyntax {

ScaleFactorSyntax by(final ScaleFactor scaleFactor);

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package uk.ac.imperial.lsds.seep.infrastructure.monitor.policy.syntax;

import uk.ac.imperial.lsds.seep.infrastructure.monitor.policy.threshold.TimeThreshold;

/**
*
* @author martinrouaux
*/
public interface TimeThresholdSyntax {

TimeThresholdSyntax forAtLeast(TimeThreshold timeThreshold);

}
Loading