Skip to content

Commit 4da895e

Browse files
committed
fixing docker image
fixed #416
1 parent 98166ad commit 4da895e

File tree

10 files changed

+99
-120
lines changed

10 files changed

+99
-120
lines changed

.travis/Dockerfile-ml

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,25 @@
11
FROM centos:centos7
22

33
ENV LANG C.UTF-8
4-
4+
ENV JAVA_VERSION 8u131
5+
ENV BUILD_VERSION b11
6+
ENV SUM d54c1d3a095b4ff2b6607d096fa80163
57
RUN yum -y install glibc.i686 \
68
gdb.x86_64 redhat-lsb.x86_64 vim \
79
bzip2 \
810
unzip \
9-
xz-utils \
10-
java-1.8.0-openjdk-devel 2>&1 > /dev/null
11+
wget \
12+
xz-utils 2>&1 > /dev/null
13+
14+
# Downloading Java
15+
RUN wget --no-cookies --no-check-certificate --header "Cookie: oraclelicense=accept-securebackup-cookie" "http://download.oracle.com/otn-pub/java/jdk/$JAVA_VERSION-$BUILD_VERSION/$SUM/jdk-$JAVA_VERSION-linux-x64.rpm" -O /tmp/jdk-8-linux-x64.rpm
16+
RUN yum -y install /tmp/jdk-8-linux-x64.rpm
17+
18+
RUN alternatives --install /usr/bin/java jar /usr/java/latest/bin/java 200000
19+
RUN alternatives --install /usr/bin/javaws javaws /usr/java/latest/bin/javaws 200000
20+
RUN alternatives --install /usr/bin/javac javac /usr/java/latest/bin/javac 200000
21+
22+
ENV JAVA_HOME /usr/java/latest
1123

1224
# Install MarkLogic
1325
COPY ./MarkLogic.rpm /tmp/MarkLogic.rpm

