Exemple #1
0
        /// <summary>
        /// Extends the OnStart phase that is called by Windows Azure runtime to initialize the role instance.
        /// </summary>
        /// <returns>True if initialization succeeds, otherwise false.</returns>
        protected override bool OnRoleStart()
        {
            this.EnsureExists <ScalableTransformConfigurationExtension>();
            this.EnsureExists <CloudStorageProviderExtension>();
            this.EnsureExists <XslTransformMetadataProviderExtension>();
            this.EnsureExists <XslTransformInProcCacheExtension>();
            this.EnsureExists <XslTransformProviderExtension>();
            this.EnsureExists <EndpointConfigurationDiscoveryExtension>();

            IEndpointConfigurationDiscoveryExtension discoveryExtension     = Extensions.Find <IEndpointConfigurationDiscoveryExtension>();
            IRoleConfigurationSettingsExtension      roleConfigExtension    = Extensions.Find <IRoleConfigurationSettingsExtension>();
            IScalableTransformConfigurationExtension serviceConfigExtension = Extensions.Find <IScalableTransformConfigurationExtension>();

            StorageAccountConfigurationSettings storageSettings     = roleConfigExtension.GetSection <StorageAccountConfigurationSettings>(StorageAccountConfigurationSettings.SectionName);
            XslTransformCloudBlobCacheExtension cloudBlobCache      = new XslTransformCloudBlobCacheExtension(storageSettings.Accounts.Get(serviceConfigExtension.Settings.CacheStorageAccount));
            CloudStorageLoadBalancingExtension  storageLoadBalancer = new CloudStorageLoadBalancingExtension(from name in serviceConfigExtension.Settings.StorageAccounts.AllKeys select storageSettings.Accounts.Get(name));

            // Configure the cache TTL for the blob caching extension.
            cloudBlobCache.CacheTimeToLive = serviceConfigExtension.Settings.BlobCacheTimeToLive;

            // Configure the cache TTL for the in-proc caching extension.
            XslTransformInProcCacheExtension memoryCache = Extensions.Find <XslTransformInProcCacheExtension>();

            memoryCache.CacheTimeToLive = serviceConfigExtension.Settings.MemoryCacheTimeToLive;

            Extensions.Add(cloudBlobCache);
            Extensions.Add(storageLoadBalancer);

            // Done with configuring all infrastructure extensions, now proceed with registering the service extension that implements the core methods.
            this.EnsureExists <ScalableTransformServiceExtension>();

            var contractTypeMatchCondition = ServiceEndpointDiscoveryCondition.ContractTypeExactMatch(typeof(IScalableTransformationServiceContract));
            var bindingTypeMatchCondition  = ServiceEndpointDiscoveryCondition.BindingTypeExactMatch(typeof(NetTcpRelayBinding));

            discoveryExtension.RegisterDiscoveryAction(new[] { contractTypeMatchCondition, bindingTypeMatchCondition }, (endpoint) =>
            {
                NetTcpRelayBinding relayBinding = endpoint.Binding as NetTcpRelayBinding;

                if (relayBinding != null)
                {
                    relayBinding.TransferMode = TransferMode.Streamed;
                }
            });

            return(true);
        }
Exemple #2
0
        /// <summary>
        /// Extends the OnStart phase that is called by Windows Azure runtime to initialize the role instance.
        /// </summary>
        /// <returns>True if initialization succeeds, otherwise false.</returns>
        protected override bool OnRoleStart()
        {
            this.EnsureExists <EndpointConfigurationDiscoveryExtension>();
            this.EnsureExists <ActivityTrackingEventStreamExtension>();

            IEndpointConfigurationDiscoveryExtension discoveryExtension = Extensions.Find <IEndpointConfigurationDiscoveryExtension>();

            var contractTypeMatchCondition = ServiceEndpointDiscoveryCondition.ContractTypeExactMatch(typeof(IPersistenceServiceContract));
            var bindingTypeMatchCondition  = ServiceEndpointDiscoveryCondition.BindingTypeExactMatch(typeof(NetTcpRelayBinding));

            discoveryExtension.RegisterDiscoveryAction(new [] { contractTypeMatchCondition, bindingTypeMatchCondition }, (endpoint) =>
            {
                NetTcpRelayBinding relayBinding = endpoint.Binding as NetTcpRelayBinding;

                if (relayBinding != null)
                {
                    relayBinding.TransferMode = TransferMode.Streamed;
                }
            });

            return(true);
        }
