Esempio n. 1
0
        public Task Init(string name, IProviderRuntime providerRuntime, IProviderConfiguration config)
        {
            Name       = name;
            _serviceId = providerRuntime.ServiceId;
            _grainReferenceConverter = providerRuntime.ServiceProvider.GetRequiredService <IGrainReferenceConverter>();
            Log = providerRuntime.GetLogger($"Storage.MongoStorage.{_serviceId}");
            if (Log.IsVerbose3)
            {
                Log.Verbose3("Going to initialize MongoDB storage.");
            }
            _options = config.DeserializeToMongoStorageOptions();
            MongoUrl mongoUrl;

            try
            {
                mongoUrl = MongoUrl.Create(_options.ConnectionString);
            }
            catch (Exception ex)
            {
                throw new InvalidOperationException("Invalid MongoDB connection string, failed to initialize.", ex);
            }
            EnsureDriverInitialized(_options.BootstrapAssemblies.SelectMany(a => a.GetMongoDriverBootstraps()));
            _client   = new MongoClient(_options.ConnectionString);
            _database = _client.GetDatabase(mongoUrl.DatabaseName);
            LogInfo($"Initialized MongoDB storage with options: {_options}.", MongoStorageLogCode.InfoInit);
            return(Task.CompletedTask);
        }
Esempio n. 2
0
 public SqlMembershipTable(IGrainReferenceConverter grainReferenceConverter, GlobalConfiguration globalConfig, IOptions <SqlMembershipOptions> membershipTableoptions, ILogger <SqlMembershipTable> logger)
 {
     this.grainReferenceConverter = grainReferenceConverter;
     this.logger = logger;
     this.membershipTableOptions = membershipTableoptions.Value;
     this.clusterId = globalConfig.ClusterId;
 }
        public CosmosDBGrainStorage(string name, CosmosDBStorageOptions options, SerializationManager serializationManager,
                                    Providers.IProviderRuntime providerRuntime, IPartitionKeyProvider partitionKeyProvider,
                                    IOptions <ClusterOptions> clusterOptions, IGrainFactory grainFactory, ITypeResolver typeResolver, ILoggerFactory loggerFactory)
        {
            this._name = name;
            this._partitionKeyProvider = partitionKeyProvider;
            this._loggerFactory        = loggerFactory;
            var loggerName = $"{typeof(CosmosDBGrainStorage).FullName}.{name}";

            this._logger  = loggerFactory.CreateLogger(loggerName);
            this._options = options;
            this._serializationManager    = serializationManager;
            this._grainFactory            = grainFactory;
            this._typeResolver            = typeResolver;
            this._serviceId               = clusterOptions.Value.ServiceId;
            this._grainReferenceConverter = providerRuntime.ServiceProvider.GetRequiredService <IGrainReferenceConverter>();

            this._sprocFiles = new Dictionary <string, string>
            {
                { LOOKUP_INDEX_SPROC, $"{LOOKUP_INDEX_SPROC}.js" }
            };

            if (this._options.JsonSerializerSettings == null)
            {
                this._options.JsonSerializerSettings = OrleansJsonSerializer.UpdateSerializerSettings(OrleansJsonSerializer.GetDefaultSerializerSettings(this._typeResolver, this._grainFactory),
                                                                                                      this._options.UseFullAssemblyNames,
                                                                                                      this._options.IndentJson,
                                                                                                      this._options.TypeNameHandling);
                this._options.JsonSerializerSettings.DefaultValueHandling       = DefaultValueHandling.Include;
                this._options.JsonSerializerSettings.PreserveReferencesHandling = PreserveReferencesHandling.None;
            }
        }
 public AzureBasedReminderTable(IGrainReferenceConverter grainReferenceConverter, ILoggerFactory loggerFactory, IOptions <SiloOptions> siloOptions)
 {
     this.grainReferenceConverter = grainReferenceConverter;
     this.logger        = loggerFactory.CreateLogger <AzureBasedReminderTable>();
     this.loggerFactory = loggerFactory;
     this.siloOptions   = siloOptions.Value;
 }
