Top Banner
Building data intensive stateful services with Orleans Anton Moldovan SBTech Twitter: https://twitter.com/AntyaDev Github: https://github.com/AntyaDev
34

Антон Молдован "Building data intensive stateful services with Orleans"

Jan 23, 2018

Download

Technology

fwdays
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Антон Молдован "Building data intensive stateful services with Orleans"

Building data intensive statefulservices with Orleans

Anton MoldovanSBTech

Twitter: https://twitter.com/AntyaDevGithub: https://github.com/AntyaDev

Page 2: Антон Молдован "Building data intensive stateful services with Orleans"

About me:

@AntyaDevlike types*

Page 3: Антон Молдован "Building data intensive stateful services with Orleans"
Page 4: Антон Молдован "Building data intensive stateful services with Orleans"

microsoft orleans

Agenda

Page 5: Антон Молдован "Building data intensive stateful services with Orleans"
Page 6: Антон Молдован "Building data intensive stateful services with Orleans"
Page 7: Антон Молдован "Building data intensive stateful services with Orleans"
Page 8: Антон Молдован "Building data intensive stateful services with Orleans"
Page 9: Антон Молдован "Building data intensive stateful services with Orleans"
Page 10: Антон Молдован "Building data intensive stateful services with Orleans"
Page 11: Антон Молдован "Building data intensive stateful services with Orleans"
Page 12: Антон Молдован "Building data intensive stateful services with Orleans"
Page 13: Антон Молдован "Building data intensive stateful services with Orleans"
Page 14: Антон Молдован "Building data intensive stateful services with Orleans"
Page 15: Антон Молдован "Building data intensive stateful services with Orleans"
Page 16: Антон Молдован "Building data intensive stateful services with Orleans"

concurrency

Page 17: Антон Молдован "Building data intensive stateful services with Orleans"
Page 18: Антон Молдован "Building data intensive stateful services with Orleans"
Page 19: Антон Молдован "Building data intensive stateful services with Orleans"
Page 20: Антон Молдован "Building data intensive stateful services with Orleans"
Page 21: Антон Молдован "Building data intensive stateful services with Orleans"
Page 22: Антон Молдован "Building data intensive stateful services with Orleans"

Unavailable Silo

courtesy of @johnazariah

Page 23: Антон Молдован "Building data intensive stateful services with Orleans"
Page 24: Антон Молдован "Building data intensive stateful services with Orleans"
Page 25: Антон Молдован "Building data intensive stateful services with Orleans"

public async Task DoSomeJob(){

// Grab the Orleans task schedulervar orleansTs = TaskScheduler.Current;

Task.Run(async () =>{

// Now let's say you need to make a grain call.await Task.Factory.StartNew(() =>{

// This code runs on the Orleans task scheduler. var grain = GrainFactory.GetGrain<IDeviceGrain>("grain_id");grain.SetChallengeName("challenge");

});});

}

Page 26: Антон Молдован "Building data intensive stateful services with Orleans"

public interface ICacheGrain : IGrain{

Task Write(string value);Task<string> Read();

}

Page 27: Антон Молдован "Building data intensive stateful services with Orleans"

public interface ICacheGrain : IGrain{

Task Write(string value);Task<string> Read();

}

Page 28: Антон Молдован "Building data intensive stateful services with Orleans"

[Reentrant][StorageProvider(ProviderName = "MongoDb")]public class CacheGrain : ICacheGrain{

public async Task Write(string value){

if (value == State.Value) return;State.Value = value;await State.WriteStateAsync();

}

public Task<string> Read(){

return Task.FromResult(State.Value);}

}

Page 29: Антон Молдован "Building data intensive stateful services with Orleans"

public override Task ActivateAsync(){

RegisterTimer(SendUpdate, null, TimeSpan.FromSeconds(1, TimeSpan.FromSeconds(5));}

Page 30: Антон Молдован "Building data intensive stateful services with Orleans"

public override Task ActivateAsync(){

RegisterTimer(SendUpdate, null, TimeSpan.FromSeconds(1, TimeSpan.FromSeconds(5));}

AggregatorDevice

Device

Page 31: Антон Молдован "Building data intensive stateful services with Orleans"

[StatelessWorker]public interface IDispatcherGrain : IGrain{

Task Send(Tuple<int, string>[] messages);}

Page 32: Антон Молдован "Building data intensive stateful services with Orleans"

[StatelessWorker]public interface IDispatcherGrain : IGrain{

Task Send(Tuple<int, string>[] messages);}

Page 33: Антон Молдован "Building data intensive stateful services with Orleans"

[StatelessWorker]public interface IDispatcherGrain : IGrain{

Task Send(Tuple<int, string>[] messages);}

Dispatcher

Dispatcher

Target

Target

Target

Page 34: Антон Молдован "Building data intensive stateful services with Orleans"