Showing posts with label System.Collections. Show all posts
Showing posts with label System.Collections. Show all posts

Saturday, 9 July 2022

Describing an Azure Service Fabric Service using ServiceManifest.xml

The ServiceManifest.xml declares information relevant to your microservice. 

Whether your service is stateless (no persistent storage, or state stored outside of the service, for example, through Azure Storage, Azure SQL Database, Azure Cosmos DB) or stateful, where Service Fabric manages your service state via Reliable Collections or Reliable Actors programming models.

Stateful applications are particularly interesting from an availability standpoint. The Reliable Collections API builds on System.Collections, and in particular, System.Collections.Concurrent, to create highly available (stateful) data structures while keeping code complexity to a minimum.

Reliable Collections ensure underlying data is replicated for high availability, operate asynchronously to ensure no blocking IO operations and transactional to ensure strong consistency (ensuring transaction commits finish only once changes are replicated on the majority quorum of replicas including the primary). They can also be persisted or volatile, the former where data is persisted to disk to protect against large scale outages.

Relevant data structures can be found in Microsoft.ServiceFabric.Data.Collections and in the assembly Microsoft.ServiceFabric.Data.Interfaces.dll.

Wednesday, 11 December 2013

The Doubly-Linked List in C#

LinkedList in System.Collections.Generic is your friend - if you want bidirectional iteration.

Warning: Relevance of System.Collections.Specialized Diminished in a Post-.NET-Generics World

This namespace (System.dll) surfaced early in .NET 1.1. and the classes and structures have remained pretty much the same since. There have been some tweaks in terms of new interfaces and delegates, but by and large, this namespace has remained fairly static. In the post-.NET-generics world it's relevance has waned somewhat but it still contains some useful and interesting abstractions, for which even the .NET 4.5 programmer can achieve rewards.

Of all the classes, StringDictionary, a dictionary whose keys and values are strings, is the most easy and obvious to use, and maybe is a bit neater than using System.Collections.Generic in this specific case.

The namespace also has ListDictionary intended to have superior performance than a Hashtable for a small number of items (less than 10) by using a singly-linked list to implement the IDictionary interface.