public override bool OnStart()
        {
            // Set the maximum number of concurrent connections
            ServicePointManager.DefaultConnectionLimit = 100;

            //Initialize Indexer
            storageAccount = CloudStorageAccount.Parse(RoleEnvironment.GetConfigurationSettingValue("CrawlerStorage"));

            //Initialize URL Queue
            urlQueueClient = storageAccount.CreateCloudQueueClient();
            urlQueue = urlQueueClient.GetQueueReference("urlqueue");
            if (urlQueue.CreateIfNotExist())
            {
                //Add first URL to the queue
                CloudQueueMessage firstURL = new CloudQueueMessage(startURL);
                urlQueue.AddMessage(firstURL);
            }

            //Initialize Index Queue
            indexQueueClient = storageAccount.CreateCloudQueueClient();
            indexQueue = indexQueueClient.GetQueueReference("indexqueue");
            indexQueue.CreateIfNotExist();

            //Initialize Database Blob
            databaseClient = storageAccount.CreateCloudBlobClient();
            databaseContainer = databaseClient.GetContainerReference("wordfrequencies");
            databaseContainer.CreateIfNotExist();
            var permission = databaseContainer.GetPermissions();
            permission.PublicAccess = BlobContainerPublicAccessType.Container;
            databaseContainer.SetPermissions(permission);

            return base.OnStart();
        }
        public override bool OnStart()
        {
            //EF stuff -- do not initialize db
            Database.SetInitializer<SqlStorageContext>(null);

            // Set the maximum number of concurrent connections  -- do we need this??
            //ServicePointManager.DefaultConnectionLimit = 12;

            // Create the queue if it does not exist already
            var connectionString = CloudConfigurationManager.GetSetting("CloudStore.ConnectionString");
            var account = CloudStorageAccount.Parse(connectionString);
            var client = account.CreateCloudQueueClient();
            _queue = client.GetQueueReference(QueueName);
            _queue.CreateIfNotExist();

            // set diagnostics
            var config = DiagnosticMonitor.GetDefaultInitialConfiguration();

            // Windows Azure logs
            config.Logs.ScheduledTransferPeriod = TimeSpan.FromMinutes(1.0);    //60 sec is min
            config.Logs.ScheduledTransferLogLevelFilter = LogLevel.Undefined;    //Undefined == everything

            var diagAccount = CloudStorageAccount.Parse(CloudConfigurationManager.GetSetting("Microsoft.WindowsAzure.Plugins.Diagnostics.ConnectionString"));

            var roleInstanceDiagnosticManager =
                diagAccount.CreateRoleInstanceDiagnosticManager(RoleEnvironment.DeploymentId,
                                                                   RoleEnvironment.CurrentRoleInstance.Role.Name,
                                                                   RoleEnvironment.CurrentRoleInstance.Id);
            roleInstanceDiagnosticManager.SetCurrentConfiguration(config);

            return base.OnStart();
        }
Example #3
0
        public override bool OnStart()
        {
            // Set the maximum number of concurrent connections
            ServicePointManager.DefaultConnectionLimit = 12;

            DiagnosticMonitor.Start("DiagnosticsConnectionString");

            // For information on handling configuration changes
            // see the MSDN topic at http://go.microsoft.com/fwlink/?LinkId=166357.
            RoleEnvironment.Changing += RoleEnvironmentChanging;

            // read storage account configuration settings
            CloudStorageAccount.SetConfigurationSettingPublisher((configName, configSetter)
                => configSetter(RoleEnvironment.GetConfigurationSettingValue(configName)));

            var storageAccount = CloudStorageAccount.FromConfigurationSetting("DataConnectionString");

            // initialize blob storage
            CloudBlobClient blobStorage = storageAccount.CreateCloudBlobClient();
            container = blobStorage.GetContainerReference("converteddata");

            // initialize queue storage
            CloudQueueClient queueStorage = storageAccount.CreateCloudQueueClient();
            queue = queueStorage.GetQueueReference("workercommands");

            Trace.TraceInformation("Creating container and queue...");

            bool storageInitialized = false;
            while (!storageInitialized)
            {
                try
                {
                    // create the blob container and allow public access
                    container.CreateIfNotExist();
                    var permissions = container.GetPermissions();
                    permissions.PublicAccess = BlobContainerPublicAccessType.Container;
                    container.SetPermissions(permissions);

                    // create the message queue
                    queue.CreateIfNotExist();
                    storageInitialized = true;
                }
                catch (StorageClientException e)
                {
                    if (e.ErrorCode == StorageErrorCode.TransportError)
                    {
                        Trace.TraceError("Storage services initialization failure. "
                          + "Check your storage account configuration settings. If running locally, "
                          + "ensure that the Development Storage service is running. Message: '{0}'", e.Message);
                        Thread.Sleep(5000);
                    }
                    else
                    {
                        throw;
                    }
                }
            }

            return base.OnStart();
        }