examples/spring-batch/build.gradle

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,3 @@
1-
buildscript {
2-
repositories {
3-
maven {url 'http://developer.marklogic.com/maven2/'}
4-
}
5-
}
6-
71
plugins {
82
id 'java'
93
id 'eclipse'
@@ -20,9 +14,11 @@ repositories {
2014

2115
dependencies {
2216
compile 'com.marklogic:marklogic-data-hub:1.1.2'
23-
compile 'com.marklogic:marklogic-spring-batch-core:0.6.0'
24-
compile 'com.marklogic:ml-javaclient-util:2.14.0'
25-
testCompile 'com.marklogic:marklogic-spring-batch-test:0.6.0'
17+
compile "com.marklogic:marklogic-spring-batch-core:0.7.4"
18+
compile 'com.marklogic:ml-javaclient-util:4.0.alpha4'
19+
20+
testCompile "com.marklogic:marklogic-spring-batch-test:0.7.4"
21+
runtime "com.marklogic:marklogic-spring-batch-core:0.7.2"
2622
}
2723

2824
distributions {
@@ -31,4 +27,4 @@ distributions {
3127
}
3228
}
3329

34-
mainClassName = "com.marklogic.spring.batch.hub.HubJobRunner"
30+
mainClassName = "com.marklogic.spring.batch.Main"

examples/spring-batch/gradle.properties

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,31 +8,65 @@
88
#
99
# ....
1010
mlHost=localhost
11-
mlAppName=data-hub
1211

12+
# Your MarkLogic Username and Password
1313
mlUsername=admin
1414
mlPassword=admin
1515

16+
# If specified, the manage username/password combo is used with the ML Management REST API for managing application
17+
# resources; this user must have the manage-admin and rest-admin roles.
18+
#
19+
# If these are not set, then mlUsername/mlPassword is used for managing application resources.
20+
# mlManageUsername=
21+
# mlManagePassword=
22+
23+
# If specified, these values can override where the DHF thinks
24+
# MarkLogic default ports are at. You would only use this if you
25+
# have changed the ports on which MarkLogic listens
26+
#
27+
# mlAppServicesPort=8000
28+
# mlAdminPort=8001
29+
# mlManagePort=8002
30+
31+
# If specified, the admin username/password combo is used with the ML Management REST API for creating users and roles. This
32+
# user must have the manage-admin or admin role. A good practice is to use your admin account here to create app-specific
33+
# users and roles, which can then be used as mlManageUsername/mlManagePassword and mlUsername/mlPassword.
34+
#
35+
# These properties are also used for connecting to the admin application on port 8001 - e.g. for initializing ML and for
36+
# waiting for ML to restart.
37+
#
38+
# If these properties are not set, then mlUsername/mlPassword will be used.
39+
# mlAdminUsername=
40+
# mlAdminPassword=
41+
1642
mlStagingAppserverName=data-hub-STAGING
1743
mlStagingPort=8010
1844
mlStagingDbName=data-hub-STAGING
1945
mlStagingForestsPerHost=4
46+
mlStagingAuth=digest
2047

2148
mlFinalAppserverName=data-hub-FINAL
2249
mlFinalPort=8011
2350
mlFinalDbName=data-hub-FINAL
2451
mlFinalForestsPerHost=4
52+
mlFinalAuth=digest
2553

2654
mlTraceAppserverName=data-hub-TRACING
2755
mlTracePort=8012
2856
mlTraceDbName=data-hub-TRACING
2957
mlTraceForestsPerHost=1
58+
mlTraceAuth=digest
3059

3160
mlJobAppserverName=data-hub-JOBS
3261
mlJobPort=8013
3362
mlJobDbName=data-hub-JOBS
3463
mlJobForestsPerHost=1
64+
mlJobAuth=digest
3565

3666
mlModulesDbName=data-hub-MODULES
3767
mlTriggersDbName=data-hub-TRIGGERS
3868
mlSchemasDbName=data-hub-SCHEMAS
69+
70+
# The name of the Role to create for Hub Access
71+
mlHubUserRole=data-hub-ROLE
72+
mlHubUserName=data-hub-user

examples/spring-batch/src/main/java/example/LoadAndRunFlow.java

Lines changed: 14 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,16 @@
55
import com.marklogic.client.document.GenericDocumentManager;
66
import com.marklogic.client.document.ServerTransform;
77
import com.marklogic.client.helper.DatabaseClientProvider;
8-
import com.marklogic.hub.HubConfig;
9-
import com.marklogic.spring.batch.hub.AbstractMarkLogicBatchConfig;
10-
import com.marklogic.spring.batch.hub.FlowConfig;
11-
import com.marklogic.spring.batch.hub.StagingConfig;
128
import com.marklogic.spring.batch.item.processor.ResourceToDocumentWriteOperationItemProcessor;
139
import com.marklogic.spring.batch.item.reader.EnhancedResourcesItemReader;
1410
import org.springframework.batch.core.Job;
1511
import org.springframework.batch.core.Step;
12+
import org.springframework.batch.core.configuration.annotation.EnableBatchProcessing;
13+
import org.springframework.batch.core.configuration.annotation.JobBuilderFactory;
1614
import org.springframework.batch.core.configuration.annotation.JobScope;
15+
import org.springframework.batch.core.configuration.annotation.StepBuilderFactory;
1716
import org.springframework.batch.item.ItemProcessor;
1817
import org.springframework.batch.item.ItemWriter;
19-
import org.springframework.beans.factory.annotation.Autowired;
2018
import org.springframework.beans.factory.annotation.Value;
2119
import org.springframework.context.EnvironmentAware;
2220
import org.springframework.context.annotation.Bean;
@@ -26,30 +24,28 @@
2624

2725
import java.util.*;
2826

29-
@Import({ StagingConfig.class, FlowConfig.class })
30-
public class LoadAndRunFlow extends AbstractMarkLogicBatchConfig implements EnvironmentAware {
27+
@EnableBatchProcessing
28+
public class LoadAndRunFlow implements EnvironmentAware {
3129

3230
private Environment env;
3331

3432
private final String JOB_NAME = "yourJob";
3533

3634
@Bean
37-
public Job job(Step step) {
35+
public Job job(JobBuilderFactory jobBuilderFactory, Step step) {
3836
return jobBuilderFactory.get(JOB_NAME).start(step).build();
3937
}
4038

41-
// This provider gives us the connection info for talking to MarkLogic
42-
@Autowired
43-
private DatabaseClientProvider databaseClientProvider;
44-
4539
@Bean
4640
@JobScope
4741
public Step step(
48-
@Value("#{jobParameters['input_file_path']}") String inputFilePath,
49-
@Value("#{jobParameters['input_file_pattern']}") String inputFilePattern,
50-
@Value("#{jobParameters['entity_name']}") String entityName,
51-
@Value("#{jobParameters['flow_name']}") String flowName) {
52-
42+
StepBuilderFactory stepBuilderFactory,
43+
DatabaseClientProvider databaseClientProvider,
44+
@Value("#{jobParameters['input_file_path']}") String inputFilePath,
45+
@Value("#{jobParameters['input_file_pattern']}") String inputFilePattern,
46+
@Value("#{jobParameters['entity_name']}") String entityName,
47+
@Value("#{jobParameters['flow_name']}") String flowName,
48+
@Value("#{jobParameters['output_collections']}") String[] collections) {
5349

5450
GenericDocumentManager docMgr = databaseClientProvider.getDatabaseClient().newDocumentManager();
5551

@@ -71,7 +67,7 @@ public void write(List<? extends DocumentWriteOperation> items) throws Exception
7167
};
7268

7369
return stepBuilderFactory.get("step1")
74-
.<Resource, DocumentWriteOperation>chunk(getChunkSize())
70+
.<Resource, DocumentWriteOperation>chunk(10)
7571
.reader(new EnhancedResourcesItemReader(inputFilePath, inputFilePattern))
7672
.processor(processor)
7773
.writer(writer)

marklogic-data-hub/src/main/java/com/marklogic/hub/deploy/commands/DeployHubDatabaseCommand.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -115,9 +115,9 @@ protected JsonNode mergeDatabaseFiles(AppConfig appConfig) {
115115
File userDatabaseDir = hubConfig.getUserDatabaseDir().toFile();
116116
files.add(new File(databaseDir, this.databaseFilename));
117117

118-
File otherDatabaseFile = new File(userDatabaseDir, this.databaseFilename);
119-
if (otherDatabaseFile != null && otherDatabaseFile.exists()) {
120-
files.add(otherDatabaseFile);
118+
File userDatabaseFile = new File(userDatabaseDir, this.databaseFilename);
119+
if (userDatabaseFile != null && userDatabaseFile.exists()) {
120+
files.add(userDatabaseFile);
121121
}
122122
if (logger.isInfoEnabled()) {
123123
logger.info("Merging JSON files at locations: " + files);

marklogic-data-hub/src/main/java/com/marklogic/hub/flow/BatchCompleteListener.java

Lines changed: 0 additions & 6 deletions
This file was deleted.

marklogic-data-hub/src/main/resources/ml-config/databases/final-database.json

Lines changed: 1 addition & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,6 @@
11
{
22
"database-name": "%%mlFinalDbName%%",
3-
"range-element-index": [
4-
{
5-
"scalar-type": "dateTime",
6-
"namespace-uri": "http://marklogic.com/xdmp/dls",
7-
"localname": "created",
8-
"collation": "",
9-
"range-value-positions": false,
10-
"invalid-values": "reject"
11-
},
12-
{
13-
"scalar-type": "dateTime",
14-
"namespace-uri": "http://marklogic.com/xdmp/dls",
15-
"localname": "replaced",
16-
"collation": "",
17-
"range-value-positions": false,
18-
"invalid-values": "reject"
19-
},
20-
{
21-
"scalar-type": "unsignedLong",
22-
"namespace-uri": "http://marklogic.com/xdmp/dls",
23-
"localname": "version-id",
24-
"collation": "",
25-
"range-value-positions": false,
26-
"invalid-values": "reject"
27-
}
28-
],
3+
"range-element-index": [],
294
"schema-database": "%%SCHEMAS_DATABASE%%",
305
"triggers-database": "%%TRIGGERS_DATABASE%%",
316
"triple-index": true,

marklogic-data-hub/src/main/resources/ml-config/databases/staging-database.json

Lines changed: 1 addition & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,6 @@
11
{
22
"database-name": "%%mlStagingDbName%%",
3-
"range-element-index": [
4-
{
5-
"scalar-type": "dateTime",
6-
"namespace-uri": "http://marklogic.com/xdmp/dls",
7-
"localname": "created",
8-
"collation": "",
9-
"range-value-positions": false,
10-
"invalid-values": "reject"
11-
},
12-
{
13-
"scalar-type": "dateTime",
14-
"namespace-uri": "http://marklogic.com/xdmp/dls",
15-
"localname": "replaced",
16-
"collation": "",
17-
"range-value-positions": false,
18-
"invalid-values": "reject"
19-
},
20-
{
21-
"scalar-type": "unsignedLong",
22-
"namespace-uri": "http://marklogic.com/xdmp/dls",
23-
"localname": "version-id",
24-
"collation": "",
25-
"range-value-positions": false,
26-
"invalid-values": "reject"
27-
}
28-
],
3+
"range-element-index": [],
294
"schema-database": "%%SCHEMAS_DATABASE%%",
305
"triggers-database": "%%TRIGGERS_DATABASE%%",
316
"triple-index": true,

marklogic-data-hub/src/main/resources/ml-config/databases/trace-database.json

Lines changed: 1 addition & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,6 @@
11
{
22
"database-name": "%%mlTraceDbName%%",
3-
"range-element-index": [
4-
{
5-
"scalar-type": "dateTime",
6-
"namespace-uri": "http://marklogic.com/xdmp/dls",
7-
"localname": "created",
8-
"collation": "",
9-
"range-value-positions": false,
10-
"invalid-values": "reject"
11-
},
12-
{
13-
"scalar-type": "dateTime",
14-
"namespace-uri": "http://marklogic.com/xdmp/dls",
15-
"localname": "replaced",
16-
"collation": "",
17-
"range-value-positions": false,
18-
"invalid-values": "reject"
19-
},
20-
{
21-
"scalar-type": "unsignedLong",
22-
"namespace-uri": "http://marklogic.com/xdmp/dls",
23-
"localname": "version-id",
24-
"collation": "",
25-
"range-value-positions": false,
26-
"invalid-values": "reject"
27-
}
28-
],
3+
"range-element-index": [],
294
"range-path-index": [
305
{
316
"scalar-type": "string",

ml-data-hub-plugin/src/main/groovy/com/marklogic/gradle/task/RunFlowTask.groovy

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@ import com.marklogic.gradle.exception.HubNotInstalledException
77
import com.marklogic.hub.FlowManager
88
import com.marklogic.hub.flow.Flow
99
import com.marklogic.hub.flow.FlowRunner
10-
import com.marklogic.hub.flow.FlowStatusListener
1110
import com.marklogic.hub.flow.FlowType
1211
import org.gradle.api.tasks.Input
1312
import org.gradle.api.tasks.TaskAction
1413

1514
class RunFlowTask extends HubTask {
15+
1616
@Input
1717
public String entityName
1818

@@ -28,6 +28,9 @@ class RunFlowTask extends HubTask {
2828
@Input
2929
public Integer threadCount
3030

31+
@Input
32+
public Boolean showOptions
33+
3134
@TaskAction
3235
void runFlow() {
3336
if (entityName == null) {
@@ -54,6 +57,10 @@ class RunFlowTask extends HubTask {
5457
threadCount = project.hasProperty("threadCount") ?
5558
Integer.parseInt(project.property("threadCount")) : 4
5659
}
60+
if (showOptions == null) {
61+
showOptions = project.hasProperty("showOptions") ?
62+
Boolean.parseBoolean(project.property("showOptions")) : false
63+
}
5764

5865
if (!isHubInstalled()) {
5966
throw new HubNotInstalledException()
@@ -66,9 +73,24 @@ class RunFlowTask extends HubTask {
6673
throw new FlowNotFoundException(entityName, flowName);
6774
}
6875

76+
Map<String, Object> options = new HashMap<>()
77+
project.ext.properties.each { key, value ->
78+
if (key.toString().startsWith("dfh.")) {
79+
options.put(key, value)
80+
}
81+
}
6982
println("Running Flow: [" + entityName + ":" + flowName + "] with batch size: " + batchSize)
83+
84+
if (showOptions) {
85+
println(" and options:")
86+
options.each { key, value ->
87+
println(" " + key + " = " + value)
88+
}
89+
}
90+
7091
FlowRunner flowRunner = fm.newFlowRunner()
7192
.withFlow(flow)
93+
.withOptions(options)
7294
.withBatchSize(batchSize)
7395
.withThreadCount(threadCount)
7496
flowRunner.run()

0 commit comments

Comments
 (0)