com.netflix.discovery.DiscoveryClient Java Examples

The following examples show how to use com.netflix.discovery.DiscoveryClient. 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: ChassisEurekaRegistrationTest.java    From chassis with Apache License 2.0 6 votes vote down vote up
@Test
 public void testServiceRegistration() throws InterruptedException {
 	// Registers "chasis-default-name" with a Eurkea server running on local host.
 	//   http://localhost:8184/v2/apps/chassis-default-name

 	// tell eureka the service is up which causes a registration
 	ApplicationInfoManager.getInstance().setInstanceStatus(InstanceInfo.InstanceStatus.UP);
 	
 	// get application registration from Eureka
 	DiscoveryClient client = DiscoveryManager.getInstance().getDiscoveryClient();
 	InstanceInfo instanceInfo = null;
 	for (int i = 0; (instanceInfo == null) && (i < 50); i++) {
 		Thread.sleep(5000);
 		try {
	instanceInfo =  client.getNextServerFromEureka("default-service", false);
} catch (RuntimeException e) {
	// eat not found runtime exception
}
 	}
 	Assert.assertNotNull(instanceInfo);
 	Assert.assertEquals(InstanceStatus.UP, instanceInfo.getStatus());
 	System.out.println("done");
 }
 
Example #2
Source File: EurekaResource.java    From karyon with Apache License 2.0 6 votes vote down vote up
@GET
public Response getEurekaDetails() {
    List<EurekaInstanceInfo> instanceInfoList = new ArrayList<EurekaInstanceInfo>();

    DiscoveryClient discoveryClient = DiscoveryManager.getInstance().getDiscoveryClient();
    if (null != discoveryClient) {
        Applications apps = discoveryClient.getApplications();
        for (Application app : apps.getRegisteredApplications()) {
            for (InstanceInfo inst : app.getInstances()) {
                instanceInfoList.add(new EurekaInstanceInfo(inst.getAppName(), inst.getId(), inst.getStatus().name(), inst.getIPAddr(), inst.getHostName()));
            }
        }
    }

    GsonBuilder gsonBuilder = new GsonBuilder().serializeNulls();
    Gson gson = gsonBuilder.create();
    String response = gson.toJson(new KaryonAdminResponse(instanceInfoList));
    return Response.ok(response).build();
}
 
Example #3
Source File: ZosmfServiceFacade.java    From api-layer with Eclipse Public License 2.0 6 votes vote down vote up
public ZosmfServiceFacade(
    final AuthConfigurationProperties authConfigurationProperties,
    final DiscoveryClient discovery,
    final @Qualifier("restTemplateWithoutKeystore") RestTemplate restTemplateWithoutKeystore,
    final ObjectMapper securityObjectMapper,
    final ApplicationContext applicationContext,
    final List<ZosmfService> implementations
) {
    super(
        authConfigurationProperties,
        discovery,
        restTemplateWithoutKeystore,
        securityObjectMapper
    );
    this.applicationContext = applicationContext;
    this.implementations = implementations;
}
 
Example #4
Source File: EurekaDynamicServerListLoadBalancerTest.java    From ribbon with Apache License 2.0 6 votes vote down vote up
@Before
public void setUp() {
    PowerMock.mockStatic(DiscoveryClient.class);

    EasyMock
            .expect(DiscoveryClient.getZone(EasyMock.isA(InstanceInfo.class)))
            .andReturn("zone")
            .anyTimes();

    eurekaClientMock = setUpEurekaClientMock(servers);
    eurekaClientProvider = new Provider<EurekaClient>() {
        @Override
        public EurekaClient get() {
            return eurekaClientMock;
        }
    };

    config = DefaultClientConfigImpl.getClientConfigWithDefaultValues();
    config.set(CommonClientConfigKey.DeploymentContextBasedVipAddresses, vipAddress);
    config.set(CommonClientConfigKey.ServerListUpdaterClassName, EurekaNotificationServerListUpdater.class.getName());
}
 
