Skip to content

Commit 2cfbaad

Browse files
committed
Merge remote-tracking branch 'origin/candidate-9.6.x' into candidate-9.8.x
2 parents 66146e6 + 00c55c7 commit 2cfbaad

File tree

8 files changed

+523
-51
lines changed

8 files changed

+523
-51
lines changed

.github/workflows/Jirabot.yml

+15-4
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,17 @@ jobs:
4444
import time
4545
import sys
4646
import json
47+
import subprocess
48+
from email.utils import parseaddr
4749
from atlassian.jira import Jira
4850
51+
def sanitizeInput(input: str, inputType: str) -> str:
52+
if inputType.lower() == 'email':
53+
# Return the email address only, returns '' if not valid or found
54+
return parseaddr(input)[1]
55+
else:
56+
return ''
57+
4958
def updateIssue(jira, issue, prAuthor : str, propertyMap: dict, pull_url: str) -> str:
5059
result = ''
5160
@@ -83,8 +92,12 @@ jobs:
8392
assigneeId = assignee['accountId']
8493
assigneeEmail = assignee["emailAddress"]
8594
95+
assigneeEmail = sanitizeInput(assigneeEmail, 'email')
96+
8697
prAuthorId = prAuthor["accountId"]
8798
prAuthorEmail = prAuthor["emailAddress"]
99+
prAuthorEmail = sanitizeInput(prAuthorEmail, 'email')
100+
88101
if assigneeId is None or assigneeId == '':
89102
jira.assign_issue(issueName, prAuthorId)
90103
result += 'Assigning user: ' + prAuthorEmail + '\n'
@@ -104,7 +117,6 @@ jobs:
104117
github_token = os.environ['GITHUB_TOKEN']
105118
comments_url = os.environ['COMMENTS_URL']
106119
107-
print("%s %s %s" % (title, prAuthor, comments_url))
108120
result = ''
109121
issuem = re.search("(HPCC4J|JAPI)-[0-9]+", title)
110122
if issuem:
@@ -126,7 +138,7 @@ jobs:
126138
if userSearchResults and len(userSearchResults) > 0:
127139
jiraUser = userSearchResults[0]
128140
else:
129-
print('Error: Unable to find Jira user: ' + prAuthor + ' continuing without assigning')
141+
print('Error: Unable to map GitHub user to Jira user, continuing without assigning')
130142
131143
if not jira.issue_exists(issue_name):
132144
sys.exit('Error: Unable to find Jira issue: ' + issue_name)
@@ -148,8 +160,7 @@ jobs:
148160
# Escape the result for JSON
149161
result = json.dumps(result)
150162
151-
curlCommand = 'curl -X POST %s -H "Content-Type: application/json" -H "Authorization: token %s" --data \'{ "body": %s }\'' % ( comments_url, github_token, result )
152-
os.system(curlCommand)
163+
subprocess.run(['curl', '-X', 'POST', comments_url, '-H', 'Content-Type: application/json', '-H', f'Authorization: token {github_token}', '--data', f'{{ "body": {result} }}'], check=True)
153164
else:
154165
print('Unable to find Jira issue name in title')
155166

.github/workflows/JirabotMerge.yml

-1
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,6 @@ jobs:
205205
comments_url = os.environ['COMMENTS_URL']
206206
project_name = 'HPCC4J'
207207
208-
print("Attempting to close out Jira issue: %s %s %s" % (title, user, comments_url))
209208
result = ''
210209
issuem = re.search("(" + project_name + ")-[0-9]+", title, re.IGNORECASE)
211210
if issuem:

dfsclient/src/main/java/org/hpccsystems/dfs/client/HPCCRemoteFileWriter.java

+28-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,14 @@
1414

1515
import org.hpccsystems.commons.ecl.FieldDef;
1616
import org.hpccsystems.commons.ecl.RecordDefinitionTranslator;
17+
1718
import org.hpccsystems.dfs.client.RowServiceOutputStream;
19+
import org.hpccsystems.dfs.client.Utils;
20+
21+
import io.opentelemetry.api.common.AttributeKey;
22+
import io.opentelemetry.api.common.Attributes;
23+
import io.opentelemetry.api.trace.Span;
24+
import io.opentelemetry.semconv.ServerAttributes;
1825

1926
import org.apache.logging.log4j.Logger;
2027
import org.apache.logging.log4j.LogManager;
@@ -37,6 +44,9 @@ public class HPCCRemoteFileWriter<T>
3744
private long recordsWritten = 0;
3845
private long openTimeMs = 0;
3946

