@@ -50,6 +50,10 @@ public class MlcpRunner extends ProcessRunner {
5050 private DatabaseClient databaseClient ;
5151 private String database = null ;
5252
53+ public MlcpRunner (String mainClass , HubConfig hubConfig , JsonNode mlcpOptions ) {
54+ this (null , mainClass , hubConfig , null , null , mlcpOptions , null );
55+ }
56+
5357 public MlcpRunner (String mlcpPath , String mainClass , HubConfig hubConfig , LegacyFlow flow , DatabaseClient databaseClient , JsonNode mlcpOptions , LegacyFlowStatusListener statusListener ) {
5458 super ();
5559
@@ -73,26 +77,40 @@ public String getJobId() {
7377 public void run () {
7478 HubConfig hubConfig = getHubConfig ();
7579
76- Job job = Job .withFlow (flow )
77- .withJobId (jobId );
78- jobManager .saveJob (job );
80+ Job job = null ;
81+ if (flow != null ) {
82+ job = Job .withFlow (flow )
83+ .withJobId (jobId );
84+ jobManager .saveJob (job );
85+ }
7986
8087 try {
8188 MlcpBean bean = new ObjectMapper ().readerFor (MlcpBean .class ).readValue (mlcpOptions );
82- bean .setHost (databaseClient .getHost ());
83- bean .setPort (databaseClient .getPort ());
89+ if (databaseClient != null ) {
90+ bean .setHost (databaseClient .getHost ());
91+ bean .setPort (databaseClient .getPort ());
92+ }
8493 if (database != null ) {
8594 bean .setDatabase (database );
8695 }
8796
88- // Assume that the HTTP credentials will work for mlcp
89- bean .setUsername (hubConfig .getAppConfig ().getAppServicesUsername ());
90- bean .setPassword (hubConfig .getAppConfig ().getAppServicesPassword ());
9197
92- File file = new File (mlcpOptions .get ("input_file_path" ).asText ());
93- String canonicalPath = file .getCanonicalPath ();
94- bean .setInput_file_path (canonicalPath );
95- bean .setTransform_param ("\" " + bean .getTransform_param () + ",job-id=" + jobId + "\" " );
98+ if (!"copy" .equals (bean .getCommand ().toLowerCase ())) {
99+ // Assume that the HTTP credentials will work for mlcp
100+ bean .setUsername (hubConfig .getAppConfig ().getAppServicesUsername ());
101+ bean .setPassword (hubConfig .getAppConfig ().getAppServicesPassword ());
102+ }
103+
104+ if (mlcpOptions .has ("input_file_path" )) {
105+ File file = new File (mlcpOptions .get ("input_file_path" ).asText ());
106+ String canonicalPath = file .getCanonicalPath ();
107+ bean .setInput_file_path (canonicalPath );
108+ }
109+
110+ if (job != null ) {
111+ bean .setTransform_param ("\" " + bean .getTransform_param () + ",job-id=" + jobId + "\" " );
112+ }
113+
96114 bean .setModules_root ("/" );
97115
98116 if (hubConfig .getIsHostLoadBalancer ()) {
@@ -108,28 +126,30 @@ public void run() {
108126 }
109127
110128 } catch (Exception e ) {
111- job .withStatus (JobStatus .FAILED )
112- .withEndTime (new Date ());
113- jobManager .saveJob (job );
129+ if (job != null ) {
130+ job .withStatus (JobStatus .FAILED )
131+ .withEndTime (new Date ());
132+ jobManager .saveJob (job );
133+ }
114134 throw new RuntimeException (e );
115135 } finally {
116- JobStatus status ;
117- if (failedEvents .get () > 0 && successfulEvents .get () > 0 ) {
118- status = JobStatus .FINISHED_WITH_ERRORS ;
119- }
120- else if (failedEvents .get () == 0 && successfulEvents .get () > 0 ) {
121- status = JobStatus .FINISHED ;
122- }
123- else {
124- status = JobStatus .FAILED ;
125- }
136+ if (job != null ) {
137+ JobStatus status ;
138+ if (failedEvents .get () > 0 && successfulEvents .get () > 0 ) {
139+ status = JobStatus .FINISHED_WITH_ERRORS ;
140+ } else if (failedEvents .get () == 0 && successfulEvents .get () > 0 ) {
141+ status = JobStatus .FINISHED ;
142+ } else {
143+ status = JobStatus .FAILED ;
144+ }
126145
127- // store the thing in MarkLogic
128- job .withJobOutput (getProcessOutput ())
129- .withStatus (status )
130- .setCounts (successfulEvents .get (), failedEvents .get (), 0 , 0 )
131- .withEndTime (new Date ());
132- jobManager .saveJob (job );
146+ // store the thing in MarkLogic
147+ job .withJobOutput (getProcessOutput ())
148+ .withStatus (status )
149+ .setCounts (successfulEvents .get (), failedEvents .get (), 0 , 0 )
150+ .withEndTime (new Date ());
151+ jobManager .saveJob (job );
152+ }
133153 }
134154 }
135155
@@ -152,8 +172,8 @@ private String buildLoggerconfig() {
152172 " <logger name=\" com.marklogic.client.impl.DatabaseClientImpl\" level=\" WARN\" />\n " +
153173 " <logger name=\" com.marklogic\" level=\" INFO\" />\n " +
154174 " <logger name=\" com.marklogic.appdeployer\" level=\" INFO\" />\n " +
155- " <logger name=\" com.marklogic.hub\" level=\" INFO \" />\n " +
156- " <logger name=\" com.marklogic.contentpump\" level=\" INFO \" />\n " +
175+ " <logger name=\" com.marklogic.hub\" level=\" DEBUG \" />\n " +
176+ " <logger name=\" com.marklogic.contentpump\" level=\" DEBUG \" />\n " +
157177 " <logger name=\" org.apache.catalina.webresources.Cache\" level=\" ERROR\" />\n " +
158178 " <logger name=\" org.apache.hadoop.util.Shell\" level=\" OFF\" />\n " +
159179 " <logger name=\" org.apache.hadoop.util.NativeCodeLoader\" level=\" ERROR\" />\n " +
@@ -211,7 +231,8 @@ else if (!mlcpFile.canExecute()) {
211231 u .contains ("guava" ) ||
212232 u .contains ("apache" ) ||
213233 u .contains ("commons" ) ||
214- u .contains ("hadoop" ))
234+ u .contains ("hadoop" ) ||
235+ u .contains ("thoughtworks" ))
215236 ).collect (Collectors .joining (File .pathSeparator ));
216237
217238 //logger.warn("Classpath filtered to: " + filteredClasspathEntries);
0 commit comments