Пример #1
0
        public static WorkerPrx checkedCast(global::Ice.ObjectPrx b, global::System.Collections.Generic.Dictionary <string, string> ctx)
        {
            if (b == null)
            {
                return(null);
            }
            WorkerPrx r = b as WorkerPrx;

            if ((r == null) && b.ice_isA(ice_staticId(), ctx))
            {
                WorkerPrxHelper h = new WorkerPrxHelper();
                h.iceCopyFrom(b);
                r = h;
            }
            return(r);
        }
Пример #2
0
        public static WorkerPrx uncheckedCast(global::Ice.ObjectPrx b)
        {
            if (b == null)
            {
                return(null);
            }
            WorkerPrx r = b as WorkerPrx;

            if (r == null)
            {
                WorkerPrxHelper h = new WorkerPrxHelper();
                h.iceCopyFrom(b);
                r = h;
            }
            return(r);
        }
Пример #3
0
 public static void write(global::Ice.OutputStream ostr, WorkerPrx v)
 {
     ostr.writeProxy(v);
 }
Пример #4
0
        public async void Start(string args, bool hold = false, bool ami = false, ACMHeartbeatFlag heartbeat = ACMHeartbeatFlag.HeartbeatOff)
        {
            Hold         = hold;
            amiEnabled   = ami;
            acmHeartbeat = heartbeat;
            if (communicator == null || communicator.isShutdown())
            {
                Status = BundleStatus.Starting;
                try
                {
                    const int SIZE_MB  = 128;
                    const int SIZE_MAX = SIZE_MB * 1024 * 1024;
                    if (contentSizeMB < 0 || contentSizeMB > SIZE_MB)
                    {
                        contentSizeMB = 1;
                    }
                    var initData = new InitializationData();
                    initData.properties = Util.createProperties();
                    initData.properties.setProperty("Ice.MessageSizeMax", $"{SIZE_MAX}");
                    initData.properties.setProperty("Filesystem.MaxFileSize", $"{SIZE_MAX}");
                    initData.properties.setProperty("Ice.ACM.Heartbeat", $"{(int)acmHeartbeat}");
                    communicator = Util.initialize(initData);
                    WorkerPrx workerPrx = WorkerPrxHelper.checkedCast(communicator.stringToProxy(args));
                    if (workerPrx == null)
                    {
                        throw new ApplicationException("Invalid Proxy");
                    }
                    isRunning = true;
                    Status    = BundleStatus.Running;
                    while (isRunning && communicator != null)
                    {
                        if (Hold)
                        {
                            Thread.Sleep(100);
                            continue;
                        }

                        var operation = operations[counter % operations.Count];
                        ++counter;
                        OnMethodInvoked?.Invoke(operation, amiEnabled);
                        if (amiEnabled)
                        {
                            try
                            {
                                var result = workerPrx?.PerformActionEx(operation, contentSizeMB);
                            }
                            catch (OperationException ex)
                            {
                                OnExceptionOccured?.Invoke(ex);
                            }
                            Thread.Sleep(rand.Next(200, 1000));
                        }
                        else
                        {
                            try
                            {
                                var result = workerPrx?.PerformAction(operation, contentSizeMB);
                            }
                            catch (OperationException ex)
                            {
                                OnExceptionOccured?.Invoke(ex);
                            }
                            Thread.Sleep(500);
                        }
                    }
                    Status = BundleStatus.Idle;
                }
                catch (System.Exception ex)
                {
                    Status = BundleStatus.Exception;
                    OnExceptionOccured?.Invoke(ex);
                }
            }
            else
            {
                isRunning = false;
                Status    = BundleStatus.Unknown;
            }
        }