Exemple #1
0
        /// <summary>
        /// Create a series repository at a specified location.
        /// </summary>
        /// <param name="path">A directory path where repository is stored. If null or empty, then
        /// a default folder is used.</param>
        /// <param name="bufferSizeMb">Buffer size in megabytes. Ignored if below default.</param>
        public DataRepository(string path = null, uint bufferSizeMb = 100) : base(GetConnectionStringFromPath(path))
        {
            if (string.IsNullOrWhiteSpace(path))
            {
                path = Path.Combine(Bootstrap.Bootstrapper.Instance.DataFolder, "Repos", "Default");
            }
            var seriesPath = Path.Combine(path, "series");

            _mapsPath = Path.Combine(path, "maps");
            if (!Directory.Exists(_mapsPath))
            {
                Directory.CreateDirectory(_mapsPath);
            }
            var writeLocksFileName = Path.Combine(seriesPath, WriteLocksFileName);

            _writeSeriesLocks = new PersistentMapFixedLength <UUID, long>(writeLocksFileName, 1000);
            var logBufferFileName = Path.Combine(seriesPath, LogBufferFileName);

            _appendLog           = new AppendLog(logBufferFileName, bufferSizeMb < MinimumBufferSize ? (int)MinimumBufferSize : (int)bufferSizeMb);
            _appendLog.OnAppend += OnLogAppend;
            _pid = (((long)_counter) << 32) | (long)Process.GetCurrentProcess().Id;
            _counter++;

            _isConductor = TryBecomeConductor();
        }
Exemple #2
0
 internal BroadcastObservable(AppendLog appendLog, string channelId, long pid)
 {
     _appendLog = appendLog;
     _channelId = channelId;
     _pid       = pid;
     _uuid      = new UUID(channelId);
     _observers = new List <IObserver <T> >();
 }
Exemple #3
0
        internal PersistentSeries(AppendLog appendLog, long pid, UUID uuid, IPersistentOrderedMap <K, V> innerMap, bool allowBatches, bool isWriter,
                                  Action <bool, bool> disposeCallback = null)
        {
            _appendLog    = appendLog;
            _pid          = pid;
            _uuid         = uuid;
            _innerMap     = innerMap;
            _allowBatches = allowBatches;
            _isWriter     = isWriter;
            var outer = (_innerMap as SortedChunkedMap <K, V>)?.OuterMap as RemoteChunksSeries <K, V>;

            if (outer != null)
            {
                outer.ReadOnly = !_isWriter;
            }
            _disposeCallback = disposeCallback;
            Interlocked.Increment(ref RefCounter);
        }
Exemple #4
0
        /// <summary>
        /// Create a series repository at a specified location.
        /// </summary>
        /// <param name="path">A directory path where repository is stored. If null or empty, then
        /// a default folder is used.</param>
        /// <param name="bufferSizeMb">Buffer size in megabytes. Ignored if below default.</param>
        public DataRepository(string path = null, uint bufferSizeMb = 100) : base(GetConnectionStringFromPath(path))
        {
            //if (!Path.IsPathRooted(path)) {
            //    path = Path.Combine(Bootstrap.Bootstrapper.Instance.DataFolder, "Repos", path);
            //}
            var seriesPath = Path.Combine(path, "series");

            _mapsPath = Path.Combine(path, "maps");
            if (!Directory.Exists(_mapsPath))
            {
                Directory.CreateDirectory(_mapsPath);
            }
            var writeLocksFileName = Path.Combine(seriesPath, WriteLocksFileName);

            _writeSeriesLocks = new PersistentMapFixedLength <UUID, int>(writeLocksFileName, 1000);
            var logBufferFileName = Path.Combine(seriesPath, LogBufferFileName);

            _appendLog           = new AppendLog(logBufferFileName, bufferSizeMb < MinimumBufferSize ? (int)MinimumBufferSize : (int)bufferSizeMb);
            _appendLog.OnAppend += OnLogAppend;
            _pid = (_counter << 16) | Process.GetCurrentProcess().Id;
            _counter++;
        }