These are chat archives for spring-cloud/spring-cloud

18th
Jan 2016
lewis-ing
@lewis-ing
Jan 18 2016 10:09
@dsyer So I want to configure eureka "Peer Awareness" according to http://projects.spring.io/spring-cloud/docs/1.0.3/spring-cloud.html,So I don't know how to configure,do you sample to me?
lewis-ing
@lewis-ing
Jan 18 2016 10:30
So I clone code from https://github.com/dsyer/eureka,I change to the configuration of application.yml

server:
port: 8761

eureka:
client:
registerWithEureka: false
fetchRegistry: false
server:
waitTimeInMsWhenSyncEmpty: 0


spring:
profiles: peer # not standalone
server:
port: 8762
eureka:
instance:
hostname: 127.0.0.1
client:
registerWithEureka: true
fetchRegistry: true
serviceUrl:
defaultZone: http://127.0.0.1:8762/eureka/


spring:
profiles: other # not standalone
server:
port: 8762
eureka:
instance:
hostname: 127.0.0.1
nonSecurePort: ${server.port}
client:
serviceUrl:
defaultZone: http://127.0.0.1:8761/eureka/

server:
port: 8762

eureka:
client:
registerWithEureka: false
fetchRegistry: false
server:
waitTimeInMsWhenSyncEmpty: 0


spring:
profiles: peer # not standalone
server:
port: 8762
eureka:
instance:
hostname: 127.0.0.1
client:
registerWithEureka: true
fetchRegistry: true
serviceUrl:
defaultZone: http://127.0.0.1:8762/eureka/


spring:
profiles: other # not standalone
server:
port: 8762
eureka:
instance:
hostname: 127.0.0.1
nonSecurePort: ${server.port}
client:
serviceUrl:
defaultZone: http://127.0.0.1:8761/eureka/

So I start 2 server for EurekaApplication and EurekaApplication2
but I got error info:
c.n.eureka.resources.StatusResource : Could not determine if the replica is available
java.lang.NullPointerException: null
at com.netflix.eureka.resources.StatusResource.isReplicaAvailable(StatusResource.java:90)
at com.netflix.eureka.resources.StatusResource.getStatusInfo(StatusResource.java:70)
at org.springframework.cloud.netflix.eureka.server.EurekaController.status(EurekaController.java:63)
Dave Syer
@dsyer
Jan 18 2016 10:32
Please use markdown to format your code snippets
I can't read the YAML
lewis-ing
@lewis-ing
Jan 18 2016 10:33
blob
Dave Syer
@dsyer
Jan 18 2016 10:33
Thanks. Markdown is still better.
It looks like you are trying to define 2 servers in one app by using Spring profiles.
Did you activate the profiles when you started the apps?
It also looks like the server.port in the peer profile is wrong
lewis-ing
@lewis-ing
Jan 18 2016 10:36
no,I only start 2 server and change port
I will try to activate 2 profiles
lewis-ing
@lewis-ing
Jan 18 2016 10:53
So I use 2 profiles and start,and still got error,
server:
  port: 8761

eureka:
  client:
    registerWithEureka: false
    fetchRegistry: false
  server:
    waitTimeInMsWhenSyncEmpty: 0

---
spring:
  profiles: peer # not standalone
server:
  port: 8762
eureka:
  instance:
    hostname: 127.0.0.1
  client:
    registerWithEureka: true
    fetchRegistry: true
    serviceUrl:
      defaultZone: http://127.0.0.1:8762/eureka/

---
spring:
  profiles: other # not standalone
server:
  port: 8762
eureka:
  instance:
    hostname: 127.0.0.1
    nonSecurePort: ${server.port}
  client:
    serviceUrl:
      defaultZone: http://127.0.0.1:8761/eureka/
@ComponentScan
@Configuration
@EnableAutoConfiguration
@EnableEurekaServer
@EnableEurekaClient
@Profile("peer")
public class EurekaApplication {

