Handles "describeAlarms" request.

@return a GetMetricStatisticsResult for metricName.
347019
private DescribeAlarmsResponse describeAlarms() {
        DescribeAlarmsResponse ret = new DescribeAlarmsResponse();
        DescribeAlarmsResult result = new DescribeAlarmsResult();
        MetricAlarms metricAlarms = new MetricAlarms();

        MetricAlarm metricAlarm = new MetricAlarm();
        metricAlarm.setAlarmDescription("CPU usage exceeds 70 percent");
        metricAlarm.setAlarmName("AwsMockAlarmCPU");
        metricAlarms.getMember().add(metricAlarm);

        metricAlarm = new MetricAlarm();
        metricAlarm.setAlarmDescription("Memory usage exceeds 80 percent");
        metricAlarm.setAlarmName("AwsMockAlarmMemory");
        metricAlarms.getMember().add(metricAlarm);

        result.setMetricAlarms(metricAlarms);

        ret.setDescribeAlarmsResult(result);
        ResponseMetadata responseMetadata = new ResponseMetadata();
        responseMetadata.setRequestId(UUID.randomUUID().toString());
        ret.setResponseMetadata(responseMetadata);
        return ret;
    }
711652
public java.util.List<MetricTransformation> getMetricTransformations() {
        if (metricTransformations == null) {
            metricTransformations = new com.amazonaws.internal.SdkInternalList<MetricTransformation>();
        }
        return metricTransformations;
    }
658971
def get_metric(run_id, metric_id):
    
    data = current_app.config["data"]  # type: DataStorage
    dao = data.get_metrics_dao()
    metric = dao.get(run_id, metric_id)

    return Response(render_template(
        "api/metric.js",
        run_id=metric["run_id"],
        metric_id=metric["metric_id"],
        name=metric["name"],
        steps=metric["steps"],
        timestamps=metric["timestamps"],
        values=metric["values"]),
        mimetype="application/json")
230287
public Metric getMetric(String metricName) {
    // [START getMetric]
    Metric metric = logging.getMetric(metricName);
    if (metric == null) {
      // metric was not found
    }
    // [END getMetric]
    return metric;
  }
733861
@Override
  public void reportMetric(final IMetric<?> metric) throws MetricException {
    final String gangliaCommand = buildCommand(metric);

    if (gangliaCommand != null) {
      // executes shell command to report metric to ganglia dashboard
      try {
        final Process emission = Runtime.getRuntime().exec(gangliaCommand);
        final int exitCode;
        exitCode = emission.waitFor();
        if (exitCode != 0) {
          throw new MetricException("Failed to report metric using gmetric");
        }
      } catch (final Exception e) {
        throw new MetricException("Failed to report metric using gmetric");
      }
    } else {
      throw new MetricException("Failed to build ganglia Command");
    }
  }
930119
@Override
	@Nullable
	public String getMetricQueryServiceGatewayRpcAddress() {
		if (queryService != null) {
			return queryService.getSelfGateway(MetricQueryServiceGateway.class).getAddress();
		} else {
			return null;
		}
	}
1024844
@Override
    public java.util.concurrent.Future<DescribeAlarmsResult> describeAlarmsAsync(
            com.amazonaws.handlers.AsyncHandler<DescribeAlarmsRequest, DescribeAlarmsResult> asyncHandler) {

        return describeAlarmsAsync(new DescribeAlarmsRequest(), asyncHandler);
    }
212600
public static MetricReportManager getInstance() {
    if (instance == null) {
      synchronized (MetricReportManager.class) {
        if (instance == null) {
          logger.info("Instantiating MetricReportManager");
          instance = new MetricReportManager();
        }
      }
    }
    return instance;
  }
220996
public java.util.List<MetricAlarm> getMetricAlarms() {
        if (metricAlarms == null) {
            metricAlarms = new com.amazonaws.internal.SdkInternalList<MetricAlarm>();
        }
        return metricAlarms;
    }
