Skip to content

Commit eb78e1d

Browse files
committed
Merge branch 'master' into 164-LoadDataImprovements
* master: updating debug logging fixing tests for returning {} for [] in headers rounded out first cut at tracing code added ml-gradle back into main gradle project to ease hub development added gradle plugins for enabling/disabling tracing updated sjs headers to return {} vs [] updating plugin version Conflicts: quick-start/src/main/java/com/marklogic/hub/web/controller/api/FlowApiController.java
2 parents 330ae40 + bdf26c3 commit eb78e1d

File tree

53 files changed

+1034
-411
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+1034
-411
lines changed

examples/gradle-advanced/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ plugins {
1010
id 'eclipse'
1111
id 'idea'
1212
id 'net.saliman.properties' version '1.4.5'
13-
id 'com.marklogic.ml-data-hub-plugin' version '1.0.0-beta.1'
13+
id 'com.marklogic.ml-data-hub-plugin' version '1.0.0-beta.2'
1414
id 'com.marklogic.ml-gradle' version '2.1.0'
1515
}
1616

examples/hr-hub/plugins/entities/Employee/conformance/conform-acme-tech/headers/headers.sjs

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* @param content - the output of your content plugin
66
* @param options - an object containing options. Options are sent from Java
77
*
8-
* @return - an array of header objects
8+
* @return - an object of headers
99
*/
1010
function createHeaders(id, content, options) {
1111
var latest = xs.date('1900-01-01');
@@ -20,17 +20,11 @@ function createHeaders(id, content, options) {
2020
}
2121
}
2222

23-
return [
24-
{
25-
employeeId: content.id
26-
},
27-
{
28-
hireDate: xs.date(xdmp.parseDateTime('[M01]/[D01]/[Y0001]', content.hireDate))
29-
},
30-
{
31-
salary: xs.int(salary)
32-
}
33-
];
23+
return {
24+
employeeId: content.id,
25+
hireDate: xs.date(xdmp.parseDateTime('[M01]/[D01]/[Y0001]', content.hireDate)),
26+
salary: xs.int(salary)
27+
};
3428
}
3529