47+
private Span writeSpan = null;
48+
private String writeSpanName = null;
49+
4050
/**
4151
* A remote file writer.
4252
*
@@ -105,9 +115,24 @@ public HPCCRemoteFileWriter(DataPartition dp, FieldDef recordDef, IRecordAccesso
105115

106116
this.recordAccessor = recordAccessor;
107117

118+
this.writeSpanName = "HPCCRemoteFileWriter.RowService/Write_" + dp.getFileName() + "_" + dp.getThisPart();
119+
this.writeSpan = Utils.createSpan(writeSpanName);
120+
121+
String primaryIP = dp.getCopyIP(0);
122+
String secondaryIP = "";
123+
if (dp.getCopyCount() > 1)
124+
{
125+
secondaryIP = dp.getCopyIP(1);
126+
}
127+
128+
Attributes attributes = Attributes.of( AttributeKey.stringKey("server.primary.address"), primaryIP,
129+
AttributeKey.stringKey("server.secondary.address"), secondaryIP,
130+
ServerAttributes.SERVER_PORT, Long.valueOf(dp.getPort()));
131+
writeSpan.setAllAttributes(attributes);
132+
108133
this.outputStream = new RowServiceOutputStream(dataPartition.getCopyIP(0), dataPartition.getPort(), dataPartition.getUseSsl(),
109134
dataPartition.getFileAccessBlob(), this.recordDef, this.dataPartition.getThisPart(), this.dataPartition.getCopyPath(0),
110-
fileCompression, connectTimeoutMs, socketOpTimeoutMs);
135+
fileCompression, connectTimeoutMs, socketOpTimeoutMs, this.writeSpan);
111136

112137
this.binaryRecordWriter = new BinaryRecordWriter(this.outputStream);
113138
this.binaryRecordWriter.initialize(this.recordAccessor);
@@ -161,6 +186,8 @@ public void close() throws Exception
161186
this.report();
162187
this.binaryRecordWriter.finalize();
163188

189+
this.writeSpan.end();
190+
164191
long closeTimeMs = System.currentTimeMillis();
165192
double writeTimeS = (closeTimeMs - openTimeMs) / 1000.0;
166193
log.info("HPCCRemoteFileWriter: Closing file part: " + dataPartition.getThisPart()

dfsclient/src/main/java/org/hpccsystems/dfs/client/HpccRemoteFileReader.java

+48-6
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,17 @@
1212
*******************************************************************************/
1313
package org.hpccsystems.dfs.client;
1414

15+
import org.hpccsystems.dfs.client.Utils;
16+
1517
import org.hpccsystems.commons.ecl.FieldDef;
1618
import org.hpccsystems.commons.ecl.RecordDefinitionTranslator;
1719
import org.hpccsystems.commons.errors.HpccFileException;
20+
21+
import io.opentelemetry.api.common.AttributeKey;
22+
import io.opentelemetry.api.common.Attributes;
23+
import io.opentelemetry.api.trace.Span;
24+
import io.opentelemetry.semconv.ServerAttributes;
25+
1826
import org.apache.logging.log4j.Logger;
1927
import org.apache.logging.log4j.LogManager;
2028

@@ -48,6 +56,9 @@ public class HpccRemoteFileReader<T> implements Iterator<T>
4856
private long openTimeMs = 0;
4957
private long recordsRead = 0;
5058