Example #5
Source File: ApimlDiscoveryClient.java    From api-layer with Eclipse Public License 2.0 6 votes vote down vote up
public void init() {
    try {
        // take scheduler and save in local variable to work with in the future
        Field schedulerField = DiscoveryClient.class.getDeclaredField("scheduler");
        schedulerField.setAccessible(true);
        scheduler = (ScheduledExecutorService) schedulerField.get(this);
        // find class with process to fetch from discovery server and construct instance for call to fetch
        Optional<Class<?>> cacheRefreshClass = Arrays.stream(DiscoveryClient.class.getDeclaredClasses())
            .filter(x -> "CacheRefreshThread".equals(x.getSimpleName())).findFirst();  // NOSONAR: This class cannot be imported for usage with instanceof
        if (!cacheRefreshClass.isPresent()) throw new NoSuchMethodException();
        Constructor cacheRefreshConstructor = cacheRefreshClass.get().getDeclaredConstructor(DiscoveryClient.class);
        cacheRefreshConstructor.setAccessible(true);
        cacheRefresh = (Runnable) cacheRefreshConstructor.newInstance(this);
    } catch (InstantiationException | InvocationTargetException | NoSuchMethodException | IllegalAccessException | NoSuchFieldException e) {
        throw new IllegalArgumentException("Implementation of discovery client was changed. Please review implementation of manual registry fetching");
    }
}
 
Example #6
Source File: DiscoveryEnabledLoadBalancerSupportsUseIpAddrTest.java    From ribbon with Apache License 2.0 6 votes vote down vote up
@Before
public void setupMock(){

    List<InstanceInfo> servers = LoadBalancerTestUtils.getDummyInstanceInfo("dummy", HOST1, IP1, 8080);
    List<InstanceInfo> servers2 = LoadBalancerTestUtils.getDummyInstanceInfo("dummy", HOST2, IP2, 8080);
    servers.addAll(servers2);


    PowerMock.mockStatic(DiscoveryManager.class);
    PowerMock.mockStatic(DiscoveryClient.class);

    DiscoveryClient mockedDiscoveryClient = LoadBalancerTestUtils.mockDiscoveryClient();
    DiscoveryManager mockedDiscoveryManager = createMock(DiscoveryManager.class);

    expect(DiscoveryManager.getInstance()).andReturn(mockedDiscoveryManager).anyTimes();
    expect(mockedDiscoveryManager.getDiscoveryClient()).andReturn(mockedDiscoveryClient).anyTimes();

    expect(mockedDiscoveryClient.getInstancesByVipAddress("dummy", false, "region")).andReturn(servers).anyTimes();

    replay(DiscoveryManager.class);
    replay(DiscoveryClient.class);
    replay(mockedDiscoveryManager);
    replay(mockedDiscoveryClient);
}
 
Example #7
Source File: MockedDiscoveryServerListTest.java    From ribbon with Apache License 2.0 6 votes vote down vote up
@Before
public void setupMock(){
    List<InstanceInfo> instances = getDummyInstanceInfo("dummy", getMockServerList());
    PowerMock.mockStatic(DiscoveryManager.class);
    PowerMock.mockStatic(DiscoveryClient.class);

    DiscoveryClient mockedDiscoveryClient = createMock(DiscoveryClient.class);
    DiscoveryManager mockedDiscoveryManager = createMock(DiscoveryManager.class);

    expect(mockedDiscoveryClient.getEurekaClientConfig()).andReturn(new DefaultEurekaClientConfig()).anyTimes();
    expect(DiscoveryManager.getInstance()).andReturn(mockedDiscoveryManager).anyTimes();
    expect(mockedDiscoveryManager.getDiscoveryClient()).andReturn(mockedDiscoveryClient).anyTimes();

    expect(mockedDiscoveryClient.getInstancesByVipAddress(getVipAddress(), false, null)).andReturn(instances).anyTimes();

    replay(DiscoveryManager.class);
    replay(DiscoveryClient.class);
    replay(mockedDiscoveryManager);
    replay(mockedDiscoveryClient);
}
 
Example #8
Source File: LBBuilderTest.java    From ribbon with Apache License 2.0 6 votes vote down vote up
@Before
public void setupMock(){
    List<InstanceInfo> instances = LoadBalancerTestUtils.getDummyInstanceInfo("dummy", expected.getHost(), "127.0.0.1", expected.getPort());
    PowerMock.mockStatic(DiscoveryManager.class);
    PowerMock.mockStatic(DiscoveryClient.class);

    DiscoveryClient mockedDiscoveryClient = LoadBalancerTestUtils.mockDiscoveryClient();
    DiscoveryManager mockedDiscoveryManager = createMock(DiscoveryManager.class);

    expect(DiscoveryManager.getInstance()).andReturn(mockedDiscoveryManager).anyTimes();
    expect(mockedDiscoveryManager.getDiscoveryClient()).andReturn(mockedDiscoveryClient).anyTimes();

    expect(mockedDiscoveryClient.getInstancesByVipAddress("dummy:7001", false, null)).andReturn(instances).anyTimes();

    replay(DiscoveryManager.class);
    replay(DiscoveryClient.class);
    replay(mockedDiscoveryManager);
    replay(mockedDiscoveryClient);
}
 
