/// <exception cref="System.IO.IOException"/>
        public virtual void SelectInputStreams(ICollection <EditLogInputStream> streams, long
                                               fromTxnId, bool inProgressOk)
        {
            QuorumCall <AsyncLogger, RemoteEditLogManifest> q = loggers.GetEditLogManifest(fromTxnId
                                                                                           , inProgressOk);
            IDictionary <AsyncLogger, RemoteEditLogManifest> resps = loggers.WaitForWriteQuorum
                                                                         (q, selectInputStreamsTimeoutMs, "selectInputStreams");

            Log.Debug("selectInputStream manifests:\n" + Joiner.On("\n").WithKeyValueSeparator
                          (": ").Join(resps));
            PriorityQueue <EditLogInputStream> allStreams = new PriorityQueue <EditLogInputStream
                                                                               >(64, JournalSet.EditLogInputStreamComparator);

            foreach (KeyValuePair <AsyncLogger, RemoteEditLogManifest> e in resps)
            {
                AsyncLogger           logger   = e.Key;
                RemoteEditLogManifest manifest = e.Value;
                foreach (RemoteEditLog remoteLog in manifest.GetLogs())
                {
                    Uri url = logger.BuildURLToFetchLogs(remoteLog.GetStartTxId());
                    EditLogInputStream elis = EditLogFileInputStream.FromUrl(connectionFactory, url,
                                                                             remoteLog.GetStartTxId(), remoteLog.GetEndTxId(), remoteLog.IsInProgress());
                    allStreams.AddItem(elis);
                }
            }
            JournalSet.ChainAndMakeRedundantStreams(streams, allStreams, fromTxnId);
        }
        private void PopulateTreeGridView(TreeGridView tgv, JournalSet jset)
        {
            TreeGridNode tgnode = tgv.Nodes.Add(string.Format("{0} {1}", jset.JournalTypeID, jset.TransactionDate.Value.ToShortDateString()), jset);

            foreach (JournalRecord jrecord in jset.JournalRecords)
            {
                tgnode.Nodes.Add(jset.TransactionNumber, jrecord.Account, jrecord.DebitDescription, jrecord.CreditDescription, jrecord.Job);
            }
            ExpandTreeGridView(tgnode);
        }
        public JournalSource GetJournalSource(JournalSet jset)
        {
            string type = jset.JournalTypeID;

            if (type == "GJ")
            {
                return(RepositoryMgr.GeneralJournalMgr.FindById(jset.SourceID));
            }
            else if (type == "PO")
            {
                return(RepositoryMgr.PurchaseMgr.FindById(jset.SourceID));
            }
            else if (type == "SI")
            {
                return(RepositoryMgr.SaleMgr.FindById(jset.SourceID));
            }
            return(null);
        }
Beispiel #4
0
        /// <exception cref="System.Exception"/>
        public virtual void TestSBNCheckpoints()
        {
            JournalSet standbyJournalSet = NameNodeAdapter.SpyOnJournalSet(nn1);

            DoEdits(0, 10);
            HATestUtil.WaitForStandbyToCatchUp(nn0, nn1);
            // Once the standby catches up, it should notice that it needs to
            // do a checkpoint and save one to its local directories.
            HATestUtil.WaitForCheckpoint(cluster, 1, ImmutableList.Of(12));
            GenericTestUtils.WaitFor(new _Supplier_147(this), 1000, 60000);
            // It should have saved the oiv image too.
            NUnit.Framework.Assert.AreEqual("One file is expected", 1, tmpOivImgDir.List().Length
                                            );
            // It should also upload it back to the active.
            HATestUtil.WaitForCheckpoint(cluster, 0, ImmutableList.Of(12));
            // The standby should never try to purge edit logs on shared storage.
            Org.Mockito.Mockito.Verify(standbyJournalSet, Org.Mockito.Mockito.Never()).PurgeLogsOlderThan
                (Org.Mockito.Mockito.AnyLong());
        }
        protected override OpResult _Store(JournalSet _obj)
        {
            if (_obj == null)
            {
                return(OpResult.NotifyStoreAction(OpResult.ResultStatus.ObjectIsNull, _obj, "JournalSet object cannot be created as it is null"));
            }

            if (Exists(_obj))
            {
                ExecuteNonQuery(GetQuery_UpdateQuery(_obj));
                return(OpResult.NotifyStoreAction(OpResult.ResultStatus.Updated, _obj));
            }

            ExecuteNonQuery(GetQuery_InsertQuery(_obj));
            if (_obj.SetID == null)
            {
                _obj.SetID = DbMgr.GetLastInsertID();
            }
            _obj.FromDb = true;
            return(OpResult.NotifyStoreAction(OpResult.ResultStatus.Created, _obj));
        }
 private DbUpdateStatement GetQuery_UpdateQuery(JournalSet _obj)
 {
     return(DbMgr.CreateUpdateClause("JournalSets", GetFields(_obj), "SetID", _obj.SetID));
 }
        private DbInsertStatement GetQuery_InsertQuery(JournalSet _obj)
        {
            Dictionary <string, DbFieldEntry> fields = GetFields(_obj);

            return(DbMgr.CreateInsertClause("JournalSets", fields));
        }