Beispiel #1
0
        private void Setting_CheckDiskSpace()
        {
            bool watchFlag = true;

            _checkDiskSpaceTimer = new WatchTimer(() =>
            {
                if (!watchFlag)
                {
                    return;
                }

                try
                {
                    bool flag = false;

                    if (_amoebaInterfaceManager.Report.Core.Cache.FreeSpace < NetworkConverter.FromSizeString("10GB"))
                    {
                        flag |= true;
                    }

                    if (!flag)
                    {
                        if (_amoebaInterfaceManager.State == ManagerState.Stop)
                        {
                            _amoebaInterfaceManager.Start();
                            Log.Information("Start");
                        }
                    }
                    else
                    {
                        if (_amoebaInterfaceManager.State == ManagerState.Start)
                        {
                            _amoebaInterfaceManager.Stop();
                            Log.Information("Stop");

                            watchFlag = false;

                            App.Current.Dispatcher.InvokeAsync(() =>
                            {
                                if (_dialogService.ShowDialog(LanguagesManager.Instance.MainWindow_SpaceNotFound_Message,
                                                              MessageBoxButton.OKCancel, MessageBoxImage.Question, MessageBoxResult.Cancel) == MessageBoxResult.OK)
                                {
                                    watchFlag = true;
                                }
                            });
                        }
                    }
                }
                catch (Exception e)
                {
                    Log.Error(e);
                }
            });
            _checkDiskSpaceTimer.Start(new TimeSpan(0, 0, 0), new TimeSpan(0, 3, 0));
        }
Beispiel #2
0
        private void Setting_CheckDiskSpace()
        {
            _checkDiskSpaceTimer = new WatchTimer(() =>
            {
                try
                {
                    bool flag = false;


                    if (_serviceManager.Report.Core.Cache.FreeSpace < NetworkConverter.FromSizeString("32GB") &&
                        _serviceManager.Report.Core.Cache.FreeSpace < (_serviceManager.Size / 3))
                    {
                        flag |= true;
                    }

                    if (!flag)
                    {
                        if (_serviceManager.State == ManagerState.Stop)
                        {
                            _serviceManager.Start();
                            Log.Information("Start");
                        }
                    }
                    else
                    {
                        if (_serviceManager.State == ManagerState.Start)
                        {
                            _serviceManager.Stop();
                            Log.Information("Stop");
                        }
                    }
                }
                catch (Exception e)
                {
                    Log.Error(e);
                }
            });
            _checkDiskSpaceTimer.Start(new TimeSpan(0, 0, 0), new TimeSpan(0, 0, 30));
        }
Beispiel #3
0
        public void Resize(long size)
        {
            lock (this.ThisLock)
            {
                size = (long)Math.Min(size, NetworkConverter.FromSizeString("256TB"));

                long unit = 256 * 1024 * 1024;
                size = ((size + (unit - 1)) / unit) * unit;

                foreach (var key in _settings.ClusterIndex.Keys.ToArray()
                         .Where(n => _settings.ClusterIndex[n].Indexes.Any(point => size < (point * CacheManager.SectorSize) + CacheManager.SectorSize))
                         .ToArray())
                {
                    this.Remove(key);
                }

                _settings.Size = ((size + ((long)CacheManager.SectorSize - 1)) / (long)CacheManager.SectorSize) * CacheManager.SectorSize;
                _fileStream.SetLength(Math.Min(_settings.Size, _fileStream.Length));

                _spaceSectors.Clear();
                _spaceSectorsInitialized = false;
            }
        }
Beispiel #4
0
        private void Setting_CheckDiskSpace()
        {
            bool watchFlag = true;

            _checkDiskSpaceTimer = new WatchTimer(() =>
            {
                if (!watchFlag)
                {
                    return;
                }

                try
                {
                    var paths = new List <string>();
                    paths.Add(AmoebaEnvironment.Config.Cache.BlocksPath);

                    bool flag = false;

                    foreach (string path in paths)
                    {
                        var drive = new DriveInfo(Path.GetFullPath(path));

                        if (drive.AvailableFreeSpace < NetworkConverter.FromSizeString("256MB"))
                        {
                            flag |= true;
                            break;
                        }
                    }

                    if (_serviceManager.Report.Core.Cache.FreeSpace < NetworkConverter.FromSizeString("10GB"))
                    {
                        flag |= true;
                    }

                    if (!flag)
                    {
                        if (_serviceManager.State == ManagerState.Stop)
                        {
                            _serviceManager.Start();
                            Log.Information("Start");
                        }
                    }
                    else
                    {
                        if (_serviceManager.State == ManagerState.Start)
                        {
                            _serviceManager.Stop();
                            Log.Information("Stop");

                            watchFlag = false;

                            App.Current.Dispatcher.InvokeAsync(() =>
                            {
                                var viewModel       = new NoticeWindowViewModel(LanguagesManager.Instance.MainWindow_SpaceNotFound_Message);
                                viewModel.Callback += () => watchFlag = true;

                                _dialogService.Show(viewModel);
                            });
                        }
                    }
                }
                catch (Exception e)
                {
                    Log.Error(e);
                }
            });
            _checkDiskSpaceTimer.Start(new TimeSpan(0, 0, 0), new TimeSpan(0, 3, 0));
        }