public RFActiveComponent(RFComponentContext context)
 {
     _context     = context;
     _isExiting   = false;
     _sync        = new object();
     _componentID = RFComponentCounter.GetNextComponentID();
 }
        public RFConsoleEnvironment(string environment, RFEngineDefinition config, string dbConnection)
        {
            _context = new RFComponentContext
            {
                CancellationTokenSource = new CancellationTokenSource(),
                Catalog      = null,
                UserConfig   = new RFCachedUserConfig(dbConnection, environment),
                UserRole     = new RFSQLUserRole(dbConnection),
                SystemConfig = new RFSystemConfig
                {
                    Environment    = environment,
                    ProcessingMode = RFProcessingMode.RFSinglePass,
                    IntervalLength = config.IntervalSeconds,
                    DocumentStoreConnectionString = dbConnection
                }
            };

            if (RFStatic.Log == null)
            {
                RFStatic.Log = new RFLog4NetLog(dbConnection);
            }

            // reuse parent context for database-access, but create a new engine and work queue (for tracking)
            var engine = new RFSimpleEngine(config, _context);

            _context.Catalog          = new RFSQLCatalog(_context);
            _context.ActiveComponents = new List <RFActiveComponent>();
            _context.Engine           = engine;
            _context.UserLog          = new RFSQLUserLog(_context);
            _context.DispatchStore    = new RFDispatchStoreSQL(_context);
            _workQueue = new RFGraphDispatchQueue(engine.GetWeights(), engine.GetDependencies(), engine.GetExclusiveProcesses(), _context);

            RFEnvironments.LogLicenseInfo(config);
        }
 public RFWorkDoneMonitorMSMQ(MessageQueue eventQueue, RFComponentContext context, IRFInstructionSink instructionSink, IRFEventSink eventSink) : base(context)
 {
     _instructionSink              = instructionSink;
     _eventSink                    = eventSink;
     _eventQueue                   = eventQueue;
     _eventQueue.ReceiveCompleted += _eventQueue_ReceiveCompleted;
 }
        public RFServiceEnvironment(string environment, RFEngineDefinition config, string dbConnection)
        {
            _context = new RFComponentContext
            {
                CancellationTokenSource = new CancellationTokenSource(),
                Catalog      = null,
                UserConfig   = new RFCachedUserConfig(dbConnection, environment),
                SystemConfig = new RFSystemConfig
                {
                    Environment    = environment,
                    IntervalLength = config.IntervalSeconds * 1000,
                    ProcessingMode = RFProcessingMode.RFContinuous,
                    DocumentStoreConnectionString = dbConnection,
                    Downtime = RFSettings.GetDowntime()
                }
            };

            RFStatic.Log = new RFLog4NetLog(dbConnection);

            var engine = new RFSimpleEngine(config, _context);

            _context.Engine        = engine;
            _context.Catalog       = new RFSQLCatalog(_context);
            _context.UserLog       = new RFSQLUserLog(_context);
            _context.UserRole      = new RFSQLUserRole(dbConnection);
            _context.DispatchStore = new RFDispatchStoreSQL(_context);

            _workQueue = new RFGraphDispatchQueue(engine.GetWeights(), engine.GetDependencies(), engine.GetExclusiveProcesses(), _context);
            RFEnvironments.LogLicenseInfo(config);
        }
Exemple #5
0
        public RFWebEnvironment(string dbConnection, string environment)
        {
            _context = new RFComponentContext
            {
                CancellationTokenSource = new CancellationTokenSource(),
                Catalog      = null,
                UserConfig   = new RFCachedUserConfig(connectionString: dbConnection, environmentName: environment),
                UserRole     = new RFSQLUserRole(dbConnection),
                SystemConfig = new RFSystemConfig
                {
                    ProcessingMode = RFProcessingMode.RFSinglePass,
                    Environment    = environment,
                    IntervalLength = 60000,
                    DocumentStoreConnectionString = dbConnection
                }
            };

            RFStatic.Log = new RFLog4NetLog(dbConnection);

            // to do - replace these managers with remote triggers
            _context.Engine        = null;
            _context.Catalog       = new RFSQLCatalog(_context);
            _context.UserLog       = new RFSQLUserLog(_context);
            _context.DispatchStore = new RFDispatchStoreSQL(_context);
        }
Exemple #6
0
 public RFWorkerThreadMSMQ(RFComponentContext context, string workerQueueName, IRFEventSink eventSink)
     : base(context)
 {
     _eventSink                     = eventSink;
     _workerQueue                   = new MessageQueue(workerQueueName);
     _workerQueue.Formatter         = new RFFormatterMSMQ();
     _workerQueue.ReceiveCompleted += _queue_ReceiveCompleted;
 }
Exemple #7
0
 public RFSimpleEngine(RFEngineDefinition config, RFComponentContext componentContext)
     : base(componentContext)
 {
     _config    = config;
     _reactors  = new List <RFEventReactor>();
     _processes = new Dictionary <string, RFEngineProcess>();
     _services  = new List <RFBackgroundServiceComponent>();
 }
