Package com.bazaarvoice.ostrich

Examples of com.bazaarvoice.ostrich.ServiceEndPoint


        URI adminUri = UriBuilder.fromPath("").scheme("http").host(ip).port(adminPort).build();
        Map<String, ?> payload = ImmutableMap.of(
                "url", serviceUri,
                "adminUrl", adminUri,
                "partition", config.getWordRange());
        final ServiceEndPoint endPoint = new ServiceEndPointBuilder()
                .withServiceName(env.getName())
                .withId(host + ":" + port)
                .withPayload(getJson(env).writeValueAsString(payload))
                .build();
View Full Code Here


    @Override
    public <R> R execute(PartitionContext partitionContext, RetryPolicy retry, ServiceCallback<S, R> callback) {
        Stopwatch sw = new Stopwatch(_ticker).start();
        int numAttempts = 0;
        do {
            ServiceEndPoint endPoint = chooseEndPoint(getValidEndPoints(), partitionContext);

            try {
                R result = executeOnEndPoint(endPoint, callback);
                _numExecuteSuccesses.mark();
                return result;
View Full Code Here

    private ServiceEndPoint chooseEndPoint(Iterable<ServiceEndPoint> endPoints, PartitionContext partitionContext) {
        endPoints = _partitionFilter.filter(endPoints, partitionContext);
        if (endPoints == null || Iterables.isEmpty(endPoints)) {
            throw new NoSuitableHostsException();
        }
        ServiceEndPoint endPoint = _loadBalanceAlgorithm.choose(endPoints, _servicePoolStatistics);
        if (endPoint == null) {
            throw new NoSuitableHostsException();
        }
        return endPoint;
    }
View Full Code Here

            // No valid end points means no healthy end points.
            return aggregate;
        }

        while (!endPoints.isEmpty()) {
            ServiceEndPoint endPoint;
            try {
                // Prefer end points in the order the load balancer recommends.
                endPoint = chooseEndPoint(endPoints, PartitionContextBuilder.empty());
            } catch (Exception e) {
                // Load balancer didn't like our end points, so just go sequentially.
                endPoint = endPoints.iterator().next();
            }

            HealthCheckResult result = checkHealth(endPoint);
            aggregate.addHealthCheckResult(result);

            if (!result.isHealthy()) {
                Exception exception = ((FailedHealthCheckResult) result).getException();
                if (exception == null || isRetriableException(exception)) {
                    LOG.debug("Unhealthy end point discovered. End point ID: {}", endPoint.getId());
                    endPoints.remove(endPoint);
                    markEndPointAsBad(endPoint);
                    continue;
                }
            }
View Full Code Here

TOP

Related Classes of com.bazaarvoice.ostrich.ServiceEndPoint

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.