Esempio n. 5
0
 public AdoNetClusteringTable(IGrainReferenceConverter grainReferenceConverter, IOptions <SiloOptions> siloOptions, IOptions <AdoNetClusteringSiloOptions> clusterinOptions, ILogger <AdoNetClusteringTable> logger)
 {
     this.grainReferenceConverter = grainReferenceConverter;
     this.logger = logger;
     this.clusteringTableOptions = clusterinOptions.Value;
     this.clusterId = siloOptions.Value.ClusterId;
 }
Esempio n. 6
0
 public SqlMembershipTable(IGrainReferenceConverter grainReferenceConverter, IOptions <SiloOptions> siloOptions, IOptions <SqlMembershipOptions> membershipTableoptions, ILogger <SqlMembershipTable> logger)
 {
     this.grainReferenceConverter = grainReferenceConverter;
     this.logger = logger;
     this.membershipTableOptions = membershipTableoptions.Value;
     this.clusterId = siloOptions.Value.ClusterId;
 }
Esempio n. 7
0
 public SqlReminderTable(IGrainReferenceConverter grainReferenceConverter, IOptions <SiloOptions> siloOptions, IOptions <AdoNetOptions> adoNetOptions, IOptions <StorageOptions> storageOptions)
 {
     this.grainReferenceConverter = grainReferenceConverter;
     this.serviceId      = siloOptions.Value.ServiceId.ToString();
     this.adoNetOptions  = adoNetOptions.Value;
     this.storageOptions = storageOptions.Value;
 }
Esempio n. 8
0
 /// <summary>
 /// Initializes a new instance of the <see cref="DynamoDBReminderTable"/> class.
 /// </summary>
 /// <param name="grainReferenceConverter">The grain factory.</param>
 /// <param name="loggerFactory">logger factory to use</param>
 public DynamoDBReminderTable(IGrainReferenceConverter grainReferenceConverter, ILoggerFactory loggerFactory, IOptions <SiloOptions> siloOptions)
 {
     this.grainReferenceConverter = grainReferenceConverter;
     this.logger        = loggerFactory.CreateLogger <DynamoDBReminderTable>();
     this.loggerFactory = loggerFactory;
     this.serviceId     = siloOptions.Value.ServiceId;
 }
Esempio n. 9
0
 public PerSiloGrainClient(IServiceProvider serviceProvider, IGrainReferenceConverter grainReferenceConverter,
                           ISiloStatusOracle siloStatusOracle, ILog log)
     : base(serviceProvider)
 {
     GrainReferenceConverter = grainReferenceConverter;
     SiloStatusOracle        = siloStatusOracle;
     Log = log;
 }
Esempio n. 10
0
 public RedisReminderTable(
     IGrainReferenceConverter converter,
     IOptions <ClusterOptions> clusterOptions,
     IOptions <RedisReminderTableOptions> options)
 {
     _converter = converter;
     _options   = options.Value;
     _serviceId = clusterOptions.Value.ServiceId;
 }
Esempio n. 11
0
 public SqlGatewayListProvider(ILogger <SqlGatewayListProvider> logger, IGrainReferenceConverter grainReferenceConverter, ClientConfiguration clientConfiguration,
                               IOptions <SqlGatewayListProviderOptions> options)
 {
     this.logger = logger;
     this.grainReferenceConverter = grainReferenceConverter;
     this.options      = options.Value;
     this.clusterId    = clientConfiguration.ClusterId;
     this.maxStaleness = clientConfiguration.GatewayListRefreshPeriod;
 }
