Search in sources :

Example 1 with ReportClientRequest

use of com.tencent.polaris.api.plugin.server.ReportClientRequest in project polaris-java by polarismesh.

the class ReportClientTask method doReport.

private ReportClientResponse doReport(String clientHost, String version) {
    BaseEngine engine = BaseEngine.getEngine(shareContext);
    ReportClientRequest req = new ReportClientRequest();
    req.setClientHost(clientHost);
    req.setVersion(version);
    ReportClientResponse rsp = null;
    long start = System.currentTimeMillis();
    ServiceCallResult serviceCallResult = new ServiceCallResult();
    try {
        rsp = extensions.getServerConnector().reportClient(req);
        serviceCallResult.setRetStatus(RetStatus.RetSuccess);
        serviceCallResult.setRetCode(ErrorCode.Success.getCode());
    } catch (PolarisException e) {
        serviceCallResult.setRetStatus(RetStatus.RetFail);
        serviceCallResult.setRetCode(e.getCode().getCode());
        LOG.warn("fail to report client info(clientHost={}, version={}), cause is {}", clientHost, version, e.getMessage());
    }
    long delay = System.currentTimeMillis() - start;
    serviceCallResult.setDelay(delay);
    if (null != engine) {
        engine.reportServerCall(serviceCallResult, req.getTargetServer(), "reportClient");
    }
    return rsp;
}
Also used : PolarisException(com.tencent.polaris.api.exception.PolarisException) ReportClientRequest(com.tencent.polaris.api.plugin.server.ReportClientRequest) ServiceCallResult(com.tencent.polaris.api.rpc.ServiceCallResult) BaseEngine(com.tencent.polaris.client.api.BaseEngine) ReportClientResponse(com.tencent.polaris.api.plugin.server.ReportClientResponse)

Aggregations

PolarisException (com.tencent.polaris.api.exception.PolarisException)1 ReportClientRequest (com.tencent.polaris.api.plugin.server.ReportClientRequest)1 ReportClientResponse (com.tencent.polaris.api.plugin.server.ReportClientResponse)1 ServiceCallResult (com.tencent.polaris.api.rpc.ServiceCallResult)1 BaseEngine (com.tencent.polaris.client.api.BaseEngine)1