Ejemplo n.º 1
0
        public void ExecuteBlock()
        {
            if (statusInfo.Status != ReorgBlockStatus.Pending)
            {
                return;
            }
            statusInfo.Status = ReorgBlockStatus.Executing;
            string           reorgAssembly = "Reorganization";
            GXReorganization o             = (GXReorganization)(ClassLoader.FindInstance(reorgAssembly, appNamespace, "reorg", null, assembly));

            try
            {
                o.initialize();
                ClassLoader.Execute(o, blockName, blockParms);
                statusInfo.Status = ReorgBlockStatus.Ended;
                if (blockEnd != null)
                {
                    blockEnd(blockName, 0);
                }
                o.context.CloseConnections();
            }
            catch (Exception e)
            {
                statusInfo.Status = ReorgBlockStatus.Error;
                if (blockEnd != null)
                {
                    blockEnd(blockName, 1);
                }
                Exception innerE = e.InnerException;
                if (innerE != null)
                {
                    statusInfo.OtherStatusInfo = innerE.Message;
                    Console.WriteLine("ERROR in " + blockName + " : " + innerE.Message + StringUtil.NewLine() + innerE.StackTrace);
                }
                else
                {
                    statusInfo.OtherStatusInfo = e.Message;
                    Console.WriteLine("ERROR in " + blockName + " : " + e.Message + StringUtil.NewLine() + e.StackTrace);
                }
            }
        }
Ejemplo n.º 2
0
        public static void SubmitAll()
        {
            // Before reorg
            ReorgBlockStatusInfo rStat;

            rStat = executeBlock(new ReorgBlock(0, "ExecBeforeReorg", Array.Empty <object>(), null, Assembly.GetCallingAssembly()));
            if (rStat.Status == ReorgBlockStatus.Error)
            {
                GXReorganization.SetStatus(0, rStat);
                return;
            }

            // Reorg
            bool   retryExecute = true;
            int    reorgMaxThreads;
            string sValue;

            if (onlyOneThread)
            {
                reorgMaxThreads = 1;
            }
            else
            {
                if (Config.GetValueOf("REORG_MAX_THREADS", out sValue))
                {
                    reorgMaxThreads = int.Parse(sValue);
                }
                else
                {
                    reorgMaxThreads = 5;
                }
            }

            while (threadsRunning > 0 || retryExecute)
            {
                Thread.Sleep(500);

                retryExecute = false;
                foreach (ReorgBlock rt in submitList)
                {
                    if (threadsRunning >= reorgMaxThreads)
                    {
                        break;
                    }
                    if (lastErrorCode == 0)
                    {
                        if (rt.StatusInfo.Status == ReorgBlockStatus.Pending)
                        {
                            retryExecute = true;
                            submitBlock(rt);
                        }
                    }
                    GXReorganization.SetStatus(rt.Id, rt.StatusInfo);
                }
            }
            if (lastErrorCode != 0 || GXReorganization.checkError)
            {
                throw new Exception("Reorganization error");
            }
            else
            {
                // After reorg
                rStat = executeBlock(new ReorgBlock(0, "ExecAfterReorg", Array.Empty <object>(), null, Assembly.GetCallingAssembly()));
                if (rStat.Status == ReorgBlockStatus.Error)
                {
                    GXReorganization.SetStatus(0, rStat);
                    return;
                }
            }
        }