Exemple #1
0
 public long GetDatabaseTransactionVersionSizeInBytes()
 {
     try
     {
         const string categoryName = "Database ==> Instances";
         if (PerformanceCounterCategory.Exists(categoryName) == false)
         {
             return(-1);
         }
         var          category      = new PerformanceCounterCategory(categoryName);
         var          instances     = category.GetInstanceNames();
         var          ravenInstance = instances.FirstOrDefault(x => x.StartsWith(uniqueRrefix));
         const string counterName   = "Version Buckets Allocated";
         if (ravenInstance == null || !category.CounterExists(counterName))
         {
             return(-2);
         }
         using (var counter = new PerformanceCounter(categoryName, counterName, ravenInstance, readOnly: true))
         {
             var value = counter.NextValue();
             return((long)(value * TransactionalStorageConfigurator.GetVersionPageSize()));
         }
     }
     catch (Exception e)
     {
         if (reportedGetDatabaseTransactionCacheSizeInBytesError == false)
         {
             reportedGetDatabaseTransactionCacheSizeInBytesError = true;
             log.WarnException("Failed to get Version Buckets Allocated value, this error will only be reported once.", e);
         }
         return(-3);
     }
 }
 public EsentExportOperation(string dataDirPath)
 {
     var dbFullPath = Path.Combine(dataDirPath, "Data");            
     try
     {
         Api.JetCreateInstance(out instance, "instance");
         var ravenConfiguration = new RavenConfiguration();
         ravenConfiguration.DataDirectory = dataDirPath;
         ravenConfiguration.Storage.PreventSchemaUpdate = true;
         ITransactionalStorage storage;
         var success = StorageExporter.TryToCreateTransactionalStorage(ravenConfiguration, out storage);
         if (!success) ConsoleUtils.PrintErrorAndFail("Failed to create transactional storage");
         var configurator = new TransactionalStorageConfigurator(ravenConfiguration, (TransactionalStorage)storage);
         configurator.ConfigureInstance(instance, dataDirPath);
         storage.Dispose();
         Api.JetInit(ref instance);
         Api.JetBeginSession(instance, out sesid, null, null);           
         Api.JetAttachDatabase(sesid, dbFullPath, AttachDatabaseGrbit.None);
         Api.JetOpenDatabase(sesid, dbFullPath, null, out dbid, OpenDatabaseGrbit.None);
     }
     catch (Exception e)
     {
         ConsoleUtils.PrintErrorAndFail(e.Message, e.StackTrace);
     }
 }
        public bool Initialize(IUuidGenerator uuidGenerator, OrderedPartCollection <AbstractDocumentCodec> documentCodecs)
        {
            try
            {
                DocumentCodecs = documentCodecs;
                generator      = uuidGenerator;
                var instanceParameters = new TransactionalStorageConfigurator(configuration).ConfigureInstance(instance, path);

                if (configuration.RunInUnreliableYetFastModeThatIsNotSuitableForProduction)
                {
                    instanceParameters = new InstanceParameters(instance)
                    {
                        CircularLog          = true,
                        Recovery             = false,
                        NoInformationEvent   = false,
                        CreatePathIfNotExist = true,
                        TempDirectory        = Path.Combine(path, "temp"),
                        SystemDirectory      = Path.Combine(path, "system"),
                        LogFileDirectory     = Path.Combine(path, "logs"),
                        MaxVerPages          = 256,
                        BaseName             = "RVN",
                        EventSource          = "Raven",
                        LogBuffers           = 8192,
                        LogFileSize          = 256,
                        MaxSessions          = TransactionalStorageConfigurator.MaxSessions,
                        MaxCursors           = 1024,
                        DbExtensionSize      = 128,
                        AlternateDatabaseRecoveryDirectory = path
                    };
                }

                log.Info(@"Esent Settings:
  MaxVerPages      = {0}
  CacheSizeMax     = {1}
  DatabasePageSize = {2}", instanceParameters.MaxVerPages, SystemParameters.CacheSizeMax, SystemParameters.DatabasePageSize);

                Api.JetInit(ref instance);

                var newDb = EnsureDatabaseIsCreatedAndAttachToDatabase();

                SetIdFromDb();

                tableColumnsCache.InitColumDictionaries(instance, database);

                return(newDb);
            }
            catch (Exception e)
            {
                Dispose();
                throw new InvalidOperationException("Could not open transactional storage: " + database, e);
            }
        }
Exemple #4
0
        public void Initialize(IUuidGenerator uuidGenerator, OrderedPartCollection <AbstractDocumentCodec> documentCodecs, Action <string> putResourceMarker = null, Action <object, Exception> onErrorAction = null)
        {
            try
            {
                DocumentCodecs = documentCodecs;
                generator      = uuidGenerator;

                InstanceParameters instanceParameters = new TransactionalStorageConfigurator(configuration, this).ConfigureInstance(instance, path);

                if (configuration.RunInUnreliableYetFastModeThatIsNotSuitableForProduction)
                {
                    instanceParameters.Recovery = false;
                }

                log.Info(@"Esent Settings:
  MaxVerPages      = {0}
  CacheSizeMax     = {1}
  DatabasePageSize = {2}", instanceParameters.MaxVerPages, SystemParameters.CacheSizeMax,
                         SystemParameters.DatabasePageSize);

                Api.JetInit(ref instance);

                EnsureDatabaseIsCreatedAndAttachToDatabase();

                SetIdFromDb();

                tableColumnsCache.InitColumDictionaries(instance, database);

                if (putResourceMarker != null)
                {
                    putResourceMarker(path);
                }
            }
            catch (Exception e)
            {
                onErrorAction?.Invoke(this, e);
                Dispose();
                var fileAccessException = e as EsentFileAccessDeniedException;
                if (fileAccessException == null)
                {
                    throw new InvalidOperationException("Could not open transactional storage: " + database, e);
                }
                throw new InvalidOperationException("Could not write to location: " + path + ". Make sure you have read/write permissions for this path.", e);
            }
        }
		public bool Initialize(IUuidGenerator uuidGenerator)
		{
			try
			{
				generator = uuidGenerator;
				var instanceParameters = new TransactionalStorageConfigurator(configuration).ConfigureInstance(instance, path);

				if (configuration.RunInUnreliableYetFastModeThatIsNotSuitableForProduction)
				{
					instanceParameters = new InstanceParameters(instance)
					{
						CircularLog = true,
						Recovery = false,
						NoInformationEvent = false,
						CreatePathIfNotExist = true,
						TempDirectory = Path.Combine(path, "temp"),
						SystemDirectory = Path.Combine(path, "system"),
						LogFileDirectory = Path.Combine(path, "logs"),
						MaxVerPages = 256,
						BaseName = "RVN",
						EventSource = "Raven",
						LogBuffers = 8192,
						LogFileSize = 256,
						MaxSessions = TransactionalStorageConfigurator.MaxSessions,
						MaxCursors = 1024,
						DbExtensionSize = 128,
						AlternateDatabaseRecoveryDirectory = path
					};
				}

				log.Info(@"Esent Settings:
  MaxVerPages      = {0}
  CacheSizeMax     = {1}
  DatabasePageSize = {2}", instanceParameters.MaxVerPages, SystemParameters.CacheSizeMax, SystemParameters.DatabasePageSize);

				Api.JetInit(ref instance);

				var newDb = EnsureDatabaseIsCreatedAndAttachToDatabase();

				SetIdFromDb();

				tableColumnsCache.InitColumDictionaries(instance, database);

				return newDb;
			}
			catch (Exception e)
			{
				Dispose();
				throw new InvalidOperationException("Could not open transactional storage: " + database, e);
			}
		}
        public void Initialize(IUuidGenerator uuidGenerator, OrderedPartCollection<AbstractDocumentCodec> documentCodecs)
        {
            try
            {
                DocumentCodecs = documentCodecs;
                generator = uuidGenerator;

                InstanceParameters instanceParameters = new TransactionalStorageConfigurator(configuration, this).ConfigureInstance(instance, path);

                if (configuration.RunInUnreliableYetFastModeThatIsNotSuitableForProduction)
                    instanceParameters.Recovery = false;

                log.Info(@"Esent Settings:
  MaxVerPages      = {0}
  CacheSizeMax     = {1}
  DatabasePageSize = {2}", instanceParameters.MaxVerPages, SystemParameters.CacheSizeMax,
                         SystemParameters.DatabasePageSize);

                Api.JetInit(ref instance);

                EnsureDatabaseIsCreatedAndAttachToDatabase();

                SetIdFromDb();

                tableColumnsCache.InitColumDictionaries(instance, database);
            }
            catch (Exception e)
            {
                Dispose();
                var fileAccessException = e as EsentFileAccessDeniedException;
                if (fileAccessException == null)
                    throw new InvalidOperationException("Could not open transactional storage: " + database, e);
                throw new InvalidOperationException("Could not write to location: " + path + ". Make sure you have read/write permissions for this path.", e);
            }
        }