Example #9
Source File: OrderApplication.java    From Mastering-Spring-Cloud with MIT License 5 votes vote down vote up
@Bean
public DiscoveryClient.DiscoveryClientOptionalArgs discoveryClientOptionalArgs() throws NoSuchAlgorithmException {
	DiscoveryClient.DiscoveryClientOptionalArgs args = new DiscoveryClient.DiscoveryClientOptionalArgs();
	System.setProperty("javax.net.ssl.keyStore", "src/main/resources/order.jks");
	System.setProperty("javax.net.ssl.keyStorePassword", "123456");
	System.setProperty("javax.net.ssl.trustStore", "src/main/resources/order.jks");
	System.setProperty("javax.net.ssl.trustStorePassword", "123456");
	EurekaJerseyClientBuilder builder = new EurekaJerseyClientBuilder();
	builder.withClientName("order-client");
	builder.withSystemSSLConfiguration();
	builder.withMaxTotalConnections(10);
	builder.withMaxConnectionsPerHost(10);
	args.setEurekaJerseyClient(builder.build());
	return args;
}
 
Example #10
Source File: ZuulSampleModule.java    From Sentinel with Apache License 2.0 5 votes vote down vote up
@Override
protected void configure() {
    // sample specific bindings
    bind(BaseServerStartup.class).to(SampleServerStartup.class);

    // use provided basic netty origin manager
    bind(OriginManager.class).to(BasicNettyOriginManager.class);

    // zuul filter loading
    install(new ZuulFiltersModule());
    bind(FilterFileManager.class).asEagerSingleton();

    install(new ZuulClasspathFiltersModule());
    // general server bindings
    // health/discovery status
    bind(ServerStatusManager.class);
    // decorate new sessions when requests come in
    bind(SessionContextDecorator.class).to(ZuulSessionContextDecorator.class);
    // atlas metrics registry
    bind(Registry.class).to(DefaultRegistry.class);
    // metrics post-request completion
    bind(RequestCompleteHandler.class).to(BasicRequestCompleteHandler.class);
    // discovery client
    bind(AbstractDiscoveryClientOptionalArgs.class).to(DiscoveryClient.DiscoveryClientOptionalArgs.class);
    // timings publisher
    bind(RequestMetricsPublisher.class).to(BasicRequestMetricsPublisher.class);

    // access logger, including request ID generator
    bind(AccessLogPublisher.class).toInstance(new AccessLogPublisher("ACCESS",
            (channel, httpRequest) -> ClientRequestReceiver.getRequestFromChannel(channel).getContext().getUUID()));
}
 
Example #11
Source File: ZosmfServiceV1.java    From api-layer with Eclipse Public License 2.0 5 votes vote down vote up
public ZosmfServiceV1(
    AuthConfigurationProperties authConfigurationProperties,
    DiscoveryClient discovery,
    @Qualifier("restTemplateWithoutKeystore") RestTemplate restTemplateWithoutKeystore,
    ObjectMapper securityObjectMapper
) {
    super(authConfigurationProperties, discovery, restTemplateWithoutKeystore, securityObjectMapper);
}
 
