Esempio n. 1
0
        internal int memp_sync(DB_LSN lsn)
        {
            int ret;

            ret = libdb_csharpPINVOKE.DB_ENV_memp_sync(swigCPtr, DB_LSN.getCPtr(lsn));
            DatabaseException.ThrowException(ret);
            return(ret);
        }
Esempio n. 2
0
        internal int log_flush(DB_LSN lsn)
        {
            int ret;

            ret = libdb_csharpPINVOKE.DB_ENV_log_flush(swigCPtr, DB_LSN.getCPtr(lsn));
            DatabaseException.ThrowException(ret);
            return(ret);
        }
Esempio n. 3
0
        internal static DB_LSN getDB_LSN(LSN inp) {
            if (inp == null)
                return null;

            DB_LSN ret = new DB_LSN();
            ret.file = inp.LogFileNumber;
            ret.offset = inp.Offset;
            return ret;
        }
Esempio n. 4
0
 internal int log_put(DB_LSN lsn, DatabaseEntry data, uint flags)
 {
     try {
         int ret;
         ret = libdb_csharpPINVOKE.DB_ENV_log_put(swigCPtr, DB_LSN.getCPtr(lsn), DBT.getCPtr(DatabaseEntry.getDBT(data)), flags);
         DatabaseException.ThrowException(ret);
         return(ret);
     } finally {
         GC.KeepAlive(data);
     }
 }
Esempio n. 5
0
 private static int doRepTransport(IntPtr envp,
     IntPtr controlp, IntPtr recp, IntPtr lsnp, int envid, uint flags) {
     DB_ENV dbenv = new DB_ENV(envp, false);
     DBT control = new DBT(controlp, false);
     DBT rec = new DBT(recp, false);
     DB_LSN tmplsn = new DB_LSN(lsnp, false);
     LSN dblsn = new LSN(tmplsn.file, tmplsn.offset);
     return dbenv.api2_internal.transportHandler(
         DatabaseEntry.fromDBT(control),
         DatabaseEntry.fromDBT(rec), dblsn, envid, flags);
 }
Esempio n. 6
0
        /// <summary>
        /// Compare two LSNs.
        /// </summary>
        /// <param name="lsn1">The first LSN to compare</param>
        /// <param name="lsn2">The second LSN to compare</param>
        /// <returns>
        /// 0 if they are equal, 1 if lsn1 is greater than lsn2, and -1 if lsn1
        /// is less than lsn2.
        /// </returns>
        public static int Compare(LSN lsn1, LSN lsn2) {
            DB_LSN a = new DB_LSN();
            a.offset = lsn1.Offset;
            a.file = lsn1.LogFileNumber;

            DB_LSN b = new DB_LSN();
            b.offset = lsn2.Offset;
            b.file = lsn2.LogFileNumber;

            return libdb_csharp.log_compare(a, b);
        }
Esempio n. 7
0
	internal string log_file(DB_LSN dblsn) {
		int err = 0;
		int len = 100;
		IntPtr namep;
		while (true) {
			namep = Marshal.AllocHGlobal(len);
			err = log_file(dblsn, namep, (uint)len);
			if (err != DbConstants.DB_BUFFER_SMALL)
				break;
			Marshal.FreeHGlobal(namep);
			len *= 2;
		}
		DatabaseException.ThrowException(err);
		string ret = Marshal.PtrToStringAnsi(namep);
		Marshal.FreeHGlobal(namep);
		return ret;
	}
Esempio n. 8
0
        internal string log_file(DB_LSN dblsn)
        {
            int    err = 0;
            int    len = 100;
            IntPtr namep;

            while (true)
            {
                namep = Marshal.AllocHGlobal(len);
                err   = log_file(dblsn, namep, (uint)len);
                if (err != DbConstants.DB_BUFFER_SMALL)
                {
                    break;
                }
                Marshal.FreeHGlobal(namep);
                len *= 2;
            }
            DatabaseException.ThrowException(err);
            string ret = Marshal.PtrToStringAnsi(namep);

            Marshal.FreeHGlobal(namep);
            return(ret);
        }
Esempio n. 9
0
 internal int memp_sync(DB_LSN lsn)
 {
     int ret;
     ret = libdb_csharpPINVOKE.DB_ENV_memp_sync(swigCPtr, DB_LSN.getCPtr(lsn));
     DatabaseException.ThrowException(ret);
     return ret;
 }
Esempio n. 10
0
 internal int log_put(DB_LSN lsn, DatabaseEntry data, uint flags)
 {
     try {
     int ret;
     ret = libdb_csharpPINVOKE.DB_ENV_log_put(swigCPtr, DB_LSN.getCPtr(lsn), DBT.getCPtr(DatabaseEntry.getDBT(data)), flags);
     DatabaseException.ThrowException(ret);
     return ret;
     } finally {
       GC.KeepAlive(data);
     }
 }
Esempio n. 11
0
 internal int log_flush(DB_LSN lsn)
 {
     int ret;
     ret = libdb_csharpPINVOKE.DB_ENV_log_flush(swigCPtr, DB_LSN.getCPtr(lsn));
     DatabaseException.ThrowException(ret);
     return ret;
 }
Esempio n. 12
0
 private int log_file(DB_LSN lsn, IntPtr namep, uint len)
 {
     return libdb_csharpPINVOKE.DB_ENV_log_file(swigCPtr, DB_LSN.getCPtr(lsn), namep, len);
 }
