The Realtime Compute development platform provides you with a local debugging environment. You can upload custom data, simulate job running, and check output results in the local debugging environment to make sure the business logic is valid.

Characteristics

The local debugging environment is completely isolated from the production environment. In the local debugging environment, all Flink SQL jobs are run in an independent debugging container, and the debugging results are displayed on the corresponding page in the debugging environment. Therefore, local debugging does not affect online production streams, online Realtime Compute jobs, or online data storage systems.
Note In the debugging mode of Realtime Compute, running failures caused by incompatible data formats in data storage resources cannot be detected. For example, the debugging process cannot detect whether the output data length has exceeded the maximum data length specified when the RDS table was created.

Procedure

Note Before debugging a job, make sure that you have developed the job. For more information about how to develop a job, see Procedure.
  1. In the job editing section, click Debug at the top.
  2. On the Debug File page that appears, enter the test data. In the local debugging mode, you can obtain test data by using either of the following two methods:
    • Upload local data
      1. In the data preview section, click Download Template.
      2. Customize debugging data according to the template.
        Note By default, the debugging data uses a comma (,) as the delimiter. For more information about how to customize a delimiter, see Delimiter.
      3. In the Data Preview section, click Upload and upload the custom debugging data.
    • Sample online data
      Note Before using the sequential online data sampling feature, make sure that the data source includes data in the sampling process.
      1. In the data preview section, click Random Online Data Sampling or Sequential Online Data Sampling.
      2. Enter the sample configuration information.
      3. Click OK.
    Note After the data is obtained, you can view the data in the data preview section.
  3. Click OK.
  4. At the bottom of the job editing section, view the debugging results.

Delimiter

By default, the debugging data uses a comma (,) as the delimiter. If the input data, such as a JSON file, already contains commas (,), you must define other characters, such as a vertical bar (|), as the delimiter for debugging data.

Note Realtime Compute only allows you to use a single character, such as a vertical bar (|), as the delimiter. You cannot use a string, such as aaa, as the delimiter.
To configure the debugging data delimiters, follow these steps:
Note Before configuring the delimiter for debugging data, make sure that you have developed a job. For more information about how to develop a job, see Procedure.
  1. On the right of the job editing page, click Parameters.
  2. In the job parameter editing section, enter the configuration of the debugging data delimiter. The following code specifies a vertical bar (|) as the delimiter:
    debug.input.delimiter = |

UDX logs

  • Display UDX logs generated during local debugging
    In Java, follow these steps to convert the log format to one that can be resolved by Realtime Compute and display the user-defined extension (UDX) logs generated during local debugging:
    public static void debugMsgOutput(String msg) {
        System.out.println(
          String.format("{\"type\":\"log\",\"level\": \"INFO\", \"time\": \"%s\", \"message\": \"%s\", \"throwable\": \"null\"}\n",new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()), msg));
    }
  • View UDX logs
    After debugging is complete, you can view the UDX logs on the Completed tab at the bottom of the job editing section.
    Note You can press Ctrl+F and search for the corresponding logs.