Exemple #8
0
 protected RFDispatchQueueMonitorBase(RFComponentContext context, IRFInstructionSink instructionSink, IRFEventSink eventSink, IRFDispatchQueue dispatchQueue)
     : base(context)
 {
     _requestTracker  = new RFRequestTracker();
     _instructionSink = instructionSink;
     _eventSink       = eventSink;
     _dispatchQueue   = dispatchQueue;
 }
Exemple #9
0
        public RFDispatchQueueMonitorMSMQ(RFComponentContext context, IRFInstructionSink instructionSink, IRFEventSink eventSink, IRFDispatchQueue dispatchQueue)
            : base(context, instructionSink, eventSink, dispatchQueue)
        {
            var localSuffix = RIFF.Core.RFCore.sShortVersion;

            _workerThreadsCount = RFSettings.GetAppSetting("MSMQWorkerThreads", 4);
            _workerQueue        = GetOrCreateQueue("WorkerQueue_" + localSuffix, _context.SystemConfig.Environment);
            _eventQueue         = GetOrCreateQueue("EventQueue_" + localSuffix, _context.SystemConfig.Environment);
            _workerQueue.DefaultPropertiesToSend.ResponseQueue = _eventQueue;
            Log.Debug(this, "Using MSMQ Queues");
        }
Exemple #10
0
 public RFIntervalComponent(RFComponentContext context, IRFEventSink eventManager)
     : base(context)
 {
     _eventManager   = eventManager;
     _intervalLength = context.SystemConfig.IntervalLength;
     if (_intervalLength == 0)
     {
         _intervalLength = 60000;
     }
     _downtime = context.SystemConfig.Downtime;
 }
 public static RFProcessingContext Create(RFComponentContext component, string processingKey, IRFInstructionSink instructionManager, IRFEventSink eventManager, RFDispatchQueueMonitorBase workQueue)
 {
     return(new RFProcessingContext
     {
         _instructions = instructionManager,
         _events = eventManager,
         _catalog = component.Catalog,
         _memoryStore = component.MemoryStore,
         UserConfig = component.UserConfig,
         Environment = component.SystemConfig.Environment,
         _workQueue = workQueue,
         UserLog = component.UserLog,
         UserRole = component.UserRole,
         ProcessingKey = processingKey,
         _dispatchStore = component.DispatchStore
     });
 }
        public RFSQLCatalog(RFComponentContext context)
            : base(context)
        {
            _connectionString = context.SystemConfig.DocumentStoreConnectionString;
            if (_firstInit && _connectionString.NotBlank())
            {
                var sqlConnection = new SqlConnection(_connectionString);
                sqlConnection.Open();
                context.Log.Info(this, "Connected to SQL Server database [{0}] on server {1} (v{2}).", sqlConnection.Database, sqlConnection.DataSource, sqlConnection.ServerVersion);
                sqlConnection.Close();
                _firstInit = false;

                _useTransactions = RFSettings.GetAppSetting("UseTransactions", true);
                _trackKeyHash    = RFSettings.GetAppSetting("TrackKeyHash", true);
                _maxResults      = RFSettings.GetAppSetting("MaxResults", _maxResults);
                _commandTimeout  = RFSettings.GetAppSetting("CommandTimeout", _commandTimeout);
                _maxKeyLength    = RFSettings.GetAppSetting("MaxKeyLength", _maxKeyLength);

                context.Log.Debug(this, "UseTransactions: {0}, CommandTimeout: {1}s, KeyHash: {2}", _useTransactions, _commandTimeout, _trackKeyHash);
            }
        }
Exemple #13
0
 public RFPassiveComponent(RFComponentContext context)
 {
     _context     = context;
     _componentID = RFComponentCounter.GetNextComponentID();
 }
Exemple #14
0
 protected RFStore(RFComponentContext context)
     : base(context)
 {
 }
        private volatile object _sync;                                                 // internal monitor

        // internal sync for statistics
        public RFGraphDispatchQueue(Dictionary <string, int> weights, Dictionary <string, SortedSet <string> > dependencies, SortedSet <string> exclusiveProcesses, RFComponentContext context)
        {
            _sync                  = new object();
            _statsSync             = new object();
            _processWeights        = weights;
            _inProgress            = new List <RFWorkQueueItem>();
            _pendingInstructions   = new SortedDictionary <long, List <RFWorkQueueItem> >();
            _readyQueue            = new List <RFWorkQueueItem>();
            _processDependencies   = dependencies ?? new Dictionary <string, SortedSet <string> >();
            _dispatchStore         = context.DispatchStore;
            _numQueuedInstructions = new Dictionary <string, int>();
            _exclusiveProcesses    = exclusiveProcesses;
        }
Exemple #16
0
 public RFDispatchQueueMonitorInProc(RFComponentContext context, IRFInstructionSink instructionManager, IRFEventSink eventManager, IRFDispatchQueue workQueue)
     : base(context, instructionManager, eventManager, workQueue)
 {
     Log.Debug(this, "Using InProc Queue");
 }
Exemple #17
0
 public RFSQLUserLog(RFComponentContext context)
 {
     _connectionString = context.SystemConfig.DocumentStoreConnectionString;
     _context          = context;
 }
 public RFBackgroundServiceComponent(RFComponentContext context, IRFBackgroundService impl) : base(context)
 {
     _impl = impl;
 }
 public RFDispatchStoreSQL(RFComponentContext context)
 {
     _context = context;
 }