Example #4
0
        public override bool OnStart()
        {
            // Set the maximum number of concurrent connections
            ServicePointManager.DefaultConnectionLimit = 12;
            #if DEBUG
            account = CloudStorageAccount.DevelopmentStorageAccount;
            #else
            account = new CloudStorageAccount(accountAndKey, true);
            #endif

            tableContext = new TableServiceContext(account.TableEndpoint.ToString(), account.Credentials);

            //client = new CloudQueueClient(account.BlobEndpoint.ToString(), account.Credentials);
            qclient = account.CreateCloudQueueClient();
            q = qclient.GetQueueReference("icd9mapplotrequests");
            rows = new List<ICD9MapPlotResultEntry>();
            bclient = account.CreateCloudBlobClient();
            container = bclient.GetContainerReference("results");
            container.CreateIfNotExist();
            client = account.CreateCloudTableClient();
            client.CreateTableIfNotExist("ICD9MapPlotResult");
            client.CreateTableIfNotExist("DoctorDetails");
            client.CreateTableIfNotExist("PatientDetails");
            // For information on handling configuration changes
            // see the MSDN topic at http://go.microsoft.com/fwlink/?LinkId=166357.

            return base.OnStart();
        }
        public QueueFrases()
        {
            queueClient = storageAccount.CreateCloudQueueClient();

            this.frasesParaProcessasQueue = this.queueClient.GetQueueReference("frasesparaprocessar");
            this.frasesParaProcessasQueue.CreateIfNotExist();
        }
        public RepositorioDePagamentosParaProcessar()
        {
            queueClient = storageAccount.CreateCloudQueueClient();

            this.vendasParaProcessasQueue = this.queueClient.GetQueueReference("vendasparaprocessar");
            this.vendasParaProcessasQueue.CreateIfNotExist();
        }
