com.netaporter.solr.CloudWatchAdminHandler.scala Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of solr-plugin-cloudwatch Show documentation
Show all versions of solr-plugin-cloudwatch Show documentation
Solr plugin to enable cloudwatch logs
package com.netaporter.solr
import org.apache.solr.common.params.CoreAdminParams
import org.apache.solr.core.CoreContainer
import org.apache.solr.handler.admin.CoreAdminHandler
import com.amazonaws.metrics.AwsSdkMetrics
import org.apache.solr.request.SolrQueryRequest
import org.apache.solr.response.SolrQueryResponse
class CloudWatchAdminHandler(coreContainer: CoreContainer) extends CoreAdminHandler(coreContainer) {
def this() = this(null)
val metricsEnabled = CloudWatch.ensureMetricsSetup()
override def handleRequestBody(req: SolrQueryRequest, res: SolrQueryResponse) = {
val action = req.getParams.get(CoreAdminParams.ACTION)
if ("cloudwatch".equalsIgnoreCase(action)) {
res.add("metricsEnabled", metricsEnabled)
if (metricsEnabled) {
res.add("hostMetricName", AwsSdkMetrics.getHostMetricName)
res.add("metricNamespace", AwsSdkMetrics.getMetricNameSpace)
}
} else {
super.handleRequestBody(req, res)
}
}
}