HA, locking, and callbacks. Application PUT(K2, V2) Cache2 Cache1 Cache3 Primary for Get(K2) Primary...
-
Upload
iyana-springs -
Category
Documents
-
view
219 -
download
0
Transcript of HA, locking, and callbacks. Application PUT(K2, V2) Cache2 Cache1 Cache3 Primary for Get(K2) Primary...
![Page 1: HA, locking, and callbacks. Application PUT(K2, V2) Cache2 Cache1 Cache3 Primary for Get(K2) Primary for K3, V3 AppFabric Caching Client Routing Table.](https://reader035.fdocuments.net/reader035/viewer/2022062620/551b5d6c550346dd1a8b6573/html5/thumbnails/1.jpg)
HA, locking, and callbacks
![Page 2: HA, locking, and callbacks. Application PUT(K2, V2) Cache2 Cache1 Cache3 Primary for Get(K2) Primary for K3, V3 AppFabric Caching Client Routing Table.](https://reader035.fdocuments.net/reader035/viewer/2022062620/551b5d6c550346dd1a8b6573/html5/thumbnails/2.jpg)
![Page 3: HA, locking, and callbacks. Application PUT(K2, V2) Cache2 Cache1 Cache3 Primary for Get(K2) Primary for K3, V3 AppFabric Caching Client Routing Table.](https://reader035.fdocuments.net/reader035/viewer/2022062620/551b5d6c550346dd1a8b6573/html5/thumbnails/3.jpg)
![Page 4: HA, locking, and callbacks. Application PUT(K2, V2) Cache2 Cache1 Cache3 Primary for Get(K2) Primary for K3, V3 AppFabric Caching Client Routing Table.](https://reader035.fdocuments.net/reader035/viewer/2022062620/551b5d6c550346dd1a8b6573/html5/thumbnails/4.jpg)
ApplicationApplicationApplicationApplication
PUT(K2, V2)
Cache2Cache2Cache1Cache1 Cache3Cache3
Primary for Primary for
Get(K2)
Primary forPrimary for Primary forPrimary for
K3, V3
AppFabric Caching ClientAppFabric Caching Client Routing
TableRouting Table
K2
, V2
Secondary forSecondary for
K2, V2
K1, V1
Secondary for Secondary for
K3, V3
Secondary forSecondary for
K1, V1
AppFabric Caching ClientAppFabric Caching Client
Routing TableRouting Table
K2, V2
Replication AgentReplication Agent
![Page 5: HA, locking, and callbacks. Application PUT(K2, V2) Cache2 Cache1 Cache3 Primary for Get(K2) Primary for K3, V3 AppFabric Caching Client Routing Table.](https://reader035.fdocuments.net/reader035/viewer/2022062620/551b5d6c550346dd1a8b6573/html5/thumbnails/5.jpg)
![Page 6: HA, locking, and callbacks. Application PUT(K2, V2) Cache2 Cache1 Cache3 Primary for Get(K2) Primary for K3, V3 AppFabric Caching Client Routing Table.](https://reader035.fdocuments.net/reader035/viewer/2022062620/551b5d6c550346dd1a8b6573/html5/thumbnails/6.jpg)
K1
• GetAndLock works on non-existent keys– Allows you to co-ordinate creating new object amongst
multiple clients
Client1: GetAndLock ("k1")
Client2: GetAndLock ("k1")
Client3: Get ("k1")
Regular Get succeeds
Regular Get succeeds
GetAndLock gets lock handle
GetAndLock gets lock handle
Other GetAndLock on same item fails Other GetAndLock on same item fails
![Page 7: HA, locking, and callbacks. Application PUT(K2, V2) Cache2 Cache1 Cache3 Primary for Get(K2) Primary for K3, V3 AppFabric Caching Client Routing Table.](https://reader035.fdocuments.net/reader035/viewer/2022062620/551b5d6c550346dd1a8b6573/html5/thumbnails/7.jpg)
![Page 8: HA, locking, and callbacks. Application PUT(K2, V2) Cache2 Cache1 Cache3 Primary for Get(K2) Primary for K3, V3 AppFabric Caching Client Routing Table.](https://reader035.fdocuments.net/reader035/viewer/2022062620/551b5d6c550346dd1a8b6573/html5/thumbnails/8.jpg)
public virtual DataCacheNotificationDescriptor AddCacheLevelBulkCallback(DataCacheBulkNotificationCallback clientCallback);
public virtual DataCacheNotificationDescriptor AddCacheLevelCallback(DataCacheOperation filter, DataCacheNotificationCallback clientCallback);
public virtual DataCacheNotificationDescriptor AddFailureNotificationCallback(DataCacheFailureNotificationCallback failureCallback);
public virtual DataCacheNotificationDescriptor AddItemLevelCallback(string key, DataCacheOperation filter, DataCacheNotificationCallback clientCallback);
public virtual DataCacheNotificationDescriptor AddItemLevelCallback(string key, DataCacheOperation filter, DataCacheNotificationCallback clientCallback, string regionName);
public virtual DataCacheNotificationDescriptor AddRegionLevelCallback(string regionName, DataCacheOperation filter, DataCacheNotificationCallback clientCallback);
![Page 9: HA, locking, and callbacks. Application PUT(K2, V2) Cache2 Cache1 Cache3 Primary for Get(K2) Primary for K3, V3 AppFabric Caching Client Routing Table.](https://reader035.fdocuments.net/reader035/viewer/2022062620/551b5d6c550346dd1a8b6573/html5/thumbnails/9.jpg)
namespace Microsoft.ApplicationServer.Caching{ [Flags] public enum DataCacheOperations { AddItem = 1, ReplaceItem = 2, RemoveItem = 4, CreateRegion = 8, RemoveRegion = 16, ClearRegion = 32, }}
![Page 10: HA, locking, and callbacks. Application PUT(K2, V2) Cache2 Cache1 Cache3 Primary for Get(K2) Primary for K3, V3 AppFabric Caching Client Routing Table.](https://reader035.fdocuments.net/reader035/viewer/2022062620/551b5d6c550346dd1a8b6573/html5/thumbnails/10.jpg)
New-Cache CallBackCache -NotificationsEnabled true
var cfg = new DataCacheFactoryConfiguration();cfg.Servers = new List<DataCacheServerEndpoint> { new DataCacheServerEndpoint("demo2010a", 22233) };var dcf = new DataCacheFactory(cfg);var cache1 = dcf.GetCache("CallBackCache");var d = cache1.AddCacheLevelCallback(DataCacheOperations.AddItem, ( cacheName, regionName, key, version, cacheOperation, nd) => { Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine("New item added to cache {0}", key); Console.ResetColor(); });
![Page 11: HA, locking, and callbacks. Application PUT(K2, V2) Cache2 Cache1 Cache3 Primary for Get(K2) Primary for K3, V3 AppFabric Caching Client Routing Table.](https://reader035.fdocuments.net/reader035/viewer/2022062620/551b5d6c550346dd1a8b6573/html5/thumbnails/11.jpg)
![Page 12: HA, locking, and callbacks. Application PUT(K2, V2) Cache2 Cache1 Cache3 Primary for Get(K2) Primary for K3, V3 AppFabric Caching Client Routing Table.](https://reader035.fdocuments.net/reader035/viewer/2022062620/551b5d6c550346dd1a8b6573/html5/thumbnails/12.jpg)