Skip to content

Commit cf41b2e

Browse files
committed
automates sample-data retrieval and runs input flows (performance sample)
1 parent 036317f commit cf41b2e

File tree

1 file changed

+113
-7
lines changed

1 file changed

+113
-7
lines changed

examples/performance-sample/build.gradle

Lines changed: 113 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,31 @@
11
plugins {
2-
// this plugin lets you create properties files
3-
// for multiple environments... like dev, qa, prod
42
id 'net.saliman.properties' version '1.4.6'
5-
6-
// this is the data hub framework gradle plugin
7-
// it includes ml-gradle. This plugin is what lets you
8-
// run DHF (Data Hub Framework) tasks from the
9-
// command line
103
id 'com.marklogic.ml-data-hub' version '2.0.0'
114
}
125

6+
repositories {
7+
jcenter()
8+
maven { url "https://developer.marklogic.com/maven2/" }
9+
10+
ivy {
11+
url 'http://download.geonames.org/'
12+
layout 'pattern', {
13+
artifact '/[organisation]/dump/[module].[ext]'
14+
}
15+
}
16+
}
17+
18+
configurations {
19+
mlcp
20+
data
21+
}
22+
23+
dependencies {
24+
mlcp "com.marklogic:mlcp:9.0.2"
25+
mlcp files("lib")
26+
data "export:cities5000:*@zip"
27+
}
28+
1329
task createXmlEntity(type: com.marklogic.gradle.task.CreateEntityTask) {
1430
doFirst { project.ext.entityName = "input-xml" }
1531
}
@@ -42,3 +58,93 @@ task createEntityInput() {
4258
finalizedBy mlLoadModules
4359
doLast { println "created XML and JSON entities and input flows" }
4460
}
61+
62+
task getInputData() {
63+
def headers = [
64+
"geonameid",
65+
"name",
66+
"asciiname",
67+
"alternatenames",
68+
"latitude",
69+
"longitude",
70+
"feature class",
71+
"feature code",
72+
"country code",
73+
"cc2",
74+
"admin1 code",
75+
"admin2 code",
76+
"admin3 code",
77+
"admin4 code",
78+
"population",
79+
"elevation",
80+
"dem",
81+
"timezone",
82+
"modification date"
83+
]
84+
85+
def zipPath = project.configurations.data.find {
86+
it.name.startsWith("cities5000")
87+
}
88+
89+
doFirst {
90+
mkdir "./input/"
91+
}
92+
doLast {
93+
def zipFile = zipTree(file(zipPath)).getFiles().first()
94+
def combined = new File('./input/raw.txt')
95+
combined.text = headers.join("\t") + "\n" + zipFile.text
96+
}
97+
}
98+
99+
task prepareMlcpLog() {
100+
mkdir "./lib/"
101+
def props = new File('./lib/log4j.properties')
102+
props.text = [
103+
"log4j.rootLogger=INFO, stdout",
104+
"log4j.appender.stdout=org.apache.log4j.ConsoleAppender",
105+
"log4j.appender.stdout.Target=System.out",
106+
"log4j.appender.stdout.layout=org.apache.log4j.PatternLayout",
107+
"log4j.appender.stdout.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n"
108+
].join("\n")
109+
}
110+
111+
task loadJson(type: com.marklogic.gradle.task.MlcpTask) {
112+
classpath = configurations.mlcp
113+
command = "IMPORT"
114+
database = mlStagingDbName
115+
port = mlStagingPort.toInteger()
116+
input_file_path = "./input/raw.txt"
117+
delimiter = "\t"
118+
input_file_type = "delimited_text"
119+
document_type = "json"
120+
output_uri_prefix = "/city/"
121+
output_uri_suffix = ".json"
122+
output_collections = "input-json"
123+
transform_module = "/com.marklogic.hub/mlcp-flow-transform.xqy"
124+
transform_namespace = "http://marklogic.com/data-hub/mlcp-flow-transform"
125+
transform_param = "entity-name=input-json,flow-name=raw-input-json"
126+
}
127+
128+
task loadXml(type: com.marklogic.gradle.task.MlcpTask) {
129+
classpath = configurations.mlcp
130+
command = "IMPORT"
131+
database = mlStagingDbName
132+
port = mlStagingPort.toInteger()
133+
input_file_path = "./input/raw.txt"
134+
delimiter = "\t"
135+
input_file_type = "delimited_text"
136+
document_type = "xml"
137+
output_uri_prefix = "/city/"
138+
output_uri_suffix = ".xml"
139+
output_collections = "input-xml"
140+
transform_module = "/com.marklogic.hub/mlcp-flow-transform.xqy"
141+
transform_namespace = "http://marklogic.com/data-hub/mlcp-flow-transform"
142+
transform_param = "entity-name=input-xml,flow-name=raw-input-xml"
143+
}
144+
145+
task loadInputData {
146+
mustRunAfter createEntityInput
147+
dependsOn getInputData
148+
dependsOn loadJson
149+
dependsOn loadXml
150+
}

0 commit comments

Comments
 (0)