Esempio n. 13
0
 internal int rep_process_message(DatabaseEntry control, DatabaseEntry rec, int envid, DB_LSN ret_lsnp)
 {
     try {
     int ret;
     ret = libdb_csharpPINVOKE.DB_ENV_rep_process_message(swigCPtr, DBT.getCPtr(DatabaseEntry.getDBT(control)), DBT.getCPtr(DatabaseEntry.getDBT(rec)), envid, DB_LSN.getCPtr(ret_lsnp));
     DatabaseException.ThrowException(ret);
     return ret;
     } finally {
       GC.KeepAlive(control);
       GC.KeepAlive(rec);
     }
 }
Esempio n. 14
0
 /// <summary>
 /// Process an incoming replication message sent by a member of the
 /// replication group to the local database environment. 
 /// </summary>
 /// <remarks>
 /// <para>
 /// RepProcessMessage is not called by most replication applications. It
 /// should only be called by applications implementing their own network
 /// transport layer, explicitly holding replication group elections and
 /// handling replication messages outside of the replication manager
 /// framework.
 /// </para>
 /// <para>
 /// For implementation reasons, all incoming replication messages must
 /// be processed using the same <see cref="DatabaseEnvironment"/>
 /// object. It is not required that a single thread of control process
 /// all messages, only that all threads of control processing messages
 /// use the same object.
 /// </para>
 /// <para>
 /// Before calling this method, the <see cref="RepTransport"/> delegate 
 /// must already have been configured to send replication messages.
 /// </para>
 /// </remarks>
 /// <param name="control">
 /// A copy of the control parameter specified by Berkeley DB on the
 /// sending environment.
 /// </param>
 /// <param name="rec">
 /// A copy of the rec parameter specified by Berkeley DB on the sending
 /// environment.
 /// </param>
 /// <param name="envid">
 /// The local identifier that corresponds to the environment that sent
 /// the message to be processed (see Replication environment IDs in the
 /// Programmer's Reference Guide for more information)..
 /// </param>
 /// <returns>The result of processing a message</returns>
 public RepProcMsgResult RepProcessMessage(
     DatabaseEntry control, DatabaseEntry rec, int envid)
 {
     DB_LSN dblsn = new DB_LSN();
     int ret = dbenv.rep_process_message(control,
         rec, envid, dblsn);
     LSN lsnp = new LSN(dblsn.file, dblsn.offset);
     RepProcMsgResult result = new RepProcMsgResult(ret, lsnp);
     if (result.Result == RepProcMsgResult.ProcMsgResult.ERROR)
         DatabaseException.ThrowException(ret);
     return result;
 }
Esempio n. 15
0
 internal static HandleRef getCPtr(DB_LSN obj)
 {
     return((obj == null) ? new HandleRef(null, IntPtr.Zero) : obj.swigCPtr);
 }
Esempio n. 16
0
 private int log_file(DB_LSN lsn, IntPtr namep, uint len)
 {
     return(libdb_csharpPINVOKE.DB_ENV_log_file(swigCPtr, DB_LSN.getCPtr(lsn), namep, len));
 }
Esempio n. 17
0
 internal LSN(DB_LSN dblsn) {
     LogFileNumber = dblsn.file;
     Offset = dblsn.offset;
 }
Esempio n. 18
0
 internal static global::System.Runtime.InteropServices.HandleRef getCPtr(DB_LSN obj)
 {
     return((obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr);
 }
Esempio n. 19
0
 internal static int log_compare(DB_LSN lsn0, DB_LSN lsn1)
 {
     return libdb_csharpPINVOKE.log_compare(DB_LSN.getCPtr(lsn0), DB_LSN.getCPtr(lsn1));
 }
Esempio n. 20
0
 internal static HandleRef getCPtr(DB_LSN obj) {
   return (obj == null) ? new HandleRef(null, IntPtr.Zero) : obj.swigCPtr;
 }
Esempio n. 21
0
        /// <summary>
        /// Append a record to the log
        /// </summary>
        /// <param name="dbt">The record to write to the log.</param>
        /// <param name="flush">
        /// If true, the log is forced to disk after this record is written,
        /// guaranteeing that all records with LSN values less than or equal to
        /// the one being "put" are on disk before LogWrite returns.
        /// </param>
        /// <returns>The LSN of the written record</returns>
        public LSN LogWrite(DatabaseEntry dbt, bool flush)
        {
            DB_LSN lsn = new DB_LSN();

            dbenv.log_put(lsn,
                dbt, flush ? DbConstants.DB_FLUSH : 0);
            return new LSN(lsn.file, lsn.offset);
        }
Esempio n. 22
0
 internal static int log_compare(DB_LSN lsn0, DB_LSN lsn1)
 {
     return(libdb_csharpPINVOKE.log_compare(DB_LSN.getCPtr(lsn0), DB_LSN.getCPtr(lsn1)));
 }
Esempio n. 23
0
 internal int rep_process_message(DatabaseEntry control, DatabaseEntry rec, int envid, DB_LSN ret_lsnp)
 {
     try {
         int ret;
         ret = libdb_csharpPINVOKE.DB_ENV_rep_process_message(swigCPtr, DBT.getCPtr(DatabaseEntry.getDBT(control)), DBT.getCPtr(DatabaseEntry.getDBT(rec)), envid, DB_LSN.getCPtr(ret_lsnp));
         DatabaseException.ThrowException(ret);
         return(ret);
     } finally {
         GC.KeepAlive(control);
         GC.KeepAlive(rec);
     }
 }