Esempio n. 12
0
 public AdoNetReminderTable(
     IGrainReferenceConverter grainReferenceConverter,
     IOptions <ClusterOptions> clusterOptions,
     IOptions <AdoNetReminderTableOptions> storageOptions)
 {
     this.grainReferenceConverter = grainReferenceConverter;
     this.serviceId = clusterOptions.Value.ServiceId.ToString();
     this.options   = storageOptions.Value;
 }
 internal EdgeProvider(DocumentClient client, DocumentCollection graph, IGrainReferenceConverter grainReferenceConverter, ILogger log, IGrainFactory grainFactory, string serviceId)
 {
     this.client = client;
     this.graph  = graph;
     this.grainReferenceConverter = grainReferenceConverter;
     this.grainFactory            = grainFactory;
     this.serviceId = serviceId;
     this.log       = log;
 }
 public AerospikeReminderTable(IGrainReferenceConverter grainReferenceConverter, ILoggerFactory loggerFactory, IOptions <ClusterOptions> clusterOptions, IOptions <AerospikeReminderStorageOptions> clusteringOptions)
 {
     _clusterOptions          = clusterOptions.Value;
     _grainReferenceConverter = grainReferenceConverter;
     _loggerFactory           = loggerFactory;
     _logger    = loggerFactory?.CreateLogger <AerospikeReminderTable>();
     _options   = clusteringOptions.Value;
     _serviceId = string.IsNullOrWhiteSpace(clusterOptions.Value.ServiceId) ? Guid.Empty.ToString() : clusterOptions.Value.ServiceId;
     _serviceId = clusterOptions.Value.ServiceId;
 }
Esempio n. 15
0
 /// <summary>Initializes a new instance of the <see cref="DynamoDBReminderTable"/> class.</summary>
 /// <param name="grainReferenceConverter">The grain factory.</param>
 /// <param name="loggerFactory">logger factory to use</param>
 /// <param name="clusterOptions"></param>
 /// <param name="storageOptions"></param>
 public DynamoDBReminderTable(
     IGrainReferenceConverter grainReferenceConverter,
     ILoggerFactory loggerFactory,
     IOptions <ClusterOptions> clusterOptions,
     IOptions <DynamoDBReminderStorageOptions> storageOptions)
 {
     this.grainReferenceConverter = grainReferenceConverter;
     this.logger    = loggerFactory.CreateLogger <DynamoDBReminderTable>();
     this.serviceId = clusterOptions.Value.ServiceId;
     this.options   = storageOptions.Value;
 }
 public MongoReminderTable(
     ILogger <MongoReminderTable> logger,
     IOptions <MongoDBRemindersOptions> options,
     IOptions <ClusterOptions> clusterOptions,
     IGrainReferenceConverter grainReferenceConverter)
 {
     this.logger    = logger;
     this.options   = options.Value;
     this.serviceId = clusterOptions.Value.ServiceId ?? string.Empty;
     this.grainReferenceConverter = grainReferenceConverter;
 }
Esempio n. 17
0
 public CosmosDBReminderTable(IGrainReferenceConverter grainReferenceConverter,
                              ILoggerFactory loggerFactory,
                              IOptions <SiloOptions> siloOptions,
                              IOptions <AzureCosmosDBReminderProviderOptions> options)
 {
     this._loggerFactory           = loggerFactory;
     this._logger                  = loggerFactory.CreateLogger(nameof(CosmosDBReminderTable));
     this._siloOptions             = siloOptions.Value;
     this._options                 = options.Value;
     this._grainReferenceConverter = grainReferenceConverter;
 }
 public AdoNetGatewayListProvider(ILogger <AdoNetGatewayListProvider> logger, IGrainReferenceConverter grainReferenceConverter,
                                  IOptions <AdoNetClusteringClientOptions> options,
                                  IOptions <GatewayOptions> gatewayOptions,
                                  IOptions <ClusterClientOptions> clusterClientOptions)
 {
     this.logger = logger;
     this.grainReferenceConverter = grainReferenceConverter;
     this.options      = options.Value;
     this.clusterId    = clusterClientOptions.Value.ClusterId;
     this.maxStaleness = gatewayOptions.Value.GatewayListRefreshPeriod;
 }
 public ReminderEntry ToEntry(IGrainReferenceConverter grainReferenceConverter)
 {
     return(new ReminderEntry
     {
         ETag = Etag,
         GrainRef = grainReferenceConverter.GetGrainFromKeyString(GrainId),
         Period = Period,
         ReminderName = ReminderName,
         StartAt = StartAt
     });
 }
 public CosmosDBReminderTable(
     IGrainReferenceConverter grainReferenceConverter,
     ILoggerFactory loggerFactory,
     IOptions <ClusterOptions> clusterOptions,
     IOptions <CosmosDBReminderStorageOptions> options)
 {
     this._loggerFactory           = loggerFactory;
     this._logger                  = loggerFactory.CreateLogger(nameof(CosmosDBReminderTable));
     this._options                 = options.Value;
     this._grainReferenceConverter = grainReferenceConverter;
     this._serviceId               = string.IsNullOrWhiteSpace(clusterOptions.Value.ServiceId) ? Guid.Empty.ToString() : clusterOptions.Value.ServiceId;
 }
