Search in sources :

Example 1 with EurekaServerConfig

use of com.netflix.eureka.EurekaServerConfig in project spring-cloud-netflix by spring-cloud.

the class RefreshablePeerEurekaNodesTests method notUpdatedWhenIrrelevantPropertiesChanged.

@Test
public void notUpdatedWhenIrrelevantPropertiesChanged() {
    // PeerEurekaNodes.updatePeerEurekaNodes() is not public, hence cannot verify with Mockito.
    class VerifyablePeerEurekNode extends RefreshablePeerEurekaNodes {

        public VerifyablePeerEurekNode(PeerAwareInstanceRegistry registry, EurekaServerConfig serverConfig, EurekaClientConfig clientConfig, ServerCodecs serverCodecs, ApplicationInfoManager applicationInfoManager) {
            super(registry, serverConfig, clientConfig, serverCodecs, applicationInfoManager);
        }

        protected void updatePeerEurekaNodes(List<String> newPeerUrls) {
            super.updatePeerEurekaNodes(newPeerUrls);
        }
    }
    // Create stubs.
    final EurekaClientConfigBean configClientBean = mock(EurekaClientConfigBean.class);
    when(configClientBean.isUseDnsForFetchingServiceUrls()).thenReturn(false);
    final VerifyablePeerEurekNode mock = spy(new VerifyablePeerEurekNode(null, null, configClientBean, null, null));
    mock.onApplicationEvent(new EnvironmentChangeEvent(Collections.singleton("some.irrelevant.property")));
    verify(mock, never()).updatePeerEurekaNodes(anyListOf(String.class));
}
Also used : EurekaClientConfig(com.netflix.discovery.EurekaClientConfig) EnvironmentChangeEvent(org.springframework.cloud.context.environment.EnvironmentChangeEvent) RefreshablePeerEurekaNodes(org.springframework.cloud.netflix.eureka.server.EurekaServerAutoConfiguration.RefreshablePeerEurekaNodes) EurekaServerConfig(com.netflix.eureka.EurekaServerConfig) List(java.util.List) EurekaClientConfigBean(org.springframework.cloud.netflix.eureka.EurekaClientConfigBean) ApplicationInfoManager(com.netflix.appinfo.ApplicationInfoManager) PeerAwareInstanceRegistry(com.netflix.eureka.registry.PeerAwareInstanceRegistry) ServerCodecs(com.netflix.eureka.resources.ServerCodecs) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 2 with EurekaServerConfig

use of com.netflix.eureka.EurekaServerConfig in project eureka by Netflix.

the class ResponseCacheTest method setUp.

@Override
@Before
public void setUp() throws Exception {
    super.setUp();
    // create a new registry that is sync'ed up with the default registry in the AbstractTester,
    // but disable transparent fetch to the remote for gets
    EurekaServerConfig serverConfig = spy(new DefaultEurekaServerConfig());
    doReturn(true).when(serverConfig).disableTransparentFallbackToOtherRegion();
    testRegistry = new PeerAwareInstanceRegistryImpl(serverConfig, new DefaultEurekaClientConfig(), new DefaultServerCodecs(serverConfig), client);
    testRegistry.init(serverContext.getPeerEurekaNodes());
    testRegistry.syncUp();
}
Also used : DefaultEurekaClientConfig(com.netflix.discovery.DefaultEurekaClientConfig) DefaultEurekaServerConfig(com.netflix.eureka.DefaultEurekaServerConfig) DefaultEurekaServerConfig(com.netflix.eureka.DefaultEurekaServerConfig) EurekaServerConfig(com.netflix.eureka.EurekaServerConfig) DefaultServerCodecs(com.netflix.eureka.resources.DefaultServerCodecs) Before(org.junit.Before)

Example 3 with EurekaServerConfig

use of com.netflix.eureka.EurekaServerConfig in project eureka by Netflix.

the class DiagnosticClient method main.

public static void main(String[] args) throws InterruptedException {
    String discoveryURL = args[0];
    long startTime = System.currentTimeMillis();
    EurekaServerConfig serverConfig = new DefaultEurekaServerConfig("eureka.");
    JerseyReplicationClient client = JerseyReplicationClient.createReplicationClient(serverConfig, new DefaultServerCodecs(serverConfig), discoveryURL);
    Applications applications = client.getApplications().getEntity();
    System.out.println("Applications count=" + applications.getRegisteredApplications().size());
    System.out.println("Instance count=" + countInstances(applications));
    while (true) {
        long delay = System.currentTimeMillis() - startTime;
        if (delay >= 30000) {
            System.out.println("Processing delay exceeds 30sec; we may be out of sync");
        } else {
            long waitTime = 30 * 1000 - delay;
            System.out.println("Waiting " + waitTime / 1000 + "sec before next fetch...");
            Thread.sleep(15 * 1000);
        }
        startTime = System.currentTimeMillis();
        Applications delta = client.getDelta().getEntity();
        Applications merged = EurekaEntityFunctions.mergeApplications(applications, delta);
        if (merged.getAppsHashCode().equals(delta.getAppsHashCode())) {
            System.out.println("Hash codes match: " + delta.getAppsHashCode() + "(delta count=" + countInstances(delta) + ')');
            applications = merged;
        } else {
            System.out.println("ERROR: hash codes do not match (" + delta.getAppsHashCode() + "(delta) != " + merged.getAppsHashCode() + " (merged) != " + applications.getAppsHashCode() + "(old apps)" + "(delta count=" + countInstances(delta) + ')');
            applications = client.getApplications().getEntity();
        }
    }
}
Also used : JerseyReplicationClient(com.netflix.eureka.transport.JerseyReplicationClient) Applications(com.netflix.discovery.shared.Applications) DefaultEurekaServerConfig(com.netflix.eureka.DefaultEurekaServerConfig) DefaultEurekaServerConfig(com.netflix.eureka.DefaultEurekaServerConfig) EurekaServerConfig(com.netflix.eureka.EurekaServerConfig) DefaultServerCodecs(com.netflix.eureka.resources.DefaultServerCodecs)

