/// <summary>
        /// Initializes the component for use using the supplied configuration.
        /// </summary>
        /// <param name="config">The config.</param>
        /// <exception cref="ArgumentNullException">Thrown if the config parameter is null.</exception>
        /// <exception cref="InvalidOperationException">Thrown if the RelayNode passes in a configuration with a missing section for this component.</exception>
        private void LoadConfig(RelayNodeConfig config)
        {
            if (config == null)
            {
                return;
            }
            if (config.RelayComponents == null)
            {
                throw new InvalidOperationException("No component configurations were found in the RelayNodeConfig passed to this component.");
            }

            var flexForwarderConfig = config.RelayComponents.GetConfigFor(GetComponentName()) as FlexForwarderConfig;
            var groupName           = (flexForwarderConfig != null) ? flexForwarderConfig.GroupName : null;

            var flexCacheClient = new FlexCacheClient(groupName);

            if (_flexCacheClient == null || flexCacheClient.GroupName != _flexCacheClient.GroupName)
            {
                _flexCacheClient = flexCacheClient;
                Log.InfoFormat("FlexCache will use group: \"{0}\".", _flexCacheClient.GroupName);

                if (_counters != null)
                {
                    _counters.RemoveInstance();
                }
                _counters = Counters.GetInstance(_flexCacheClient.GroupName);
            }
        }
 /// <summary>
 /// Shut down the component.
 /// </summary>
 public void Shutdown()
 {
     Log.Info("Shutting down.");
     _flexCacheClient = null;
     if (_counters != null)
     {
         _counters.RemoveInstance();
     }
     // TODO: Probably need to wait until all messages have been serviced by _flexCacheClient before completing shutdown.
     Log.Info("Shutting down has completed.");
 }
Exemple #3
0
        public static Future GetFuture(this FlexCacheClient client, RelayMessage message)
        {
            switch (message.GetMessageActionType())
            {
            case MessageActionType.Put:
                return(client.Put(message.GetKeySpace(), message.GetKey(), new MemoryStream(message.Payload.ByteArray), new ContentType(FlexCache.MediaTypeNames.Auto)));

            case MessageActionType.Delete:
                return(client.Delete(message.GetKeySpace(), message.GetKey()));

            case MessageActionType.Get:
                return(client.Get(message.GetKeySpace(), message.GetKey()));
            }

            throw new NotSupportedException("Message type is not supported by Flex Cache.");
        }