Example #12
Source File: EurekaDynamicServerListLoadBalancerTest.java    From ribbon with Apache License 2.0 5 votes vote down vote up
@Test
public void testLoadBalancerHappyCase() throws Exception {
    Assert.assertNotEquals("the two test server list counts should be different",
            secondServerListSize, initialServerListSize);

    DynamicServerListLoadBalancer<DiscoveryEnabledServer> lb = null;
    try {
        Capture<EurekaEventListener> eventListenerCapture = new Capture<EurekaEventListener>();
        eurekaClientMock.registerEventListener(EasyMock.capture(eventListenerCapture));

        PowerMock.replay(DiscoveryClient.class);
        PowerMock.replay(eurekaClientMock);

        // actual testing
        // initial creation and loading of the first serverlist
        lb = new DynamicServerListLoadBalancer<DiscoveryEnabledServer>(
                config,
                new AvailabilityFilteringRule(),
                new DummyPing(),
                new DiscoveryEnabledNIWSServerList(vipAddress, eurekaClientProvider),
                new ZoneAffinityServerListFilter<DiscoveryEnabledServer>(),
                new EurekaNotificationServerListUpdater(eurekaClientProvider)
        );

        Assert.assertEquals(initialServerListSize, lb.getServerCount(false));

        // trigger an eureka CacheRefreshEvent
        eventListenerCapture.getValue().onEvent(new CacheRefreshedEvent());

        Assert.assertTrue(verifyFinalServerListCount(secondServerListSize, lb));

    } finally {
        if (lb != null) {
            lb.shutdown();

            PowerMock.verify(eurekaClientMock);
            PowerMock.verify(DiscoveryClient.class);
        }
    }
}
 
Example #13
Source File: AuthenticationServiceTest.java    From api-layer with Eclipse Public License 2.0 5 votes vote down vote up
private String mockZosmfUrl(DiscoveryClient discoveryClient) {
    final InstanceInfo instanceInfo = mock(InstanceInfo.class);
    when(instanceInfo.getHostName()).thenReturn(ZOSMF_HOSTNAME);
    when(instanceInfo.getPort()).thenReturn(ZOSMF_PORT);

    final Application application = mock(Application.class);
    when(application.getInstances()).thenReturn(Collections.singletonList(instanceInfo));
    when(discoveryClient.getApplication(ZOSMF)).thenReturn(application);

    return EurekaUtils.getUrl(instanceInfo);
}
 
Example #14
Source File: ZosmfAuthenticationProviderTest.java    From api-layer with Eclipse Public License 2.0 5 votes vote down vote up
@BeforeEach
public void setUp() {
    usernamePasswordAuthentication = new UsernamePasswordAuthenticationToken(USERNAME, PASSWORD);
    authConfigurationProperties = new AuthConfigurationProperties();
    discovery = mock(DiscoveryClient.class);
    authenticationService = mock(AuthenticationService.class);
    mapper = new ObjectMapper();
    restTemplate = mock(RestTemplate.class);
    zosmfInstance = createInstanceInfo(SERVICE_ID, HOST, PORT);

    doAnswer((Answer<TokenAuthentication>) invocation -> TokenAuthentication.createAuthenticated(invocation.getArgument(0), invocation.getArgument(1))).when(authenticationService).createTokenAuthentication(anyString(), anyString());
    when(authenticationService.createJwtToken(anyString(), anyString(), anyString())).thenReturn("someJwtToken");
}
 
Example #15
Source File: AbstractZosmfService.java    From api-layer with Eclipse Public License 2.0 5 votes vote down vote up
public AbstractZosmfService(
    AuthConfigurationProperties authConfigurationProperties,
    DiscoveryClient discovery,
    @Qualifier("restTemplateWithoutKeystore") RestTemplate restTemplateWithoutKeystore,
    ObjectMapper securityObjectMapper
) {
    this.authConfigurationProperties = authConfigurationProperties;
    this.discovery = discovery;
    this.restTemplateWithoutKeystore = restTemplateWithoutKeystore;
    this.securityObjectMapper = securityObjectMapper;
}
 
Example #16
Source File: KaryonEurekaModule.java    From karyon with Apache License 2.0 5 votes vote down vote up
@Override
protected void configure() {
    bind(com.netflix.appinfo.HealthCheckHandler.class).to(EurekaHealthCheckHandler.class);
    bind(ApplicationInfoManager.class).asEagerSingleton();
    bind(DiscoveryClient.class).asEagerSingleton();

    configureEureka();
}
 