Example #7
0
 public AnObjectEventConsumer()
 {
     var storageAccount = CloudStorageAccount.Parse(CloudConfigurationManager.GetSetting("Storage"));
     var queueClient = storageAccount.CreateCloudQueueClient();
     _queue = queueClient.GetQueueReference("anobjectqueue");
     _queue.CreateIfNotExist();
 }
 public StatelessAzureQueueWriter(IEnvelopeStreamer streamer, CloudBlobContainer container, CloudQueue queue, string name)
 {
     _streamer = streamer;
     _cloudBlob = container;
     _queue = queue;
     Name = name;
 }
 public AddMessagesExample( String queueName)
 {
     CloudStorageAccount cloudStorageAccount = CloudStorageAccount.Parse(ConfigurationManager.AppSettings["DataConnectionString"]);
     CloudQueueClient cloudQueueClient = cloudStorageAccount.CreateCloudQueueClient();
     cloudQueue = cloudQueueClient.GetQueueReference(queueName);
     cloudQueue.CreateIfNotExist();
 }
 public LargeDataExample(String queueName)
 {
     CloudStorageAccount cloudStorageAccount = CloudStorageAccount.Parse(ConfigurationManager.AppSettings["DataConnectionString"]);
     CloudQueueClient cloudQueueClient = cloudStorageAccount.CreateCloudQueueClient();
     cloudQueue = cloudQueueClient.GetQueueReference(queueName);
     cloudBlobClient = cloudStorageAccount.CreateCloudBlobClient();
 }
        public override bool OnStart()
        {
            // Set the maximum number of concurrent connections
            ServicePointManager.DefaultConnectionLimit = 12;

            // read storage account configuration settings
            CloudStorageAccount.SetConfigurationSettingPublisher((configName, configSetter) =>
            {
                configSetter(RoleEnvironment.GetConfigurationSettingValue(configName));
            });

            var storageAccount = CloudStorageAccount.FromConfigurationSetting("DataConnectionString");

            // initialize blob storage
            var blobStorage = storageAccount.CreateCloudBlobClient();
            blobContainer = blobStorage.GetContainerReference("guestbookpics");

            // initialize queue storage
            var queueStorage = storageAccount.CreateCloudQueueClient();
            queue = queueStorage.GetQueueReference("guestbookthumbs");

            Trace.TraceInformation("Creating container and queue...");

            bool storageInitialized = false;
            while (!storageInitialized)
            {
                try
                {
                    // create the blob container and allow public access
                    this.blobContainer.CreateIfNotExist();
                    var permissions = this.blobContainer.GetPermissions();
                    permissions.PublicAccess = BlobContainerPublicAccessType.Container;
                    this.blobContainer.SetPermissions(permissions);

                    // create the message queue(s)
                    this.queue.CreateIfNotExist();

                    storageInitialized = true;
                }
                catch (StorageClientException e)
                {
                    if (e.ErrorCode == StorageErrorCode.TransportError)
                    {
                        Trace.TraceError(
                            "Storage services initialization failure. "
                          + "Check your storage account configuration settings. If running locally, "
                          + "ensure that the Development Storage service is running. Message: '{0}'",
                          e.Message);
                        System.Threading.Thread.Sleep(5000);
                    }
                    else
                    {
                        throw;
                    }
                }
            }

            return base.OnStart();
        }
 public DefaultJobSupplier()
 {
     Logger.Log.Instance.Info(string.Format("DefaultJobSupplier. Constructor. Create queue '{0}' client", RoleSettings.JobRequestsQueueName));
     _queue = AzureClient.Instance.QueueClient.GetQueueReference(RoleSettings.JobRequestsQueueName);
     Logger.Log.Instance.Info(string.Format("DefaultJobSupplier. Queue client created: {0}", 
         _queue == null ? "failed" : "successfully"));
     _queue.CreateIfNotExist();
 }
Example #13
0
        public override bool OnStart()
        {
            // Set the maximum number of concurrent connections
            ServicePointManager.DefaultConnectionLimit = 12;

            // Restart the role upon all configuration changes
            RoleEnvironment.Changing += RoleEnvironmentChanging;

            CloudStorageAccount.SetConfigurationSettingPublisher((configName, configSetter) =>
            {
                try
                {
                    configSetter(RoleEnvironment.GetConfigurationSettingValue(configName));
                }
                catch (RoleEnvironmentException e)
                {
                    Trace.TraceError(e.Message);
                    System.Threading.Thread.Sleep(5000);
                }
            });

            CloudStorageAccount storageAccount = CloudStorageAccount.FromConfigurationSetting("DataConnectionString");

            // initialize queue storage
            CloudQueueClient queueStorage = storageAccount.CreateCloudQueueClient();

            requestQueue = queueStorage.GetQueueReference("requests");
            responseQueue = queueStorage.GetQueueReference("responses");

            bool storageInitialized = false;
            while (!storageInitialized)
            {
                try
                {
                    // create the message queue
                    requestQueue.CreateIfNotExist();
                    responseQueue.CreateIfNotExist();

                    storageInitialized = true;
                }
                catch (StorageClientException e)
                {
                    if (e.ErrorCode == StorageErrorCode.TransportError)
                    {
                        Trace.TraceError("Storage services initialization failure. "
                          + "Check your storage account configuration settings. If running locally, "
                          + "ensure that the Development Storage service is running. Message: '{0}'", e.Message);
                        System.Threading.Thread.Sleep(5000);
                    }
                    else
                    {
                        throw;
                    }
                }
            }

            return base.OnStart();
        }
Example #14
0
        public SingleDeliveryQueueClient(CloudStorageAccount account, string queueName)
        {
            var queueClient = account.CreateCloudQueueClient();
            queue = queueClient.GetQueueReference(queueName);
            queue.CreateIfNotExist();

            tableClient = account.CreateCloudTableClient();
            tableClient.CreateTableIfNotExist(TableName);
        }
        public QueueClient()
        {
            var account = CloudStorageAccount.DevelopmentStorageAccount;

            var queueClient = account.CreateCloudQueueClient();

            this.queue = queueClient.GetQueueReference("messages");
            this.queue.CreateIfNotExist();
        }
