MCPcopy Create free account
hub / github.com/cloudfoundry/java-buildpack / getHeapDumpPath

Method getHeapDumpPath

src/java/jres/jvmkill.go:189–219  ·  view source on GitHub ↗

getHeapDumpPath checks for volume service with heap-dump tag and returns path

()

Source from the content-addressed store, hash-verified

187
188// getHeapDumpPath checks for volume service with heap-dump tag and returns path
189func (j *JVMKillAgent) getHeapDumpPath() string {
190 // Check VCAP_SERVICES for volume service with heap-dump tag
191 vcapServices, err := common.GetVCAPServices()
192 if err != nil {
193 return ""
194 }
195
196 // Look for volume service with "heap-dump" tag
197 for _, services := range vcapServices {
198 for _, service := range services {
199 if service.HasTag("heap-dump") {
200 // Extract volume mount path from credentials
201 if volumeMounts, ok := service.Credentials["volume_mounts"].([]interface{}); ok && len(volumeMounts) > 0 {
202 if mount, ok := volumeMounts[0].(map[string]interface{}); ok {
203 if containerDir, ok := mount["container_dir"].(string); ok {
204 // Build heap dump path
205 // Format: /container/dir/space-id/app-id/instance-index.hprof
206 appDetails := j.getAppDetails()
207 return filepath.Join(containerDir,
208 appDetails.spaceID,
209 appDetails.appID,
210 "$CF_INSTANCE_INDEX-%FT%T%z-${CF_INSTANCE_GUID:0:8}.hprof")
211 }
212 }
213 }
214 }
215 }
216 }
217
218 return ""
219}
220
221// appDetails holds application identification info
222type appDetails struct {

Callers 1

FinalizeMethod · 0.95

Calls 3

getAppDetailsMethod · 0.95
GetVCAPServicesFunction · 0.92
HasTagMethod · 0.45

Tested by

no test coverage detected