Skip to content
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -58,25 +58,25 @@ public override Task ParameterAndStateAreNotUpdatedWhenEpochDoesNotMatch()


[TestMethod]
public override Task RestartExecutionsWithoutMessagesReturnsEmptyDictionaryWhenNoFlowsAreEligible()
=> RestartExecutionsWithoutMessagesReturnsEmptyDictionaryWhenNoFlowsAreEligible(FunctionStoreFactory.Create());
public override Task RestartExecutionsReturnsEmptyDictionaryWhenNoFlowsAreEligible()
=> RestartExecutionsReturnsEmptyDictionaryWhenNoFlowsAreEligible(FunctionStoreFactory.Create());




[TestMethod]
public override Task RestartExecutionsWithoutMessagesRestartsMultipleUnownedFlows()
=> RestartExecutionsWithoutMessagesRestartsMultipleUnownedFlows(FunctionStoreFactory.Create());
public override Task RestartExecutionsRestartsMultipleUnownedFlows()
=> RestartExecutionsRestartsMultipleUnownedFlows(FunctionStoreFactory.Create());

[TestMethod]
public override Task RestartExecutionsWithoutMessagesRestartsOnlyUnownedFlows()
=> RestartExecutionsWithoutMessagesRestartsOnlyUnownedFlows(FunctionStoreFactory.Create());
public override Task RestartExecutionsRestartsOnlyUnownedFlows()
=> RestartExecutionsRestartsOnlyUnownedFlows(FunctionStoreFactory.Create());

[TestMethod]
public override Task RestartExecutionsWithoutMessagesReturnsEmptyDictionaryForEmptyInput()
=> RestartExecutionsWithoutMessagesReturnsEmptyDictionaryForEmptyInput(FunctionStoreFactory.Create());
public override Task RestartExecutionsReturnsEmptyDictionaryForEmptyInput()
=> RestartExecutionsReturnsEmptyDictionaryForEmptyInput(FunctionStoreFactory.Create());

[TestMethod]
public override Task RestartExecutionsWithoutMessagesIncludesExistingEffects()
=> RestartExecutionsWithoutMessagesIncludesExistingEffects(FunctionStoreFactory.Create());
public override Task RestartExecutionsIncludesExistingEffects()
=> RestartExecutionsIncludesExistingEffects(FunctionStoreFactory.Create());
}
Original file line number Diff line number Diff line change
Expand Up @@ -212,8 +212,8 @@ public override Task GetResultsReturnsOnlyExistingFunctionResults()


[TestMethod]
public override Task RestartExecutionsWithoutMessagesDoesNotReturnFlowClaimedByPreviousCall()
=> RestartExecutionsWithoutMessagesDoesNotReturnFlowClaimedByPreviousCall(FunctionStoreFactory.Create());
public override Task RestartExecutionsDoesNotReturnFlowClaimedByPreviousCall()
=> RestartExecutionsDoesNotReturnFlowClaimedByPreviousCall(FunctionStoreFactory.Create());

[TestMethod]
public override Task RestartExecutionsDoesNotClaimSucceededFlow()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -312,8 +312,8 @@ await store.SetParameters(
sf.Parameter.ShouldNotBeNull();
}

public abstract Task RestartExecutionsWithoutMessagesReturnsEmptyDictionaryWhenNoFlowsAreEligible();
public async Task RestartExecutionsWithoutMessagesReturnsEmptyDictionaryWhenNoFlowsAreEligible(Task<IFunctionStore> storeTask)
public abstract Task RestartExecutionsReturnsEmptyDictionaryWhenNoFlowsAreEligible();
public async Task RestartExecutionsReturnsEmptyDictionaryWhenNoFlowsAreEligible(Task<IFunctionStore> storeTask)
{
var store = await storeTask;
var storedId1 = TestStoredId.Create();
Expand Down Expand Up @@ -342,13 +342,13 @@ await store.CreateFunction(
);

// Try to restart - should return empty dictionary
var result = await store.RestartExecutionsWithoutMessages([storedId1, storedId2], newOwner);
var result = await store.RestartExecutions([storedId1, storedId2], newOwner);

result.Count.ShouldBe(0);
}