Example #16
0
        public AzureChannel(CloudQueue queue)
        {
            if (queue == null)
            {
                throw new ArgumentNullException("queue");
            }

            this.queue = queue;
        }
        public QueueClient()
        {
            var account = CloudStorageAccount.FromConfigurationSetting("QueueSettings");

            var queueClient = account.CreateCloudQueueClient();

            this.queue = queueClient.GetQueueReference("messages");
            this.queue.CreateIfNotExist();
        }
Example #18
0
        public ProcessingQueue()
        {
            _formatter = new BinaryFormatter();

            storageAccount = CloudStorageAccount.Parse(RoleEnvironment.GetConfigurationSettingValue("StorageConnectionString"));
            queueClient = storageAccount.CreateCloudQueueClient();
            queue = queueClient.GetQueueReference(TableName);
            queue.CreateIfNotExist();
        }
        public ProcessingQueue()
        {
            _formatter = new BinaryFormatter();

            storageAccount = CloudStorageAccount.Parse(ConfigurationManager.AppSettings["StorageConnectionString"]);
            queueClient = storageAccount.CreateCloudQueueClient();
            queue = queueClient.GetQueueReference(TableName);
            queue.CreateIfNotExist();
        }
Example #20
0
		public override ChannelState Close()
		{
			lock (Locker)
			{
				_queue = null;
				State = ChannelState.Closed;
			}

			return State;
		}
        public AzureMessageQueueTransactionSimulator(CloudQueue inputQueue)
        {
            _inputQueue = inputQueue;

            if (Transaction.Current != null)
            {
                _enlistedInAmbientTx = true;
                Transaction.Current.EnlistVolatile(this, EnlistmentOptions.None);
            }
        }
        public AzureQueueTraceListener(string applicationName, string queueConnectionString, string queueName = "tracelogs")
        {
            if (string.IsNullOrEmpty(applicationName))
                throw new ArgumentNullException("applicationName",
                    "You must define an ApplicationName to log trace messages");

            ApplicationName = applicationName;
            var storageAccount = CloudStorageAccount.Parse(queueConnectionString);
            var queueClient = storageAccount.CreateCloudQueueClient();
            _queue = queueClient.GetQueueReference(queueName);
            _queue.CreateIfNotExist();
        }
 public StatelessAzureQueueReader(
     string name,
     CloudQueue primaryQueue,
     CloudBlobDirectory container,
     Lazy<CloudQueue> poisonQueue,
     TimeSpan visibilityTimeout)
 {
     _cloudBlob = container;
     _queue = primaryQueue;
     _posionQueue = poisonQueue;
     _queueName = name;
     _visibilityTimeout = visibilityTimeout;
 }
Example #24
0
        public override bool OnStart()
        {
            // Set the maximum number of concurrent connections
            ServicePointManager.DefaultConnectionLimit = 12;

            // For information on handling configuration changes
            // see the MSDN topic at http://go.microsoft.com/fwlink/?LinkId=166357.

            _membershipsPumpQueue = StorageService.GetCloudQueue(StorageConstants.MembershipsPumpQueue);
            _testMembershipsPumpQueue = StorageService.GetCloudQueue(StorageConstants.TestMembershipPumpQueue);

            return base.OnStart();
        }
Example #25
0
        public MsdnQueueSource()
        {
            queueClient = storageAccount.CreateCloudQueueClient();

            this.namespacesQueue = this.queueClient.GetQueueReference("namespaces");
            this.namespacesQueue.CreateIfNotExist();

            this.typesQueue = this.queueClient.GetQueueReference("types");
            this.typesQueue.CreateIfNotExist();

            this.membersQueue = this.queueClient.GetQueueReference("members");
            this.membersQueue.CreateIfNotExist();
        }
