use of com.datastax.driver.core.policies.ConstantReconnectionPolicy in project ASAP by salmant.
the class AlarmTrigger method Calculate_MAX.
// ////////
public double Calculate_MAX(String metric_name, String subid, String event_date) {
Cluster cluster;
Session session;
cluster = Cluster.builder().addContactPoints(TSDB_Server_IP).withCredentials(TSDB_Server_Username, TSDB_Server_Password).withPort(9042).withRetryPolicy(DowngradingConsistencyRetryPolicy.INSTANCE).withReconnectionPolicy(new ConstantReconnectionPolicy(1000L)).build();
session = cluster.connect("jcatascopiadb");
// find the agents in the cluster
ResultSet results = session.execute("SELECT agentid FROM jcatascopiadb.subscription_agents_table WHERE subid=\'" + subid + "\'");
double MAX = -Double.MAX_VALUE;
for (Row row : results) {
String AgentIDs = new String();
AgentIDs = row.getString("agentid");
AgentIDs = AgentIDs + ":" + metric_name;
ResultSet results2 = session.execute("select value, toTimestamp(event_timestamp) AS ET from jcatascopiadb.metric_value_table where metricid=\'" + AgentIDs + "\' and event_date=\'" + event_date + "\' ORDER BY event_timestamp DESC LIMIT 1");
for (Row row2 : results2) {
if (Double.parseDouble(row2.getString("value")) > MAX)
MAX = Double.parseDouble(row2.getString("value"));
}
}
return MAX;
}
use of com.datastax.driver.core.policies.ConstantReconnectionPolicy in project ASAP by salmant.
the class HPA method Calculate_AVG.
// ///////////////////////////////////////////
public static double Calculate_AVG(String metric_name, String subid, String event_date) {
Cluster cluster;
Session session;
cluster = Cluster.builder().addContactPoints("194.249.1.175").withCredentials("catascopia_user", "catascopia_pass").withPort(9042).withRetryPolicy(DowngradingConsistencyRetryPolicy.INSTANCE).withReconnectionPolicy(new ConstantReconnectionPolicy(1000L)).build();
session = cluster.connect("jcatascopiadb");
ResultSet results = session.execute("SELECT agentid FROM jcatascopiadb.subscription_agents_table WHERE subid=\'" + subid + "\'");
double AVG = 0.0;
double count = 0.0;
for (Row row : results) {
String AgentIDs = new String();
AgentIDs = row.getString("agentid");
AgentIDs = AgentIDs + ":" + metric_name;
ResultSet results2 = session.execute("select value, toTimestamp(event_timestamp) AS ET from jcatascopiadb.metric_value_table where metricid=\'" + AgentIDs + "\' and event_date=\'" + event_date + "\' ORDER BY event_timestamp DESC LIMIT 1");
for (Row row2 : results2) {
AVG = AVG + Double.parseDouble(row2.getString("value"));
count = count + 1;
}
}
AVG = AVG / count;
return AVG;
}
use of com.datastax.driver.core.policies.ConstantReconnectionPolicy in project ASAP by salmant.
the class HPA method Fetch_request_rate_metric.
// ///////////////////////////////////////////
public static double Fetch_request_rate_metric(String metric_name, String haproxy_agentid, String event_date) {
Cluster cluster;
Session session;
cluster = Cluster.builder().addContactPoints("194.249.1.175").withCredentials("catascopia_user", "catascopia_pass").withPort(9042).withRetryPolicy(DowngradingConsistencyRetryPolicy.INSTANCE).withReconnectionPolicy(new ConstantReconnectionPolicy(1000L)).build();
session = cluster.connect("jcatascopiadb");
haproxy_agentid = haproxy_agentid + ":" + metric_name;
ResultSet results = session.execute("select value from jcatascopiadb.metric_value_table where metricid=\'" + haproxy_agentid + "\' and event_date=\'" + event_date + "\' ORDER BY event_timestamp DESC LIMIT 1");
double GoodPut = 0.0;
for (Row row : results) {
GoodPut = Double.parseDouble(row.getString("value"));
}
return Math.abs(GoodPut);
}
use of com.datastax.driver.core.policies.ConstantReconnectionPolicy in project ASAP by salmant.
the class DM method Fetch_request_rate_metric.
// ///////////////////////////////////////////
public static double Fetch_request_rate_metric(String metric_name, String haproxy_agentid, String event_date) {
Cluster cluster;
Session session;
cluster = Cluster.builder().addContactPoints("194.249.1.175").withCredentials("catascopia_user", "catascopia_pass").withPort(9042).withRetryPolicy(DowngradingConsistencyRetryPolicy.INSTANCE).withReconnectionPolicy(new ConstantReconnectionPolicy(1000L)).build();
session = cluster.connect("jcatascopiadb");
haproxy_agentid = haproxy_agentid + ":" + metric_name;
ResultSet results = session.execute("select value from jcatascopiadb.metric_value_table where metricid=\'" + haproxy_agentid + "\' and event_date=\'" + event_date + "\' ORDER BY event_timestamp DESC LIMIT 1");
double GoodPut = 0.0;
for (Row row : results) {
GoodPut = Double.parseDouble(row.getString("value"));
}
return Math.abs(GoodPut);
}
use of com.datastax.driver.core.policies.ConstantReconnectionPolicy in project ASAP by salmant.
the class DM method Calculate_AVG.
// ///////////////////////////////////////////
public static double Calculate_AVG(String metric_name, String subid, String event_date) {
Cluster cluster;
Session session;
cluster = Cluster.builder().addContactPoints("194.249.1.175").withCredentials("catascopia_user", "catascopia_pass").withPort(9042).withRetryPolicy(DowngradingConsistencyRetryPolicy.INSTANCE).withReconnectionPolicy(new ConstantReconnectionPolicy(1000L)).build();
session = cluster.connect("jcatascopiadb");
ResultSet results = session.execute("SELECT agentid FROM jcatascopiadb.subscription_agents_table WHERE subid=\'" + subid + "\'");
double AVG = 0.0;
double count = 0.0;
for (Row row : results) {
String AgentIDs = new String();
AgentIDs = row.getString("agentid");
AgentIDs = AgentIDs + ":" + metric_name;
ResultSet results2 = session.execute("select value, toTimestamp(event_timestamp) AS ET from jcatascopiadb.metric_value_table where metricid=\'" + AgentIDs + "\' and event_date=\'" + event_date + "\' ORDER BY event_timestamp DESC LIMIT 1");
for (Row row2 : results2) {
AVG = AVG + Double.parseDouble(row2.getString("value"));
count = count + 1;
}
}
AVG = AVG / count;
return AVG;
}
Aggregations