Skip to content

Commit

Permalink
Merge pull request #160 from Dynatrace/bugfixes-27
Browse files Browse the repository at this point in the history
Bugfixes
  • Loading branch information
discostu105 authored Feb 22, 2019
2 parents a7e8fdd + 8dab978 commit 413c158
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 13 deletions.
19 changes: 16 additions & 3 deletions src/SuperDumpService/Services/JiraApiService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
using System.Net.Http;
using System.Net.Http.Headers;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Web;
using Microsoft.Extensions.Options;
Expand Down Expand Up @@ -38,6 +39,7 @@ public class JiraApiService : IJiraApiService {
private const string JsonMediaType = "application/json";
private const string JiraIssueFields = "status,resolution";
private readonly string[] JiraIssueFieldsArray = JiraIssueFields.Split(",");
private readonly SemaphoreSlim authSync = new SemaphoreSlim(1, 1);

private readonly JiraIntegrationSettings settings;
private readonly HttpClient client;
Expand Down Expand Up @@ -81,12 +83,23 @@ private async Task Authenticate() {
}

private async Task EnsureAuthentication() {
// reauthenticate every 10 minutes
if (Session == null || (DateTime.Now - Session.loginInfo.previousLoginTime).Minutes > 10) {
await Authenticate();
if (ShallAuthenticate()) {
await authSync.WaitAsync().ConfigureAwait(false);
try {
if (ShallAuthenticate()) {
await Authenticate();
}
} finally {
authSync.Release();
}
}
}

private bool ShallAuthenticate() {
// reauthenticate every 10 minutes
return Session == null || (DateTime.Now - Session.loginInfo.previousLoginTime).Minutes > 10;
}

public async Task<IEnumerable<JiraIssueModel>> GetJiraIssues(string bundleId) {
return await JiraSearch($"text ~ {bundleId}");
}
Expand Down
11 changes: 5 additions & 6 deletions src/SuperDumpService/Services/SimilarityService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -138,20 +138,20 @@ public async Task CalculateSimilarityAsync(DumpMetainfo dumpA, bool force, DateT
var allDumps = dumpRepo.GetAll().Where(x => x.Created >= timeFrom).OrderBy(x => x.Created);
Console.WriteLine($"starting CalculateSimilarity for {allDumps.Count()} dumps; {dumpA} (TID:{Thread.CurrentThread.ManagedThreadId})");

var tasks = allDumps.Select(dumpB => Task.Run(async () => {
foreach(var dumpB in allDumps) {
if (!force) {
var existingSimilarity = await relationShipRepo.GetRelationShip(dumpA.Id, dumpB.Id);
if (existingSimilarity != 0) {
// relationship already exists. skip!
// but make sure the relationship is stored bi-directional
await relationShipRepo.UpdateSimilarity(dumpA.Id, dumpB.Id, existingSimilarity);
return;
continue;
}
}

if (!PreSelectOnMetadata(dumpA, dumpB)) return;
if (!PreSelectOnMetadata(dumpA, dumpB)) continue;
var resultB = await GetOrCreateMiniInfo(dumpB.Id);
if (!PreSelectOnResults(resultA, resultB)) return;
if (!PreSelectOnResults(resultA, resultB)) continue;

CrashSimilarity crashSimilarity = CrashSimilarity.Calculate(resultA, resultB);

Expand All @@ -160,8 +160,7 @@ public async Task CalculateSimilarityAsync(DumpMetainfo dumpA, bool force, DateT
await relationShipRepo.UpdateSimilarity(dumpA.Id, dumpB.Id, crashSimilarity.OverallSimilarity);
}
//Console.WriteLine($"CalculateSimilarity.Finished for {dumpA}/{dumpB} ({i} to go...); (elapsed: {sw.Elapsed}) (TID:{Thread.CurrentThread.ManagedThreadId})");
}));
await Task.WhenAll(tasks);
}

await relationShipRepo.FlushDirtyRelationships();
swTotal.Stop();
Expand Down
5 changes: 1 addition & 4 deletions src/SuperDumpService/Webterm/WebTermHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,7 @@ public void ReceiveMessage(string socketId, string input) {

// called by WebSocketManager
public void StartSession(string socketId, string bundleId, string dumpId, string initialCommand) {
StartSession0(socketId, DumpIdentifier.Create(bundleId, dumpId), initialCommand);
}

public void StartSession0(string socketId, DumpIdentifier id, string initialCommand) {
var id = DumpIdentifier.Create(bundleId, dumpId);
try {
System.Console.WriteLine($"StartSession ({socketId}): {id}");
if (string.IsNullOrEmpty(id.BundleId) || string.IsNullOrEmpty(id.DumpId)) {
Expand Down
6 changes: 6 additions & 0 deletions src/SuperDumpService/web.config
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,11 @@
<environmentVariable name="ASPNETCORE_HTTPS_PORT" value="44379" />
</environmentVariables>
</aspNetCore>
<security>
<requestFiltering>
<!-- set max allowed request content length to 4GB - 1byte (IIS does not allow a value >= 4GB) -->
<requestLimits maxAllowedContentLength="4294967295" />
</requestFiltering>
</security>
</system.webServer>
</configuration>

0 comments on commit 413c158

Please sign in to comment.