Beispiel #1
0
    public static Manager CreateManager(string envdir)
    {
        EnvironmentConfig envconf = new EnvironmentConfig();
        envconf.CacheSize = 50 * 1024 * 1024;
        envconf.Create = true;
        envconf.InitializeCache = true;
        envconf.Transactional = true;
        envconf.InitializeLocking = true;
        envconf.InitializeLogging = true;
        envconf.Recover = true;

        ManagerConfig mgrconfig = new ManagerConfig();
        mgrconfig.AdoptEnvironment = true;

        Environment env = new Environment(envdir, envconf);
        try
        {
            return new Manager(env, mgrconfig);
        }
        catch(System.Exception e)
        {
            env.Dispose();
            throw e;
        }
    }
Beispiel #2
0
    public static void Main(string[] args)
    {
        // The path the directory where you want to place the environment
        // must exist!!
        string environmentPath = "/path/to/environment/directory";

        // Environment configuration is minimal:
        // create + 50MB cache
        // no transactions, logging, or locking
        EnvironmentConfig config = new EnvironmentConfig();
        config.CacheSize = 50 * 1024 * 1024;
        config.Create = true;
        config.InitializeCache = true;
        Environment env = new Environment(environmentPath, config);

        // Create Manager using that environment, no DBXML flags
        Manager mgr = new Manager(env, new ManagerConfig());

        // Multiple containers can be opened in the same database environment
        using(Container container1 = mgr.CreateContainer(null, "myContainer1"))
        {
            using(Container container2 = mgr.CreateContainer(null, "myContainer2"))
            {
                using(Container container3 = mgr.CreateContainer(null, "myContainer3"))
                {
                    // do work here //
                }
            }
        }
    }
Beispiel #3
0
 public Environment(string home, EnvironmentConfig config)
 {
     this.env_ = null;
     this.envClosed_ = true;
     this.env_ = config.openDbEnv(home);
     this.envClosed_ = false;
     this.config_ = config;
 }
Beispiel #4
0
 public Environment(string home, EnvironmentConfig config)
 {
     this.env_       = null;
     this.envClosed_ = true;
     this.env_       = config.openDbEnv(home);
     this.envClosed_ = false;
     this.config_    = config;
 }
Beispiel #5
0
        public static void Remove(string home, bool force, EnvironmentConfig config)
        {
            DbEnv env   = config.createDbEnv();
            uint  flags = 0;

            if (force)
            {
                flags |= (uint)DbXml.DB_FORCE;
            }
            if (config.UseEnvironment)
            {
                flags |= (uint)DbXml.DB_USE_ENVIRON;
            }
            if (config.UseEnvironmentRoot)
            {
                flags |= (uint)DbXml.DB_USE_ENVIRON_ROOT;
            }
            env.remove(home, flags);
        }
Beispiel #6
0
 internal Environment(DbEnv e)
 {
     this.env_ = e;
     this.envClosed_ = true;
     this.config_ = null;
 }
Beispiel #7
0
 public Environment(EnvironmentConfig config)
     : this(null, config)
 {
 }
Beispiel #8
0
 public static void Remove(string home, bool force, EnvironmentConfig config)
 {
     DbEnv env = config.createDbEnv();
     uint flags = 0;
     if (force)
     {
         flags |= (uint) DbXml.DB_FORCE;
     }
     if (config.UseEnvironment)
     {
         flags |= (uint) DbXml.DB_USE_ENVIRON;
     }
     if (config.UseEnvironmentRoot)
     {
         flags |= (uint) DbXml.DB_USE_ENVIRON_ROOT;
     }
     env.remove(home, flags);
 }
Beispiel #9
0
 internal Environment(DbEnv e)
 {
     this.env_       = e;
     this.envClosed_ = true;
     this.config_    = null;
 }
Beispiel #10
0
 public Environment(EnvironmentConfig config) : this(null, config)
 {
 }