Skip to Content

The latest update of SAP HANA Cloud Platform is probably the biggest so far in terms of number of released features – one can count as many as 20 entries in the Release Notes for SAP HANA Cloud Platform on 19 December 2013. So it is quite possible that amongst all the great stuff like WebSocket support and SDK artifacts in Maven Central, you might have missed some “smaller” features. But what does “smaller” actually mean? A feature is as big as your need and demand for it, isn’t it? 😉 In this blog post I’d like to bring to your attention and show how you can use some of those features. It’s about several capabilities and methods for troubleshooting Java applications on SAP HCP that were made available recently.

Debugging

Connecting a debugger and inspecting the runtime state and behavior of an applications is one of the most common techniques used when the application behaves erroneously or not as expected. Unfortunately, it’s not so common feature of cloud platforms – mainly because the combination of the really verbose JDWP debug protocol and remote network latency makes for a miserable user experience and renders it practically unusable. Well, it’s not the case with HANA Cloud Platform. You can debug your application on the cloud and have (almost) the same experience as if it’s running on your local machine!

It’s that simple. In the Eclipse IDE set the breakpoints you want. Then right click on the class (e.g. MyServlet) and from the context menu select Debug As > Debug on Server:

/wp-content/uploads/2014/01/debug_on_server_359454.png

In the wizard that opens, choose a cloud server or create a new one, and when it gets started the execution will stop at the breakpoint and you’ll be able to examine contents of variables, step through the code and do all the usual debugging tasks:

/wp-content/uploads/2014/01/debug_perspective_359455.png

And what’s even better – since cloud servers are running on SAP JVM, if your server has already been started it will not restart when switching to debug mode, and you’ll just see its state changing from Started to Debugging in the Servers view. How cool is that? 😎

Profiling

OK, you have identified and fixed the functional errors in your application but you are still not that happy as there are also resource-related problems – e.g. it might consume a lot of memory, or execution of certain operations could take more time than set in the requirements. You know you have to find the root cause for these issues and optimize, but you have no clue where to start from? Well, here the SAP JVM Profiler comes to help. It’s a very handy tool that allows you to do exactly those kinds of analysis and it’s now integrated with SAP HCP.

To start the Profiler, go to the Servers view and from the server context menu choose Profile (if the server is stopped) or Restart in Profile (if it is started):

/wp-content/uploads/2014/01/restart_in_profile_359477.png

Note again that if the server is started it will not actually restart but just the Profiler will be attached to it and its state will change to Profiling. When it changes, the profiling session will be also open in the editor space:

/wp-content/uploads/2014/01/profiling_0_359478.png

Now open or switch to the Profiling perspective (currently, it cannot be switched automatically and you have to do this manually):

/wp-content/uploads/2014/01/profiling_1_359479.png

From here, you can start several different types of analysis. For example, if you want to optimize memory consumption, you can start Allocation Analysis to find the largest objects and the methods where they have been allocated. After you have started the analysis, trigger some work load on your application and create snapshots of the profiling data:

/wp-content/uploads/2014/01/profiling_alloc_snapshot_359480.png

Now you can analyze the results and do all different kinds of drill-downs into it:

/wp-content/uploads/2014/01/profiling_alloc_objects_359481.png

For more information about the available analysis options (including examples and tutorials), consult the SAP JVM Profiler documentation in the Eclipse IDE by going to Help > Help Contents > SAP JVM Profiler.

When you have finished with the profiling session, you can stop it either by selecting Disconnect from its context menu in the Profile view or by clicking on the corresponding button in the top right corner:

/wp-content/uploads/2014/01/profiling_disconnect_359482.png

Logging

Logging related features (managing log levels and retrieving log files) have been around for quite some time, but with the latest platform update a new convenience functionality was added. Imagine that as part of the troubleshooting process you have changed multiple log levels for your application. Now that you have identified and fixed the issues, you would like to revert them back to their initial state so that redundant logs are not written any longer. To achieve that, you can use the new reset-log-levels console client command:

/wp-content/uploads/2014/01/reset_log_levels_359498.png

Restart is required because once created Log4j loggers cannot be removed while the JVM is running. After a restart, the custom loggers above are not present in the output of the list-loggers command:

/wp-content/uploads/2014/01/list_loggers_359499.png

Final Words

I hope you find this overview and the presented features helpful. Have fun coding and troubleshooting with SAP HANA Cloud Platform! And do let us know if you have any feedback or questions.

To report this post you need to login first.

15 Comments

You must be Logged on to comment or reply to a post.

  1. Nikolay Dimitrov

    Thanks for posting Vlado !

    Let me ask for clarification on these :

    – is this the regular Eclipse with some specific plugins for debugging

    – is the debugging protocol JDWP

    Regards

    (0) 
    1. Vladimir Pavlov Post author

      Thanks for your interest, Niki!

      – is this the regular Eclipse with some specific plugins for debugging

      Yes, regular Eclipse with SAP HCP plugins from https://tools.hana.ondemand.com/

      – is the debugging protocol JDWP

      No, JDWP is too talkative and, as I mentioned, the latency in network communication between the user’s machine and the cloud “makes for a miserable user experience and renders it practically unusable“. Therefore, this debugging feature of SAP HCP is exceptional as “you can debug your application on the cloud and have (almost) the same experience as if it’s running on your local machine!” 🙂

      Cheers,

      –Vlado

      (0) 
  2. Ashok Babu Kumili

    Hello Vladimir Pavlov,

    Thank you so much for this blog. This is very cool. I specifically love that it is SOLUTION oriented. This is so organised and well described.

    Regards

    Ashok

    (0) 
  3. Pranjal Jain

    Hi Vladimir Pavlov,

    While trying debugging on HCP server from eclipse as you suggested, it gives me error saying “unable to launch a cloud debugging session”. Can you help me with this issue?

    Thanks & Best Regards,

    Pranjal

    (0) 

Leave a Reply