Example #26
0
        //----------------------------------------------------------------------
        // ToDo.CountMutualFriends
        //
        // Input   : requestQueue - queue to sent messages to worker roles
        //           responseQueue - queue to receive messages from worker roles
        // Return  : A dictionary which contains the number of mutual friends for each user
        // Purpose : Count the number of mutual friends for each user
        // Note    : You should implement the case of arriving messages from worker roles via responseQueue.
        //           The messages have numbers of mutual friends for each user
        //           in a way you describe in ToDo.CountMutualFriendsInEachWorkerRole.
        //           You should check whether there is a message of the counts in the responseQueue,
        //           and aggregate the counts from worker roles.
        //
        // * Data type of dictionary which will be returned is Dictionary<int, int>.
        //   Key (first generic type parameter) of this dictionary indicates user ID.
        //   Value (second generic type parameter) of this dictionary indicates
        //    the number of mutual friends of the user.
        //----------------------------------------------------------------------
        public static Dictionary<int, int> CountMutualFriends(CloudQueue requestQueue, CloudQueue responseQueue)
        {
            Dictionary<int, int> countMutualFriends = new Dictionary<int, int>();

            // request each worker role to count mutual friends it found
            for (int i = 0; i < ToDo.NumWorkerRoleInstances; i++)
                requestQueue.AddMessage(new CloudQueueMessage("COUNT_MUTUAL_FRIENDS_#" + i));

            // wait for finishing all of worker roles
            int numFinishedRoles = 0;
            while (numFinishedRoles < ToDo.NumWorkerRoleInstances)
            {
                // retrieve a new message from the queue
                CloudQueueMessage msg = responseQueue.GetMessage();
                if (msg == null)
                {
                    System.Threading.Thread.Sleep(sleepTime);
                    continue;
                }

                // remove message from queue
                responseQueue.DeleteMessage(msg);

                string msgStr = msg.AsString;

                if (msgStr.StartsWith("COMPLETE_COUNTING_MUTUAL_FRIENDS"))
                {
                    numFinishedRoles++;
                }
                else
                {
                    // YOU MUST IMPLEMENT ADDITIONAL CODE HERE
                    //
                    // * To receive the number of friends of users from worker roles, using response queue,
                    //
                    // check whether there is a message for the counts in the response queue,
                    // and aggregate the counts from every worker role.

                    String[] split = msgStr.Split(new Char[] { ':' });
                    int key = Convert.ToInt32(split[0]);
                    int value = Convert.ToInt32(split[1]);

                    if (countMutualFriends.ContainsKey(key))
                        countMutualFriends[key] += value;
                    else
                        countMutualFriends.Add(key, value);
                }
            }

            return countMutualFriends;
        }
Example #27
0
        SearchEngine()
        {
            // Instantiate the AzureDirectory storage object for use by Lucene
            CloudStorageAccount.SetConfigurationSettingPublisher((configName, configSetter) =>
            {
                configSetter(CloudSettingsResolver.GetConfigSetting(configName));
            });
            CloudStorageAccount cloudStorageAccount = CloudStorageAccount.FromConfigurationSetting("BlobStorageEndpoint");
            _Directory = new AzureDirectory(cloudStorageAccount, "LuceneStorage", new RAMDirectory());

            // Create search index queue
            CloudQueueClient client = cloudStorageAccount.CreateCloudQueueClient();
            _CloudQueue = client.GetQueueReference("searchindexqueue");
            _CloudQueue.CreateIfNotExist();
        }
        public override bool OnStart()
        {
            // Set the maximum number of concurrent connections 
            ServicePointManager.DefaultConnectionLimit = 12;

            // For information on handling configuration changes
            // see the MSDN topic at http://go.microsoft.com/fwlink/?LinkId=166357.

            var storageAccount = CloudStorageAccount.Parse(RoleEnvironment.GetConfigurationSettingValue("QueueInterRole"));
            var queueClient = storageAccount.CreateCloudQueueClient();
            _queue = queueClient.GetQueueReference("myqueue");
            _queue.CreateIfNotExist();

            return base.OnStart();
        }
Example #29
0
 // Initialize
 public void Initialize(string queueName)
 {
     // create the queue
     try
     {
         // ?? why is this API behavior different from Tables?
         physicalQueue = cloudAccount.QueueClient.GetQueueReference(queueName);
         physicalQueue.CreateIfNotExist();
     }
     catch (StorageClientException ex)
     {
         // TODO: not sure what to do with the exception
         throw ex;
     }
 }
 static Action<IAsyncResult> EndDelete(CloudQueue c)
 {
     return result =>
         {
             try
             {
                 c.EndDelete(result);
             }
             catch (StorageClientException ex)
             {
                 if (ex.ErrorCode == StorageErrorCode.ResourceNotFound)
                     return;
                 throw;
             }
         };
 }