59+
private Span readSpan = null;
60+
private String readSpanName = null;
61+
5162
public static final int NO_RECORD_LIMIT = -1;
5263
public static final int DEFAULT_READ_SIZE_OPTION = -1;
5364
public static final int DEFAULT_CONNECT_TIMEOUT_OPTION = -1;
@@ -204,6 +215,22 @@ public HpccRemoteFileReader(DataPartition dp, FieldDef originalRD, IRecordBuilde
204215
this.createPrefetchThread = createPrefetchThread;
205216
this.socketOpTimeoutMs = socketOpTimeoutMs;
206217

218+
this.readSpanName = "HPCCRemoteFileReader.RowService/Read_" + dp.getFileName() + "_" + dp.getThisPart();
219+
this.readSpan = Utils.createSpan(readSpanName);
220+
221+
String primaryIP = dp.getCopyIP(0);
222+
String secondaryIP = "";
223+
if (dp.getCopyCount() > 1)
224+
{
225+
secondaryIP = dp.getCopyIP(1);
226+
}
227+
228+
Attributes attributes = Attributes.of( AttributeKey.stringKey("server.primary.address"), primaryIP,
229+
AttributeKey.stringKey("server.secondary.address"), secondaryIP,
230+
ServerAttributes.SERVER_PORT, Long.valueOf(dp.getPort()),
231+
AttributeKey.longKey("read.size"), Long.valueOf(readSizeKB*1000));
232+
readSpan.setAllAttributes(attributes);
233+
207234
if (connectTimeout < 1)
208235
{
209236
connectTimeout = RowServiceInputStream.DEFAULT_CONNECT_TIMEOUT_MILIS;
@@ -212,18 +239,24 @@ public HpccRemoteFileReader(DataPartition dp, FieldDef originalRD, IRecordBuilde
212239

213240
if (this.originalRecordDef == null)
214241
{
215-
throw new Exception("HpccRemoteFileReader: Provided original record definition is null, original record definition is required.");
242+
Exception e = new Exception("HpccRemoteFileReader: Provided original record definition is null, original record definition is required.");
243+
this.readSpan.recordException(e);
244+
this.readSpan.end();
245+
throw e;
216246
}
217247

218248
FieldDef projectedRecordDefinition = recBuilder.getRecordDefinition();
219249
if (projectedRecordDefinition == null)
220250
{
221-
throw new Exception("IRecordBuilder does not have a valid record definition.");
251+
Exception e = new Exception("IRecordBuilder does not have a valid record definition.");
252+
this.readSpan.recordException(e);
253+
this.readSpan.end();
254+
throw e;
222255
}
223256

224257
if (resumeInfo == null)
225258
{
226-
this.inputStream = new RowServiceInputStream(this.dataPartition, this.originalRecordDef, projectedRecordDefinition, connectTimeout, limit, createPrefetchThread, readSizeKB, null, false, socketOpTimeoutMs);
259+
this.inputStream = new RowServiceInputStream(this.dataPartition, this.originalRecordDef, projectedRecordDefinition, connectTimeout, limit, createPrefetchThread, readSizeKB, null, false, socketOpTimeoutMs, readSpan);
227260
this.binaryRecordReader = new BinaryRecordReader(this.inputStream);
228261
this.binaryRecordReader.initialize(this.recordBuilder);
229262

@@ -238,11 +271,14 @@ public HpccRemoteFileReader(DataPartition dp, FieldDef originalRD, IRecordBuilde
238271
restartInfo.streamPos = resumeInfo.inputStreamPos;
239272
restartInfo.tokenBin = resumeInfo.tokenBin;
240273

241-
this.inputStream = new RowServiceInputStream(this.dataPartition, this.originalRecordDef, projectedRecordDefinition, connectTimeout, limit, createPrefetchThread, readSizeKB, restartInfo, false, socketOpTimeoutMs);
274+
this.inputStream = new RowServiceInputStream(this.dataPartition, this.originalRecordDef, projectedRecordDefinition, connectTimeout, limit, createPrefetchThread, readSizeKB, restartInfo, false, socketOpTimeoutMs, this.readSpan);
275+
242276
long bytesToSkip = resumeInfo.recordReaderStreamPos - resumeInfo.inputStreamPos;
243277
if (bytesToSkip < 0)
244278
{
245-
throw new Exception("Unable to restart unexpected stream pos in record reader.");
279+
Exception e = new Exception("Unable to restart read stream, unexpected stream position in record reader.");
280+
this.readSpan.recordException(e);
281+
this.readSpan.end();
246282
}
247283
this.inputStream.skip(bytesToSkip);
248284

@@ -279,9 +315,11 @@ private boolean retryRead()
279315

280316
try
281317
{
318+
this.readSpan = Utils.createSpan(readSpanName);
282319
this.inputStream = new RowServiceInputStream(this.dataPartition, this.originalRecordDef,
283320
this.recordBuilder.getRecordDefinition(), this.connectTimeout, this.limit, this.createPrefetchThread,
284-
this.readSizeKB, restartInfo, false, this.socketOpTimeoutMs);
321+
this.readSizeKB, restartInfo, false, this.socketOpTimeoutMs, this.readSpan);
322+
285323
long bytesToSkip = resumeInfo.recordReaderStreamPos - resumeInfo.inputStreamPos;
286324
if (bytesToSkip < 0)
287325
{
@@ -294,6 +332,8 @@ private boolean retryRead()
294332
}
295333
catch (Exception e)
296334
{
335+
this.readSpan.recordException(e);
336+
this.readSpan.end();
297337
log.error("Failed to retry read for " + this.dataPartition.toString() + " " + e.getMessage(), e);
298338
return false;
299339
}
@@ -499,7 +539,9 @@ public void close() throws Exception
499539
return;
500540
}
501541

542+
this.readSpan.end();
502543
report();
544+
503545
this.inputStream.close();
504546
isClosed = true;
505547

0 commit comments

Comments
 (0)