Search in sources :

Example 1 with ServiceCombException

use of org.apache.servicecomb.foundation.common.exceptions.ServiceCombException in project incubator-servicecomb-java-chassis by apache.

the class MicroserviceConfigLoader method loadAndSort.

public void loadAndSort() {
    try {
        String configFileFromClasspath = System.getProperty("cse.configurationSource.defaultFileName") == null ? DEFAULT_CONFIG_FILE_NAME : System.getProperty("cse.configurationSource.defaultFileName");
        super.load(configFileFromClasspath);
        loadAdditionalConfig();
        if (configModels.isEmpty()) {
            LOGGER.warn("No URLs will be polled as dynamic configuration sources.");
            LOGGER.warn("To enable URLs as dynamic configuration sources, define System property {} or make {} available on classpath.", ADDITIONAL_CONFIG_URL, configFileFromClasspath);
        }
        sort();
    } catch (IOException e) {
        throw new ServiceCombException("Failed to load microservice config", e);
    }
}
Also used : ServiceCombException(org.apache.servicecomb.foundation.common.exceptions.ServiceCombException) IOException(java.io.IOException)

Example 2 with ServiceCombException

use of org.apache.servicecomb.foundation.common.exceptions.ServiceCombException in project incubator-servicecomb-java-chassis by apache.

the class AbstractTransport method genAddressWithoutSchemaForOldSC.

private String genAddressWithoutSchemaForOldSC(String addressWithoutSchema, String encodedQuery) {
    // traced by JAV-307
    try {
        LOGGER.warn("Service center do not support encoded query, so we use unencoded query, " + "this caused not support chinese/space (and maybe other char) in query value.");
        String decodedQuery = URLDecoder.decode(encodedQuery, StandardCharsets.UTF_8.name());
        addressWithoutSchema += decodedQuery;
    } catch (UnsupportedEncodingException e) {
        // never happened
        throw new ServiceCombException("Failed to decode query.", e);
    }
    try {
        // make sure consumer can handle this endpoint
        new URI(Const.RESTFUL + "://" + addressWithoutSchema);
    } catch (URISyntaxException e) {
        throw new ServiceCombException("current service center not support encoded endpoint, please do not use chinese or space or anything need to be encoded.", e);
    }
    return addressWithoutSchema;
}
Also used : UnsupportedEncodingException(java.io.UnsupportedEncodingException) ServiceCombException(org.apache.servicecomb.foundation.common.exceptions.ServiceCombException) URISyntaxException(java.net.URISyntaxException) URI(java.net.URI)

Example 3 with ServiceCombException

use of org.apache.servicecomb.foundation.common.exceptions.ServiceCombException in project incubator-servicecomb-java-chassis by apache.

the class MetricsHttpPublisher method init.

private void init(String address) {
    try {
        InetSocketAddress socketAddress = getSocketAddress(address);
        MetricsCollector metricsCollector = new MetricsCollector();
        metricsCollector.register();
        this.httpServer = new HTTPServer(socketAddress, CollectorRegistry.defaultRegistry, true);
        LOGGER.info("Prometheus httpServer listened : {}.", address);
    } catch (Exception e) {
        throw new ServiceCombException("create http publish server failed,may bad address : " + address, e);
    }
}
Also used : HTTPServer(io.prometheus.client.exporter.HTTPServer) InetSocketAddress(java.net.InetSocketAddress) ServiceCombException(org.apache.servicecomb.foundation.common.exceptions.ServiceCombException) ServiceCombException(org.apache.servicecomb.foundation.common.exceptions.ServiceCombException)

Example 4 with ServiceCombException

use of org.apache.servicecomb.foundation.common.exceptions.ServiceCombException in project java-chassis by ServiceComb.

the class PrometheusPublisher method init.

@Override
public void init(GlobalRegistry globalRegistry, EventBus eventBus, MetricsBootstrapConfig config) {
    this.globalRegistry = globalRegistry;
    // prometheus default port allocation is here : https://github.com/prometheus/prometheus/wiki/Default-port-allocations
    String address = DynamicPropertyFactory.getInstance().getStringProperty(METRICS_PROMETHEUS_ADDRESS, "0.0.0.0:9696").get();
    try {
        InetSocketAddress socketAddress = getSocketAddress(address);
        register();
        this.httpServer = new HTTPServer(socketAddress, CollectorRegistry.defaultRegistry, true);
        LOGGER.info("Prometheus httpServer listened : {}.", address);
    } catch (Exception e) {
        throw new ServiceCombException("create http publish server failed,may bad address : " + address, e);
    }
}
Also used : HTTPServer(io.prometheus.client.exporter.HTTPServer) InetSocketAddress(java.net.InetSocketAddress) ServiceCombException(org.apache.servicecomb.foundation.common.exceptions.ServiceCombException) ServiceCombException(org.apache.servicecomb.foundation.common.exceptions.ServiceCombException)

Example 5 with ServiceCombException

use of org.apache.servicecomb.foundation.common.exceptions.ServiceCombException in project java-chassis by ServiceComb.

the class MicroserviceConfigLoader method loadAndSort.

public void loadAndSort() {
    String configFileFromClasspath = null;
    try {
        configFileFromClasspath = System.getProperty(DEFAULT_FILE_NAME) == null ? DEFAULT_CONFIG_FILE_NAME : System.getProperty(DEFAULT_FILE_NAME);
        super.load(configFileFromClasspath);
        loadAdditionalConfig();
        if (configModels.isEmpty()) {
            LOGGER.warn("No URLs will be polled as dynamic configuration sources.");
            LOGGER.warn("To enable URLs as dynamic configuration sources, define System property {} or make {} available on classpath.", ADDITIONAL_CONFIG_URL, configFileFromClasspath);
        }
        sort();
    } catch (Exception e) {
        throw new ServiceCombException("Failed to load microservice configFile " + configFileFromClasspath, e);
    }
}
Also used : ServiceCombException(org.apache.servicecomb.foundation.common.exceptions.ServiceCombException) IOException(java.io.IOException) ServiceCombException(org.apache.servicecomb.foundation.common.exceptions.ServiceCombException)

Aggregations

ServiceCombException (org.apache.servicecomb.foundation.common.exceptions.ServiceCombException)10 Test (org.junit.Test)3 HTTPServer (io.prometheus.client.exporter.HTTPServer)2 IOException (java.io.IOException)2 InetSocketAddress (java.net.InetSocketAddress)2 Expectations (mockit.Expectations)2 UnsupportedEncodingException (java.io.UnsupportedEncodingException)1 URI (java.net.URI)1 URISyntaxException (java.net.URISyntaxException)1 RestOperationMeta (org.apache.servicecomb.common.rest.definition.RestOperationMeta)1 AbstractQpsStrategy (org.apache.servicecomb.qps.strategy.AbstractQpsStrategy)1 IStrategyFactory (org.apache.servicecomb.qps.strategy.IStrategyFactory)1