class RestMetricsPropertyProvider extends ThreadPoolEnabledPropertyProvider {

  protected String resolvePort(Cluster cluster, String hostname, String componentName,
                          Map<String, String> metricsProperties, String protocol)
      throws AmbariException {
    String portConfigType = null;
    String portPropertyNameInMetricsProperties = protocol.equalsIgnoreCase(HTTPS_PROTOCOL) ? HTTPS_PORT_PROPERTY_NAME_PROPERTY : PORT_PROPERTY_NAME_PROPERTY;
    String portPropertyName = null;
    if (metricsProperties.containsKey(PORT_CONFIG_TYPE_PROPERTY) &&
        metricsProperties.containsKey(portPropertyNameInMetricsProperties)) {
      portConfigType = metricsProperties.get(PORT_CONFIG_TYPE_PROPERTY);
      portPropertyName = metricsProperties.get(portPropertyNameInMetricsProperties);
    }
    String portStr = getPropertyValueByNameAndConfigType(portPropertyName, portConfigType, cluster, hostname);
    if (portStr == null && metricsProperties.containsKey(DEFAULT_PORT_PROPERTY)) {
      if (metricsProperties.containsKey(DEFAULT_PORT_PROPERTY)) {
        portStr = metricsProperties.get(DEFAULT_PORT_PROPERTY);
      } else {
        String message = String.format("Can not determine REST port for " +
            "component %s. " +
            "Default REST port property %s is not defined at metrics.json " +
            "file for service, and there is no any other available ways " +
            "to determine port information.",
            componentName, DEFAULT_PORT_PROPERTY);
        throw new AmbariException(message);
      }
    }
      return portStr;
  }

  @AssistedInject  RestMetricsPropertyProvider(
      @Assisted("metricsProperties") Map<String, String> metricsProperties,
      @Assisted("componentMetrics") Map<String, Map<String, PropertyInfo>> componentMetrics,
      @Assisted("streamProvider") StreamProvider streamProvider,
      @Assisted("metricHostProvider") MetricHostProvider metricHostProvider,
      @Assisted("clusterNamePropertyId") String clusterNamePropertyId,
      @Assisted("hostNamePropertyId") @Nullable String hostNamePropertyId,
      @Assisted("componentNamePropertyId") String componentNamePropertyId,
      @Assisted("statePropertyId") @Nullable String statePropertyId,
      @Assisted("componentName") @Nullable String componentName);

}