예제 #1
0
        public SportsTeamGrain(
#if USE_TRANSACTIONS
            [TransactionalIndexedState("stateName", GrainStoreName)]
#else
            [NonFaultTolerantWorkflowIndexedState("stateName", GrainStoreName)]
#endif
            IIndexedState <SportsTeamState> indexedState) => this.indexedState = indexedState;
        internal TestMultiIndexGrainBase(Type grainClassType, IIndexedState <TGrainState> indexedState)
        {
            this.IndexedState = indexedState;

            var grainInterfaceTypes = ApplicationPartsIndexableGrainLoader.EnumerateIndexedInterfacesForAGrainClassType(grainClassType).ToArray();

            Assert.Single(grainInterfaceTypes);
            var propertiesType = grainInterfaceTypes[0].propertiesType;

            Assert.True(propertiesType.IsClass);

            bool isIndexed(string propertyName)
            {
                var propInfo = propertiesType.GetProperty(propertyName);

                return(propInfo.GetCustomAttributes <IndexAttribute>(inherit: false).Any());
            }

            this.IsUniqueIntIndexed       = isIndexed(nameof(ITestMultiIndexProperties.UniqueInt));
            this.IsUniqueStringIndexed    = isIndexed(nameof(ITestMultiIndexProperties.UniqueString));
            this.IsNonUniqueIntIndexed    = isIndexed(nameof(ITestMultiIndexProperties.NonUniqueInt));
            this.IsNonUniqueStringIndexed = isIndexed(nameof(ITestMultiIndexProperties.NonUniqueString));

            Assert.True(this.IsUniqueIntIndexed || this.IsUniqueStringIndexed || this.IsNonUniqueIntIndexed || this.IsNonUniqueStringIndexed);
        }
 public TXN_Grain_UIUSNINS_TI_EG_PK(
     [TransactionalIndexedState(IndexingConstants.IndexedGrainStateName, IndexingConstants.MEMORY_STORAGE_PROVIDER_NAME)]
     IIndexedState <TestMultiIndexState> indexedState)
     : base(indexedState)
 {
 }
 public NFT_Grain_Employee_XI_EG_PK(
     [NonFaultTolerantWorkflowIndexedState(IndexingConstants.MEMORY_STORAGE_PROVIDER_NAME)]
     IIndexedState <EmployeeGrainState> indexedState)
     : base(indexedState)
 {
 }
 public static Task PerformUpdate <TGrainState>(this IIndexedState <TGrainState> indexedState, Action <TGrainState> updateAction)
     where TGrainState : class, new()
 => indexedState.PerformUpdate(state => { updateAction(state); return(true); });
예제 #6
0
 public NFT_Grain_UIUSNINS_XI_LZ_PK(
     [NonFaultTolerantWorkflowIndexedState(IndexingConstants.MEMORY_STORAGE_PROVIDER_NAME)]
     IIndexedState <TestMultiIndexState> indexedState)
     : base(indexedState)
 {
 }
예제 #7
0
 public NFT_Grain_UIUSNINS_DSMI_LZ_PK(
     [NonFaultTolerantWorkflowIndexedState(IndexingConstants.IndexedGrainStateName, IndexingTestConstants.CosmosDBGrainStorage)]
     IIndexedState <TestMultiIndexState> indexedState)
     : base(indexedState)
 {
 }
 public IndexingGrainTransactional_PK(
     [TransactionalIndexedState(IndexUtils.IndexedGrainStateName)]
     IIndexedState <IndexingState> indexedState)
     : base(indexedState)
 {
 }
 public Player3Grain(
     [FaultTolerantWorkflowIndexedState(IndexingTestConstants.GrainStore)]
     IIndexedState <PlayerGrainState> indexedState)
     : base(indexedState)
 {
 }
예제 #10
0
 public FT_Grain_UIUSNINS_TI_LZ_SB(
     [FaultTolerantWorkflowIndexedState(IndexingConstants.IndexedGrainStateName, IndexingConstants.MEMORY_STORAGE_PROVIDER_NAME)]
     IIndexedState <TestMultiIndexState> indexedState)
     : base(indexedState)
 {
 }
예제 #11
0
 public TestMultiIndexGrainTransactional(IIndexedState <TGrainState> indexedState) : base(indexedState)
     => Debug.Assert(this.GetType().GetConsistencyScheme() == ConsistencyScheme.Transactional);
예제 #12
0
 public TestMultiIndexGrainFaultTolerant(IIndexedState <TGrainState> indexedState) : base(indexedState)
     => Debug.Assert(this.GetType().GetConsistencyScheme() == ConsistencyScheme.FaultTolerantWorkflow);
예제 #13
0
 public PlayerGrain(IIndexedState <TGrainState> indexedState) => this.indexedState = indexedState;
