public Miner(IBlockFactory blockFactory, IFifoQueue unconfirmedData) { _blockFactory = blockFactory; _unconfirmedDataFifo = unconfirmedData; var genesisBlock = _blockFactory.GenerateGenesisBlock(); Blockchain = new Blockchain(genesisBlock); }
public Miner(IBlockFactory blockFactory, IFifoQueue unconfirmedData, Miner minerBefore) { _blockFactory = blockFactory; _unconfirmedDataFifo = unconfirmedData; var genesisBlock = _blockFactory.GenerateGenesisBlock(); Blockchain = new Blockchain(genesisBlock); FixPointers(minerBefore); }
public SimpleOutChannel() { _startDelegate = new ThreadStart(Start); _stopDelegate = new ThreadStart(Stop); _transportLock = new ReaderWriterLock(); _transports = new Dictionary <string, IOutboundTransport>(); _messageQueue = new FastFifoQueue <SyslogMessage>(16384); _statistics = new Timer(LogStatistics, null, new TimeSpan(0, 1, 0), new TimeSpan(0, 1, 0)); }
public SyslogTlsCollector() { _log = LoggerHelper.GetLogger(WellKnownLogger.CollectorInternal); _queue = new FastFifoQueue <SyslogMessage>(QUEUE_CAPACITY); _deliveryThread = new Thread(DeliveryLoop) { Name = "SyslogTlsCollector.DeliveryThread" }; _configured = false; }
public SyslogTlsTransport(X509Certificate2 serverCert, bool validateClientCert) { _clients = new Dictionary <string, TlsClient>(); _listLock = new ReaderWriterLock(); ServerCertificate = serverCert; ValidateClientCertificate = validateClientCert; _queue = new FastFifoQueue <SyslogMessage>(2048); _worker = new Thread(DispatchLoop) { Name = "SyslogTlsTransport.DispatchLoop", IsBackground = true }; _worker.Start(); _tmrCleaner = new Timer(CleanupClients, null, TIMER_CYCLE_TIMEOUT, TIMER_CYCLE_TIMEOUT); _tmrStatistics = new Timer(LogStatistics, null, TIMER_CYCLE_TIMEOUT, TIMER_CYCLE_TIMEOUT); }
private void LoopProducer(object queue) { long writes = 0; try { IFifoQueue <object> q = (IFifoQueue <object>)queue; while (true) { q.Enqueue(new object()); writes++; Thread.Sleep(0); } } catch (ThreadAbortException) { TestContext.WriteLine("Wrote {0} elements", writes); } }
private void LoopConsumer(object queue) { long reads = 0; try { IFifoQueue <object> q = (IFifoQueue <object>)queue; while (true) { object item = q.Dequeue(); if (item == null) { Interlocked.Increment(ref _errors); } else { reads++; } Thread.Sleep(0); } } catch (ThreadAbortException) { TestContext.WriteLine("Read {0} elements", reads); } }
/// <summary> /// Initializes a new instance of EntityPlugin /// </summary> public EntityPlugin() { _messageQueue = new FastFifoQueue <SyslogMessage>(QUEUE_SIZE); _tmrStatistics = new Timer(LogStatistics, null, new TimeSpan(0, 1, 0), new TimeSpan(0, 1, 0)); _workerThread = new Thread(WorkerLoop) { IsBackground = true, Name = "EntityPlugin.WorkerLoop" }; _workerThread.Start(); _entityTable = new DataTable("Entities"); _colHost = new DataColumn("Host", typeof(string)) { AllowDBNull = true, ReadOnly = true, Unique = false }; _colProc = new DataColumn("Process", typeof(string)) { AllowDBNull = true, ReadOnly = true, Unique = false }; _colLogger = new DataColumn("Logger", typeof(string)) { AllowDBNull = true, ReadOnly = true, Unique = false }; _colModule = new DataColumn("Module", typeof(string)) { AllowDBNull = true, ReadOnly = true, Unique = false }; _colClass = new DataColumn("Class", typeof(string)) { AllowDBNull = true, ReadOnly = true, Unique = false }; _colMethod = new DataColumn("Method", typeof(string)) { AllowDBNull = true, Unique = false, ReadOnly = true }; _colAppName = new DataColumn("AppName", typeof(string)) { AllowDBNull = true, ReadOnly = true, Unique = false }; _colFfda = new DataColumn("FFDA", typeof(bool)) { AllowDBNull = false, DefaultValue = false, ReadOnly = false, Unique = false }; _colLastAction = new DataColumn("LastAction", typeof(DateTime)) { AllowDBNull = false, ReadOnly = false, Unique = false, DateTimeMode = DataSetDateTime.Utc, }; _colLastHeartbeat = new DataColumn("LstHeartbeat", typeof(DateTime)) { AllowDBNull = true, ReadOnly = false, Unique = false, DateTimeMode = DataSetDateTime.Utc, }; _colChannelId = new DataColumn("ChannelId", typeof(string)) { AllowDBNull = true, ReadOnly = false, Unique = false }; _colFfdaChannelId = new DataColumn("FfdaChannelId", typeof(string)) { AllowDBNull = true, ReadOnly = false, Unique = false }; _entityTable.Columns.Add(_colHost); _entityTable.Columns.Add(_colProc); _entityTable.Columns.Add(_colLogger); _entityTable.Columns.Add(_colAppName); _entityTable.Columns.Add(_colFfda); _entityTable.Columns.Add(_colLastAction); _entityTable.Columns.Add(_colLastHeartbeat); _entityTable.Columns.Add(_colChannelId); _entityTable.Columns.Add(_colFfdaChannelId); try { _config = ConfigurationManager.GetSection("logbus-entityplugin") as EntityPluginConfiguration; } catch { } finally { if (_config == null || _config.entitykey == null || _config.entitykey.Length == 0) { _config = DefaultConfiguration; } } List <DataColumn> primaryKey = new List <DataColumn>(3); foreach (FieldType field in _config.entitykey) { switch (field) { case FieldType.host: { if (_isHostKey) { throw new InvalidOperationException("Primary key configuration broken"); } primaryKey.Add(_colHost); _isHostKey = true; break; } case FieldType.process: { if (_isProcessKey) { throw new InvalidOperationException("Primary key configuration broken"); } primaryKey.Add(_colProc); _isProcessKey = true; break; } case FieldType.logger: { if (_isLoggerKey) { throw new InvalidOperationException("Primary key configuration broken"); } primaryKey.Add(_colLogger); _isLoggerKey = true; break; } case FieldType.module: { if (_isModuleKey) { throw new InvalidOperationException("Primary key configuration broken"); } primaryKey.Add(_colModule); _isModuleKey = true; break; } case FieldType.@class: { if (_isClassKey) { throw new InvalidOperationException("Primary key configuration broken"); } primaryKey.Add(_colClass); _isClassKey = true; break; } case FieldType.method: { if (_isMethodKey) { throw new InvalidOperationException("Primary key configuration broken"); } primaryKey.Add(_colMethod); _isMethodKey = true; break; } } } _primaryKey = new UniqueConstraint("Primary", primaryKey.ToArray(), true); _entityTable.Constraints.Add(_primaryKey); }