    public static void main(String[] args) {
        SpringApplication.run(EurekaApplication.class, args);
    }

}
Dave Syer
@dsyer
Jan 18 2016 10:54
Did you see where I said above that the port is wrong in the "peer"?
Also adding @Profile("peer") switches all that off if you don't run in that profile
Maybe you need to read up on Spring Profiles a bit?
lewis-ing
@lewis-ing
Jan 18 2016 10:56
I only start EurekaApplication server and don't switches
org.springframework.context.ApplicationContextException: Unable to start embedded container; nested exception is org.springframework.context.ApplicationContextException: Unable to start EmbeddedWebApplicationContext due to missing EmbeddedServletContainerFactory bean.
Dave Syer
@dsyer
Jan 18 2016 11:12
That's because you switched off the autoconfig with the @Profile
You need to
1) remove that @Profile
2) fix the server.port in the "peer" (remove it and go back to the default)
3) launch your apps with spring.profiles.active=peer and spring.profiles.active=other
(e.g. for 3) use a command line argument)
lewis-ing
@lewis-ing
Jan 18 2016 11:14
thx,I fixed it and according to your tips,
It's work
thx
Dave Syer
@dsyer
Jan 18 2016 11:15
NP
Alex Filatov
@sprgn
Jan 18 2016 22:10
I am running eureka server deployed as war on tomcat 8. Upon undeploy, there are a lot of exceptions related to started threads not being able to be killed, and some values on thread local that could not be cleared. Below is my stack trace
2016-01-18 15:53:49.567  INFO 8596 --- [       Thread-9] e.s.EurekaServerInitializerConfiguration : Started Eureka Server
18-Jan-2016 15:54:40.733 INFO [ContainerBackgroundProcessor[StandardEngine[Catalina]]] org.apache.catalina.startup.HostConfig.undeploy Undeploying context [/ws_eureka]
2016-01-18 15:54:40.742  INFO 8596 --- [gine[Catalina]]] ationConfigEmbeddedWebApplicationContext : Closing org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@362c
412: startup date [Mon Jan 18 15:51:12 CST 2016]; parent: org.springframework.context.annotation.AnnotationConfigApplicationContext@1f9529d5
2016-01-18 15:54:40.747  INFO 8596 --- [gine[Catalina]]] o.s.c.support.DefaultLifecycleProcessor  : Stopping beans in phase 0
2016-01-18 15:54:40.758  INFO 8596 --- [gine[Catalina]]] c.n.e.EurekaDiscoveryClientConfiguration : Unregistering application ws_eureka with eureka with status DOWN
2016-01-18 15:54:40.773  INFO 8596 --- [gine[Catalina]]] o.s.c.n.servo.ServoMetricCollector       : Stopping Servo PollScheduler
2016-01-18 15:54:40.776  INFO 8596 --- [gine[Catalina]]] c.n.e.EurekaDiscoveryClientConfiguration : Closing DiscoveryClient.jerseyClient
2016-01-18 15:54:40.777  INFO 8596 --- [gine[Catalina]]] c.n.e.EurekaDiscoveryClientConfiguration : Removing application ws_eureka from eureka
18-Jan-2016 15:54:40.803 WARNING [ContainerBackgroundProcessor[StandardEngine[Catalina]]] org.apache.catalina.loader.WebappClassLoaderBase.clearReferencesThreads The web application [ws_eureka] appear
s to have started a thread named [Thread-8] but has failed to stop it. This is very likely to create a memory leak. Stack trace of thread:
 sun.net.dns.ResolverConfigurationImpl.notifyAddrChange0(Native Method)
 sun.net.dns.ResolverConfigurationImpl$AddressChangeListener.run(ResolverConfigurationImpl.java:144)
18-Jan-2016 15:54:40.806 WARNING [ContainerBackgroundProcessor[StandardEngine[Catalina]]] org.apache.catalina.loader.WebappClassLoaderBase.clearReferencesThreads The web application [ws_eureka] appear
s to have started a thread named [Eureka-EIPBinder] but has failed to stop it. This is very likely to create a memory leak. Stack trace of thread:
 java.lang.Object.wait(Native Method)
 java.lang.Object.wait(Object.java:502)
 java.util.TimerThread.mainLoop(Timer.java:526)
 java.util.TimerThread.run(Timer.java:505)
18-Jan-2016 15:54:40.808 WARNING [ContainerBackgroundProcessor[StandardEngine[Catalina]]] org.apache.catalina.loader.WebappClassLoaderBase.clearReferencesThreads The web application [ws_eureka] appear
s to have started a thread named [Eureka-PeerNodesUpdater] but has failed to stop it. This is very likely to create a memory leak. Stack trace of thread:
 java.lang.Object.wait(Native Method)
 java.util.TimerThread.mainLoop(Timer.java:552)
 java.util.TimerThread.run(Timer.java:505)
18-Jan-2016 15:54:40.814 WARNING [ContainerBackgroundProcessor[StandardEngine[Catalina]]] org.apache.catalina.loader.WebappClassLoaderBase.clearReferencesThreads The web application [ws_eureka] appear
s to have started a thread named [Eureka-EvictionTimer] but has failed to stop it. This is very likely to create a memory leak. Stack trace of thread:
 java.lang.Object.wait(Native Method)
 java.util.TimerThread.mainLoop(Timer.java:552)
 java.util.TimerThread.run(Timer.java:505)
18-Jan-2016 15:54:40.822 WARNING [ContainerBackgroundProcessor[StandardEngine[Catalina]]] org.apache.catalina.loader.WebappClassLoaderBase.clearReferencesThreads The web application [ws_eureka] appear
s to have started a thread named [Eureka-DeltaRetentionTimer] but has failed to stop it. This is very likely to create a memory leak. Stack trace of thread:
 java.lang.Object.wait(Native Method)
 java.util.TimerThread.mainLoop(Timer.java:552)
 java.util.TimerThread.run(Timer.java:505)
18-Jan-2016 15:54:40.823 WARNING [ContainerBackgroundProcessor[StandardEngine[Catalina]]] org.apache.catalina.loader.WebappClassLoaderBase.clearReferencesThreads The web application [ws_eureka] appear
s to have started a thread named [Eureka-MeasureRateTimer] but has fail
Is eureka not meant to be undeployed/redeployed and I need to cycle the tomcat instance?
Spencer Gibb
@spencergibb
Jan 18 2016 22:17
We’ve been aware of that for a while. spring-cloud/spring-cloud-netflix#106