Inheritance: FdbSafeHandle
Esempio n. 1
0
        public static FutureHandle ClusterCreateDatabase(ClusterHandle cluster, string name)
        {
            var future = NativeMethods.fdb_cluster_create_database(cluster, name, name == null ? 0 : name.Length);

            Contract.Assert(future != null);
#if DEBUG_NATIVE_CALLS
            Debug.WriteLine("fdb_cluster_create_database(0x" + cluster.Handle.ToString("x") + ", name: '" + name + "') => 0x" + cluster.Handle.ToString("x"));
#endif
            return(future);
        }
Esempio n. 2
0
        public static FdbError FutureGetCluster(FutureHandle future, out ClusterHandle cluster)
        {
            var err = NativeMethods.fdb_future_get_cluster(future, out cluster);

#if DEBUG_NATIVE_CALLS
            Debug.WriteLine("fdb_future_get_cluster(0x" + future.Handle.ToString("x") + ") => err=" + err + ", handle=0x" + cluster.Handle.ToString("x"));
#endif
            //TODO: check if err == Success ?
            return(err);
        }
Esempio n. 3
0
        public FdbNativeDatabase([NotNull] DatabaseHandle handle, [CanBeNull] string clusterFile, ClusterHandle cluster = null)
        {
            Contract.NotNull(handle, nameof(handle));

            m_handle        = handle;
            m_clusterFile   = clusterFile;
            m_clusterHandle = cluster;
#if CAPTURE_STACKTRACES
            m_stackTrace = new StackTrace();
#endif
        }
Esempio n. 4
0
        private static async ValueTask <IFdbDatabaseHandler> CreateDatabaseLegacyAsync(string clusterFile, CancellationToken ct)
        {
            // In legacy API versions, you first had to create "cluster" handle and then obtain a database handle that that cluster.
            // The API is async, but the future always completed inline...

            ClusterHandle  cluster  = null;
            DatabaseHandle database = null;

            try
            {
                cluster = await FdbFuture.CreateTaskFromHandle(
                    FdbNative.CreateCluster(clusterFile),
                    h =>
                {
                    var err = FdbNative.FutureGetCluster(h, out var handle);
                    if (err != FdbError.Success)
                    {
                        throw Fdb.MapToException(err);
                    }

                    return(handle);
                },
                    ct).ConfigureAwait(false);

                database = await FdbFuture.CreateTaskFromHandle(
                    FdbNative.ClusterCreateDatabase(cluster, "DB"),
                    h =>
                {
                    var err = FdbNative.FutureGetDatabase(h, out var handle);
                    if (err != FdbError.Success)
                    {
                        throw Fdb.MapToException(err);
                    }

                    return(handle);
                },
                    ct).ConfigureAwait(false);

                return(new FdbNativeDatabase(database, clusterFile, cluster));
            }
            catch (Exception)
            {
                database?.Dispose();
                cluster?.Dispose();
                throw;
            }
        }
Esempio n. 5
0
 public static FdbError ClusterSetOption(ClusterHandle cluster, FdbClusterOption option, byte *value, int valueLength)
 {
     return(NativeMethods.fdb_cluster_set_option(cluster, option, value, valueLength));
 }
Esempio n. 6
0
 public static extern FdbError fdb_future_get_cluster(FutureHandle future, out ClusterHandle cluster);
Esempio n. 7
0
 public static extern FutureHandle fdb_cluster_create_database(ClusterHandle cluster, [MarshalAs(UnmanagedType.LPStr)] string dbName, int dbNameLength);
Esempio n. 8
0
 public static extern FdbError fdb_cluster_set_option(ClusterHandle cluster, FdbClusterOption option, byte *value, int valueLength);
		public FdbNativeCluster(ClusterHandle handle)
		{
			Contract.Requires(handle != null);
			m_handle = handle;
		}
Esempio n. 10
0
 public FdbNativeCluster(ClusterHandle handle)
 {
     Contract.Requires(handle != null);
     m_handle = handle;
 }
		public static FutureHandle ClusterCreateDatabase(ClusterHandle cluster, string name)
		{
			var future = NativeMethods.fdb_cluster_create_database(cluster, name, name == null ? 0 : name.Length);
			Contract.Assert(future != null);
#if DEBUG_NATIVE_CALLS
			Debug.WriteLine("fdb_cluster_create_database(0x" + cluster.Handle.ToString("x") + ", name: '" + name + "') => 0x" + cluster.Handle.ToString("x"));
#endif
			return future;
		}
		public static FdbError FutureGetCluster(FutureHandle future, out ClusterHandle cluster)
		{
			var err = NativeMethods.fdb_future_get_cluster(future, out cluster);
#if DEBUG_NATIVE_CALLS
			Debug.WriteLine("fdb_future_get_cluster(0x" + future.Handle.ToString("x") + ") => err=" + err + ", handle=0x" + cluster.Handle.ToString("x"));
#endif
			//TODO: check if err == Success ?
			return err;
		}
		public static FdbError ClusterSetOption(ClusterHandle cluster, FdbClusterOption option, byte* value, int valueLength)
		{
			return NativeMethods.fdb_cluster_set_option(cluster, option, value, valueLength);
		}
			public static extern FdbError fdb_future_get_cluster(FutureHandle future, out ClusterHandle cluster);
			public static extern FutureHandle fdb_cluster_create_database(ClusterHandle cluster, [MarshalAs(UnmanagedType.LPStr)] string dbName, int dbNameLength);
			public static extern FdbError fdb_cluster_set_option(ClusterHandle cluster, FdbClusterOption option, byte* value, int valueLength);