예제 #14
0
 public TestMultiIndexGrain(IIndexedState <TGrainState> indexedState) =>
 this.testBase = new TestMultiIndexGrainBase <TGrainState>(this.GetType(), indexedState);
예제 #15
0
 public GrainShared2(
     [NonFaultTolerantWorkflowIndexedState(IndexingConstants.IndexedGrainStateName, IndexingConstants.MEMORY_STORAGE_PROVIDER_NAME)]
     IIndexedState <GrainState> indexedState)
     : base(indexedState)
 {
 }
예제 #16
0
 protected TestEmployeeGrain(IIndexedState <TGrainState> indexedState) => this.indexedState = indexedState;
 public TXN_Grain_UIUSNINS_DSMI_EG_PK(
     [TransactionalIndexedState(IndexingConstants.IndexedGrainStateName, IndexingTestConstants.CosmosDBGrainStorage)]
     IIndexedState <TestMultiIndexState> indexedState)
     : base(indexedState)
 {
 }
 public Player_FT_TI_LZ_PK(
     [FaultTolerantWorkflowIndexedState(IndexingConstants.IndexedGrainStateName, IndexingTestConstants.GrainStore)]
     IIndexedState <PlayerGrainState> indexedState)
     : base(indexedState)
 {
 }
 public IndexingGrainWorkflowFT_PK(
     [FaultTolerantWorkflowIndexedState(IndexUtils.IndexedGrainStateName)]
     IIndexedState <IndexingState> indexedState)
     : base(indexedState)
 {
 }
 public FT_Grain_UIUSNINS_DSMI_LZ_SB(
     [FaultTolerantWorkflowIndexedState(IndexingTestConstants.CosmosDBGrainStorage)]
     IIndexedState <TestMultiIndexState> indexedState)
     : base(indexedState)
 {
 }
예제 #21
0
 public TXN_Grain_Employee_TI_EG_PK(
     [TransactionalIndexedState(IndexingConstants.IndexedGrainStateName, IndexingConstants.MEMORY_STORAGE_PROVIDER_NAME)]
     IIndexedState <EmployeeGrainState> indexedState)
     : base(indexedState)
 {
 }
 public SportsTeamGrain(
     [NonFaultTolerantWorkflowIndexedState(GrainStoreName)]
     IIndexedState <SportsTeamState> indexedState) => this.indexedState = indexedState;
 public static Task PerformRead <TGrainState>(this IIndexedState <TGrainState> indexedState)
     where TGrainState : class, new()
 => indexedState.PerformRead(_ => true);
예제 #24
0
 public Player_NFT_AI_EG_PSPS(
     [NonFaultTolerantWorkflowIndexedState(IndexingConstants.IndexedGrainStateName, IndexingConstants.MEMORY_STORAGE_PROVIDER_NAME)]
     IIndexedState <PlayerGrainState> indexedState)
     : base(indexedState)
 {
 }
 public Player5GrainNonFaultTolerant(
     [NonFaultTolerantWorkflowIndexedState(IndexingConstants.MEMORY_STORAGE_PROVIDER_NAME)]
     IIndexedState <PlayerGrainState> indexedState)
     : base(indexedState)
 {
 }
예제 #26
0
 public TransactionalPlayerGrain(
     [TransactionalIndexedState(IndexingConstants.IndexedGrainStateName, IndexingConstants.MEMORY_STORAGE_PROVIDER_NAME)]
     IIndexedState <PlayerGrainState> indexedState)
     : base(indexedState)
 {
 }
예제 #27
0
 public FT_Grain_Employee_TI_LZ_SB(
     [FaultTolerantWorkflowIndexedState(IndexingConstants.MEMORY_STORAGE_PROVIDER_NAME)]
     IIndexedState <EmployeeGrainState> indexedState)
     : base(indexedState)
 {
 }
예제 #28
0
 public GrainBase(IIndexedState <GrainState> indexedState) => this.indexedState = indexedState;
 public Player_FT_TI_LZ_SB(
     [FaultTolerantWorkflowIndexedState(IndexingConstants.IndexedGrainStateName, IndexingConstants.MEMORY_STORAGE_PROVIDER_NAME)]
     IIndexedState <PlayerGrainState> indexedState)
     : base(indexedState)
 {
 }
        internal static async Task SetPropertyAndWriteStateAsync <TGrainState>(Action <TGrainState> setterAction, IIndexedState <TGrainState> indexedState, bool retry)
            where TGrainState : class, new()
        {
            const int MaxRetries = 10;
            int       retries    = 0;

            while (true)
            {
                try
                {
                    await indexedState.PerformUpdate(setterAction);

                    return;
                }
                catch (Exception) when(retry && retries < MaxRetries)
                {
                    ++retries;
                    await indexedState.PerformRead();
                }
            }
        }