3630
module.exports = {

examples/hr-hub/plugins/entities/Employee/conformance/conform-global-corp/headers/headers.sjs

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,14 @@
55
* @param content - the output of your content plugin
66
* @param options - an object containing options. Options are sent from Java
77
*
8-
* @return - an array of header objects
8+
* @return - an object of headers
99
*/
1010
function createHeaders(id, content, options) {
11-
return [
12-
{
13-
employeeId: content.emp_id
14-
},
15-
{
16-
hireDate: xs.date(xdmp.parseDateTime('[M01]/[D01]/[Y0001]', content.hire_date))
17-
},
18-
{
19-
salary: xs.int(content.base_salary) + xs.int(content.bonus)
20-
}
21-
];
11+
return {
12+
employeeId: content.emp_id,
13+
hireDate: xs.date(xdmp.parseDateTime('[M01]/[D01]/[Y0001]', content.hire_date)),
14+
salary: xs.int(content.base_salary) + xs.int(content.bonus)
15+
};
2216
}
2317

2418
module.exports = {

examples/hr-hub/plugins/entities/Employee/input/load-acme-tech/headers/headers.sjs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@
55
* @param content - the output of your content plugin
66
* @param options - an object containing options. Options are sent from Java
77
*
8-
* @return - an array of header objects
8+
* @return - an object of headers
99
*/
1010
function createHeaders(id, content, options) {
11-
return [];
11+
return {};
1212
}
1313

1414
module.exports = {

examples/hr-hub/plugins/entities/Employee/input/load-global-corp/headers/headers.sjs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@
55
* @param content - the output of your content plugin
66
* @param options - an object containing options. Options are sent from Java
77
*
8-
* @return - an array of header objects
8+
* @return - an object of headers
99
*/
1010
function createHeaders(id, content, options) {
11-
return [];
11+
return {};
1212
}
1313

1414
module.exports = {

marklogic-data-hub/build.gradle

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ plugins {
55
id 'idea'
66
id 'maven-publish'
77
id 'com.jfrog.bintray' version '1.6'
8+
id 'com.marklogic.ml-gradle' version '2.1.0'
89
}
910

1011
repositories {
@@ -121,3 +122,70 @@ bintray {
121122
issueTrackerUrl = 'https://github.com/marklogic/marklogic-data-hub/issues'
122123
}
123124
}
125+
126+
ext {
127+
// mlAppConfig is an instance of com.marklogic.appdeployer.AppConfig
128+
mlAppConfig {
129+
// override some default values with our values
130+
modulesDatabaseName = mlModulesDbName
131+
triggersDatabaseName = mlTriggersDbName
132+
schemasDatabaseName = mlSchemasDbName
133+
restPort = Integer.parseInt(mlStagingPort)
134+
135+
// Configure custom tokens for our json files
136+
customTokens.put("%%STAGING_SERVER_NAME%%", mlStagingAppserverName)
137+
customTokens.put("%%STAGING_SERVER_PORT%%", mlStagingPort)
138+
customTokens.put("%%STAGING_DB_NAME%%", mlStagingDbName)
139+
140+
customTokens.put("%%FINAL_SERVER_NAME%%", mlFinalAppserverName)
141+
customTokens.put("%%FINAL_SERVER_PORT%%", mlFinalPort)
142+
customTokens.put("%%FINAL_DB_NAME%%", mlFinalDbName)
143+
144+
customTokens.put("%%TRACE_SERVER_NAME%%", mlTraceAppserverName)
145+
customTokens.put("%%TRACE_SERVER_PORT%%", mlTracePort)
146+
customTokens.put("%%TRACE_DB_NAME%%", mlTraceDbName)
147+
148+
customTokens.put("%%MODULES_DB_NAME%%", mlModulesDbName)
149+
150+
modulePaths = ["marklogic-data-hub/src/main/resources/ml-modules"]
151+
}
152+
}
153+
154+
ext {
155+
// don't create the REST Api. We will do it manually
156+
mlAppDeployer.commands.remove(mlAppDeployer.getCommand("DeployRestApiServersCommand"))
157+
mlAppDeployer.commands.remove(mlAppDeployer.getCommand("UpdateRestApiServersCommand"))
158+
159+
// remove the original deploy content database command
160+
// as we do not need it.
161+
def deployDbCmd = mlAppDeployer.getCommand("DeployContentDatabasesCommand")
162+
mlAppDeployer.commands.remove(deployDbCmd)
163+
164+
// install the staging database
165+
def stagingDbCommand = new com.marklogic.appdeployer.command.databases.DeployDatabaseCommand("staging-database.json")
166+
stagingDbCommand.setForestsPerHost(Integer.parseInt(mlStagingForestsPerHost));
167+
mlAppDeployer.commands.add(stagingDbCommand)
168+
mlDatabaseCommands.add(stagingDbCommand)
169+
170+
// install the final database
171+
def finalDbCommand = new com.marklogic.appdeployer.command.databases.DeployDatabaseCommand("final-database.json")
172+
finalDbCommand.setForestsPerHost(Integer.parseInt(mlFinalForestsPerHost));
173+
mlAppDeployer.commands.add(finalDbCommand)
174+
mlDatabaseCommands.add(finalDbCommand)
175+
176+
// install the trace database
177+
def traceDbCommand = new com.marklogic.appdeployer.command.databases.DeployDatabaseCommand("trace-database.json")
178+
traceDbCommand.setForestsPerHost(Integer.parseInt(mlTraceForestsPerHost));
179+
mlAppDeployer.commands.add(traceDbCommand)
180+
mlDatabaseCommands.add(traceDbCommand)
181+
182+
// install the modules database
183+
def modulesDbCommand = new com.marklogic.appdeployer.command.databases.DeployDatabaseCommand("modules-database.json")
184+
mlAppDeployer.commands.add(modulesDbCommand)
185+
mlDatabaseCommands.add(modulesDbCommand)
186+
187+
// temp workaround for ml-gradle issue #78
188+
// https://github.com/rjrudin/ml-gradle/issues/78
189+
def lmc = mlAppDeployer.getCommand("LoadModulesCommand")
190+
lmc.setModulesLoader(new com.marklogic.client.modulesloader.impl.DefaultModulesLoader(mlAppConfig.newXccAssetLoader()))
191+
}
Lines changed: 28 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,33 @@
1-
mlAppDeployerDependency=com.marklogic:ml-app-deployer:+
21
mlConfigDir=marklogic-data-hub/src/main/resources/ml-config
3-
publishUrl=file:../marklogic-data-hub/releases
4-
mlStagingRestPort=8010
5-
mlFinalRestPort=8011
6-
mlTraceRestPort=8012
7-
mlUsername=admin
8-
mlPassword=admin
2+
93
mlHost=localhost
104
mlAppName=data-hub
5+
6+
mlUsername=admin
7+
mlPassword=admin
118
auth=digest
9+
10+
mlStagingAppserverName=data-hub-STAGING
11+
mlStagingPort=8010
12+
mlStagingDbName=data-hub-STAGING
13+
mlStagingForestsPerHost=4
14+
15+
mlFinalAppserverName=data-hub-FINAL
16+
mlFinalPort=8011
17+
mlFinalDbName=data-hub-FINAL
18+
mlFinalForestsPerHost=4
19+
20+
mlTraceAppserverName=data-hub-TRACING
21+
mlTracePort=8012
22+
mlTraceDbName=data-hub-TRACING
23+
mlTraceForestsPerHost=1
24+
25+
mlModulesDbName=data-hub-MODULES
26+
mlTriggersDbName=data-hub-TRIGGERS
27+
mlSchemasDbName=data-hub-SCHEMAS
28+
29+
hubModulesPath=exmaples/hr-hub/plugins
30+
1231
version=1.0.0-beta.2
32+
33+

marklogic-data-hub/src/main/java/com/marklogic/hub/DataHub.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@
5858
import com.marklogic.hub.commands.DeployModulesDatabaseCommand;
5959
import com.marklogic.hub.commands.DeployRestApiCommand;
6060
import com.marklogic.hub.commands.LoadModulesCommand;
61+
import com.marklogic.hub.commands.UpdateRestApiServersCommand;
6162
import com.marklogic.hub.util.HubFileFilter;
6263
import com.marklogic.hub.util.HubModulesLoader;
6364
import com.marklogic.mgmt.ManageClient;
@@ -315,15 +316,17 @@ private List<Command> getCommands(AppConfig config) {
315316
dbCommands.add(tracingDb);
316317

317318
dbCommands.add(new DeployModulesDatabaseCommand(hubConfig.modulesDbName));
318-
dbCommands.add(new DeployTriggersDatabaseCommand());
319-
dbCommands.add(new DeploySchemasDatabaseCommand());
320319
commands.addAll(dbCommands);
321320

322321
// App Servers
323322
commands.add(new DeployRestApiCommand(hubConfig.stagingHttpName, hubConfig.stagingPort));
324323
commands.add(new DeployRestApiCommand(hubConfig.finalHttpName, hubConfig.finalPort));
325324
commands.add(new DeployRestApiCommand(hubConfig.tracingHttpName, hubConfig.tracePort));
326325

326+
commands.add(new UpdateRestApiServersCommand(hubConfig.stagingHttpName));
327+
commands.add(new UpdateRestApiServersCommand(hubConfig.finalHttpName));
328+
commands.add(new UpdateRestApiServersCommand(hubConfig.tracingHttpName));
329+
327330
// Modules
328331
commands.add(new LoadModulesCommand());
329332

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
package com.marklogic.hub;
2+
3+
import com.marklogic.client.DatabaseClient;
4+
import com.marklogic.client.extensions.ResourceManager;
5+
import com.marklogic.client.extensions.ResourceServices.ServiceResult;
6+
import com.marklogic.client.extensions.ResourceServices.ServiceResultIterator;
7+
import com.marklogic.client.io.StringHandle;
8+
import com.marklogic.client.util.RequestParameters;
9+
10+
public class Debugging extends ResourceManager {
11+
private static final String NAME = "debug";
12+
13+
public Debugging(DatabaseClient client) {
14+
super();
15+
client.init(NAME, this);
16+
}
17+
18+
/**
19+
* Enables tracing
20+
*/
21+
public void enable() {
22+
RequestParameters params = new RequestParameters();
23+
params.add("enable", "true");
24+
this.getServices().post(params, new StringHandle("{}"));
25+
}
26+
27+
/**
28+
* Disables tracing
29+
*/
30+
public void disable() {
31+
RequestParameters params = new RequestParameters();
32+
params.add("enable", "false");
33+
this.getServices().post(params, new StringHandle("{}"));
34+
}
35+
36+
/**
37+
* Determines if the hub has tracing enabled or not
38+
*
39+
* @return - true if enabled, false otherwise
40+
*/
41+
public boolean isEnabled() {
42+
RequestParameters params = new RequestParameters();
43+
ServiceResultIterator resultItr = this.getServices().get(params);
44+
if (resultItr == null || ! resultItr.hasNext()) {
45+
return false;
46+
}
47+
ServiceResult res = resultItr.next();
48+
StringHandle handle = new StringHandle();
49+
String enabled = res.getContent(handle).get();
50+
return Boolean.parseBoolean(enabled);
51+
}
52+
}

marklogic-data-hub/src/main/java/com/marklogic/hub/HubConfig.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ public class HubConfig {
5959

6060
public String tracingDbName = DEFAULT_TRACING_NAME;
6161
public String tracingHttpName = DEFAULT_TRACING_NAME;
62-
public int tracingForestsPerHost = DEFAULT_FORESTS_PER_HOST;
62+
public int tracingForestsPerHost = 1;
6363
public Integer tracePort = DEFAULT_TRACE_PORT;
6464

6565
public String modulesDbName = DEFAULT_MODULES_DB_NAME;

0 commit comments

Comments
 (0)