示例#1
0
 public static WorkerPrx read(global::Ice.InputStream istr)
 {
     global::Ice.ObjectPrx proxy = istr.readProxy();
     if (proxy != null)
     {
         WorkerPrxHelper result = new WorkerPrxHelper();
         result.iceCopyFrom(proxy);
         return(result);
     }
     return(null);
 }
示例#2
0
        public static WorkerPrx uncheckedCast(global::Ice.ObjectPrx b, string f)
        {
            if (b == null)
            {
                return(null);
            }
            global::Ice.ObjectPrx bb = b.ice_facet(f);
            WorkerPrxHelper       h  = new WorkerPrxHelper();

            h.iceCopyFrom(bb);
            return(h);
        }
示例#3
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);
        }
示例#4
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);
        }
示例#5
0
 public static WorkerPrx checkedCast(global::Ice.ObjectPrx b, string f, global::System.Collections.Generic.Dictionary <string, string> ctx)
 {
     if (b == null)
     {
         return(null);
     }
     global::Ice.ObjectPrx bb = b.ice_facet(f);
     try
     {
         if (bb.ice_isA(ice_staticId(), ctx))
         {
             WorkerPrxHelper h = new WorkerPrxHelper();
             h.iceCopyFrom(bb);
             return(h);
         }
     }
     catch (global::Ice.FacetNotExistException)
     {
     }
     return(null);
 }
示例#6
0
 public static WorkerPrx checkedCast(global::Ice.ObjectPrx b, string f)
 {
     if (b == null)
     {
         return(null);
     }
     global::Ice.ObjectPrx bb = b.ice_facet(f);
     try
     {
         if (bb.ice_isA(ice_staticId()))
         {
             WorkerPrxHelper h = new WorkerPrxHelper();
             h.iceCopyFrom(bb);
             return(h);
         }
     }
     catch (global::Ice.FacetNotExistException)
     {
     }
     return(null);
 }
示例#7
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;
            }
        }