You can translate the document:

Goal

The aim of this document is to provide guidance and advice on how to debug Denodo custom extensions using IntelliJ IDEA.

Debugging custom extensions

Denodo provides a series of APIs that allow users to develop their own Denodo extensions using Java code. This increases the flexibility of Denodo allowing the user to implement their own business logic or custom connectors to not supported sources.

These APIs allow:

  • Creating Denodo Virtual DataPort (VDP) custom functions, stored procedures, custom input filters, custom policies or custom wrappers. The Virtual DataPort Developer Guide section of the documentation describes the steps to create these artifacts.
  • Creating Scheduler custom exporters or custom handlers. Refer to the Scheduler Developer API to find further information about Scheduler extensions.

When developing any code, having debugging capability is one of the most important tools to create code and find errors as it allows the developer to check how the code is working step by step.

So the question is, how can a Denodo custom extension be debugged? We have different alternatives.

In this article we describe how to debug Denodo Extensions using IntelliJ IDEA.

Debug Denodo projects using IntelliJ IDEA

Enabling a project to be debugged is very easy, but let’s look at it with an example.

We can use for this article a predefined Maven project with a very simple “Hello World” custom function.

The code is very simple and it is out of the scope of this article. You can learn more about how to develop custom elements for Denodo in  the Virtual DataPort Developer Guide.

package com.denodo.vdp;

import org.apache.logging.log4j.Logger;

import org.apache.logging.log4j.LogManager;

import com.denodo.common.custom.annotations.CustomElement;

import com.denodo.common.custom.annotations.CustomElementType;

import com.denodo.common.custom.annotations.CustomExecutor;

import com.denodo.common.custom.annotations.CustomExecutorReturnType;

@CustomElement(type=CustomElementType.VDPFUNCTION, name="helloworld")

public class HelloWorld {    

    private static final Logger logger = LogManager.getLogger(HelloWorld.class);

   

    /**

     * This method is invoked when the custom function is executed

     *

     * @param input parameters

     *

     * @return custom value

     */

    @CustomExecutor

    public String execute () {

       

        logger.debug("Executing Custom Function");

        String hello = "Hello World!";

        return hello;

    }

   

    /**

     * This method is invoked to compute the return type before executing the function.

     * If the execute method returns a simple Java type, this method is not needed.

     *

     * @param type for execute method input parameters

     *

     * @return custom type that execute method will return

     */

    @CustomExecutorReturnType

    public Class<String> executeReturnType () {

       

        logger.debug("Getting Custom Function return type");

       

        return String.class;

    }  

}

This custom function, once deployed to VDP, just returns a text column with the value “Hello World!”.

Obviously, this code is easy to understand and does not require much debugging but, what if your code is more complex? How could we debug a complex component?

In order to do it, we need to configure two different things.

  1. The VDP server. We will need to enable our VDP server to be able to listen through a port to debug our extensions once they are deployed.
  2. Enable your IntelliJ IDEA to connect to the VDP debug port defined above.

Enabling Debugging options in the Denodo VDP Server

From the Denodo Platform Control Center, go to Configure > JVM Options.

There, we have to append the following settings for the Virtual DataPort Server.

 

 -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=0.0.0.0:1099

NOTE: we are using the port 1099 for this example but any free port could be used.

Click on “Ok” and “Apply” to persist the new settings, then restart the VDP server.

If using a headless installation and the Denodo Platform Control Center is not available, include the aforementioned settings following these steps.

  1. Open the <DENODO_HOME>/conf/vdp/VDBConfiguration.properties file.
  2. Find the java.env.DENODO_OPTS_START property and append the settings -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=0.0.0.0:1099 to the current values.

  1. Save the file.
  2. For the changes to take effect run the <DENODO_HOME>/bin/regenerateFiles.(bat/sh)script.
  3. Restart the VDP server.

NOTE: Adding this parameter to the JVM may have effects in the performance of the JVM. It is not recommended to modify the configuration in this way in production environments.

Once the server is started, it will be ready to listen to IDEs trying to connect and debug a custom extension.

Enabling Debugging options in IntelliJ

From IntelliJ, go to Run > Edit Configurations Click on Add new configurations and select ¨Remote JVM Debug¨ from the list.

IntelliJ will automatically fill the fields, make sure that they match the following specifications:

  • Name: a recognizable name, such as Denodo VDP Debug.
  • Debugger mode: Attach to remote JVM.
  • Transport: “Socket”.
  • Host: the hostname configured in the VDP JVM options.
  • Port: the port defined as the entry point in the VDP JVM options.
  • Use module classpath: make sure to select your project.

Click Apply and then OK.

Open the Java class and define a breakpoint in the line you want to debug. In our example, we are going to set one on line 29.

In order to test it, go to Run > Debug <Configuration name> or press Shift + F9.

The console will display the message Connected to the target VM, address: 'localhost:1099', transport: 'socket'

Go to the Denodo Web Design Studio to test it by running a simple query in a VQL Shell such as “select helloworld()”.

Note: Any changes to the lines of code, like creating a breakpoint, require regenerating the JAR file and re-importing it into Denodo. Otherwise, the breakpoint will appear as 'not executable' because the two versions do not match.

As you can see, the data is displayed alongside the variables. Additionally, you can “step over” to see how these variables change line by line to help you debug the code.

References

Virtual DataPort Developer Guide

Scheduler Developer API

Importing Extensions

Disclaimer

The information provided in the Denodo Knowledge Base is intended to assist our users in advanced uses of Denodo. Please note that the results from the application of processes and configurations detailed in these documents may vary depending on your specific environment. Use them at your own discretion.

For an official guide of supported features, please refer to the User Manuals. For questions on critical systems or complex environments we recommend you to contact your Denodo Customer Success Manager.
Recommendation

Questions

Ask a question

You must sign in to ask a question. If you do not have an account, you can register here