Skip to content

Commit 8367c7e

Browse files
author
drealeed
committed
changed base64 encoder, added setmaxtime to submitecl so asynchronous
runs can run
1 parent 6429af1 commit 8367c7e

File tree

2 files changed

+64
-14
lines changed

2 files changed

+64
-14
lines changed

pom.xml

+5
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,11 @@
126126
<artifactId>junit</artifactId>
127127
<scope>test</scope>
128128
</dependency>
129+
<dependency>
130+
<groupId>commons-codec</groupId>
131+
<artifactId>commons-codec</artifactId>
132+
<version>1.2</version>
133+
</dependency>
129134
</dependencies>
130135

131136
</project>

src/main/java/org/hpccsystems/javaecl/ECLSoap.java

+59-14
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import java.net.*;
77
import java.io.*;
88
import java.util.*;
9-
import sun.misc.BASE64Encoder;
9+
import org.apache.commons.codec.binary.Base64;
1010
import java.io.BufferedReader;
1111
import java.io.BufferedWriter;
1212
import java.io.ByteArrayInputStream;
@@ -64,7 +64,7 @@ public class ECLSoap {
6464
private String maxReturn = "";
6565
private String cluster = "";
6666
private boolean includeML = false;
67-
67+
private int maxRunTime=300; //in seconds, 300 is server default;
6868
private String outputName = "";
6969

7070
private String wuid = "";
@@ -73,6 +73,7 @@ public class ECLSoap {
7373

7474
private int errorCount = 0;
7575
private int warningCount = 0;
76+
private String errorText = "";
7677

7778
private String user = "";
7879
private String pass = "";
@@ -239,6 +240,8 @@ public void setIncludeSALT(boolean includeSALT) {
239240
//end getters and setters
240241

241242

243+
244+
242245
public ECLSoap() {
243246
if (System.getProperty("os.name").startsWith("Windows")) {
244247
this.tempDir = System.getProperty("java.io.tmpdir");
@@ -249,7 +252,15 @@ public ECLSoap() {
249252

250253
//System.out.println("OS Temp Dir is: " + tempDir);
251254
}
252-
public String syntaxCheck(String ecl){
255+
public String getErrorText() {
256+
return errorText;
257+
}
258+
259+
public void setErrorText(String errorText) {
260+
this.errorText = errorText;
261+
}
262+
263+
public String syntaxCheck(String ecl){
253264
String res = "";
254265
int test = 0;
255266
String inFile = this.outputName + "CheckSpoonEclCode.ecl";
@@ -324,6 +335,12 @@ public String syntaxCheck(String ecl){
324335

325336
pb.redirectErrorStream(true); // merge stdout, stderr of process
326337
System.out.println(pb.command().toString());
338+
boolean pathExists = (new File(eclccInstallDir)).exists();
339+
if(!pathExists){
340+
errorCount++;
341+
res += "Unable to locate the ecl compiler, Check Global Variables\r\n";
342+
errorText += "Unable to locate the ecl compiler, Check Global Variables\r\n";
343+
}
327344
File path = new File(eclccInstallDir);
328345
pb.directory(path);
329346
Process p = pb.start();
@@ -333,6 +350,7 @@ public String syntaxCheck(String ecl){
333350
String line;
334351
while((line = br.readLine()) != null){
335352
res += cleanError(line)+"\r\n";
353+
errorText += cleanError(line)+"\r\n";
336354
}
337355

338356
InputStream iError = p.getErrorStream();
@@ -342,6 +360,7 @@ public String syntaxCheck(String ecl){
342360
while((lineErr = brErr.readLine()) != null){
343361

344362
res += cleanError(lineErr)+"\r\n";
363+
errorText += cleanError(lineErr)+"\r\n";
345364
}
346365

347366
//deleteFile(this.tempDir+inFile);
@@ -388,7 +407,7 @@ public String cleanError(String in){
388407
String ec = matcher.group();
389408

390409
try{
391-
this.errorCount = Integer.parseInt(ec);
410+
this.errorCount = Integer.parseInt(ec) + this.errorCount;
392411
}catch (Exception ee){
393412

394413
}
@@ -415,7 +434,7 @@ public String cleanError(String in){
415434
String wc = matcher.group();
416435

417436
try{
418-
this.warningCount = Integer.parseInt(wc);
437+
this.warningCount = Integer.parseInt(wc) + this.warningCount;
419438
}catch (Exception we){
420439

421440
}
@@ -730,13 +749,16 @@ public void submitSoapCall(String wuid){
730749
"<soapenv:Body>"+
731750
"<WUSubmit xmlns=\"urn:hpccsystems:ws:wsworkunits\">"+
732751
"<Wuid>" + wuid + "</Wuid>"+
752+
"<MaxRunTime>" + maxRunTime + "<MaxRunTime>" +
733753
"<Cluster>" + this.cluster + "</Cluster>"+
734754
"</WUSubmit>"+
735755
"</soapenv:Body>"+
736756
"</soapenv:Envelope>";
737757

738758
String path = "/WsWorkunits/WUSubmit";
739759
InputStream is2 = this.doSoap(xml, path);
760+
761+
//need to check for errors here
740762
}
741763

742764
/*
@@ -1139,7 +1161,7 @@ public InputStream doSoap(String xmldata, String path){
11391161
URLConnection conn = null;
11401162
boolean isError = false;
11411163
boolean isSuccess = false;
1142-
1164+
11431165
int errorCnt = 0;
11441166
InputStream is = null;
11451167
while(errorCnt < 5 && !isSuccess && !isLogonFail){
@@ -1167,8 +1189,7 @@ public InputStream doSoap(String xmldata, String path){
11671189
if(!user.equals("")){
11681190
String authStr = user + ":" + pass;
11691191
//System.out.println("USER INFO: " + authStr);
1170-
BASE64Encoder encoder = new BASE64Encoder();
1171-
String encoded = encoder.encode(authStr.getBytes());
1192+
String encoded = new String(Base64.encodeBase64(authStr.getBytes()));
11721193

11731194

11741195
conn.setRequestProperty("Authorization","Basic "+encoded);
@@ -1266,7 +1287,12 @@ private String compileECL(String ecl){
12661287

12671288
// System.out.println("_________________________ECLCC_______________________________");
12681289

1269-
1290+
boolean pathExists = (new File(eclccInstallDir)).exists();
1291+
if(!pathExists){
1292+
errorCount++;
1293+
errorText += "Unable to locate the ecl compiler, Check Global Variables\r\n";
1294+
}
1295+
12701296
ArrayList<String> paramsAL = new ArrayList<String>();
12711297
paramsAL.add(c);
12721298
paramsAL.add("-E");
@@ -1322,9 +1348,9 @@ private String compileECL(String ecl){
13221348
// System.out.println("+++++++++++++++++++++");
13231349
// System.out.println("+++++++++++++++++++++");
13241350
// System.out.println("+++++++++++++++++++++");
1325-
System.out.println("++++++++++Compile ECLSOAP+++++++++++");
1326-
System.out.println("+++++++++++++++++++++");
1327-
System.out.println(pb.command().toString());
1351+
//System.out.println("++++++++++Compile ECLSOAP+++++++++++");
1352+
// System.out.println("+++++++++++++++++++++");
1353+
//System.out.println(pb.command().toString());
13281354
pb.redirectErrorStream(true); // merge stdout, stderr of process
13291355

13301356
File path = new File(eclccInstallDir);
@@ -1337,7 +1363,7 @@ private String compileECL(String ecl){
13371363
String lineErr;
13381364
while((lineErr = brErr.readLine()) != null){
13391365
//System.out.println("#####"+lineErr);
1340-
1366+
errorText += lineErr + "\r\n";
13411367
}
13421368

13431369
InputStream is = p.getInputStream();
@@ -1347,6 +1373,7 @@ private String compileECL(String ecl){
13471373

13481374
while((line = br.readLine()) != null){
13491375
//System.out.println(line);
1376+
13501377
}
13511378

13521379

@@ -1453,10 +1480,20 @@ public static void main(String[] args){
14531480
System.out.println(line);
14541481
}
14551482

1483+
1484+
14561485
}catch (Exception e){
14571486
System.out.println(e.toString());
14581487
e.printStackTrace();
14591488
}
1489+
1490+
ECLSoap es = new ECLSoap();
1491+
es.setCluster("mythor");
1492+
es.setHostname("10.239.227.6");
1493+
es.setEclccInstallDir(eclccInstallDir);
1494+
es.setJobName("test");
1495+
es.executeECL("output('hi');");
1496+
14601497
}
14611498

14621499
/*
@@ -1499,7 +1536,15 @@ private static String openFile(String filePath){
14991536
return fileData.toString();
15001537
}
15011538

1502-
/*
1539+
public int getMaxRunTime() {
1540+
return maxRunTime;
1541+
}
1542+
1543+
public void setMaxRunTime(int maxRunTime) {
1544+
this.maxRunTime = maxRunTime;
1545+
}
1546+
1547+
/*
15031548
* ECLAuthenticator
15041549
*
15051550
* Hnadles the http authentication for the soap request

0 commit comments

Comments
 (0)