Data Hub Installation Using Recipes

Out-of-the-box, Data Hub has powerful functionality. However, the functionality does not present itself until you add custom extensions. The extensions tell Data Hub what to do with your data. Data Hub does not come with any extensions.

Prerequisites: For additional background or context regarding the following material, see Installing SAP Commerce Cloud Using Installer Recipes.

For the first few times you install Data Hub, SAP Commerce Cloud strongly recommends that you follow the full manual process. The manual process is described in the previous files of this section. Doing so thoroughly familiarizes you with all the different parts of Data Hub and how they interact. Once you are comfortable with the process though, you must automate it. The following information and the accompanying sample files in the Solution Book describe how you can use recipes to do that.

A Quick Look at a Sample Recipe

Data Hub supports platform installer recipes and provides a DSL to be used in the recipes for Data Hub server specification. Here is a basic sample recipe:
apply plugin: 'installer-datahub-plugin'
def datahubServerId = 'datahub-tomcat' 
def datahubCfg = { 
	webappDir platformHome + "/../ext-integration/datahub/web-app"
 
	ports { 
			http 8080 
	} 
} 

task setup << { 
	datahub(datahubServerId).setup datahubCfg 
} 

task start << { 
	def CATALINA_OPTS = "-Xms8192m -Xmx8192m" 
	datahub(datahubServerId).start CATALINA_OPTS 
} 

task stop << { 
	datahub(datahubServerId).stop() 
}

The recipe begins with a Data Hub WAR file distributed with SAP Commerce Cloud. It then allows the WAR file to start/stop a Tomcat server with the Data Hub distribution. Users can connect to it using port 8080, and then it can be stopped. The deployment does not have any extensions or configuration files, so it's not really useful. Further, let's discuss this recipe so we understand what it consists of and how it can be enhanced to be more useful. There are three additional recipe templates in the Solution Book.

Overall Recipe Structure

The Plugin

The DSL for configuring and manipulating Data Hub server is provided in a Gradle plugin called installer-datahub-plugin, hence there is apply plugin: 'installer-datahub-plugin' at the beginning of the recipe to enable Data Hub configuration structures and commands in the recipe script.

Server ID

Notice the datahubServerId value defined on line 3. That value is the name/ID ('datahub-tomcat') we are giving to the Data Hub server, which we are going to manipulate in the recipe. The name is required by the datahub(...) command and can be anything consisting of letters, numbers, '_', and '-' symbols. The name becomes more useful when the recipe provides more than one Data Hub server instance. Then it allows you to distinguish the instances in the recipe tasks, but it must be unique. In the case of a single Data Hub server instance, it does not play an important role but is still required. In fact, you can see the datahubServerId is used later only inside setup, start, and stop tasks. Nothing before those tasks in the recipe refers to datahubServerId. For that reason, the server ID does not have to be in the script. Instead, 'datahub-tomcat' (or another name) can be used in places where the datahubServiceId is used. However, extracting this value to a variable allows easy change of the server name on a single line. Instead of searching for it in the tasks where it's used.

Data Hub Configuration

Data Hub configuration appears on lines 4 through 10 in the sample script and looks like the following:
def <configuration_object_name> = {
	 ... 
}
In our sample recipe, theconfiguration_object_name is <datahubCfg>. The name follows Gradle variable rules. The name is a reference to a specific configuration inside the curly braces. In the case where the recipe has multiple configurations, you can distinguish between them and specify the configuration to use for a task. The configuration allows you to customize the Tomcat server instance.

Configuring Server Ports

Data Hub configuration must include port configuration for the Tomcat server:
def datahubCfg = { 
	ports { 
			http 8080 
			ssl 4343 
		} 
}
If ports are unspecified, connection to the Data Hub server is not possible. However, the ssl port used for an HTTPS connection is optional.