Package com.bazaarvoice.ostrich

Examples of com.bazaarvoice.ostrich.HostDiscovery


    @VisibleForTesting
    ServicePool<S> buildInternal() {
        checkNotNull(_serviceFactory);
        checkNotNull(_metrics);

        HostDiscovery hostDiscovery = findHostDiscovery(_serviceName);

        boolean shutdownHealthCheckExecutorOnClose = (_healthCheckExecutor == null);

        try {
            if (_cachingPolicy == null) {
                _cachingPolicy = ServiceCachingPolicyBuilder.NO_CACHING;
            }

            if (_healthCheckExecutor == null) {
                _healthCheckExecutor = Executors.newScheduledThreadPool(DEFAULT_NUM_HEALTH_CHECK_THREADS,
                        new ThreadFactoryBuilder()
                                .setNameFormat(_serviceName + "-HealthCheckThread-%d")
                                .setDaemon(true)
                                .build());
            }

            ServicePool<S> servicePool = new ServicePool<>(Ticker.systemTicker(), hostDiscovery, _closeHostDiscovery,
                    _serviceFactory, _cachingPolicy, _partitionFilter, _loadBalanceAlgorithm, _healthCheckExecutor,
                    shutdownHealthCheckExecutorOnClose, _healthCheckRetryDelay, _metrics);

            _closeHostDiscovery = false;

            return servicePool;
        } catch (Throwable t) {
            if (shutdownHealthCheckExecutorOnClose && _healthCheckExecutor != null) {
                _healthCheckExecutor.shutdownNow();
                _healthCheckExecutor = null;
            }

            try {
                if (_closeHostDiscovery) {
                    hostDiscovery.close();
                }
            } catch (IOException e) {
                // NOP
            } finally {
                _closeHostDiscovery = false;
View Full Code Here


        }
    }

    private HostDiscovery findHostDiscovery(String serviceName) {
        for (HostDiscoverySource source : _hostDiscoverySources) {
            HostDiscovery hostDiscovery = source.forService(serviceName);
            if (hostDiscovery != null) {
                return hostDiscovery;
            }
        }
        throw new IllegalStateException(format("No HostDiscovery found for service: %s", serviceName));
View Full Code Here

            _wrappedSource = wrappedSource;
        }

        @Override
        public HostDiscovery forService(String serviceName) {
            HostDiscovery hostDiscovery = _wrappedSource.forService(serviceName);
            if (hostDiscovery != null) {
                _closeHostDiscovery = true;
            }
            return hostDiscovery;
        }
View Full Code Here

    @VisibleForTesting
    ServicePool<S> buildInternal() {
        checkNotNull(_serviceFactory);

        HostDiscovery hostDiscovery = findHostDiscovery(_serviceName);

        boolean shutdownHealthCheckExecutorOnClose = (_healthCheckExecutor == null);

        try {
            if (_cachingPolicy == null) {
                _cachingPolicy = ServiceCachingPolicyBuilder.NO_CACHING;
            }

            if (_healthCheckExecutor == null) {
                _healthCheckExecutor = Executors.newScheduledThreadPool(DEFAULT_NUM_HEALTH_CHECK_THREADS,
                        new ThreadFactoryBuilder()
                                .setNameFormat(_serviceName + "-HealthCheckThread-%d")
                                .setDaemon(true)
                                .build());
            }

            ServicePool<S> servicePool = new ServicePool<S>(Ticker.systemTicker(), hostDiscovery, _closeHostDiscovery,
                    _serviceFactory, _cachingPolicy, _partitionFilter, _loadBalanceAlgorithm, _healthCheckExecutor,
                    shutdownHealthCheckExecutorOnClose);

            _closeHostDiscovery = false;

            return servicePool;
        } catch (Throwable t) {
            if (shutdownHealthCheckExecutorOnClose && _healthCheckExecutor != null) {
                _healthCheckExecutor.shutdownNow();
                _healthCheckExecutor = null;
            }

            try {
                if (_closeHostDiscovery) {
                    hostDiscovery.close();
                }
            } catch (IOException e) {
                // NOP
            } finally {
                _closeHostDiscovery = false;
View Full Code Here

        }
    }

    private HostDiscovery findHostDiscovery(String serviceName) {
        for (HostDiscoverySource source : _hostDiscoverySources) {
            HostDiscovery hostDiscovery = source.forService(serviceName);
            if (hostDiscovery != null) {
                return hostDiscovery;
            }
        }
        throw new IllegalStateException(format("No HostDiscovery found for service: %s", serviceName));
View Full Code Here

            _wrappedSource = wrappedSource;
        }

        @Override
        public HostDiscovery forService(String serviceName) {
            HostDiscovery hostDiscovery = _wrappedSource.forService(serviceName);
            if (hostDiscovery != null) {
                _closeHostDiscovery = true;
            }
            return hostDiscovery;
        }
View Full Code Here

    @VisibleForTesting
    ServicePool<S> buildInternal() {
        checkNotNull(_serviceFactory);
        checkNotNull(_metrics);

        HostDiscovery hostDiscovery = findHostDiscovery(_serviceName);

        boolean shutdownHealthCheckExecutorOnClose = (_healthCheckExecutor == null);

        try {
            if (_cachingPolicy == null) {
                _cachingPolicy = ServiceCachingPolicyBuilder.NO_CACHING;
            }

            if (_healthCheckExecutor == null) {
                _healthCheckExecutor = Executors.newScheduledThreadPool(DEFAULT_NUM_HEALTH_CHECK_THREADS,
                        new ThreadFactoryBuilder()
                                .setNameFormat(_serviceName + "-HealthCheckThread-%d")
                                .setDaemon(true)
                                .build());
            }

            ServicePool<S> servicePool = new ServicePool<>(Ticker.systemTicker(), hostDiscovery, _closeHostDiscovery,
                    _serviceFactory, _cachingPolicy, _partitionFilter, _loadBalanceAlgorithm, _healthCheckExecutor,
                    shutdownHealthCheckExecutorOnClose, _metrics);

            _closeHostDiscovery = false;

            return servicePool;
        } catch (Throwable t) {
            if (shutdownHealthCheckExecutorOnClose && _healthCheckExecutor != null) {
                _healthCheckExecutor.shutdownNow();
                _healthCheckExecutor = null;
            }

            try {
                if (_closeHostDiscovery) {
                    hostDiscovery.close();
                }
            } catch (IOException e) {
                // NOP
            } finally {
                _closeHostDiscovery = false;
View Full Code Here

        }
    }

    private HostDiscovery findHostDiscovery(String serviceName) {
        for (HostDiscoverySource source : _hostDiscoverySources) {
            HostDiscovery hostDiscovery = source.forService(serviceName);
            if (hostDiscovery != null) {
                return hostDiscovery;
            }
        }
        throw new IllegalStateException(format("No HostDiscovery found for service: %s", serviceName));
View Full Code Here

            _wrappedSource = wrappedSource;
        }

        @Override
        public HostDiscovery forService(String serviceName) {
            HostDiscovery hostDiscovery = _wrappedSource.forService(serviceName);
            if (hostDiscovery != null) {
                _closeHostDiscovery = true;
            }
            return hostDiscovery;
        }
View Full Code Here

TOP

Related Classes of com.bazaarvoice.ostrich.HostDiscovery

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.