예제 #1
0
        public void JsonConcertCanSerializeMetaData()
        {
            ITransactionTestGrain testGrain = this.RandomTestGrain(TransactionTestConstants.SingleStateTransactionalGrain);
            GrainReference        reference = (GrainReference)testGrain;
            var metaData = new TransactionalStateMetaData();

            metaData.TimeStamp = DateTime.UtcNow;
            metaData.CommitRecords.Add(Guid.NewGuid(), new CommitRecord()
            {
                Timestamp         = DateTime.UtcNow,
                WriteParticipants = new List <ParticipantId>()
                {
                    new ParticipantId("bob", reference, ParticipantId.Role.Resource | ParticipantId.Role.Manager)
                }
            });
            JsonSerializerSettings serializerSettings = TransactionalStateFactory.GetJsonSerializerSettings(
                this.fixture.Client.ServiceProvider.GetService <ITypeResolver>(),
                this.grainFactory);
            //should be able to serialize it
            string jsonMetaData = JsonConvert.SerializeObject(metaData, serializerSettings);

            TransactionalStateMetaData deseriliazedMetaData = JsonConvert.DeserializeObject <TransactionalStateMetaData>(jsonMetaData, serializerSettings);

            Assert.Equal(metaData.TimeStamp, deseriliazedMetaData.TimeStamp);
        }
 public AzureTableTransactionalStateStorageFactory(string name, AzureTableTransactionalStateOptions options, IOptions <ClusterOptions> clusterOptions, IServiceProvider services, ILoggerFactory loggerFactory)
 {
     this.name           = name;
     this.options        = options;
     this.clusterOptions = clusterOptions.Value;
     this.jsonSettings   = TransactionalStateFactory.GetJsonSerializerSettings(services);
     this.loggerFactory  = loggerFactory;
 }
 public PostgreSqlTransactionalStateStorageFactory(string name, PostgreSqlTransactionalStateOptions options,
                                                   ITypeResolver typeResolver, IGrainFactory grainFactory)
 {
     _name         = name;
     _options      = options;
     _jsonSettings = TransactionalStateFactory.GetJsonSerializerSettings(
         typeResolver,
         grainFactory);
 }
예제 #4
0
        private static async Task <ITransactionalStateStorage <TestState> > StateStorageFactory(TestFixture fixture)
        {
            var table = await InitTableAsync(NullLogger.Instance);

            var jsonSettings = TransactionalStateFactory.GetJsonSerializerSettings(fixture.HostedCluster.ServiceProvider);
            var stateStorage = new AzureTableTransactionalStateStorage <TestState>(table, $"{partition}{DateTime.UtcNow.Ticks}", jsonSettings,
                                                                                   NullLoggerFactory.Instance.CreateLogger <AzureTableTransactionalStateStorage <TestState> >());

            return(stateStorage);
        }
예제 #5
0
 public AzureTableTransactionalStateStorageFactory(string name, AzureTableTransactionalStateOptions options, IOptions <ClusterOptions> clusterOptions, ITypeResolver typeResolver, IGrainFactory grainFactory, ILoggerFactory loggerFactory)
 {
     this.name           = name;
     this.options        = options;
     this.clusterOptions = clusterOptions.Value;
     this.jsonSettings   = TransactionalStateFactory.GetJsonSerializerSettings(
         typeResolver,
         grainFactory);
     this.loggerFactory = loggerFactory;
 }
예제 #6
0
        public MongoDBTransactionalStateStorageFactory(string name,
                                                       MongoDBTransactionalStateOptions options,
                                                       IOptions <ClusterOptions> clusterOptions,
                                                       ITypeResolver typeResolver,
                                                       IGrainFactory grainFactory,
                                                       ILoggerFactory loggerFactory)
        {
            this.name         = name;
            this.jsonSettings = TransactionalStateFactory.GetJsonSerializerSettings(
                typeResolver,
                grainFactory);
            var client = new MongoClient(options.ConnectionString);

            db = client.GetDatabase(options.Database);
            this.clusterOptions = clusterOptions.Value;
            this.loggerFactory  = loggerFactory;
        }
예제 #7
0
 public FaultInjectionTransactionalStateFactory(IGrainActivationContext context, ITypeResolver typeResolver, IGrainFactory grainFactory)
 {
     this.context            = context;
     this.serializerSettings =
         TransactionalStateFactory.GetJsonSerializerSettings(typeResolver, grainFactory);
 }