Example #1
0
        internal virtual bool Initialize()
        {
            bool indexedDefined = false;
            if (_props != null)
            {
                if (_props.Contains("index-for-all"))
                {
                    _indexForAll = Convert.ToBoolean(_props["index-for-all"]);
                    indexedDefined = _indexForAll;
                }

                if (_props.Contains("index-classes"))
                {
                    Hashtable indexClasses = _props["index-classes"] as Hashtable;
                    _typeMap = new TypeInfoMap(indexClasses);

                    IDictionaryEnumerator ie = indexClasses.GetEnumerator();
                    while (ie.MoveNext())
                    {
                        Hashtable innerProps = ie.Value as Hashtable;
                        string typename = "";

                        if (innerProps != null)
                        {
                            typename = (string)innerProps["id"];
                            ArrayList attribList = new ArrayList();
                            IDictionaryEnumerator en = innerProps.GetEnumerator();
                            while (en.MoveNext())
                            {
                                Hashtable attribs = en.Value as Hashtable;
                                if (attribs != null)
                                {
                                    IDictionaryEnumerator ide = attribs.GetEnumerator();
                                    while (ide.MoveNext())
                                    {
                                        Hashtable attrib = ide.Value as Hashtable;
                                        if (attrib != null)
                                        {
                                            attribList.Add(attrib["id"] as string);
                                        }
                                    }
                                }
                            }

                            //attrib level index.
                            if (attribList.Count > 0)
                            {
                                _indexMap[typename] = new AttributeIndex(attribList, _cacheName, typename, _typeMap);
                            }
                            //just a key level index.
                            else
                                _indexMap[typename] = new TypeIndex(typename, _indexForAll);
                            indexedDefined = true;
                        }
                    }
                }
            }
            else
            {
                _indexMap["default"] = new VirtualQueryIndex(_cache);
            }
            if (indexedDefined)
            {
                _asyncProcessor = new AsyncProcessor(_cache.Context.NCacheLog);
                _asyncProcessor.Start();
            }
            return indexedDefined;
        }
Example #2
0
        public override void start()
        {
            // Incase of TCP stack we'll get a reference to TOTAL, which is the top
            // protocol in our case.
            upper = Stack.findProtocol("TOTAL");

            ct = getConnectionTable(reaper_interval, conn_expire_time, bind_addr1, bind_addr2, start_port, _retries, _retryInterval);

            
            ct.addConnectionListener(this);
            ct.ReceiveBufferSize = recv_buf_size;
            ct.SendBufferSize = send_buf_size;
            local_addr = ct.LocalAddress;
            if (additional_data != null /*&& local_addr is Address*/)
                ((Address)local_addr).AdditionalData = additional_data;
            passUp(new Event(Event.SET_LOCAL_ADDRESS, local_addr, Priority.Critical));
            _asyncProcessor = new AsyncProcessor(stack.NCacheLog);
            _asyncProcessor.Start();

            _keepAlive = new ConnectionKeepAlive(this, ct, _heartBeatInterval);
            if (_useKeepAlive)
                _keepAlive.Start();


            Stack.NCacheLog.CriticalInfo("TCP.start", "operating parameters -> [ heart_beat:" + _useKeepAlive + " ;heart_beat_interval: " + _heartBeatInterval + " ;async_up_deliver: " + asyncPassup + " ;connection_retries: " + _retries + " ;connection_retry_interval: " + _retryInterval + " ]");
            
        }
Example #3
0
        internal void StartServices(string cacheId, string server, int port)
        {
            this._cacheId = cacheId;

            if (
                !string.IsNullOrEmpty(
                    System.Configuration.ConfigurationSettings.AppSettings.Get(
                        "NCacheClient.AsynchronousEventNotification")))
            {
                try
                {
                    _notifyAsync =
                        Convert.ToBoolean(
                            System.Configuration.ConfigurationSettings.AppSettings.Get(
                                "NCacheClient.AsynchronousEventNotification"));
                }
                catch (Exception ex)
                {
                    throw new Exception("Invalid value specified for NCacheClient.AsynchronousEventNotification.");
                }

                if (!_notifyAsync)
                {
                    if (
                        !string.IsNullOrEmpty(
                            System.Configuration.ConfigurationSettings.AppSettings.Get(
                                "NCacheClient.NumberofEventProccesingThreads")))
                    {
                        try
                        {
                            _asyncProccesorThreadCount =
                                Convert.ToInt32(
                                    System.Configuration.ConfigurationSettings.AppSettings.Get(
                                        "NCacheClient.NumberofEventProccesingThreads"));
                        }
                        catch (Exception e)
                        {
                            throw new Exception(
                                "Invalid value specified for NCacheClient.NumberofEventProccesingThreads.");
                        }
                    }

                    if (_asyncProccesorThreadCount <= 0)
                        _asyncProccesorThreadCount = 1;

                    if (_asyncProccesorThreadCount > 5)
                        _asyncProccesorThreadCount = 5;

                    _eventProcessor = new AsyncProcessor(_asyncProccesorThreadCount);
                    _eventProcessor.Start();
                }
            }

            //Check the type of license the application
            try
            {
                _clientConfig.LoadConfiguration();
            }
            catch (Exception)
            {
            }

            bool enable_logs = false;
            bool detailed_logs = false;

            if (System.Configuration.ConfigurationSettings.AppSettings.Get("enableNCWebLogs") != null)
            {
                enable_logs =
                    Convert.ToBoolean(System.Configuration.ConfigurationSettings.AppSettings["enableNCWebLogs"]);
            }
            else
                enable_logs = _clientConfig.EnableClientLogs;

            if (System.Configuration.ConfigurationSettings.AppSettings.Get("enableDetailedNCWebLogs") != null)
            {
                detailed_logs =
                    Convert.ToBoolean(System.Configuration.ConfigurationSettings.AppSettings["enableDetailedNCWebLogs"]);
            }
            else
                detailed_logs = _clientConfig.EnableDetailedClientLogs;

            InitializeLogs(enable_logs, detailed_logs);

            if (System.Configuration.ConfigurationSettings.AppSettings.Get("enablePerfStats") != null)
            {
                _perfStatsEnabled =
                    Convert.ToBoolean(System.Configuration.ConfigurationSettings.AppSettings["enablePerfStats"]);
            }

            if (_perfStatsEnabled)
            {
                _perfStatsColl.InitializePerfCounters();
            }

            int conTimeout = _connectionRetries*(_connectionTimeout + _retryInterval);
            if (conTimeout > 0) _connectionMutexTimeout = conTimeout;
            if (_operationTimeout < 60000) _operationTimeout = 60000; //minimum timeout is 60 seconds.

            _connection = new Connection(_commandReieved, _serverLost, _logger, _perfStatsColl, _responseIntegrator,
                _clientConfig.BindIP);

            RemoteServer remoteServer = new RemoteServer(server, port);

            if (this._importHashmap)
            {
                this._processor = new AsyncProcessor();
            }

            if (remoteServer.IP != null)
            {
                remoteServer.IsUserProvided = true;

                try
                {
                    ConnectRemoteServer(_connection, remoteServer, true);
                }

                catch (OperationNotSupportedException oe)
                {
                    if (_logger.IsErrorLogsEnabled) _logger.NCacheLog.Error("Broker.StartServices", oe.ToString());
                }
            }
            if (!IsConnected)
            {
                try
                {

                    TryNextServer();
                }

                catch (OperationNotSupportedException oe)
                {
                    if (_logger.IsErrorLogsEnabled) _logger.NCacheLog.Error("Broker.StartServices", oe.ToString());
                    throw;
                }

            }
        }