Example #17
Source File: DefaultServerStore.java    From qconfig with MIT License 5 votes vote down vote up
@Override
public List<QConfigServer> getAvailableServers() {
    DiscoveryClient client = DiscoveryManager.getInstance().getDiscoveryClient();
    Application application = client.getApplication("eureka");
    if (application == null) {
        logger.warn("eureka application is null");
        return emptyServers();
    }

    List<InstanceInfo> instances = application.getInstances();
    if (instances == null || instances.isEmpty()) {
        logger.warn("eureka instance is empty");
        return emptyServers();
    }

    List<QConfigServer> servers = Lists.newArrayListWithCapacity(instances.size());
    for (InstanceInfo instance : instances) {
        logger.debug("eureka qconfig server instance {}:{}", instance.getIPAddr(), instance.getPort());
        try {
            String ip = instance.getIPAddr();
            if ("127.0.0.1".equals(ip)) {
                logger.warn("illegal qconfig server ip 127.0.0.1");
                Monitor.serverLocalIpError.inc();
                continue;
            }
            servers.add(new QConfigServer(ip, instance.getPort(), getRoom(ip)));
        } catch (Exception e) {
            // get room info error
            continue;
        }
    }

    if (servers.isEmpty()) {
        logger.warn("no legal eureka servers");
        return emptyServers();
    }
    return servers;
}
 
Example #18
Source File: CustomerApplication.java    From Mastering-Spring-Cloud with MIT License 5 votes vote down vote up
@Bean
public DiscoveryClient.DiscoveryClientOptionalArgs discoveryClientOptionalArgs() throws NoSuchAlgorithmException {
	DiscoveryClient.DiscoveryClientOptionalArgs args = new DiscoveryClient.DiscoveryClientOptionalArgs();
	System.setProperty("javax.net.ssl.keyStore", "src/main/resources/customer.jks");
	System.setProperty("javax.net.ssl.keyStorePassword", "123456");
	System.setProperty("javax.net.ssl.trustStore", "src/main/resources/customer.jks");
	System.setProperty("javax.net.ssl.trustStorePassword", "123456");
	EurekaJerseyClientBuilder builder = new EurekaJerseyClientBuilder();
	builder.withClientName("customer-client");
	builder.withSystemSSLConfiguration();
	builder.withMaxTotalConnections(10);
	builder.withMaxConnectionsPerHost(10);
	args.setEurekaJerseyClient(builder.build());
	return args;
}
 
Example #19
Source File: AccountApplication.java    From Mastering-Spring-Cloud with MIT License 5 votes vote down vote up
@Bean
public DiscoveryClient.DiscoveryClientOptionalArgs discoveryClientOptionalArgs() throws NoSuchAlgorithmException {
	DiscoveryClient.DiscoveryClientOptionalArgs args = new DiscoveryClient.DiscoveryClientOptionalArgs();
	System.setProperty("javax.net.ssl.keyStore", "src/main/resources/account.jks");
	System.setProperty("javax.net.ssl.keyStorePassword", "123456");
	System.setProperty("javax.net.ssl.trustStore", "src/main/resources/account.jks");
	System.setProperty("javax.net.ssl.trustStorePassword", "123456");
	EurekaJerseyClientBuilder builder = new EurekaJerseyClientBuilder();
	builder.withClientName("account-client");
	builder.withSystemSSLConfiguration();
	builder.withMaxTotalConnections(10);
	builder.withMaxConnectionsPerHost(10);
	args.setEurekaJerseyClient(builder.build());
	return args;
}
 
Example #20
Source File: CustomerApplication.java    From Mastering-Spring-Cloud with MIT License 5 votes vote down vote up
@Bean
public DiscoveryClient.DiscoveryClientOptionalArgs discoveryClientOptionalArgs() throws NoSuchAlgorithmException {
	DiscoveryClient.DiscoveryClientOptionalArgs args = new DiscoveryClient.DiscoveryClientOptionalArgs();
	System.setProperty("javax.net.ssl.keyStore", "src/main/resources/customer.jks");
	System.setProperty("javax.net.ssl.keyStorePassword", "123456");
	System.setProperty("javax.net.ssl.trustStore", "src/main/resources/customer.jks");
	System.setProperty("javax.net.ssl.trustStorePassword", "123456");
	EurekaJerseyClientBuilder builder = new EurekaJerseyClientBuilder();
	builder.withClientName("customer-client");
	builder.withSystemSSLConfiguration();
	builder.withMaxTotalConnections(10);
	builder.withMaxConnectionsPerHost(10);
	args.setEurekaJerseyClient(builder.build());
	return args;
}
 