Esempio n. 21
0
 public AzureBasedReminderTable(
     IGrainReferenceConverter grainReferenceConverter,
     ILoggerFactory loggerFactory,
     IOptions <ClusterOptions> clusterOptions,
     IOptions <AzureTableReminderStorageOptions> storageOptions)
 {
     this.grainReferenceConverter = grainReferenceConverter;
     this.logger         = loggerFactory.CreateLogger <AzureBasedReminderTable>();
     this.loggerFactory  = loggerFactory;
     this.clusterOptions = clusterOptions.Value;
     this.storageOptions = storageOptions.Value;
 }
Esempio n. 22
0
 public MongoReminderCollection(
     string connectionsString,
     string databaseName,
     string collectionPrefix,
     string serviceId,
     IGrainReferenceConverter grainReferenceConverter)
     : base(connectionsString, databaseName)
 {
     this.serviceId               = serviceId;
     this.collectionPrefix        = collectionPrefix;
     this.grainReferenceConverter = grainReferenceConverter;
 }
Esempio n. 23
0
 public MongoReminderTable(
     IMongoClientFactory mongoClientFactory,
     ILogger <MongoReminderTable> logger,
     IOptions <MongoDBRemindersOptions> options,
     IOptions <ClusterOptions> clusterOptions,
     IGrainReferenceConverter grainReferenceConverter)
 {
     this.mongoClient             = mongoClientFactory.Create(options.Value, "Membership");
     this.logger                  = logger;
     this.options                 = options.Value;
     this.serviceId               = clusterOptions.Value.ServiceId ?? string.Empty;
     this.grainReferenceConverter = grainReferenceConverter;
 }
Esempio n. 24
0
 public MongoReminderCollection(
     IMongoClient mongoClient,
     string databaseName,
     string collectionPrefix,
     bool createShardKey,
     string serviceId,
     IGrainReferenceConverter grainReferenceConverter)
     : base(mongoClient, databaseName, createShardKey)
 {
     this.serviceId               = serviceId;
     this.collectionPrefix        = collectionPrefix;
     this.grainReferenceConverter = grainReferenceConverter;
 }
        public RedisReminderTable(
            ILogger <RedisReminderTable> logger,
            IOptions <ClusterOptions> clusterOptions,
            IOptions <RedisReminderTableOptions> redisOptions,
            IGrainReferenceConverter grainReferenceConverter)
        {
            _redisOptions   = redisOptions.Value;
            _clusterOptions = clusterOptions.Value;
            _logger         = logger;

            RemindersRedisKey        = $"{_clusterOptions.ServiceId}_Reminders";
            _grainReferenceConverter = grainReferenceConverter;
        }
