Skip to content

Commit

Permalink
CONT-93: Forecast microservice
Browse files Browse the repository at this point in the history
  • Loading branch information
Hidiroglu Alper committed Nov 14, 2018
1 parent a702334 commit e9eba7d
Show file tree
Hide file tree
Showing 97 changed files with 5,803 additions and 33 deletions.
1 change: 1 addition & 0 deletions continuity.api/continuity.api.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ dependencyManagement {

dependencies {
compile project(':continuity.idpa')
compile project(':continuity.dsl')

compile("org.springframework.boot:spring-boot-starter-web")
compile("org.springframework.boot:spring-boot-starter-amqp")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,14 +78,16 @@ private SessionLogs() {
/**
* AMQP API of the workload model services, e.g., wessbas.
*
* @author Henning Schulz
* @author Henning Schulz, Alper Hidiroglu
*
*/
public static class WorkloadModel {

private static final String SCOPE = "workloadmodel";

public static final ExchangeDefinition<WorkloadType> TASK_CREATE = ExchangeDefinition.task(SCOPE, "create").nonDurable().autoDelete().withRoutingKey(WorkloadType.INSTANCE);

public static final ExchangeDefinition<WorkloadType> MIX_CREATE = ExchangeDefinition.task(SCOPE, "createmix").nonDurable().autoDelete().withRoutingKey(WorkloadType.INSTANCE);

public static final ExchangeDefinition<WorkloadType> EVENT_CREATED = ExchangeDefinition.event(SCOPE, "created").nonDurable().autoDelete().withRoutingKey(WorkloadType.INSTANCE);

Expand Down Expand Up @@ -146,5 +148,22 @@ private IdpaApplication() {
}

}

/**
* AMQP API of the forecast service.
*
* @author Alper Hidiroglu
*
*/
public static class Forecast {

private static final String SCOPE = "forecast";

public static final ExchangeDefinition<ServiceName> TASK_CREATE = ExchangeDefinition.task(SCOPE, "create").nonDurable().autoDelete().withRoutingKey(ServiceName.INSTANCE);

private Forecast() {
}

}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
package org.continuity.api.entities.artifact;

import java.util.Date;
import java.util.LinkedList;

import com.fasterxml.jackson.annotation.JsonFormat;

/**
*
* @author Alper Hidiroglu
*
*/
public class ForecastBundle {

@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH-mm-ss-SSSX")
private Date timestamp;

private int workloadIntensity;

private LinkedList<Double> probabilities;

public ForecastBundle(Date timestamp, Integer workloadIntensity, LinkedList<Double> probabilities) {
this.timestamp = timestamp;
this.workloadIntensity = workloadIntensity;
this.probabilities = probabilities;
}

public ForecastBundle() {

}

public Date getTimestamp() {
return timestamp;
}

public void setTimestamp(Date timestamp) {
this.timestamp = timestamp;
}

public Integer getWorkloadIntensity() {
return workloadIntensity;
}

public void setWorkloadIntensity(Integer workloadIntensity) {
this.workloadIntensity = workloadIntensity;
}

public LinkedList<Double> getProbabilities() {
return probabilities;
}

public void setProbabilities(LinkedList<Double> probabilities) {
this.probabilities = probabilities;
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package org.continuity.api.entities.artifact;

import java.util.List;

/**
*
* @author Alper Hidiroglu
*
*/
public class SessionsBundle {

private int behaviorId;
private List<SimplifiedSession> sessions;

public SessionsBundle(int behaviorId, List<SimplifiedSession> sessions) {
this.behaviorId = behaviorId;
this.sessions = sessions;
}

public SessionsBundle() {

}

public int getBehaviorId() {
return behaviorId;
}
public void setBehaviorId(int behaviorId) {
this.behaviorId = behaviorId;
}
public List<SimplifiedSession> getSessions() {
return sessions;
}
public void setSessions(List<SimplifiedSession> sessions) {
this.sessions = sessions;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package org.continuity.api.entities.artifact;

import java.util.Date;
import java.util.List;

import com.fasterxml.jackson.annotation.JsonFormat;

public class SessionsBundlePack {

@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH-mm-ss-SSSX")
private Date timestamp;

private List<SessionsBundle> sessionsBundles;

public SessionsBundlePack(Date timestamp, List<SessionsBundle> sessionsBundles) {
super();
this.timestamp = timestamp;
this.sessionsBundles = sessionsBundles;
}

public SessionsBundlePack() {

}

public Date getTimestamp() {
return timestamp;
}

public void setTimestamp(Date timestamp) {
this.timestamp = timestamp;
}

public List<SessionsBundle> getSessionsBundles() {
return sessionsBundles;
}

public void setSessionsBundles(List<SessionsBundle> sessionsBundles) {
this.sessionsBundles = sessionsBundles;
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
package org.continuity.api.entities.artifact;

/**
* Represents a simplified session.
* @author Alper Hidiroglu
*
*/
public class SimplifiedSession {

private String id;
private long startTime;
private long endTime;

/**
* Constructor.
* @param id
* @param startTime
* @param endTime
*/
public SimplifiedSession(String id, long startTime, long endTime) {
this.id = id;
this.startTime = startTime;
this.endTime = endTime;
}

public SimplifiedSession() {

}

public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public long getStartTime() {
return startTime;
}
public void setStartTime(long startTime) {
this.startTime = startTime;
}
public long getEndTime() {
return endTime;
}
public void setEndTime(long endTime) {
this.endTime = endTime;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,14 @@
import java.util.Set;

import org.continuity.api.entities.links.LinkExchangeModel;
import org.continuity.dsl.description.ForecastInput;

import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonInclude.Include;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonPropertyOrder;

@JsonPropertyOrder({ "goal", "mode", "tag", "testing-context", "options", "source" })
@JsonPropertyOrder({ "goal", "mode", "tag", "testing-context", "options", "source", "forecast-input" })
public class Order {

private String tag;
Expand All @@ -28,6 +29,10 @@ public class Order {

@JsonInclude(Include.NON_NULL)
private OrderOptions options;

@JsonInclude(Include.NON_NULL)
@JsonProperty("forecast-input")
private ForecastInput forecastInput;

@JsonProperty("modularization")
@JsonInclude(Include.NON_NULL)
Expand Down Expand Up @@ -88,5 +93,13 @@ public ModularizationOptions getModularizationOptions() {
public void setModularizationOptions(ModularizationOptions modularizationOptions) {
this.modularizationOptions = modularizationOptions;
}

public ForecastInput getForecastInput() {
return forecastInput;
}

public void setForecastInput(ForecastInput forecastInput) {
this.forecastInput = forecastInput;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

public enum OrderGoal {

CREATE_SESSION_LOGS, CREATE_WORKLOAD_MODEL, CREATE_LOAD_TEST, EXECUTE_LOAD_TEST;
CREATE_SESSION_LOGS, CREATE_BEHAVIOR_MIX, CREATE_FORECAST, CREATE_WORKLOAD_MODEL, CREATE_LOAD_TEST, EXECUTE_LOAD_TEST;

private static final Map<String, OrderGoal> prettyStringToGoal = new HashMap<>();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

public enum OrderMode {

PAST_SESSIONS, PAST_REQUESTS;
PAST_SESSIONS, PAST_REQUESTS, FORECASTED_WORKLOAD;

private static final Map<String, OrderMode> prettyStringToMode = new HashMap<>();

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package org.continuity.api.entities.config;

import org.continuity.api.entities.links.LinkExchangeModel;
import org.continuity.dsl.description.ForecastInput;

import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonInclude.Include;
Expand All @@ -25,6 +26,8 @@ public class TaskDescription {

@JsonProperty("modularization-options")
private ModularizationOptions modularizationOptions;

private ForecastInput forecastInput;

public String getTaskId() {
return taskId;
Expand Down Expand Up @@ -73,5 +76,13 @@ public ModularizationOptions getModularizationOptions() {
public void setModularizationOptions(ModularizationOptions modularizationOptions) {
this.modularizationOptions = modularizationOptions;
}

public ForecastInput getForecastInput() {
return forecastInput;
}

public void setForecastInput(ForecastInput forecastInput) {
this.forecastInput = forecastInput;
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
package org.continuity.api.entities.links;

import java.lang.reflect.Field;

import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonInclude.Include;
import com.fasterxml.jackson.annotation.JsonProperty;

public class ForecastLinks extends AbstractLinks<ForecastLinks> {

@JsonProperty(value = "link", required = false)
@JsonInclude(Include.NON_NULL)
private String link;

public ForecastLinks(LinkExchangeModel parent) {
super(parent);
}

public ForecastLinks() {
this(null);
}

public String getLink() {
return link;
}

public ForecastLinks setLink(String forecastLink) {
this.link = forecastLink;
return this;
}

@Override
public boolean isEmpty() {
for (Field field : ForecastLinks.class.getDeclaredFields()) {
try {
if ((field.getName() != "parent") && (field.get(this) != null)) {
return false;
}
} catch (IllegalArgumentException | IllegalAccessException e) {
e.printStackTrace();
}
}

return true;
}

@Override
public void merge(ForecastLinks other) throws IllegalArgumentException, IllegalAccessException {
for (Field field : ForecastLinks.class.getDeclaredFields()) {
if ((field.getName() != "parent") && (field.get(this) == null)) {
field.set(this, field.get(other));
}
}
}

}
Loading

0 comments on commit e9eba7d

Please sign in to comment.