Created
April 22, 2014 17:25
-
-
Save duane/11187583 to your computer and use it in GitHub Desktop.
Scalac crash
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def run() { | |
Thread.sleep(60000) | |
while (true) { | |
val start = System.currentTimeMillis() | |
val next = start + 60000 | |
val numJobsToReport = numJobs | |
if (numJobsToReport != 0) { | |
val totalJobTimeToReport = totalJobTime | |
val avgJobTime = totalJobTime.toDouble/numJobs | |
val dimension = new Dimension().withName("InstanceId").withValue(config.instanceId) | |
val datum1 = new MetricDatum(). | |
withMetricName("Jobs"). | |
withUnit(StandardUnit.Count). | |
withValue(numJobsToReport.toDouble). | |
withDimensions(List(dimension)) | |
val datum2 = new MetricDatum(). | |
withMetricName("AvgTime"). | |
withUnit(StandardUnit.Milliseconds). | |
withValue(avgJobTime.toDouble). | |
withDimensions(List(dimension)) | |
val data = List(datum1, datum2) | |
try { | |
val req = new PutMetricDataRequest().withNamespace(namespace).withMetricData(data) | |
config.cloudwatch.putMetricData(req) | |
numJobs -= numJobsToReport | |
totalJobTime -= totalJobTimeToReport | |
} | |
catch { | |
case e: Exception => { | |
logger.error("Unable to report metrics to CloudWatch", e) | |
} | |
} | |
} | |
val sleep = next - System.currentTimeMillis() | |
if (sleep > 0) { | |
Thread.sleep(sleep) | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment