Search in sources :

Example 1 with StringUtils

use of org.apache.druid.java.util.common.StringUtils in project druid by druid-io.

the class TaskRunnerUtils method makeWorkerURL.

public static URL makeWorkerURL(Worker worker, String pathFormat, String... pathParams) {
    Preconditions.checkArgument(pathFormat.startsWith("/"), "path must start with '/': %s", pathFormat);
    final String path = StringUtils.format(pathFormat, Arrays.stream(pathParams).map(StringUtils::urlEncode).toArray());
    try {
        return new URI(StringUtils.format("%s://%s%s", worker.getScheme(), worker.getHost(), path)).toURL();
    } catch (URISyntaxException | MalformedURLException e) {
        throw new RuntimeException(e);
    }
}
Also used : MalformedURLException(java.net.MalformedURLException) StringUtils(org.apache.druid.java.util.common.StringUtils) URISyntaxException(java.net.URISyntaxException) URI(java.net.URI)

Aggregations

MalformedURLException (java.net.MalformedURLException)1 URI (java.net.URI)1 URISyntaxException (java.net.URISyntaxException)1 StringUtils (org.apache.druid.java.util.common.StringUtils)1