You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+21-18Lines changed: 21 additions & 18 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -3,8 +3,8 @@
3
3
This plugin for the [Cloud Foundry Command Line](https://github.com/cloudfoundry/cli) provides convenience utilities to work with Java applications deployed on Cloud Foundry.
4
4
5
5
Currently, it allows to:
6
-
* Trigger and retrieve a heap-dump from an instance of a Cloud Foundry Java application
7
-
* Trigger and retrieve a thread-dump from an instance of a Cloud Foundry Java application
6
+
* Trigger and retrieve a heapdump from an instance of a Cloud Foundry Java application
7
+
* Trigger and retrieve a threaddump from an instance of a Cloud Foundry Java application
8
8
9
9
## Installation
10
10
@@ -25,7 +25,7 @@ On Windows, the plugin will refuse to install unless the binary has the `.exe` f
25
25
26
26
<pre>
27
27
NAME:
28
-
java - Obtain a heap-dump or thread-dump from a running, Diego-enabled, SSH-enabled Java application
28
+
java - Obtain a heapdump or threaddump from a running, Diego-enabled, SSH-enabled Java application
29
29
30
30
USAGE:
31
31
cf java [heap-dump|thread-dump] APP_NAME
@@ -36,12 +36,12 @@ OPTIONS:
36
36
-keep -k, keep the heap dump in the container; by default the heap dump will be deleted from the container's filesystem after been downloaded
37
37
</pre>
38
38
39
-
The heap-dump or thread-dump (depending on what you execute) will be outputted to `std-out`.
39
+
The heapdump or threaddump (depending on what you execute) will be outputted to `std-out`.
40
40
You may want to redirect the command's output to file, e.g., by executing:
The `-k` flag is invalid when invoking `cf java thread-dump`.
44
-
(Unlike with heap-dumps, the JVM does not need to output the threaddump to file before streaming it out.)
44
+
(Unlike with heapdumps, the JVM does not need to output the threaddump to file before streaming it out.)
45
45
46
46
## Limitations
47
47
@@ -53,6 +53,13 @@ If `cf java` is having issues connecting to your app, chances are the problem is
53
53
To verify, run your `cf java` command in "dry-run" mode by adding the `-n` flag and try to execute the command line that `cf java` gives you back.
54
54
If it fails, the issue is not in `cf java`, but in whatever makes `cf ssh` fail.
55
55
56
+
The capability of creating heap dumps is also limited by the filesystem available to the container.
57
+
The `cf java heap-dump` command triggers the heap dump to file system, read the content of the file over the SSH connection, and then remove the heap dump file from the container's file system (unless you have the `-k` flag set).
58
+
The amount of filesystem space available to a container is set for the entire Cloud Foundry landscape with a global configuration.
59
+
The size of a heap dump is roughly linear with the allocated memory of the heap.
60
+
So, it could be that, in case of large heaps or the filesystem having too much stuff in it, there is not enough space on the filesystem for creating the heap dump.
61
+
In that case, the creation of the heap dump and thus the command will fail.
62
+
56
63
From the perspective of integration in workflows and overall shell-friendliness, the `cf java` plugin suffers from some shortcomings in the current `cf-cli` plugin framework:
57
64
* There is no distinction between `stdout` and `stderr` output from the underlying `cf ssh` command (see [this issue on the `cf-cli` project](https://github.com/cloudfoundry/cli/issues/1074))
58
65
* The `cf java` will however exit with status code `1` when the underpinning `cf ssh` command fails
@@ -62,26 +69,22 @@ From the perspective of integration in workflows and overall shell-friendliness,
62
69
63
70
## Side-effects on the running instance
64
71
65
-
Executing a thread-dump via the `cf java` command does not have much of an overhead on the affected JVM.
72
+
Executing a threaddump via the `cf java` command does not have much of an overhead on the affected JVM.
66
73
(Unless you have **a lot** of threads, that is.)
67
74
68
-
Heap-dumps, on the other hand, have to be treated with a little more care.
69
-
First of all, triggering the heap-dump of a JVM makes the latter execute in most cases a full garbage collection, which will cause your JVM to become unresponsive for the duration.
70
-
How much time is needed to execute the heap-dump, depends on the size of the heap (the bigger, the slower), the algorithm used and, above all, whether your container is swapping memory to disk or not (swap is *bad* for the JVM).
75
+
Heapdumps, on the other hand, have to be treated with a little more care.
76
+
First of all, triggering the heapdump of a JVM makes the latter execute in most cases a full garbage collection, which will cause your JVM to become unresponsive for the duration.
77
+
How much time is needed to execute the heapdump, depends on the size of the heap (the bigger, the slower), the algorithm used and, above all, whether your container is swapping memory to disk or not (swap is *bad* for the JVM).
71
78
Since Cloud Foundry allows for over-commit in its cells, it is possible that a container would begin swapping when executing a full garbage collection.
72
79
(To be fair, it could be swapping even *before* the garbage collection begins, but let's not knit-pick here.)
73
80
So, it is theoretically possible that execuing a heap dump on a JVM in poor status of health will make it go even worse.
74
81
75
-
Secondly, JVMs output heap dumps to the filesystem.
76
-
What the `cf java heap-dump` command does it, quite literally, trigger the heap dump to file system, read the content of the file over the SSH connection, and then remove the heap dump file from the container's file system (unless you have the `-k` flag set).
77
-
The amount of filesystem space available to a container is set for the entire Cloud Foundry landscape with a global configuration.
78
-
The size of a heap dump is linear with the size of the heap.
79
-
So, it could be that, in case of large heaps or the filesystem having too much stuff in it, there is not enough space on the filesystem for creating the heap dump.
80
-
In that case, the command will likely fail in a rather unpredictable fashion.
82
+
Secondly, as the JVMs output heap dumps to the filesystem, creating a heap dump may lead to to not enough space on the filesystem been available for other tasks (e.g., temp files).
83
+
In that case, the application in the container may suffer unexpected errors.
81
84
82
85
## Tests and Mocking
83
86
84
-
The tests are written using [Ginkgo](https://onsi.github.io/ginkgo/)and[Gomega](https://onsi.github.io/gomega/) for the BDD structure, and [Counterfeit](https://github.com/maxbrunsfeld/counterfeiter) for the mocking generation.
85
-
Unless modifications are needed to the helper interfaces `cmd.CommandExecutor` and `uuid.UUIDGenerator` are needed, there should be no need to regenerate the mocks.
87
+
The tests are written using [Ginkgo](https://onsi.github.io/ginkgo/)with[Gomega](https://onsi.github.io/gomega/) for the BDD structure, and [Counterfeiter](https://github.com/maxbrunsfeld/counterfeiter) for the mocking generation.
88
+
Unless modifications to the helper interfaces `cmd.CommandExecutor` and `uuid.UUIDGenerator` are needed, there should be no need to regenerate the mocks.
86
89
87
-
To run the tests, go to the root of the repository and simply run `gingko` (you may need to install the package, e.g., `sudo apt install golang-ginkgo-dev` on Ubuntu).
90
+
To run the tests, go to the root of the repository and simply run `gingko` (you may need to install Ginkgo first, e.g., `go get github.com/onsi/ginkgo/ginkgo` puts the executable under `$GOPATH/bin`).
0 commit comments