All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.netaporter.solr.CloudWatchAdminHandler.scala Maven / Gradle / Ivy

There is a newer version: 0.2
Show newest version
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)
    }
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy