Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 20 additions & 9 deletions src/OrleansRuntime/GrainTypeManager/TypeManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

namespace Orleans.Runtime
{
internal class TypeManager : SystemTarget, IClusterTypeManager, ISiloTypeManager, ISiloStatusListener
internal class TypeManager : SystemTarget, IClusterTypeManager, ISiloTypeManager, ISiloStatusListener, IDisposable
{
private readonly Logger logger = LogManager.GetLogger("TypeManager");
private readonly GrainTypeManager grainTypeManager;
Expand All @@ -20,17 +20,17 @@ internal class TypeManager : SystemTarget, IClusterTypeManager, ISiloTypeManager
private readonly IInternalGrainFactory grainFactory;
private readonly CachedVersionSelectorManager versionSelectorManager;
private readonly OrleansTaskScheduler scheduler;
private readonly TimeSpan refreshClusterMapTimeout;
private readonly TimeSpan refreshClusterMapInterval;
private bool hasToRefreshClusterGrainInterfaceMap;
private AsyncTaskSafeTimer refreshClusterGrainInterfaceMapTimer;
private IDisposable refreshClusterGrainInterfaceMapTimer;
private IVersionStore versionStore;

internal TypeManager(
SiloAddress myAddr,
GrainTypeManager grainTypeManager,
ISiloStatusOracle oracle,
OrleansTaskScheduler scheduler,
TimeSpan refreshClusterMapTimeout,
TimeSpan refreshClusterMapInterval,
ImplicitStreamSubscriberTable implicitStreamSubscriberTable,
IInternalGrainFactory grainFactory,
CachedVersionSelectorManager versionSelectorManager)
Expand All @@ -51,18 +51,21 @@ internal TypeManager(
this.grainFactory = grainFactory;
this.versionSelectorManager = versionSelectorManager;
this.scheduler = scheduler;
this.refreshClusterMapTimeout = refreshClusterMapTimeout;
this.refreshClusterMapInterval = refreshClusterMapInterval;
}

internal void Initialize(IVersionStore store)
internal async Task Initialize(IVersionStore store)
{
this.versionStore = store;
this.hasToRefreshClusterGrainInterfaceMap = true;
this.refreshClusterGrainInterfaceMapTimer = new AsyncTaskSafeTimer(

await this.OnRefreshClusterMapTimer(null);

this.refreshClusterGrainInterfaceMapTimer = this.RegisterTimer(
OnRefreshClusterMapTimer,
null,
TimeSpan.Zero, // Force to do it once right now
refreshClusterMapTimeout);
this.refreshClusterMapInterval,
this.refreshClusterMapInterval);
}

public Task<IGrainTypeResolver> GetClusterTypeCodeMap()
Expand Down Expand Up @@ -221,6 +224,14 @@ private async Task<KeyValuePair<SiloAddress, GrainInterfaceMap>> GetTargetSiloGr
return new KeyValuePair<SiloAddress, GrainInterfaceMap>(siloAddress, null);
}
}

public void Dispose()
{
if (this.refreshClusterGrainInterfaceMapTimer != null)
{
this.refreshClusterGrainInterfaceMapTimer.Dispose();
}
}
}
}

Expand Down
3 changes: 2 additions & 1 deletion src/OrleansRuntime/Silo/Silo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -591,7 +591,8 @@ private void DoStart()
allSiloProviders.AddRange(storageProviderManager.GetProviders());
var versionStore = Services.GetService<IVersionStore>() as GrainVersionStore;
versionStore?.SetStorageManager(storageProviderManager);
typeManager.Initialize(versionStore);
scheduler.QueueTask(() => this.typeManager.Initialize(versionStore), this.typeManager.SchedulingContext)
.WaitWithThrow(this.initTimeout);
if (logger.IsVerbose) { logger.Verbose("Storage provider manager created successfully."); }

// Initialize log consistency providers once we have a basic silo runtime environment operating
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,11 +142,11 @@ public async Task ChangeDefaultVersionSelectorStrategy()
var grainV1 = Client.GetGrain<IVersionUpgradeTestGrain>(0);
Assert.Equal(1, await grainV1.GetVersion());

await StartSiloV2();

// Change default to minimum version
await ManagementGrain.SetSelectorStrategy(MinimumVersion.Singleton);

await StartSiloV2();

// But only activate V1
for (int i = 0; i < 100; i++)
{
Expand Down