334945
private void handleGetMetricHistory(final int executorId, final HttpServletRequest req,
      final HashMap<String, Object> ret, final User user) throws IOException,
      ServletException {
    try {
      final Map<String, Object> result =
          this.execManagerAdapter.callExecutorStats(executorId,
              ConnectorParams.STATS_GET_METRICHISTORY, getAllParams(req));
      if (result.containsKey(ConnectorParams.RESPONSE_ERROR)) {
        ret.put(ConnectorParams.RESPONSE_ERROR,
            result.get(ConnectorParams.RESPONSE_ERROR).toString());
      } else {
        ret.put("data", result.get("data"));
      }
    } catch (final ExecutorManagerException ex) {
      logger.error(ex.getMessage(), ex);
      ret.put("error", "Failed to fetch metric history");
    }
  }
1317138
public <G extends Serializable> Metric<G> getMetric(CxxMetricsFactory.Key metricKey) {
    Metric<G> metric = (Metric<G>) this.langSpecificMetrics.get(metricKey);
    if (metric == null) {
      throw new IllegalStateException("Requested metric " + metricKey + " couldn't be found");
    }
    return metric;
  }
279280
public function createMetricAction()
    {
        $metricData = Binput::get('metric');

        try {
            execute(new CreateMetricCommand(
                $metricData['name'],
                $metricData['suffix'],
                $metricData['description'],
                $metricData['default_value'],
                $metricData['calc_type'],
                $metricData['display_chart'],
                $metricData['places'],
                $metricData['default_view'],
                $metricData['threshold'],
                0, // Default order
                $metricData['visible']
            ));
        } catch (ValidationException $e) {
            return cachet_redirect('dashboard.metrics.create')
                ->withInput(Binput::all())
                ->withTitle(sprintf('%s %s', trans('dashboard.notifications.whoops'), trans('dashboard.metrics.add.failure')))
                ->withErrors($e->getMessageBag());
        }

        return cachet_redirect('dashboard.metrics')
            ->withSuccess(sprintf('%s %s', trans('dashboard.notifications.awesome'), trans('dashboard.metrics.add.success')));
    }
423397
@Override
    protected void collectMetrics(final Metrics metrics) {
        for (final Map.Entry<String, ExecutorService> entry : _executorServices.entrySet()) {
            final String name = entry.getKey();
            final ExecutorService executorService = entry.getValue();
            if (executorService instanceof ForkJoinPool) {
                processForkJoinPool(metrics, name, (ForkJoinPool) executorService);
            }
            if (executorService instanceof ThreadPoolExecutor) {
                // NOTE: That a ScheduledThreadPoolExecutor is a ThreadPoolExecutor
                processThreadPoolExecutor(metrics, name, (ThreadPoolExecutor) executorService);
            }
        }
    }
759608
public MetricFilter metricsFilter() {
        if (id() == null) {
            return (name, metric) -> false;
        }
        return new MetricUtils.SingleMetricFilter(metricName);

    }
954596
public Metric getMetricAsync(String metricName) throws ExecutionException, InterruptedException {
    // [START getMetricAsync]
    Future<Metric> future = logging.getMetricAsync(metricName);
    // ...
    Metric metric = future.get();
    if (metric == null) {
      // metric was not found
    }
    // [END getMetricAsync]
    return metric;
  }
109543
private void handleGetAllMetricName(final int executorId, final HttpServletRequest req,
      final HashMap<String, Object> ret) throws IOException {
    final Map<String, Object> result;
    try {
      result =
          this.execManagerAdapter.callExecutorStats(executorId,
              ConnectorParams.STATS_GET_ALLMETRICSNAME,
              (Pair<String, String>[]) null);

      if (result.containsKey(ConnectorParams.RESPONSE_ERROR)) {
        ret.put("error", result.get(ConnectorParams.RESPONSE_ERROR).toString());
      } else {
        ret.put("metricList", result.get("data"));
      }
    } catch (final ExecutorManagerException e) {
      logger.error(e.getMessage(), e);
      ret.put("error", "Failed to fetch metric names for executor : "
          + executorId);
    }
  }
1344111
public MetricFilter metricsFilter() {
        if (id() == null) {
            return (name, metric) -> false;
        }
        return (name, metric) -> metricNames.contains(name);

    }