Class Metrics
- java.lang.Object
-
- edu.isi.pegasus.planner.code.generator.Metrics
-
public class Metrics extends java.lang.Object
Logs workflow metrics to a file in the submit directory and also sends them over a HTTP connection to a Metrics Server.- Version:
- $Revision$
- Author:
- Karan Vahi
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
COLLECT_METRICS_ENV_VARIABLE
The name of the environment variable that sets whether to collect metrics or notstatic java.lang.String
METRICS_FILE_SUFFIX
The suffix to use while constructing the name of the metrics filestatic int
METRICS_SEND_TIMEOUT
The timeout in seconds for sending the metrics to the serverstatic java.lang.String
METRICS_SERVER_DEFAULT_URL
The default URL for the metrics server to useprivate LogManager
mLogger
The logger objectprivate java.util.List<java.lang.String>
mMetricsServers
The List of URLS for the metrics servers to report to.private boolean
mSendMetricsToServer
boolean indicating whether to log metrics or notstatic java.lang.String
PRIMARY_METRICS_SERVER_URL_ENV_VARIABLE
The name of the environment variable that overrides the default server urlstatic java.lang.String
SECONDARY_METRICS_SERVER_URL_ENV_VARIABLE
The name of the environment variable that overrides the default server url
-
Constructor Summary
Constructors Constructor Description Metrics()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
initialize(PegasusBag bag)
Initializes the objectvoid
logMetrics(PlannerMetrics metrics)
Logs the metrics to the metrics server and to the submit directoryprivate void
sendMetricsAsynchronously(PlannerMetrics metrics, java.lang.String url)
Sends the planner metrics to the metrics server asynchrnously with a timeout of 5 secondsprivate void
sendMetricsSynchronously(PlannerMetrics metrics, java.lang.String url)
Sends the planner metrics to the metrics serverprivate java.io.File
writeOutMetricsFile(PlannerMetrics metrics)
Writes out the workflow metrics file in the submit directory
-
-
-
Field Detail
-
METRICS_FILE_SUFFIX
public static final java.lang.String METRICS_FILE_SUFFIX
The suffix to use while constructing the name of the metrics file- See Also:
- Constant Field Values
-
METRICS_SERVER_DEFAULT_URL
public static final java.lang.String METRICS_SERVER_DEFAULT_URL
The default URL for the metrics server to use- See Also:
- Constant Field Values
-
COLLECT_METRICS_ENV_VARIABLE
public static final java.lang.String COLLECT_METRICS_ENV_VARIABLE
The name of the environment variable that sets whether to collect metrics or not- See Also:
- Constant Field Values
-
PRIMARY_METRICS_SERVER_URL_ENV_VARIABLE
public static final java.lang.String PRIMARY_METRICS_SERVER_URL_ENV_VARIABLE
The name of the environment variable that overrides the default server url- See Also:
- Constant Field Values
-
SECONDARY_METRICS_SERVER_URL_ENV_VARIABLE
public static final java.lang.String SECONDARY_METRICS_SERVER_URL_ENV_VARIABLE
The name of the environment variable that overrides the default server url- See Also:
- Constant Field Values
-
METRICS_SEND_TIMEOUT
public static final int METRICS_SEND_TIMEOUT
The timeout in seconds for sending the metrics to the server- See Also:
- Constant Field Values
-
mSendMetricsToServer
private boolean mSendMetricsToServer
boolean indicating whether to log metrics or not
-
mMetricsServers
private java.util.List<java.lang.String> mMetricsServers
The List of URLS for the metrics servers to report to.
-
mLogger
private LogManager mLogger
The logger object
-
-
Method Detail
-
initialize
public void initialize(PegasusBag bag)
Initializes the object- Parameters:
bag
- bag of pegasus objects
-
logMetrics
public void logMetrics(PlannerMetrics metrics) throws java.io.IOException
Logs the metrics to the metrics server and to the submit directory- Parameters:
metrics
-- Throws:
java.io.IOException
-
writeOutMetricsFile
private java.io.File writeOutMetricsFile(PlannerMetrics metrics) throws java.io.IOException
Writes out the workflow metrics file in the submit directory- Parameters:
metrics
- the metrics to be written out.- Returns:
- the path to metrics file in the submit directory
- Throws:
java.io.IOException
- in case of error while writing out file.
-
sendMetricsSynchronously
private void sendMetricsSynchronously(PlannerMetrics metrics, java.lang.String url) throws java.io.IOException
Sends the planner metrics to the metrics server- Parameters:
metrics
- the metrics to logurl
- the url to send the metrics to- Throws:
java.io.IOException
-
sendMetricsAsynchronously
private void sendMetricsAsynchronously(PlannerMetrics metrics, java.lang.String url)
Sends the planner metrics to the metrics server asynchrnously with a timeout of 5 seconds- Parameters:
metrics
- the metrics to logurl
- the url to send the metrics to
-
-