Skip to content
This repository has been archived by the owner on Aug 2, 2022. It is now read-only.

Commit

Permalink
Including the Protobuf re-factoring changes
Browse files Browse the repository at this point in the history
  • Loading branch information
khushbr committed Jul 1, 2020
1 parent 03cc597 commit b6f1a51
Show file tree
Hide file tree
Showing 36 changed files with 1,014 additions and 415 deletions.
12 changes: 12 additions & 0 deletions INSTALL.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,18 @@ This document walks you through the process of building and deploying the RCA fr
a. Launch IntelliJ IDEA

b. Choose Import Project and select the `build.gradle` file in the root of this package

5. (Optional) TLS Setup

a. Open pa_config/performance-analyzer.properties

b. Modify the certificate-file-path, private-key-file-path, and https-enabled entries

c. Example performance-analyzer.properties:

certificate-file-path = /etc/ssl/certs/example.com.crt
private-key-file-path = /home/myUser/.ssh/id_rsa
https-enabled = true

### Build RCA framework
This package uses the [Gradle](https://docs.gradle.org/current/userguide/userguide.html) build system. Gradle comes with excellent documentation that should be your first stop when trying to figure out how to operate or modify the build.
Expand Down
5 changes: 5 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,11 @@ spotbugsTest {
ignoreFailures = true
}

check {
dependsOn spotbugsMain
dependsOn spotbugsTest
}

jacoco {
toolVersion = "0.8.5"
}
Expand Down
4 changes: 2 additions & 2 deletions pa_bin/performance-analyzer-agent
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@ else
fi

if ! echo $* | grep -E '(^-d |-d$| -d |--daemonize$|--daemonize )' > /dev/null; then
export JAVA_OPTS=-Des.path.home=$ES_HOME\ -Dlog4j.configurationFile=$ES_HOME/performance-analyzer-rca/pa_config/log4j2.xml
export JAVA_OPTS=-Des.path.home=$ES_HOME\ -Dlog4j.configurationFile=$ES_HOME/performance-analyzer-rca/pa_config/log4j2.xml\ -DconfigFilePath=$ES_HOME/performance-analyzer-rca/pa_config/performance-analyzer.properties
exec $ES_HOME/performance-analyzer-rca/bin/performance-analyzer-rca
else
echo 'Starting deamon'
export JAVA_OPTS=-Des.path.home=$ES_HOME\ -Dlog4j.configurationFile=$ES_HOME/performance-analyzer-rca/pa_config/log4j2.xml
export JAVA_OPTS=-Des.path.home=$ES_HOME\ -Dlog4j.configurationFile=$ES_HOME/performance-analyzer-rca/pa_config/log4j2.xml\ -DconfigFilePath=$ES_HOME/performance-analyzer-rca/pa_config/performance-analyzer.properties
exec $ES_HOME/performance-analyzer-rca/bin/performance-analyzer-rca &

pid=$!
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,12 @@

import com.amazon.opendistro.elasticsearch.performanceanalyzer.grpc.FlowUnitMessage;
import com.amazon.opendistro.elasticsearch.performanceanalyzer.grpc.HotResourceSummaryMessage;
import com.amazon.opendistro.elasticsearch.performanceanalyzer.grpc.ResourceType;
import com.amazon.opendistro.elasticsearch.performanceanalyzer.grpc.Resource;
import com.amazon.opendistro.elasticsearch.performanceanalyzer.rca.framework.api.persist.JooqFieldValue;
import com.amazon.opendistro.elasticsearch.performanceanalyzer.rca.framework.core.GenericSummary;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import javax.annotation.Nullable;
Expand Down Expand Up @@ -52,7 +50,7 @@ public class HotResourceSummary extends GenericSummary {

public static final String HOT_RESOURCE_SUMMARY_TABLE = HotResourceSummary.class.getSimpleName();
private static final Logger LOG = LogManager.getLogger(HotResourceSummary.class);
private final ResourceType resourceType;
private final Resource resource;
private double threshold;
private double value;
private double avgValue;
Expand All @@ -62,10 +60,10 @@ public class HotResourceSummary extends GenericSummary {
private String metaData;
private List<TopConsumerSummary> topConsumerSummaryList;

public HotResourceSummary(ResourceType resourceType, double threshold,
public HotResourceSummary(Resource resource, double threshold,
double value, int timePeriod) {
super();
this.resourceType = resourceType;
this.resource = resource;
this.threshold = threshold;
this.value = value;

Expand All @@ -77,10 +75,10 @@ public HotResourceSummary(ResourceType resourceType, double threshold,
this.topConsumerSummaryList = new ArrayList<>();
}

public HotResourceSummary(ResourceType resourceType, double threshold,
public HotResourceSummary(Resource resource, double threshold,
double value, int timePeriod, String metaData) {
super();
this.resourceType = resourceType;
this.resource = resource;
this.threshold = threshold;
this.value = value;

Expand All @@ -98,8 +96,8 @@ public void setValueDistribution(double minValue, double maxValue, double avgVal
this.avgValue = avgValue;
}

public ResourceType getResourceType() {
return this.resourceType;
public Resource getResource() {
return this.resource;
}

public double getValue() {
Expand Down Expand Up @@ -130,7 +128,7 @@ public void appendNestedSummary(TopConsumerSummary summary) {
public HotResourceSummaryMessage buildSummaryMessage() {
final HotResourceSummaryMessage.Builder summaryMessageBuilder = HotResourceSummaryMessage
.newBuilder();
summaryMessageBuilder.setResourceType(this.resourceType);
summaryMessageBuilder.setResource(this.resource);
summaryMessageBuilder.setThreshold(this.threshold);
summaryMessageBuilder.setValue(this.value);
summaryMessageBuilder.setAvgValue(this.avgValue);
Expand All @@ -151,7 +149,7 @@ public void buildSummaryMessageAndAddToFlowUnit(FlowUnitMessage.Builder messageB
}

public static HotResourceSummary buildHotResourceSummaryFromMessage(HotResourceSummaryMessage message) {
HotResourceSummary newSummary = new HotResourceSummary(message.getResourceType(), message.getThreshold(),
HotResourceSummary newSummary = new HotResourceSummary(message.getResource(), message.getThreshold(),
message.getValue(), message.getTimePeriod());
newSummary.setValueDistribution(message.getMinValue(), message.getMaxValue(), message.getAvgValue());
if (message.hasConsumers()) {
Expand All @@ -166,14 +164,14 @@ public static HotResourceSummary buildHotResourceSummaryFromMessage(HotResourceS
@Override
public String toString() {
return new StringBuilder()
.append(ResourceTypeUtil.getResourceTypeName(this.resourceType))
.append(ResourceUtil.getResourceTypeName(resource))
.append(" ")
.append(ResourceUtil.getResourceMetricName(resource))
.append(" ")
.append(this.threshold)
.append(" ")
.append(this.value)
.append(" ")
.append(ResourceTypeUtil.getResourceTypeUnit(this.resourceType))
.append(" ")
.append(this.topConsumerSummaryList)
.append(" ")
.append(this.metaData)
Expand All @@ -189,12 +187,12 @@ public String getTableName() {
public List<Field<?>> getSqlSchema() {
List<Field<?>> schema = new ArrayList<>();
schema.add(ResourceSummaryField.RESOURCE_TYPE_FIELD.getField());
schema.add(ResourceSummaryField.RESOURCE_METRIC_FIELD.getField());
schema.add(ResourceSummaryField.THRESHOLD_FIELD.getField());
schema.add(ResourceSummaryField.VALUE_FIELD.getField());
schema.add(ResourceSummaryField.AVG_VALUE_FIELD.getField());
schema.add(ResourceSummaryField.MIN_VALUE_FIELD.getField());
schema.add(ResourceSummaryField.MAX_VALUE_FIELD.getField());
schema.add(ResourceSummaryField.UNIT_TYPE_FIELD.getField());
schema.add(ResourceSummaryField.TIME_PERIOD_FIELD.getField());
schema.add(ResourceSummaryField.METADATA_FIELD.getField());
return schema;
Expand All @@ -203,13 +201,13 @@ public List<Field<?>> getSqlSchema() {
@Override
public List<Object> getSqlValue() {
List<Object> value = new ArrayList<>();
value.add(ResourceTypeUtil.getResourceTypeName(this.resourceType));
value.add(resource.getResourceEnumValue());
value.add(resource.getMetricEnumValue());
value.add(Double.valueOf(this.threshold));
value.add(Double.valueOf(this.value));
value.add(Double.valueOf(this.avgValue));
value.add(Double.valueOf(this.minValue));
value.add(Double.valueOf(this.maxValue));
value.add(ResourceTypeUtil.getResourceTypeUnit(this.resourceType));
value.add(Integer.valueOf(this.timePeriod));
value.add(metaData);
return value;
Expand All @@ -223,14 +221,14 @@ public List<Object> getSqlValue() {
public JsonElement toJson() {
JsonObject summaryObj = new JsonObject();
summaryObj.addProperty(SQL_SCHEMA_CONSTANTS.RESOURCE_TYPE_COL_NAME,
ResourceTypeUtil.getResourceTypeName(this.resourceType));
ResourceUtil.getResourceTypeName(this.resource));
summaryObj.addProperty(SQL_SCHEMA_CONSTANTS.RESOURCE_METRIC_COL_NAME,
ResourceUtil.getResourceMetricName(this.resource));
summaryObj.addProperty(SQL_SCHEMA_CONSTANTS.THRESHOLD_COL_NAME, this.threshold);
summaryObj.addProperty(SQL_SCHEMA_CONSTANTS.VALUE_COL_NAME, this.value);
summaryObj.addProperty(SQL_SCHEMA_CONSTANTS.AVG_VALUE_COL_NAME, this.avgValue);
summaryObj.addProperty(SQL_SCHEMA_CONSTANTS.MIN_VALUE_COL_NAME, this.minValue);
summaryObj.addProperty(SQL_SCHEMA_CONSTANTS.MAX_VALUE_COL_NAME, this.maxValue);
summaryObj.addProperty(SQL_SCHEMA_CONSTANTS.UNIT_TYPE_COL_NAME,
ResourceTypeUtil.getResourceTypeUnit(this.resourceType));
summaryObj.addProperty(SQL_SCHEMA_CONSTANTS.TIME_PERIOD_COL_NAME, this.timePeriod);
summaryObj.addProperty(SQL_SCHEMA_CONSTANTS.META_DATA_COL_NAME, this.metaData);
if (!getNestedSummaryList().isEmpty()) {
Expand Down Expand Up @@ -268,12 +266,12 @@ public List<String> getNestedSummaryTables() {
public static class SQL_SCHEMA_CONSTANTS {

public static final String RESOURCE_TYPE_COL_NAME = "resource_type";
public static final String RESOURCE_METRIC_COL_NAME = "resource_metric";
public static final String THRESHOLD_COL_NAME = "threshold";
public static final String VALUE_COL_NAME = "value";
public static final String AVG_VALUE_COL_NAME = "avg";
public static final String MIN_VALUE_COL_NAME = "min";
public static final String MAX_VALUE_COL_NAME = "max";
public static final String UNIT_TYPE_COL_NAME = "unit_type";
public static final String TIME_PERIOD_COL_NAME = "time_period_seconds";
public static final String META_DATA_COL_NAME = "meta_data";
}
Expand All @@ -282,13 +280,13 @@ public static class SQL_SCHEMA_CONSTANTS {
* Cluster summary SQL fields
*/
public enum ResourceSummaryField implements JooqFieldValue {
RESOURCE_TYPE_FIELD(SQL_SCHEMA_CONSTANTS.RESOURCE_TYPE_COL_NAME, String.class),
RESOURCE_TYPE_FIELD(SQL_SCHEMA_CONSTANTS.RESOURCE_TYPE_COL_NAME, Integer.class),
RESOURCE_METRIC_FIELD(SQL_SCHEMA_CONSTANTS.RESOURCE_METRIC_COL_NAME, Integer.class),
THRESHOLD_FIELD(SQL_SCHEMA_CONSTANTS.THRESHOLD_COL_NAME, Double.class),
VALUE_FIELD(SQL_SCHEMA_CONSTANTS.VALUE_COL_NAME, Double.class),
AVG_VALUE_FIELD(SQL_SCHEMA_CONSTANTS.AVG_VALUE_COL_NAME, Double.class),
MIN_VALUE_FIELD(SQL_SCHEMA_CONSTANTS.MIN_VALUE_COL_NAME, Double.class),
MAX_VALUE_FIELD(SQL_SCHEMA_CONSTANTS.MAX_VALUE_COL_NAME, Double.class),
UNIT_TYPE_FIELD(SQL_SCHEMA_CONSTANTS.UNIT_TYPE_COL_NAME, String.class),
TIME_PERIOD_FIELD(SQL_SCHEMA_CONSTANTS.TIME_PERIOD_COL_NAME, Integer.class),
METADATA_FIELD(SQL_SCHEMA_CONSTANTS.META_DATA_COL_NAME, String.class);

Expand Down Expand Up @@ -321,15 +319,17 @@ public String getName() {
public static HotResourceSummary buildSummary(Record record) {
HotResourceSummary summary = null;
try {
String resourceTypeName = record.get(ResourceSummaryField.RESOURCE_TYPE_FIELD.getField(), String.class);
int resourceTypeEnumVal = record.get(ResourceSummaryField.RESOURCE_TYPE_FIELD.getField(), Integer.class);
int resourceMetricEnumVal = record.get(ResourceSummaryField.RESOURCE_METRIC_FIELD.getField(), Integer.class);
Double threshold = record.get(ResourceSummaryField.THRESHOLD_FIELD.getField(), Double.class);
Double value = record.get(ResourceSummaryField.VALUE_FIELD.getField(), Double.class);
Double avgValue = record.get(ResourceSummaryField.AVG_VALUE_FIELD.getField(), Double.class);
Double minValue = record.get(ResourceSummaryField.MIN_VALUE_FIELD.getField(), Double.class);
Double maxValue = record.get(ResourceSummaryField.MAX_VALUE_FIELD.getField(), Double.class);
Integer timePeriod = record.get(ResourceSummaryField.TIME_PERIOD_FIELD.getField(), Integer.class);
String metaData = record.get(ResourceSummaryField.METADATA_FIELD.getField(), String.class);
summary = new HotResourceSummary(ResourceTypeUtil.buildResourceType(resourceTypeName),
summary = new HotResourceSummary(
ResourceUtil.buildResource(resourceTypeEnumVal, resourceMetricEnumVal),
threshold, value, timePeriod, metaData);
// those three fields are optional. check before setting to the obj
if (avgValue != null
Expand Down

This file was deleted.

Loading

0 comments on commit b6f1a51

Please sign in to comment.