Example 4 with EurekaServerConfig

use of com.netflix.eureka.EurekaServerConfig in project eureka by Netflix.

the class AwsAsgUtilTest method setUp.

@Before
public void setUp() throws Exception {
    ConfigurationManager.getConfigInstance().setProperty("eureka.awsAccessId", "fakeId");
    ConfigurationManager.getConfigInstance().setProperty("eureka.awsSecretKey", "fakeKey");
    AmazonInfo dataCenterInfo = mock(AmazonInfo.class);
    EurekaServerConfig serverConfig = new DefaultEurekaServerConfig();
    InstanceInfo.Builder builder = InstanceInfo.Builder.newBuilder();
    builder.setIPAddr("10.10.101.00");
    builder.setHostName("fakeHost");
    builder.setAppName("fake-" + UUID.randomUUID());
    builder.setLeaseInfo(LeaseInfo.Builder.newBuilder().build());
    builder.setDataCenterInfo(dataCenterInfo);
    instanceInfo = builder.build();
    applicationInfoManager = new ApplicationInfoManager(new MyDataCenterInstanceConfig(), instanceInfo);
    DefaultEurekaClientConfig clientConfig = new DefaultEurekaClientConfig();
    // setup config in advance, used in initialize converter
    client = mock(DiscoveryClient.class);
    registry = mock(PeerAwareInstanceRegistry.class);
    awsAsgUtil = spy(new AwsAsgUtil(serverConfig, clientConfig, registry));
}
Also used : DefaultEurekaClientConfig(com.netflix.discovery.DefaultEurekaClientConfig) DefaultEurekaServerConfig(com.netflix.eureka.DefaultEurekaServerConfig) MyDataCenterInstanceConfig(com.netflix.appinfo.MyDataCenterInstanceConfig) AwsAsgUtil(com.netflix.eureka.aws.AwsAsgUtil) DefaultEurekaServerConfig(com.netflix.eureka.DefaultEurekaServerConfig) EurekaServerConfig(com.netflix.eureka.EurekaServerConfig) DiscoveryClient(com.netflix.discovery.DiscoveryClient) AmazonInfo(com.netflix.appinfo.AmazonInfo) InstanceInfo(com.netflix.appinfo.InstanceInfo) ApplicationInfoManager(com.netflix.appinfo.ApplicationInfoManager) PeerAwareInstanceRegistry(com.netflix.eureka.registry.PeerAwareInstanceRegistry) Before(org.junit.Before)

Example 5 with EurekaServerConfig

use of com.netflix.eureka.EurekaServerConfig in project eureka by Netflix.

the class ClusterSampleData method newEurekaServerConfig.

public static EurekaServerConfig newEurekaServerConfig() {
    EurekaServerConfig config = mock(EurekaServerConfig.class);
    // Cluster management related
    when(config.getPeerEurekaNodesUpdateIntervalMs()).thenReturn((int) EUREKA_NODES_UPDATE_INTERVAL_MS);
    // Replication logic related
    when(config.shouldSyncWhenTimestampDiffers()).thenReturn(true);
    when(config.getMaxTimeForReplication()).thenReturn((int) REPLICATION_EXPIRY_TIME_MS);
    when(config.getMaxElementsInPeerReplicationPool()).thenReturn(10);
    when(config.getMaxElementsInStatusReplicationPool()).thenReturn(10);
    when(config.getMaxThreadsForPeerReplication()).thenReturn(1);
    when(config.getMaxThreadsForStatusReplication()).thenReturn(1);
    return config;
}
Also used : EurekaServerConfig(com.netflix.eureka.EurekaServerConfig)

Aggregations

EurekaServerConfig (com.netflix.eureka.EurekaServerConfig)7 ApplicationInfoManager (com.netflix.appinfo.ApplicationInfoManager)3 DefaultEurekaServerConfig (com.netflix.eureka.DefaultEurekaServerConfig)3 PeerAwareInstanceRegistry (com.netflix.eureka.registry.PeerAwareInstanceRegistry)3 InstanceInfo (com.netflix.appinfo.InstanceInfo)2 DefaultEurekaClientConfig (com.netflix.discovery.DefaultEurekaClientConfig)2 EurekaClientConfig (com.netflix.discovery.EurekaClientConfig)2 DefaultServerCodecs (com.netflix.eureka.resources.DefaultServerCodecs)2 Before (org.junit.Before)2 AmazonInfo (com.netflix.appinfo.AmazonInfo)1 MyDataCenterInstanceConfig (com.netflix.appinfo.MyDataCenterInstanceConfig)1 DiscoveryClient (com.netflix.discovery.DiscoveryClient)1 Application (com.netflix.discovery.shared.Application)1 Applications (com.netflix.discovery.shared.Applications)1 EurekaTransportConfig (com.netflix.discovery.shared.transport.EurekaTransportConfig)1 EurekaServerContext (com.netflix.eureka.EurekaServerContext)1 AwsAsgUtil (com.netflix.eureka.aws.AwsAsgUtil)1 PeerEurekaNode (com.netflix.eureka.cluster.PeerEurekaNode)1 PeerEurekaNodes (com.netflix.eureka.cluster.PeerEurekaNodes)1 ServerCodecs (com.netflix.eureka.resources.ServerCodecs)1