public abstract Task RestartExecutionsWithoutMessagesRestartsMultipleUnownedFlows();
public async Task RestartExecutionsWithoutMessagesRestartsMultipleUnownedFlows(Task<IFunctionStore> storeTask)
public abstract Task RestartExecutionsRestartsMultipleUnownedFlows();
public async Task RestartExecutionsRestartsMultipleUnownedFlows(Task<IFunctionStore> storeTask)
{
var store = await storeTask;
var storedId1 = TestStoredId.Create();
Expand Down Expand Up @@ -386,7 +386,7 @@ await store.CreateFunction(
);

// Restart all three
var result = await store.RestartExecutionsWithoutMessages([storedId1, storedId2, storedId3], owner);
var result = await store.RestartExecutions([storedId1, storedId2, storedId3], owner);

// All three should be restarted
result.Count.ShouldBe(3);
Expand All @@ -402,8 +402,8 @@ await store.CreateFunction(
result[storedId3].StoredFlow.Status.ShouldBe(Status.Executing);
}

public abstract Task RestartExecutionsWithoutMessagesRestartsOnlyUnownedFlows();
public async Task RestartExecutionsWithoutMessagesRestartsOnlyUnownedFlows(Task<IFunctionStore> storeTask)
public abstract Task RestartExecutionsRestartsOnlyUnownedFlows();
public async Task RestartExecutionsRestartsOnlyUnownedFlows(Task<IFunctionStore> storeTask)
{
var store = await storeTask;
var storedId1 = TestStoredId.Create();
Expand Down Expand Up @@ -442,7 +442,7 @@ await store.CreateFunction(
);

// Restart all three - only 1 and 3 should succeed
var result = await store.RestartExecutionsWithoutMessages([storedId1, storedId2, storedId3], newOwner);
var result = await store.RestartExecutions([storedId1, storedId2, storedId3], newOwner);

result.Count.ShouldBe(2);
result.ContainsKey(storedId1).ShouldBeTrue();
Expand All @@ -453,19 +453,19 @@ await store.CreateFunction(
result[storedId3].StoredFlow.OwnerId.ShouldBe(newOwner);
}

public abstract Task RestartExecutionsWithoutMessagesReturnsEmptyDictionaryForEmptyInput();
public async Task RestartExecutionsWithoutMessagesReturnsEmptyDictionaryForEmptyInput(Task<IFunctionStore> storeTask)
public abstract Task RestartExecutionsReturnsEmptyDictionaryForEmptyInput();
public async Task RestartExecutionsReturnsEmptyDictionaryForEmptyInput(Task<IFunctionStore> storeTask)
{
var store = await storeTask;
var owner = ReplicaId.NewId();

var result = await store.RestartExecutionsWithoutMessages([], owner);
var result = await store.RestartExecutions([], owner);

result.Count.ShouldBe(0);
}

public abstract Task RestartExecutionsWithoutMessagesIncludesExistingEffects();
public async Task RestartExecutionsWithoutMessagesIncludesExistingEffects(Task<IFunctionStore> storeTask)
public abstract Task RestartExecutionsIncludesExistingEffects();
public async Task RestartExecutionsIncludesExistingEffects(Task<IFunctionStore> storeTask)
{
var store = await storeTask;
var storedId1 = TestStoredId.Create();
Expand All @@ -488,7 +488,7 @@ public async Task RestartExecutionsWithoutMessagesIncludesExistingEffects(Task<I
Alias: null
);

// Create messages - these must NOT be fetched by RestartExecutionsWithoutMessages
// Create messages - these must NOT be fetched by RestartExecutions
var message1 = new StoredMessage(
MessageContent: "message1".ToUtf8Bytes(),
MessageType: "Type1".ToUtf8Bytes(),
Expand Down Expand Up @@ -529,7 +529,7 @@ await store.CreateFunction(
);

// Restart both
var result = await store.RestartExecutionsWithoutMessages([storedId1, storedId2], owner);
var result = await store.RestartExecutions([storedId1, storedId2], owner);

// Verify both flows returned with their effects
result.Count.ShouldBe(2);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1763,8 +1763,8 @@ await store.SucceedFunction(
results.ContainsKey(nonExistentFunctionId).ShouldBeFalse();
}

public abstract Task RestartExecutionsWithoutMessagesDoesNotReturnFlowClaimedByPreviousCall();
protected async Task RestartExecutionsWithoutMessagesDoesNotReturnFlowClaimedByPreviousCall(Task<IFunctionStore> storeTask)
public abstract Task RestartExecutionsDoesNotReturnFlowClaimedByPreviousCall();
protected async Task RestartExecutionsDoesNotReturnFlowClaimedByPreviousCall(Task<IFunctionStore> storeTask)
{
var store = await storeTask;
var functionId = TestStoredId.Create();
Expand All @@ -1780,13 +1780,13 @@ await store.CreateFunction(
owner: null
);

var firstClaim = await store.RestartExecutionsWithoutMessages([functionId], replicaId);
var firstClaim = await store.RestartExecutions([functionId], replicaId);
firstClaim.Count.ShouldBe(1);
firstClaim.ContainsKey(functionId).ShouldBeTrue();
firstClaim[functionId].StoredFlow.OwnerId.ShouldBe(replicaId);
firstClaim[functionId].StoredFlow.Status.ShouldBe(Status.Executing);

var secondClaim = await store.RestartExecutionsWithoutMessages([functionId], replicaId);
var secondClaim = await store.RestartExecutions([functionId], replicaId);
secondClaim.ShouldBeEmpty();
}

Expand Down Expand Up @@ -1818,7 +1818,7 @@ await store.SucceedFunction(
).ShouldBeTrueAsync();

// A message arriving after the flow completed must not resurrect it.
var claimedWithoutMessages = await store.RestartExecutionsWithoutMessages([functionId], ReplicaId.NewId());
var claimedWithoutMessages = await store.RestartExecutions([functionId], ReplicaId.NewId());
claimedWithoutMessages.ShouldBeEmpty();

var sf = await store.GetFunction(functionId);
Expand Down Expand Up @@ -1853,7 +1853,7 @@ await store.SuspendFunction(
).ShouldBeTrueAsync();

var newOwner = ReplicaId.NewId();
var claimed = await store.RestartExecutionsWithoutMessages([functionId], newOwner);
var claimed = await store.RestartExecutions([functionId], newOwner);
claimed.Count.ShouldBe(1);
claimed[functionId].StoredFlow.OwnerId.ShouldBe(newOwner);
claimed[functionId].StoredFlow.Status.ShouldBe(Status.Executing);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,10 @@ public Task<int> BulkScheduleFunctions(IEnumerable<IdWithParam> functionsWithPar
? Task.FromException<StoredFlowWithEffects?>(new TimeoutException())
: _inner.RestartExecution(storedId, replicaId);

public Task<Dictionary<StoredId, StoredFlowWithEffects>> RestartExecutionsWithoutMessages(IReadOnlyList<StoredId> storedIds, ReplicaId owner)
public Task<Dictionary<StoredId, StoredFlowWithEffects>> RestartExecutions(IReadOnlyList<StoredId> storedIds, ReplicaId owner)
=> _crashed
? Task.FromException<Dictionary<StoredId, StoredFlowWithEffects>>(new TimeoutException())
: _inner.RestartExecutionsWithoutMessages(storedIds, owner);
: _inner.RestartExecutions(storedIds, owner);

public Task<IReadOnlyList<StoredId>> GetExpiredFunctions(long isEligibleBefore)
=> _crashed
Expand Down
4 changes: 2 additions & 2 deletions Core/Cleipnir.ResilientFunctions/CoreRuntime/FlowsManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ public async Task RestartExecutions(IEnumerable<StoredMessages> messages)
try
{
results = await _functionStore
.RestartExecutionsWithoutMessages(groups.Keys.ToList(), _clusterInfo.ReplicaId);
.RestartExecutions(groups.Keys.ToList(), _clusterInfo.ReplicaId);
}
catch
{
Expand Down Expand Up @@ -148,7 +148,7 @@ public async Task RestartExecutions(IEnumerable<StoredMessages> messages)

// Resume each restarted flow, supplying the messages we already hold so it does not re-fetch them. Empty
// messages exist only to force the restart, so they are excluded from delivery. The claim + flow snapshot
// returned by RestartExecutionsWithoutMessages is everything the delegate needs, so no further store
// returned by RestartExecutions is everything the delegate needs, so no further store
// round-trip or re-claim is performed.
foreach (var (storedId, storedFlowWithEffects) in results)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ private async Task Start()
.ToList();

var restarts = await _functionStore
.RestartExecutionsWithoutMessages(ownedFunctions, _clusterInfo.ReplicaId);
.RestartExecutions(ownedFunctions, _clusterInfo.ReplicaId);

foreach (var id in restarts.Keys)
{
Expand Down
2 changes: 1 addition & 1 deletion Core/Cleipnir.ResilientFunctions/Storage/IFunctionStore.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ Task<int> BulkScheduleFunctions(
);

Task<StoredFlowWithEffects?> RestartExecution(StoredId storedId, ReplicaId owner);
Task<Dictionary<StoredId, StoredFlowWithEffects>> RestartExecutionsWithoutMessages(IReadOnlyList<StoredId> storedIds, ReplicaId owner);
Task<Dictionary<StoredId, StoredFlowWithEffects>> RestartExecutions(IReadOnlyList<StoredId> storedIds, ReplicaId owner);

Task<IReadOnlyList<StoredId>> GetExpiredFunctions(long expiresBefore);
Task<IReadOnlyList<StoredId>> GetSucceededFunctions(long completedBefore);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ public Task<int> BulkScheduleFunctions(IEnumerable<IdWithParam> functionsWithPar
);
}

public virtual async Task<Dictionary<StoredId, StoredFlowWithEffects>> RestartExecutionsWithoutMessages(
public virtual async Task<Dictionary<StoredId, StoredFlowWithEffects>> RestartExecutions(
IReadOnlyList<StoredId> storedIds,
ReplicaId owner)
{
Expand Down
4 changes: 2 additions & 2 deletions Samples/Sample.ConsoleApp/Utils/CrashableFunctionStore.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,10 @@ public Task<int> BulkScheduleFunctions(IEnumerable<IdWithParam> functionsWithPar
? Task.FromException<StoredFlowWithEffects?>(new TimeoutException())
: _inner.RestartExecution(storedId, replicaId);

public Task<Dictionary<StoredId, StoredFlowWithEffects>> RestartExecutionsWithoutMessages(IReadOnlyList<StoredId> storedIds, ReplicaId owner)
public Task<Dictionary<StoredId, StoredFlowWithEffects>> RestartExecutions(IReadOnlyList<StoredId> storedIds, ReplicaId owner)
=> _crashed
? Task.FromException<Dictionary<StoredId, StoredFlowWithEffects>>(new TimeoutException())
: _inner.RestartExecutionsWithoutMessages(storedIds, owner);
: _inner.RestartExecutions(storedIds, owner);

public Task<IReadOnlyList<StoredId>> GetExpiredFunctions(long expiresBefore)
=> _crashed
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,25 +55,25 @@ public override Task ParameterAndStateAreNotUpdatedWhenEpochDoesNotMatch()


[TestMethod]
public override Task RestartExecutionsWithoutMessagesReturnsEmptyDictionaryWhenNoFlowsAreEligible()
=> RestartExecutionsWithoutMessagesReturnsEmptyDictionaryWhenNoFlowsAreEligible(FunctionStoreFactory.Create());
public override Task RestartExecutionsReturnsEmptyDictionaryWhenNoFlowsAreEligible()
=> RestartExecutionsReturnsEmptyDictionaryWhenNoFlowsAreEligible(FunctionStoreFactory.Create());




[TestMethod]
public override Task RestartExecutionsWithoutMessagesRestartsMultipleUnownedFlows()
=> RestartExecutionsWithoutMessagesRestartsMultipleUnownedFlows(FunctionStoreFactory.Create());
public override Task RestartExecutionsRestartsMultipleUnownedFlows()
=> RestartExecutionsRestartsMultipleUnownedFlows(FunctionStoreFactory.Create());

[TestMethod]
public override Task RestartExecutionsWithoutMessagesRestartsOnlyUnownedFlows()
=> RestartExecutionsWithoutMessagesRestartsOnlyUnownedFlows(FunctionStoreFactory.Create());
public override Task RestartExecutionsRestartsOnlyUnownedFlows()
=> RestartExecutionsRestartsOnlyUnownedFlows(FunctionStoreFactory.Create());

[TestMethod]
public override Task RestartExecutionsWithoutMessagesReturnsEmptyDictionaryForEmptyInput()
=> RestartExecutionsWithoutMessagesReturnsEmptyDictionaryForEmptyInput(FunctionStoreFactory.Create());
public override Task RestartExecutionsReturnsEmptyDictionaryForEmptyInput()
=> RestartExecutionsReturnsEmptyDictionaryForEmptyInput(FunctionStoreFactory.Create());

[TestMethod]
public override Task RestartExecutionsWithoutMessagesIncludesExistingEffects()
=> RestartExecutionsWithoutMessagesIncludesExistingEffects(FunctionStoreFactory.Create());
public override Task RestartExecutionsIncludesExistingEffects()
=> RestartExecutionsIncludesExistingEffects(FunctionStoreFactory.Create());
}
Original file line number Diff line number Diff line change
Expand Up @@ -201,8 +201,8 @@ public override Task GetResultsReturnsOnlyExistingFunctionResults()


[TestMethod]
public override Task RestartExecutionsWithoutMessagesDoesNotReturnFlowClaimedByPreviousCall()
=> RestartExecutionsWithoutMessagesDoesNotReturnFlowClaimedByPreviousCall(FunctionStoreFactory.Create());
public override Task RestartExecutionsDoesNotReturnFlowClaimedByPreviousCall()
=> RestartExecutionsDoesNotReturnFlowClaimedByPreviousCall(FunctionStoreFactory.Create());

[TestMethod]
public override Task RestartExecutionsDoesNotClaimSucceededFlow()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ INSERT IGNORE INTO {_tablePrefix}
return new StoredFlowWithEffects(sf, effects, session);
}

public async Task<Dictionary<StoredId, StoredFlowWithEffects>> RestartExecutionsWithoutMessages(
public async Task<Dictionary<StoredId, StoredFlowWithEffects>> RestartExecutions(
IReadOnlyList<StoredId> storedIds,
ReplicaId owner)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,25 +56,25 @@ public override Task ParameterAndStateAreNotUpdatedWhenEpochDoesNotMatch()


[TestMethod]
public override Task RestartExecutionsWithoutMessagesReturnsEmptyDictionaryWhenNoFlowsAreEligible()
=> RestartExecutionsWithoutMessagesReturnsEmptyDictionaryWhenNoFlowsAreEligible(FunctionStoreFactory.Create());
public override Task RestartExecutionsReturnsEmptyDictionaryWhenNoFlowsAreEligible()
=> RestartExecutionsReturnsEmptyDictionaryWhenNoFlowsAreEligible(FunctionStoreFactory.Create());




[TestMethod]
public override Task RestartExecutionsWithoutMessagesRestartsMultipleUnownedFlows()
=> RestartExecutionsWithoutMessagesRestartsMultipleUnownedFlows(FunctionStoreFactory.Create());
public override Task RestartExecutionsRestartsMultipleUnownedFlows()
=> RestartExecutionsRestartsMultipleUnownedFlows(FunctionStoreFactory.Create());

[TestMethod]
public override Task RestartExecutionsWithoutMessagesRestartsOnlyUnownedFlows()
=> RestartExecutionsWithoutMessagesRestartsOnlyUnownedFlows(FunctionStoreFactory.Create());
public override Task RestartExecutionsRestartsOnlyUnownedFlows()
=> RestartExecutionsRestartsOnlyUnownedFlows(FunctionStoreFactory.Create());

[TestMethod]
public override Task RestartExecutionsWithoutMessagesReturnsEmptyDictionaryForEmptyInput()
=> RestartExecutionsWithoutMessagesReturnsEmptyDictionaryForEmptyInput(FunctionStoreFactory.Create());
public override Task RestartExecutionsReturnsEmptyDictionaryForEmptyInput()
=> RestartExecutionsReturnsEmptyDictionaryForEmptyInput(FunctionStoreFactory.Create());

[TestMethod]
public override Task RestartExecutionsWithoutMessagesIncludesExistingEffects()
=> RestartExecutionsWithoutMessagesIncludesExistingEffects(FunctionStoreFactory.Create());
public override Task RestartExecutionsIncludesExistingEffects()
=> RestartExecutionsIncludesExistingEffects(FunctionStoreFactory.Create());
}
Original file line number Diff line number Diff line change
Expand Up @@ -204,8 +204,8 @@ public override Task GetResultsReturnsOnlyExistingFunctionResults()


[TestMethod]
public override Task RestartExecutionsWithoutMessagesDoesNotReturnFlowClaimedByPreviousCall()
=> RestartExecutionsWithoutMessagesDoesNotReturnFlowClaimedByPreviousCall(FunctionStoreFactory.Create());
public override Task RestartExecutionsDoesNotReturnFlowClaimedByPreviousCall()
=> RestartExecutionsDoesNotReturnFlowClaimedByPreviousCall(FunctionStoreFactory.Create());

[TestMethod]
public override Task RestartExecutionsDoesNotClaimSucceededFlow()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ private static (List<StoredEffect> Effects, SnapshotStorageSession Session) Read
return (effects, session);
}

public async Task<Dictionary<StoredId, StoredFlowWithEffects>> RestartExecutionsWithoutMessages(
public async Task<Dictionary<StoredId, StoredFlowWithEffects>> RestartExecutions(
IReadOnlyList<StoredId> storedIds,
ReplicaId owner)
{
Expand Down
Loading
Loading