forked from LGouellec/streamiz
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
applied changes to fix issue LGouellec#328
- Loading branch information
Showing
11 changed files
with
108 additions
and
66 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
core/Processors/Internal/SequentiallyGracefullyShutdownHook.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
using System.Threading; | ||
using Microsoft.Extensions.Logging; | ||
using Streamiz.Kafka.Net.Crosscutting; | ||
|
||
namespace Streamiz.Kafka.Net.Processors.Internal | ||
{ | ||
internal class SequentiallyGracefullyShutdownHook | ||
{ | ||
private readonly IThread[] _streamThreads; | ||
private readonly GlobalStreamThread _globalStreamThread; | ||
private readonly IThread _externalStreamThread; | ||
private readonly CancellationTokenSource _tokenSource; | ||
private readonly ILogger log = Logger.GetLogger(typeof(SequentiallyGracefullyShutdownHook)); | ||
|
||
public SequentiallyGracefullyShutdownHook( | ||
IThread[] streamThreads, | ||
GlobalStreamThread globalStreamThread, | ||
IThread externalStreamThread, | ||
CancellationTokenSource tokenSource | ||
) | ||
{ | ||
_streamThreads = streamThreads; | ||
_globalStreamThread = globalStreamThread; | ||
_externalStreamThread = externalStreamThread; | ||
_tokenSource = tokenSource; | ||
} | ||
|
||
public void Shutdown() | ||
{ | ||
log.LogInformation($"Request shutdown gracefully"); | ||
_tokenSource.Cancel(); | ||
|
||
foreach (var t in _streamThreads) | ||
{ | ||
t.Dispose(); | ||
} | ||
|
||
_externalStreamThread?.Dispose(); | ||
_globalStreamThread?.Dispose(); | ||
|
||
log.LogInformation($"Shutdown gracefully successful"); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.