Esempio n. 26
0
        /// <summary>
        /// Maps the specified source.
        /// </summary>
        /// <param name="converter"></param>
        /// <param name="src">The source.</param>
        /// <param name="dst">The DST.</param>
        /// <returns></returns>
        internal static ReminderTableData Map(
            IGrainReferenceConverter converter,
            List <OrleansEFReminder> src,
            ReminderTableData dst = null
            )
        {
            var entries = src
                          .Select(a => Map(converter, a))
                          .ToList();

            dst = dst ?? new ReminderTableData(entries);

            return(dst);
        }
        /// <summary>
        /// Initializes publisher
        /// </summary>
        /// <param name="name">Provider name</param>
        /// <param name="providerRuntime">Provider runtime API</param>
        /// <param name="config">Provider configuration</param>
        /// <returns></returns>
        public async Task Init(string name, IProviderRuntime providerRuntime, IProviderConfiguration config)
        {
            Name   = name;
            logger = providerRuntime.ServiceProvider.GetRequiredService <ILogger <AdoNetStatisticsPublisher> >();
            this.grainReferenceConverter = providerRuntime.ServiceProvider.GetRequiredService <IGrainReferenceConverter>();

            string adoInvariant = AdoNetInvariants.InvariantNameSqlServer;

            if (config.Properties.ContainsKey("AdoInvariant"))
            {
                adoInvariant = config.Properties["AdoInvariant"];
            }

            orleansQueries = await RelationalOrleansQueries.CreateInstance(adoInvariant, config.Properties["ConnectionString"], this.grainReferenceConverter);
        }
        public OrleansEFReminderGrain(
            IOptions <ClusterOptions> clusterOptions,
            IGrainReferenceConverter grainReferenceConverter,
            OrleansEFContext db
            )
        {
            _clusterOptions = clusterOptions ??
                              throw new ArgumentNullException(nameof(clusterOptions));

            _grainReferenceConverter = grainReferenceConverter ??
                                       throw new ArgumentNullException(nameof(grainReferenceConverter));

            _db = db ??
                  throw new ArgumentNullException(nameof(db));
        }
Esempio n. 29
0
        /// <summary>
        /// Maps the specified converter.
        /// </summary>
        /// <param name="converter">The converter.</param>
        /// <param name="src">The source.</param>
        /// <param name="dst">The DST.</param>
        /// <returns></returns>
        internal static ReminderEntry Map(
            IGrainReferenceConverter converter,
            OrleansEFReminder src,
            ReminderEntry dst = null
            )
        {
            dst = dst ?? new ReminderEntry();

            dst.ETag         = src.ETag;
            dst.GrainRef     = converter.GetGrainFromKeyString(src.GrainId);
            dst.Period       = TimeSpan.FromMilliseconds(src.Period);
            dst.ReminderName = src.ReminderName;
            dst.StartAt      = src.StartTime;

            return(dst);
        }
        /// <summary>
        ///     Initializes a new instance of the <see cref="CosmosDbGraphStorage"/> class.
        /// </summary>
        /// <param name="name">Name assigned for this provider</param>
        /// <param name="options"></param>
        /// <param name="clusterOptions"></param>
        /// <param name="grainFactory"></param>
        /// <param name="grainReferenceConverter"></param>
        /// <param name="loggerFactory"></param>
        public CosmosDbGraphStorage(string name,
                                    CosmosDbGraphStorageOptions options,
                                    IOptions <ClusterOptions> clusterOptions,
                                    IGrainFactory grainFactory,
                                    IGrainReferenceConverter grainReferenceConverter,
                                    ILoggerFactory loggerFactory)
        {
            this.name                    = name;
            this.options                 = options;
            this.clusterOptions          = clusterOptions;
            this.grainFactory            = grainFactory;
            this.grainReferenceConverter = grainReferenceConverter;

            var loggerName = $"{typeof(CosmosDbGraphStorage).FullName}.{name}";

            log       = loggerFactory.CreateLogger(loggerName);
            serviceId = clusterOptions.Value.ServiceId;
        }