Example #21
Source File: ProductApplication.java    From Mastering-Spring-Cloud with MIT License 5 votes vote down vote up
@Bean
public DiscoveryClient.DiscoveryClientOptionalArgs discoveryClientOptionalArgs() throws NoSuchAlgorithmException {
	DiscoveryClient.DiscoveryClientOptionalArgs args = new DiscoveryClient.DiscoveryClientOptionalArgs();
	System.setProperty("javax.net.ssl.keyStore", "src/main/resources/product.jks");
	System.setProperty("javax.net.ssl.keyStorePassword", "123456");
	System.setProperty("javax.net.ssl.trustStore", "src/main/resources/product.jks");
	System.setProperty("javax.net.ssl.trustStorePassword", "123456");
	EurekaJerseyClientBuilder builder = new EurekaJerseyClientBuilder();
	builder.withClientName("product-client");
	builder.withSystemSSLConfiguration();
	builder.withMaxTotalConnections(10);
	builder.withMaxConnectionsPerHost(10);
	args.setEurekaJerseyClient(builder.build());
	return args;
}
 
Example #22
Source File: OrderApplication.java    From Mastering-Spring-Cloud with MIT License 5 votes vote down vote up
@Bean
public DiscoveryClient.DiscoveryClientOptionalArgs discoveryClientOptionalArgs() throws NoSuchAlgorithmException {
	DiscoveryClient.DiscoveryClientOptionalArgs args = new DiscoveryClient.DiscoveryClientOptionalArgs();
	System.setProperty("javax.net.ssl.keyStore", "src/main/resources/order.jks");
	System.setProperty("javax.net.ssl.keyStorePassword", "123456");
	System.setProperty("javax.net.ssl.trustStore", "src/main/resources/order.jks");
	System.setProperty("javax.net.ssl.trustStorePassword", "123456");
	EurekaJerseyClientBuilder builder = new EurekaJerseyClientBuilder();
	builder.withClientName("order-client");
	builder.withSystemSSLConfiguration();
	builder.withMaxTotalConnections(10);
	builder.withMaxConnectionsPerHost(10);
	args.setEurekaJerseyClient(builder.build());
	return args;
}
 
Example #23
Source File: AccountApplication.java    From Mastering-Spring-Cloud with MIT License 5 votes vote down vote up
@Bean
public DiscoveryClient.DiscoveryClientOptionalArgs discoveryClientOptionalArgs() throws NoSuchAlgorithmException {
	DiscoveryClient.DiscoveryClientOptionalArgs args = new DiscoveryClient.DiscoveryClientOptionalArgs();
	System.setProperty("javax.net.ssl.keyStore", "src/main/resources/account.jks");
	System.setProperty("javax.net.ssl.keyStorePassword", "123456");
	System.setProperty("javax.net.ssl.trustStore", "src/main/resources/account.jks");
	System.setProperty("javax.net.ssl.trustStorePassword", "123456");
	EurekaJerseyClientBuilder builder = new EurekaJerseyClientBuilder();
	builder.withClientName("account-client");
	builder.withSystemSSLConfiguration();
	builder.withMaxTotalConnections(10);
	builder.withMaxConnectionsPerHost(10);
	args.setEurekaJerseyClient(builder.build());
	return args;
}
 
Example #24
Source File: DynoProxy.java    From conductor with Apache License 2.0 5 votes vote down vote up
/**
 * @deprecated The preferred method of construction for this use case is via DynoProxyDiscoveryProvider.
 */
@Deprecated
public DynoProxy(DiscoveryClient discoveryClient, Configuration config) throws DynoException, InterruptedException, ExecutionException {
    this.discoveryClient = discoveryClient;
    String cluster = config.getProperty("workflow.dynomite.cluster", null);
    String applicationName = config.getAppId();
    this.dynoClient = new DynoJedisClient.Builder()
            .withApplicationName(applicationName)
            .withDynomiteClusterName(cluster)
            .withDiscoveryClient(discoveryClient)
            .build();
}
 