Exemple #3
0
        /// <summary>
        /// Extends the OnStart phase that is called by Windows Azure runtime to initialize the role instance.
        /// </summary>
        /// <returns>True if initialization succeeds, otherwise false.</returns>
        protected override bool OnRoleStart()
        {
            this.EnsureExists <WorkItemProcessorConfigurationExtension>();
            this.EnsureExists <WorkQueueLocationResolverExtension>();
            this.EnsureExists <ScalableTransformServiceClientExtension>();
            this.EnsureExists <EndpointConfigurationDiscoveryExtension>();
            this.EnsureExists <RulesEngineServiceClientExtension>();
            this.EnsureExists <InterRoleEventSubscriberExtension>();

            IWorkItemProcessorConfigurationExtension configSettingsExtension = Extensions.Find <IWorkItemProcessorConfigurationExtension>();
            IEndpointConfigurationDiscoveryExtension discoveryExtension      = Extensions.Find <IEndpointConfigurationDiscoveryExtension>();
            IInterRoleCommunicationExtension         interCommExtension      = Extensions.Find <IInterRoleCommunicationExtension>();
            IInterRoleEventSubscriberExtension       interCommSubscriber     = Extensions.Find <IInterRoleEventSubscriberExtension>();

            CloudQueueLocation inputQueueLocation = new CloudQueueLocation()
            {
                StorageAccount    = configSettingsExtension.Settings.CloudStorageAccount,
                QueueName         = configSettingsExtension.Settings.WorkItemQueue,
                VisibilityTimeout = configSettingsExtension.Settings.WorkItemQueueVisibilityTimeout
            };

            CloudQueueLocation outputQueueLocation = new CloudQueueLocation()
            {
                StorageAccount    = configSettingsExtension.Settings.CloudStorageAccount,
                QueueName         = configSettingsExtension.Settings.OutputQueue,
                VisibilityTimeout = configSettingsExtension.Settings.OutputQueueVisibilityTimeout
            };

            // Instantiate queue listeners.
            var inputQueueListener  = new CloudQueueListenerExtension <XDocument>(inputQueueLocation);
            var outputQueueListener = new CloudQueueListenerExtension <XDocument>(outputQueueLocation);

            // Configure the input queue listener.
            inputQueueListener.QueueEmpty      += HandleQueueEmptyEvent;
            inputQueueListener.DequeueBatchSize = configSettingsExtension.Settings.DequeueBatchSize;
            inputQueueListener.DequeueInterval  = configSettingsExtension.Settings.MinimumIdleInterval;

            // Configure the output queue listener.
            outputQueueListener.QueueEmpty      += HandleQueueEmptyEvent;
            outputQueueListener.DequeueBatchSize = configSettingsExtension.Settings.DequeueBatchSize;
            outputQueueListener.DequeueInterval  = configSettingsExtension.Settings.MinimumIdleInterval;

            // Instantiate queue subscribers.
            InputQueueSubscriberExtension  inputQueueSubscriber  = new InputQueueSubscriberExtension();
            OutputQueueSubscriberExtension outputQueueSubscriber = new OutputQueueSubscriberExtension();

            // Register subscribers with queue listeners.
            inputQueueListener.Subscribe(inputQueueSubscriber);
            outputQueueListener.Subscribe(outputQueueSubscriber);

            // Register custom extensions for this worker role.
            Extensions.Add(inputQueueSubscriber);
            Extensions.Add(outputQueueSubscriber);
            Extensions.Add(outputQueueListener);
            Extensions.Add(inputQueueListener);

            var contractTypeMatchCondition = ServiceEndpointDiscoveryCondition.ContractTypeExactMatch(typeof(IScalableTransformationServiceContract));
            var bindingTypeMatchCondition  = ServiceEndpointDiscoveryCondition.BindingTypeExactMatch(typeof(NetTcpRelayBinding));

            discoveryExtension.RegisterDiscoveryAction(new[] { contractTypeMatchCondition, bindingTypeMatchCondition }, (endpoint) =>
            {
                NetTcpRelayBinding relayBinding = endpoint.Binding as NetTcpRelayBinding;
                if (relayBinding != null)
                {
                    relayBinding.TransferMode = TransferMode.Streamed;
                }
            });

            // Register a subscriber for all inter-role communication events.
            if (interCommExtension != null && interCommSubscriber != null)
            {
                this.interCommSubscription = interCommExtension.Subscribe(interCommSubscriber);
            }

            return(true);
        }