Exemplo n.º 1
0
        public ReadStatus Get(ref Lsn lsn, ref DbEntry data, GetMode mode)
        {
            DbRetVal ret;

            lock (rscLock) {
                DB_LOGC *logcp = CheckDisposed();
                fixed(byte *dataBufP = data.Buffer)
                {
                    data.dbt.data = dataBufP + data.Start;
                    ret           = LogcGet(logcp, ref lsn.lsn, ref data.dbt, unchecked ((UInt32)mode));
                }
            }
            switch (ret)
            {
            case DbRetVal.NOTFOUND: break;

            case DbRetVal.BUFFER_SMALL: break;

            default:
                Util.CheckRetVal(ret);
                break;
            }
            data.SetReturnType(DbType.Unknown, 0);
            return((ReadStatus)ret);
        }
Exemplo n.º 2
0
 public ReadStatus Get(ref Lsn lsn, ref DbEntry data, GetMode mode) {
   DbRetVal ret;
   lock (rscLock) {
     DB_LOGC* logcp = CheckDisposed();
     fixed (byte* dataBufP = data.Buffer) {
       data.dbt.data = dataBufP + data.Start;
       ret = LogcGet(logcp, ref lsn.lsn, ref data.dbt, unchecked((UInt32)mode));
     }
   }
   switch (ret) {
     case DbRetVal.NOTFOUND: break;
     case DbRetVal.BUFFER_SMALL: break;
     default:
       Util.CheckRetVal(ret);
       break;
   }
   data.SetReturnType(DbType.Unknown, 0);
   return (ReadStatus)ret;
 }
Exemplo n.º 3
0
 public static unsafe int Compare(Lsn lsn0, Lsn lsn1)
 {
     return(LibDb.log_compare(&lsn0.lsn, &lsn1.lsn));
 }
Exemplo n.º 4
0
 public static unsafe int Compare(Lsn lsn0, Lsn lsn1) {
   return LibDb.log_compare(&lsn0.lsn, &lsn1.lsn);
 }
Exemplo n.º 5
0
 public void LogFlush(Lsn? lsn) {
   DbRetVal ret;
   lock (rscLock) {
     DB_ENV* evp = CheckDisposed();
     DB_LSN dbLsn = lsn.GetValueOrDefault().lsn;
     ret = evp->LogFlush(evp, lsn == null ? null : &dbLsn);
   }
   Util.CheckRetVal(ret);
 }
Exemplo n.º 6
0
 public string LogFile(Lsn lsn) {
   byte* filep = stackalloc byte[MaxLogFileNameLen];
   lock (rscLock) {
     DB_ENV* evp = CheckDisposed();
     DbRetVal ret = evp->LogFile(evp, ref lsn.lsn, filep, MaxLogFileNameLen);
     Util.CheckRetVal(ret);
     return Util.Utf8PtrToString(filep);
   }
 }
Exemplo n.º 7
0
    static DbRetVal AppRecoverWrapCLS(DB_ENV* evp, ref DBT logrec, DB_LSN* lsnp, DB_RECOPS op) {
      Env env = null;
      try {
        env = (Env)((GCHandle)evp->api_internal).Target;

        // construct DbEntry for log_rec
        int size = unchecked((int)logrec.size);
        // we are not using a shared buffer - the call-back might take
        // a long time and we do not want to lock the buffer that long
        byte[] buffer = new byte[size];
        Marshal.Copy((IntPtr)logrec.data, buffer, 0, size);
        DbEntry logEntry = DbEntry.InOut(buffer, 0, size);
        logEntry.dbt.flags = logrec.flags;
        logEntry.dbt.dlen = logrec.dlen;
        logEntry.dbt.doff = logrec.doff;
        // construct Lsn
        Lsn? lsn;
        if (lsnp == null) lsn = null; else lsn = new Lsn(*lsnp);
        // call CLS compliant delegate - we assume it is not null
        CallbackStatus cs =  env.appRecoverCLS(env, ref logEntry, lsn, (RecoveryOps)op);
        return cs == CallbackStatus.Success ? DbRetVal.SUCCESS : DbRetVal.APP_RECOVER_FAILED;
      }
      catch (Exception ex) {
        Trace.WriteLine(ex.Message, "TxnRecover");
        return DbRetVal.APP_RECOVER_FAILED;
      }
    }
Exemplo n.º 8
0
 static DbRetVal RepSendWrapCLS(
   DB_ENV* evp,
   ref DBT control,
   ref DBT rec,
   DB_LSN* lsnp,
   int envid,
   uint flags)
 {
   Env env = null;
   try {
     env = Util.GetEnv(evp);
     lock (env.callBackLock) {
       // construct DbEntry for control
       int size = unchecked((int)control.size);
       if (size > env.callBackBuffer1.Length)
         env.callBackBuffer1 = new byte[size];
       Marshal.Copy((IntPtr)control.data, env.callBackBuffer1, 0, size);
       DbEntry ctrlEntry = DbEntry.InOut(env.callBackBuffer1, 0, size);
       // construct DbEntry for rec
       size = unchecked((int)rec.size);
       if (size > env.callBackBuffer2.Length)
         env.callBackBuffer2 = new byte[size];
       Marshal.Copy((IntPtr)rec.data, env.callBackBuffer2, 0, size);
       DbEntry recEntry = DbEntry.InOut(env.callBackBuffer2, 0, size);
       // construct Lsn
       Lsn? lsn;
       if (lsnp == null) lsn = null; else lsn = new Lsn(*lsnp);
       // call CLS compliant delegate - we assume it is not null
       CallbackStatus cs = env.repSendCLS(
         env, ref ctrlEntry, ref recEntry, lsn, envid, unchecked((RepSendFlags)flags));
       return cs == CallbackStatus.Success ? DbRetVal.SUCCESS : DbRetVal.REPSEND_FAILED;
     }
   }
   catch (Exception ex) {
     Trace.WriteLine(ex.Message, "RepSend");
     if (env != null)
       env.Error((int)DbRetVal.REPSEND_FAILED, ex.Message);
     else
       evp->Err(evp, (int)DbRetVal.REPSEND_FAILED, null);
     return DbRetVal.REPSEND_FAILED;
   }
 }
Exemplo n.º 9
0
    public RepStatus RepProcessMessage(ref DbEntry control, ref DbEntry rec, ref int envId, ref Lsn retLsn) {
      DbRetVal ret;
      DB_LSN lsn;
      lock (rscLock) {
        DB_ENV* evp = CheckDisposed();
        ret = evp->RepProcessMessage(evp, ref control.dbt, ref rec.dbt, ref envId, out lsn);
      }
      switch (ret) {
        case DbRetVal.SUCCESS:
          break;
        case DbRetVal.REP_DUPMASTER:
          break;
        case DbRetVal.REP_HOLDELECTION:
          break;
#if BDB_4_5_20
        case DbRetVal.REP_IGNORE:
          break;
#endif
        case DbRetVal.REP_ISPERM:
          retLsn.lsn = lsn;
          break;
#if BDB_4_5_20
        case DbRetVal.REP_JOIN_FAILURE:
          break;
#endif
        case DbRetVal.REP_NEWMASTER:
          break;
        case DbRetVal.REP_NEWSITE:
          break;
        case DbRetVal.REP_NOTPERM:
          retLsn.lsn = lsn;
          break;
#if BDB_4_3_29
        case DbRetVal.REP_STARTUPDONE:
          break;
#endif
        default: 
          Util.CheckRetVal(ret);
          break;
      }
      return (RepStatus)ret;
    }