Example #25
Source File: UserRolesSyncer.java    From fiat with Apache License 2.0 5 votes vote down vote up
@Autowired
public UserRolesSyncer(
    Optional<DiscoveryClient> discoveryClient,
    Registry registry,
    LockManager lockManager,
    PermissionsRepository permissionsRepository,
    PermissionsResolver permissionsResolver,
    ResourceProvider<ServiceAccount> serviceAccountProvider,
    ResourceProvidersHealthIndicator healthIndicator,
    @Value("${fiat.write-mode.retry-interval-ms:10000}") long retryIntervalMs,
    @Value("${fiat.write-mode.sync-delay-ms:600000}") long syncDelayMs,
    @Value("${fiat.write-mode.sync-failure-delay-ms:600000}") long syncFailureDelayMs,
    @Value("${fiat.write-mode.sync-delay-timeout-ms:30000}") long syncDelayTimeoutMs) {
  this.discoveryClient = discoveryClient;

  this.lockManager = lockManager;
  this.permissionsRepository = permissionsRepository;
  this.permissionsResolver = permissionsResolver;
  this.serviceAccountProvider = serviceAccountProvider;
  this.healthIndicator = healthIndicator;

  this.retryIntervalMs = retryIntervalMs;
  this.syncDelayMs = syncDelayMs;
  this.syncFailureDelayMs = syncFailureDelayMs;
  this.syncDelayTimeoutMs = syncDelayTimeoutMs;

  this.isEnabled =
      new AtomicBoolean(
          // default to enabled iff discovery is not available
          !discoveryClient.isPresent());

  this.registry = registry;
  this.userRolesSyncCount = registry.gauge(metricName("syncCount"));
}
 
Example #26
Source File: EurekaVipAddressRoundRobinWithAzAffinityService.java    From riposte with Apache License 2.0 5 votes vote down vote up
@Inject
public EurekaVipAddressRoundRobinWithAzAffinityService(
        @Named("eurekaRoundRobinDiscoveryClientSupplier") Supplier<DiscoveryClient> discoveryClientSupplier,
        @Named("currentAvailabilityZone") String currentAvailabilityZone
) {
    super(discoveryClientSupplier);
    this.currentAvailabilityZone = currentAvailabilityZone;
}
 
Example #27
Source File: CloudEurekaClient.java    From spring-cloud-netflix with Apache License 2.0 5 votes vote down vote up
public CloudEurekaClient(ApplicationInfoManager applicationInfoManager,
		EurekaClientConfig config, AbstractDiscoveryClientOptionalArgs<?> args,
		ApplicationEventPublisher publisher) {
	super(applicationInfoManager, config, args);
	this.applicationInfoManager = applicationInfoManager;
	this.publisher = publisher;
	this.eurekaTransportField = ReflectionUtils.findField(DiscoveryClient.class,
			"eurekaTransport");
	ReflectionUtils.makeAccessible(this.eurekaTransportField);
}
 
Example #28
Source File: EurekaComponents.java    From kork with Apache License 2.0 5 votes vote down vote up
@Bean
@Deprecated // prefer to use EurekaClient interface rather than directly depending on
// DiscoveryClient
public DiscoveryClient discoveryClient(
    ApplicationInfoManager applicationInfoManager,
    EurekaClientConfig eurekaClientConfig,
    DiscoveryClient.DiscoveryClientOptionalArgs optionalArgs) {
  return new DiscoveryClient(applicationInfoManager, eurekaClientConfig, optionalArgs);
}
 
Example #29
Source File: EurekaComponents.java    From kork with Apache License 2.0 5 votes vote down vote up
@Bean
DiscoveryClient.DiscoveryClientOptionalArgs optionalArgs(
    EventBus eventBus, HealthCheckHandler healthCheckHandler) {
  DiscoveryClient.DiscoveryClientOptionalArgs args =
      new DiscoveryClient.DiscoveryClientOptionalArgs();
  args.setEventBus(eventBus);
  args.setHealthCheckHandlerProvider(new StaticProvider<>(healthCheckHandler));
  return args;
}
 
Example #30
Source File: EurekaComponents.java    From kork with Apache License 2.0 5 votes vote down vote up
public EurekaStatusSubscriber(
    ApplicationEventPublisher publisher, EventBus eventBus, DiscoveryClient discoveryClient) {
  this.publisher = Objects.requireNonNull(publisher, "publisher");
  this.eventBus = Objects.requireNonNull(eventBus, "eventBus");
  publish(
      new StatusChangeEvent(
          InstanceInfo.InstanceStatus.UNKNOWN, discoveryClient.getInstanceRemoteStatus()));
  try {
    eventBus.registerSubscriber(this);
  } catch (InvalidSubscriberException ise) {
    throw new SystemException(ise);
  }
}