Reputation: 87
I am using the FabricClient QueryManager to iterate over all partitions to find all actors and return a list. This works fine on my local cluster but throws InvalidCastException when running in our Azure sandbox. Specifically, "Unable to cast object of type 'System.Fabric.SingletonPartitionInformation' to type 'System.Fabric.Int64RangePartitionInformation'."
public async Task<List<Store>> GetStores()
{
var cancelToken = new CancellationToken(false);
var fabricClient = new FabricClient();
var actorServiceUri = new ServiceUriBuilder("StoreActorService").ToUri();
var partitions = await fabricClient.QueryManager.GetPartitionListAsync(actorServiceUri);
var actorIds = new List<ActorId>();
foreach (var partition in partitions)
{
// the following cast works locally but throws InvalidCast in our Azure sandbox
var partitionInfo = (Int64RangePartitionInformation)partition.PartitionInformation;
var actorServiceProxy = ActorServiceProxy.Create(
actorServiceUri,
partitionInfo.LowKey);
var continueToken = (ContinuationToken)null;
do
{
var page = await actorServiceProxy.GetActorsAsync(continueToken, cancelToken);
actorIds.AddRange(page.Items.Select(actor => actor.ActorId));
continueToken = page.ContinuationToken;
} while (continueToken != null);
}
var stores = new List<Store>();
foreach (var actorId in actorIds)
{
var proxy = ActorProxy.Create<IStoreActor>(actorId, actorServiceUri);
var store = await proxy.RetrieveAsync(actorId.ToString());
stores.Add(store);
}
return stores;
}
As shown in Service Fabric Explorer, the service is partitioned for Int64Range
as required.
Any thoughts on why Azure thinks it's a SingletonPartition
?
Thanks. Chuck
Upvotes: 2
Views: 69
Reputation: 87
It turns out that somehow this Actor Service did get created in a Singleton Partition in our Sandbox environment, but not in either local or production environments. I didn't think this was possible, but I guess it is.
Upvotes: 0