Skip to main content
In this recipe we’ll learn how to automatically schedule Apache Pinot’s Real-Time to Offline job. This job is used to transition data from real-time to offline tables. For background reading on the use case for doing this, see Managed Offline Flow.

Prerequisites

To follow the code examples in this guide, you must install Docker locally and download recipes.
  1. If you haven’t already, download recipes.
  2. In terminal, go to the recipe by running the following command:

Launch Pinot Cluster

You can spin up a Pinot Cluster by running the following command:
This command will run a single instance of the Pinot Controller, Pinot Server, Pinot Broker, Pinot Minion, Kafka, and Zookeeper. You can find the docker-compose.yml file on GitHub.

Controller configuration

We need to provide configuration parameters to the Pinot Controller to have the Real-Time to Offline job (RT2OFF) run automatically. This is done in the following section of the Docker Compose file:
The configuration is specified in /config/controller-conf.conf, the contents of which are shown below:
/config/controller-conf.conf We’re particularly interested in the last two lines:
  • controller.task.scheduler.enabled=true enables the automatic running of the RT2OFF job
  • controller.task.frequencyPeriod=5m configures it to run every 5 minutes

Pinot Schema and Tables

Now let’s create a Pinot Schema, as well as real-time and offline tables. Pinot is going to take care of populating data into the offline table, but it still expects us to configure the table.

Schema

Our schema is going to capture some simple events, and looks like this:
config/schema.json You can create the schema by running the following command:

Offline Table

The offline table config is defined below:
config/table-offline.json You can create the table by running the following command:

Real-Time Table

And the real-time table is defined below:
config/table-realtime.json
The realtime.segment.flush.threshold.rows config is intentionally set to an extremely small value so that the segment will be committed after 10,000 records have been ingested. In a production system this value should be set much higher, as described in the configuring segment threshold guide.
The main thing that we’re interested in is the RealtimeToOfflineSegmentsTask, which is extracted below:
This configuration enables the job and defines what should happen when it runs. The schedule parameter indicates when this task will be run. The value is a Quartz Cron expression and in this case we have the job running once a minute.
The values for bufferTimePeriod and bucketTimePeriod, and schedule are intentionally set to very low values so that it’s easier to see how they work.In a production setup, bufferTimePeriod and bucketTimePeriod would usually be set to a time of 1 day or more, and schedule could be set to run once a day.
For a breakdown of all the parameters that can be defined for the RealtimeToOfflineSegmentsTask, see the Manually scheduling real-time to offline job guide.
You can create the table by running the following command:

Ingesting Data

Let’s ingest data into the events Kafka topic, by running the following:
Data will make its way into the real-time table. We can see how many records have been ingested by running the following query:

Checking that the job is running

We can check that the job is running by querying the logs on the Pinot Controller, as shown below:
We should see the following output:
When the job can’t create any new segments for the offline table it will instead output the following:
or
If you see these messages often, it might make sense to reduce the frequency of the RT2OFF job.