1010
1111namespace Orleans . Runtime
1212{
13- internal sealed partial class Catalog : SystemTarget , ICatalog , ILifecycleParticipant < ISiloLifecycle >
13+ internal sealed partial class Catalog : SystemTarget , ICatalog , ILifecycleParticipant < ISiloLifecycle > , ISiloStatusListener
1414 {
1515 private readonly SiloAddress _siloAddress ;
1616 private readonly ActivationCollector activationCollector ;
@@ -302,6 +302,14 @@ await Parallel.ForEachAsync(addresses, (activationAddress, cancellationToken) =>
302302 } ) ;
303303 }
304304
305+ void ISiloStatusListener . SiloStatusChangeNotification ( SiloAddress updatedSilo , SiloStatus status )
306+ {
307+ if ( status == SiloStatus . Dead )
308+ {
309+ this . RuntimeClient . BreakOutstandingMessagesToSilo ( updatedSilo ) ;
310+ }
311+ }
312+
305313 // TODO move this logic in the LocalGrainDirectory
306314 internal void OnSiloStatusChange ( ILocalGrainDirectory directory , SiloAddress updatedSilo , SiloStatus status )
307315 {
@@ -313,10 +321,6 @@ internal void OnSiloStatusChange(ILocalGrainDirectory directory, SiloAddress upd
313321 // thus it will only deliver a "remove" notification for a given silo once to us. Therefore, we need to react the fist time we are notified.
314322 // We may review the directory behavior in the future and treat ShuttingDown differently ("drain only") and then this code will have to change a well.
315323 if ( ! status . IsTerminating ( ) ) return ;
316- if ( status == SiloStatus . Dead )
317- {
318- this . RuntimeClient . BreakOutstandingMessagesToSilo ( updatedSilo ) ;
319- }
320324
321325 var activationsToShutdown = new List < IGrainContext > ( ) ;
322326 try
@@ -374,6 +378,7 @@ void ILifecycleParticipant<ISiloLifecycle>.Participate(ISiloLifecycle lifecycle)
374378 {
375379 // Do nothing, just ensure that this instance is created so that it can register itself in the activation directory.
376380 _siloStatusOracle = serviceProvider . GetRequiredService < ISiloStatusOracle > ( ) ;
381+ _siloStatusOracle . SubscribeToSiloStatusEvents ( this ) ;
377382 }
378383
379384 private readonly struct SiloAddressLogValue ( SiloAddress silo )
@@ -430,6 +435,5 @@ private readonly struct SiloAddressLogValue(SiloAddress silo)
430435 Message = "Failed to unregister non-existent activation {Address}"
431436 ) ]
432437 private partial void LogFailedToUnregisterNonExistingActivation ( GrainAddress address , Exception exception ) ;
433-
434438 }
435439}
0 commit comments