0

I have a Spring Boot app that I am using to start a Pivotal GemFire CacheServer.

When I jar up the file and run it locally:

java -jar gemfire-server-0.0.1-SNAPSHOT.jar 

It runs fine without issue. The server is using the default properties

spring.data.gemfire.cache.log-level=info
spring.data.gemfire.locators=localhost[10334]
spring.data.gemfire.cache.server.port=40404
spring.data.gemfire.name=CacheServer
spring.data.gemfire.cache.server.bind-address=localhost
spring.data.gemfire.cache.server.host-name-for-clients=localhost

If I deploy this to a Centos distribution and run it with the same script but passing the "test" profile:

java -jar gemfire-server-0.0.1-SNAPSHOT.jar -Dspring.profiles.active=test

with my test profile application-test.properties looking like this:

spring.data.gemfire.cache.server.host-name-for-clients=server.centralus.cloudapp.azure.com

I can see during startup that the server finds the Locator already running on the host (I start it through a separate process with Gfsh).

enter image description here

The server even joins the cluster for about a minute. But then it shuts down because of a bind exception.

enter image description here

I have checked to see if there is anything running on that port (40404) - and nothing shows up

enter image description here

EDIT

Apparently I DO get this exception locally - it just takes a lot longer.

It is almost instant when I start it up on the Centos distribution. On my Mac it takes around 2 minutes before the process throws the exception:

enter image description here

Adding a few more images of this:

Two bash windows - left is monitoring GF locally and right I use to check the port and start the Java process:

enter image description here

The server is added to the cluster. Note the timestamp of 16:45:05.

Here is the server added and it appears to be running:

enter image description here

Finally, the exception after about two minutes - again look at the timestamp on the exception - 16:47:09. The server is stopped and dropped from the cluster.

enter image description here

John Blum
  • 7,381
  • 1
  • 20
  • 30
JDBennett
  • 1,323
  • 17
  • 45

1 Answers1

0

Did you start other servers using Gfsh? That is, with a Gfsh command similar to...

gfsh>start server --name=ExampleGfshServer --log-level=config

Gfsh will start CacheServers listening on the default CacheServer port of 40404.

You have a few options.

1) First, you can disable the default CacheServer when starting a server with Gfsh like so...

gfsh>start server --name=ExampleGfshServer --log-level=config --disable-default-server

2) Alternatively, you can change the CacheServer port when starting other servers using Gfsh...

gfsh>start server --name=ExampleGfshServer --log-level=config --server-port=50505

3) If you are starting multiple instances of your Spring Boot, Pivotal GemFire CacheServer class, then you can vary the spring.data.gemfire.cache.server.port property by declaring the property as a System property when you startup.

For instance, you can, in the Spring Boot application.properties, do...

#application.properties
...
spring.data.gemfire.cache.server.port=${gemfire.cache.server.port:40404}

And then when starting the application from the command-line...

java -Dgemfire.cache.server.port=48484 -jar ...

Of course, you could just set the SDG property from the command line too...

java -Dspring.data.gemfire.cache.server.port=48484 --jar ...

Anyway, I guarantee you that you have another process (e.g. Pivotal GemFire CacheServer) with a ServerSocket listening on port 40404, running. netstat -a | grep 40404 should give you better results.

Hope this helps.

Regards, John

John Blum
  • 7,381
  • 1
  • 20
  • 30
  • I just doubled checked. Nothing is running on 40404 before I start the java process. I added in a few screen shots above to show you my terminal output. I have the locator running before I start the java process. The java process starts and I see the server added to the cluster. It takes about two minutes (locally) - and then the exception is thrown. – JDBennett Aug 08 '18 at 21:50
  • Well, most certainly something is using this port after GemFire attempts to start a `CacheServer` instance in your Spring Boot, GemFire server application. Perhaps using `jps` on the machine where you are running the Spring Boot app will reveal what other JVM processes are running. If you could also share your source code (as a GitHub repo) that would be helpful. Thanks. – John Blum Aug 09 '18 at 16:54
  • Observing that you also posted this question yesterday (https://stackoverflow.com/questions/51737079/spring-boot-gemfire-server-configuration) are you still using the `spring-boot-gemfire-server-example` app (https://github.com/jxblum/spring-boot-gemfire-server-example) in your testing/experimenting? Have you modified this code in anyway? Again, please share a repo with your code/fork, whatever. – John Blum Aug 09 '18 at 17:07