com.alibaba.rocketmq.common.utils.HttpTinyClient.HttpResult Java Examples

The following examples show how to use com.alibaba.rocketmq.common.utils.HttpTinyClient.HttpResult. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: HttpFilterClassFetchMethod.java    From reading-and-annotate-rocketmq-3.4.6 with GNU General Public License v3.0 6 votes vote down vote up
@Override
public String fetch(String topic, String consumerGroup, String className) {
    String thisUrl = String.format("%s/%s.java", this.url, className);

    try {
        HttpResult result = HttpTinyClient.httpGet(thisUrl, null, null, "UTF-8", 5000);
        if (200 == result.code) {
            return result.content;
        }
    }
    catch (Exception e) {
        log.error(
            String.format("call <%s> exception, Topic: %s Group: %s", thisUrl, topic, consumerGroup), e);
    }

    return null;
}
 
Example #2
Source File: HttpFilterClassFetchMethod.java    From rocketmq with Apache License 2.0 6 votes vote down vote up
@Override
public String fetch(String topic, String consumerGroup, String className) {
    String thisUrl = String.format("%s/%s.java", this.url, className);

    try {
        HttpResult result = HttpTinyClient.httpGet(thisUrl, null, null, "UTF-8", 5000);
        if (200 == result.code) {
            return result.content;
        }
    } catch (Exception e) {
        log.error(
                String.format("call <%s> exception, Topic: %s Group: %s", thisUrl, topic, consumerGroup), e);
    }

    return null;
}
 
Example #3
Source File: HttpFilterClassFetchMethod.java    From RocketMQ-Master-analyze with Apache License 2.0 6 votes vote down vote up
@Override
public String fetch(String topic, String consumerGroup, String className) {
    String thisUrl = String.format("%s/%s.java", this.url, className);

    try {
        HttpResult result = HttpTinyClient.httpGet(thisUrl, null, null, "UTF-8", 5000);
        if (200 == result.code) {
            return result.content;
        }
    }
    catch (Exception e) {
        log.error(
            String.format("call <%s> exception, Topic: %s Group: %s", thisUrl, topic, consumerGroup), e);
    }

    return null;
}
 
Example #4
Source File: TopAddressing.java    From reading-and-annotate-rocketmq-3.4.6 with GNU General Public License v3.0 5 votes vote down vote up
public final String fetchNSAddr(boolean verbose, long timeoutMills) {
    String url = this.wsAddr;
    try {
        if (!UtilAll.isBlank(this.unitName)) {
            url = url + "-" + this.unitName + "?nofix=1";
        }
        HttpResult result = HttpTinyClient.httpGet(url, null, null, "UTF-8", timeoutMills);
        if (200 == result.code) {
            String responseStr = result.content;
            if (responseStr != null) {
                return clearNewLine(responseStr);
            }
            else {
                log.error("fetch nameserver address is null");
            }
        }
        else {
            log.error("fetch nameserver address failed. statusCode={}", result.code);
        }
    }
    catch (IOException e) {
        if (verbose) {
            log.error("fetch name server address exception", e);
        }
    }

    if (verbose) {
        String errorMsg =
                "connect to " + url + " failed, maybe the domain name " + MixAll.WS_DOMAIN_NAME + " not bind in /etc/hosts";
        errorMsg += FAQUrl.suggestTodo(FAQUrl.NAME_SERVER_ADDR_NOT_EXIST_URL);

        log.warn(errorMsg);
    }
    return null;
}
 
Example #5
Source File: TopAddressing.java    From rocketmq with Apache License 2.0 5 votes vote down vote up
public final String fetchNSAddr(boolean verbose, long timeoutMills) {
    String url = this.wsAddr;
    try {
        if (!UtilAll.isBlank(this.unitName)) {
            url = url + "-" + this.unitName + "?nofix=1";
        }
        HttpResult result = HttpTinyClient.httpGet(url, null, null, "UTF-8", timeoutMills);
        if (200 == result.code) {
            String responseStr = result.content;
            if (responseStr != null) {
                return clearNewLine(responseStr);
            } else {
                log.error("fetch nameserver address is null");
            }
        } else {
            log.error("fetch nameserver address failed. statusCode={}", result.code);
        }
    } catch (IOException e) {
        if (verbose) {
            log.error("fetch name server address exception", e);
        }
    }

    if (verbose) {
        String errorMsg =
                "connect to " + url + " failed, maybe the domain name " + MixAll.WS_DOMAIN_NAME + " not bind in /etc/hosts";
        errorMsg += FAQUrl.suggestTodo(FAQUrl.NAME_SERVER_ADDR_NOT_EXIST_URL);

        log.warn(errorMsg);
    }
    return null;
}
 
Example #6
Source File: TopAddressing.java    From RocketMQ-Master-analyze with Apache License 2.0 5 votes vote down vote up
public final String fetchNSAddr(boolean verbose, long timeoutMills) {
    try {
        HttpResult result = HttpTinyClient.httpGet(this.wsAddr, null, null, "UTF-8", timeoutMills);
        if (200 == result.code) {
            String responseStr = result.content;
            if (responseStr != null) {
                return clearNewLine(responseStr);
            }
            else {
                log.error("fetch nameserver address is null");
            }
        }
        else {
            log.error("fetch nameserver address failed. statusCode={}", result.code);
        }
    }
    catch (IOException e) {
        if (verbose) {
            log.error("fetchZKAddr exception", e);
        }
    }

    if (verbose) {
        String errorMsg = "connect to " + wsAddr + " failed, maybe the domain name "
                + MixAll.WS_DOMAIN_NAME + " not bind in /etc/hosts";
        errorMsg += FAQUrl.suggestTodo(FAQUrl.NAME_SERVER_ADDR_NOT_EXIST_URL);

        log.warn(errorMsg);
    }
    return null;
}