Example #1
0
        public static async Task <GossipTableInstanceManager> GetManager(Guid globalServiceId, string storageConnectionString, ILoggerFactory loggerFactory)
        {
            if (loggerFactory == null)
            {
                throw new ArgumentNullException(nameof(loggerFactory));
            }

            var instance = new GossipTableInstanceManager(globalServiceId, storageConnectionString, loggerFactory);

            try
            {
                await instance.storage.InitTableAsync()
                .WithTimeout(initTimeout).ConfigureAwait(false);
            }
            catch (TimeoutException te)
            {
                string errorMsg = String.Format("Unable to create or connect to the Azure table {0} in {1}",
                                                instance.TableName, initTimeout);
                instance.logger.Error((int)TableStorageErrorCode.AzureTable_65, errorMsg, te);
                throw new OrleansException(errorMsg, te);
            }
            catch (Exception ex)
            {
                string errorMsg = String.Format("Exception trying to create or connect to Azure table {0} : {1}",
                                                instance.TableName, ex.Message);
                instance.logger.Error((int)TableStorageErrorCode.AzureTable_66, errorMsg, ex);
                throw new OrleansException(errorMsg, ex);
            }
            return(instance);
        }
        public async Task Initialize(Guid serviceid, string connectionstring)
        {
            logger.Info("Initializing Gossip Channel for ServiceId={0} using connection: {1}",
                        serviceid, ConfigUtilities.RedactConnectionStringInfo(connectionstring));

            tableManager = await GossipTableInstanceManager.GetManager(serviceid, connectionstring, this.loggerFactory);
        }
        public async Task Initialize(Guid serviceid, string connectionstring)
        {
            Name = "AzureTableBasedGossipChannel-" + ++sequenceNumber;
            logger = LogManager.GetLogger(Name, LoggerType.Runtime);

            logger.Info("Initializing Gossip Channel for ServiceId={0} using connection: {1}, SeverityLevel={2}",
                serviceid, ConfigUtilities.RedactConnectionStringInfo(connectionstring), logger.SeverityLevel);

            tableManager = await GossipTableInstanceManager.GetManager(serviceid, connectionstring, logger);
        }
        public async Task Initialize(Guid serviceid, string connectionstring)
        {
            Name   = "AzureTableBasedGossipChannel-" + ++sequenceNumber;
            logger = TraceLogger.GetLogger(Name, TraceLogger.LoggerType.Runtime);

            logger.Info("Initializing Gossip Channel for ServiceId={0} using connection: {1}, SeverityLevel={2}",
                        serviceid, ConfigUtilities.RedactConnectionStringInfo(connectionstring), logger.SeverityLevel);

            tableManager = await GossipTableInstanceManager.GetManager(serviceid, connectionstring, logger);
        }
 public static async Task<GossipTableInstanceManager> GetManager(Guid globalServiceId, string storageConnectionString, Logger logger)
 {
     if (logger == null) throw new ArgumentNullException("logger");
     
     var instance = new GossipTableInstanceManager(globalServiceId, storageConnectionString, logger);
     try
     {
         await instance.storage.InitTableAsync()
             .WithTimeout(initTimeout).ConfigureAwait(false);
     }
     catch (TimeoutException te)
     {
         string errorMsg = String.Format("Unable to create or connect to the Azure table {0} in {1}", 
             instance.TableName, initTimeout);
         instance.logger.Error(ErrorCode.AzureTable_32, errorMsg, te);
         throw new OrleansException(errorMsg, te);
     }
     catch (Exception ex)
     {
         string errorMsg = String.Format("Exception trying to create or connect to Azure table {0} : {1}", 
             instance.TableName, ex.Message);
         instance.logger.Error(ErrorCode.AzureTable_33, errorMsg, ex);
         throw new OrleansException(errorMsg, ex);
     }
     return instance;
 }