Beispiel #1
0
    public void relayUnknownPreservedAsKnownPreserved(IRelayPrx r, Ice.Current current)
    {
        IRelayPrx p = current.Connection.CreateProxy(r.Identity, IRelayPrx.Factory);

        p.unknownPreservedAsKnownPreserved();
        test(false);
    }
Beispiel #2
0
    public void finished(Ice.Current current, Ice.Object servant, System.Object cookie)
    {
        lock (this)
        {
            test(!_deactivated);
        }

        //
        // Ensure finished() is only called once per request.
        //
        test(_requestId == current.requestId);
        _requestId = -1;

        test(current.id.category.Equals(_category) || _category.Length == 0);
        test(current.id.name.Equals("locate") || current.id.name.Equals("finished"));

        if (current.id.name.Equals("finished"))
        {
            exception(current);
        }

        Cookie co = (Cookie)cookie;

        test(co.message().Equals("blahblah"));
    }
Beispiel #3
0
        public override string GetStockCodesInfo(Ice.Current current__)
        {
            //DataService ds = GetDataService();
            //if (ds is DataService)
            //{
            //    DSIceStockCode[] codes = null;
            //    List<StockCode> mcd;
            //    int count = ds.GetStockCodes(out mcd);
            //    App.Logger.Info(string.Format("ICE订阅服务:获取股票定义{0}", count));
            //    if (count > 0 && mcd != null)
            //    {
            //        codes = new DSIceStockCode[count];
            //        for (int i = 0; i < count; i++)
            //        {
            //            codes[i] = mcd[i].GetDSIceStockCode();
            //        }
            //    }
            //    else
            //    {
            //        codes = null;
            //    }
            //    //string codesInfo = ds.GetStockCodesInfo();
            //    App.Logger.Info("ICE订阅服务:获取股票定义");
            //    return codes == null ? null : Helper.JsonHelper.ToJSON(codes);


            //    //return codesInfo;
            //}

            //App.Logger.Error("DataService对象不存在!");

            return(null);
        }
Beispiel #4
0
        getLog(Ice.LogMessageType[] messageTypes, string[] categories, int messageMax, out string prefix,
               Ice.Current current)
        {
            LinkedList <Ice.LogMessage> logMessages = null;

            lock (this)
            {
                if (messageMax != 0)
                {
                    logMessages = new LinkedList <Ice.LogMessage>(_queue);
                }
                else
                {
                    logMessages = new LinkedList <Ice.LogMessage>();
                }
            }

            prefix = _logger.getPrefix();

            if (logMessages.Count > 0)
            {
                Filters filters = new Filters(messageTypes, categories);
                filterLogMessages(logMessages, filters.messageTypes, filters.traceCategories, messageMax);
            }
            return(logMessages.ToArray());
        }
Beispiel #5
0
        detachRemoteLogger(Ice.RemoteLoggerPrx remoteLogger, Ice.Current current)
        {
            if (remoteLogger == null)
            {
                return(false);
            }

            //
            // No need to convert the proxy as we only use its identity
            //
            bool found = removeRemoteLogger(remoteLogger);

            if (_traceLevel > 0)
            {
                if (found)
                {
                    _logger.trace(_traceCategory, "detached `" + remoteLogger.ToString() + "'");
                }
                else
                {
                    _logger.trace(_traceCategory, "cannot detach `" + remoteLogger.ToString() + "': not found");
                }
            }

            return(found);
        }
Beispiel #6
0
        public void findAdapterById(string domainId, string adapterId, LookupReplyPrx reply,
                                    Ice.Current current)
        {
            if (!domainId.Equals(_domainId))
            {
                return; // Ignore
            }

            bool isReplicaGroup;

            Ice.IObjectPrx proxy = _registry.findAdapter(adapterId, out isReplicaGroup);
            if (proxy != null)
            {
                //
                // Reply to the multicast request using the given proxy.
                //
                try
                {
                    reply.foundAdapterByIdAsync(adapterId, proxy, isReplicaGroup);
                }
                catch (Ice.LocalException)
                {
                    // Ignore.
                }
            }
        }
Beispiel #7
0
 setReplicatedAdapterDirectProxyAsync(string adapterId, string replicaGroupId, Ice.IObjectPrx proxy,
                                      Ice.Current current)
 {
     lock (this)
     {
         if (proxy != null)
         {
             _adapters.Add(adapterId, proxy);
             HashSet <string> adapterIds;
             if (!_replicaGroups.TryGetValue(replicaGroupId, out adapterIds))
             {
                 adapterIds = new HashSet <string>();
                 _replicaGroups.Add(replicaGroupId, adapterIds);
             }
             adapterIds.Add(adapterId);
         }
         else
         {
             _adapters.Remove(adapterId);
             HashSet <string> adapterIds;
             if (_replicaGroups.TryGetValue(replicaGroupId, out adapterIds))
             {
                 adapterIds.Remove(adapterId);
                 if (adapterIds.Count == 0)
                 {
                     _replicaGroups.Remove(replicaGroupId);
                 }
             }
         }
     }
     return(null);
 }
Beispiel #8
0
    ice_invokeAsync(byte[] inEncaps, Ice.Current current)
    {
        Debug.Assert(current.Connection != null);
        var prx = current.Connection.createProxy(current.Id).Clone(facet: current.Facet, oneway: current.RequestId == 0);

        return(prx.InvokeAsync(current.Operation, current.Mode, inEncaps, current.Context));
    }
Beispiel #9
0
 IceInvokeAsync(byte[] inEncaps, Ice.Current current)
 {
     Debug.Assert(current.Connection != null);
     var prx = current.Connection.CreateProxy(current.Id, IObjectPrx.Factory)
         .Clone(facet: current.Facet, oneway: current.RequestId == 0);
     return prx.InvokeAsync(current.Operation, current.IsIdempotent, inEncaps, current.Context);
 }
Beispiel #10
0
    public Ice.Object locate(Ice.Current current, out System.Object cookie)
    {
        lock (this)
        {
            test(!_deactivated);
        }

        test(current.id.category.Equals(_category) || _category.Length == 0);

        if (current.id.name.Equals("unknown"))
        {
            cookie = null;
            return(null);
        }

        test(current.id.name.Equals("locate") || current.id.name.Equals("finished"));
        if (current.id.name.Equals("locate"))
        {
            exception(current);
        }

        //
        // Ensure locate() is only called once per request.
        //
        test(_requestId == -1);
        _requestId = current.requestId;

        cookie = new CookieI();

        return(new TestI());
    }
Beispiel #11
0
        public override void Shutdown(Ice.Current current)
        {
            current.adapter.getCommunicator().shutdown();

            var logger = current.adapter.getCommunicator().getLogger();

            logger.print("Ice Shutting downed!");
        }
Beispiel #12
0
 ice_invokeAsync(byte[] inParams, Ice.Current current)
 {
     lock (this)
     {
         var request = new Request(this, current.operation, current.mode, inParams, current.ctx);
         invoke(null, request);
         return(request.Task);
     }
 }
Beispiel #13
0
        public void knownPreservedAsKnownPreserved(Ice.Current current)
        {
            KnownPreservedDerived ex = new KnownPreservedDerived();

            ex.b   = "base";
            ex.kp  = "preserved";
            ex.kpd = "derived";
            throw ex;
        }
Beispiel #14
0
        /// <summary>Creates a new response frame that represents "success" with a void return value. The returned
        /// frame is complete and no additional data can be included in its payload.</summary>
        /// <param name="current">The current parameter holds decoded header data and other information about the
        /// request currently dispatched.</param>
        /// <returns>An <see cref="Ice.OutputStream"/> that holds the new frame.</returns>
        public static Ice.OutputStream CreateEmptyResponseFrame(Ice.Current current)
        {
            var ostr = new Ice.OutputStream(current.Adapter.Communicator, Ice.Util.CurrentProtocolEncoding);

            ostr.WriteBlob(Protocol.replyHdr);
            ostr.WriteInt(current.RequestId);
            ostr.WriteByte(ReplyStatus.replyOK);
            ostr.WriteEmptyEncapsulation(current.Encoding);
            return(ostr);
        }
Beispiel #15
0
        /// <summary>Starts a new response frame and the encapsulation in that frame. This frame encodes a "success"
        /// response.</summary>
        /// <param name="current">The current parameter holds decoded header data and other information about the
        /// request currently dispatched.</param>
        /// <param name="format">The Slice format (Compact or Sliced) used by the encapsulation.</param>
        /// <returns>An <see cref="Ice.OutputStream"/> that holds the new frame.</returns>
        public static Ice.OutputStream StartResponseFrame(Ice.Current current, Ice.FormatType?format = null)
        {
            var ostr = new Ice.OutputStream(current.Adapter.Communicator, Ice.Util.CurrentProtocolEncoding);

            ostr.WriteBlob(Protocol.replyHdr);
            ostr.WriteInt(current.RequestId);
            ostr.WriteByte(ReplyStatus.replyOK);
            ostr.StartEncapsulation(current.Encoding, format);
            return(ostr);
        }
Beispiel #16
0
        /// <summary>Starts a new response frame and the encapsulation in that frame. This frame encodes a "failure"
        /// response.</summary>
        /// <param name="current">The current parameter holds decoded header data and other information about the
        /// request currently dispatched.</param>
        /// <returns>An <see cref="Ice.OutputStream"/> that holds the new frame.</returns>
        public static Ice.OutputStream StartFailureResponseFrame(Ice.Current current)
        {
            var ostr = new Ice.OutputStream(current.Adapter.Communicator, Ice.Util.CurrentProtocolEncoding);

            ostr.WriteBlob(Protocol.replyHdr);
            ostr.WriteInt(current.RequestId);
            ostr.WriteByte(ReplyStatus.replyUserException);
            // Exceptions are always marshaled in the sliced format:
            ostr.StartEncapsulation(current.Encoding, FormatType.SlicedFormat);
            return(ostr);
        }
Beispiel #17
0
    unknownPreservedAsKnownPreservedAsync(Ice.Current current)
    {
        SPreserved2 ex = new SPreserved2();

        ex.b   = "base";
        ex.kp  = "preserved";
        ex.kpd = "derived";
        ex.p1  = new SPreservedClass("bc", "spc");
        ex.p2  = ex.p1;
        throw ex;
    }
Beispiel #18
0
        public void unknownPreservedAsKnownPreserved(Ice.Current current)
        {
            Preserved2 ex = new Preserved2();

            ex.b   = "base";
            ex.kp  = "preserved";
            ex.kpd = "derived";
            ex.p1  = new PreservedClass("bc", "pc");
            ex.p2  = ex.p1;
            throw ex;
        }
Beispiel #19
0
 public override void shutdown(Ice.Current current)
 {
     System.Console.Out.WriteLine("Shutting down...");
     try
     {
         current.adapter.getCommunicator().shutdown();
     }
     catch (System.Exception ex)
     {
         System.Console.Error.WriteLine(ex);
     }
 }
Beispiel #20
0
    public void relayUnknownPreservedAsKnownPreserved(IRelayPrx?r, Ice.Current current)
    {
        TestHelper.Assert(r != null);
        IRelayPrx p = current.Connection !.CreateProxy(r.Identity, IRelayPrx.Factory);

        try
        {
            p.unknownPreservedAsKnownPreserved();
        }
        catch (RemoteException ex)
        {
            TestHelper.Assert(ex.ConvertToUnhandled);
            ex.ConvertToUnhandled = false;
            throw;
        }
        TestHelper.Assert(false);
    }
Beispiel #21
0
 public override int UnsubscribeCodes(string username, string[] codelist, Ice.Current current__)
 {
     try
     {
         DataServantPrx prx = GetDataServant();
         if (prx != null)
         {
             int retval = prx.UnsubscribeCodes(username, codelist);
             return(retval);
         }
     }
     catch (Ice.Exception ex)
     {
         LogHelper.Instance.Info("AASDataWService:UnsubscribeCodes调用失败\n" + ex.Message);
     }
     return(0);
 }
Beispiel #22
0
 public override int GetPubType(Ice.Current current__)
 {
     try
     {
         DataServantPrx prx = GetDataServant();
         if (prx != null)
         {
             var re = prx.GetPubType();
             LogHelper.Instance.Info("AASDataWService:获取当前pub模式成功");
             return(re);
         }
     }
     catch (System.Exception ex)
     {
         LogHelper.Instance.Info("AASDataWService:获取当前pub模式失败!异常信息:" + ex.Message);
     }
     return(-1);
 }
Beispiel #23
0
    relayKnownPreservedAsBaseAsync(IRelayPrx?r, Ice.Current current)
    {
        Debug.Assert(r != null);
        IRelayPrx p = current.Connection.CreateProxy(r.Identity, IRelayPrx.Factory);

        try
        {
            p.knownPreservedAsBase();
        }
        catch (RemoteException ex)
        {
            test(ex.ConvertToUnhandled);
            ex.ConvertToUnhandled = false;
            throw;
        }
        test(false);
        return(new ValueTask(Task.CompletedTask));
    }
Beispiel #24
0
        //DataService _dataService;

        //private DataService GetDataService()
        //{
        //    if (!(_dataService is DataService))
        //    {
        //        _dataService = UnityContainerHost.Container.Resolve<IDataService>() as DataService;
        //    }
        //    return _dataService;
        //}

        public override int SubscribeCodes(string username, string[] codelist, Ice.Current current__)
        {
            try
            {
                DataServantPrx prx = GetDataServant();
                if (prx != null && codelist.Length > 0)
                {
                    int retval = prx.SubscribeCodes(username, codelist);
                    LogHelper.Instance.Info("AASDataWService:" + username + " 已订阅股票:" + string.Join(",", codelist));
                    return(retval);
                }
            }
            catch (System.Exception ex)
            {
                LogHelper.Instance.Info("AASDataWService:SubscribeCodes调用失败\n" + ex.Message);
            }
            return(0);
        }
Beispiel #25
0
 public override bool SetSubType(string username, int subType, Ice.Current current__)
 {
     try
     {
         DataServantPrx prx = GetDataServant();
         if (prx != null)
         {
             var re = prx.SetSubType(username, subType);
             LogHelper.Instance.Info("AASDataWService:设置订阅模式成功");
             return(re);
         }
     }
     catch (System.Exception ex)
     {
         LogHelper.Instance.Info("AASDataWService:设置订阅模式失败!异常信息:" + ex.Message);
     }
     return(false);
 }
Beispiel #26
0
 public override void FlushCodes(string username, string[] codelist, Ice.Current current__)
 {
     try
     {
         DataServantPrx prx = GetDataServant();
         if (prx != null)
         {
             if (codelist.Length > 0)
             {
                 prx.FlushCodes(username, codelist);
             }
         }
     }
     catch (System.Exception ex)
     {
         LogHelper.Instance.Info("AASDataWService:FlushCodes调用失败\n" + ex.Message);
     }
 }
Beispiel #27
0
 public override int GetStockCodes(out DSIceStockCode[] codes, Ice.Current current__)
 {
     try
     {
         DataServantPrx prx = GetDataServant();
         if (prx != null)
         {
             DSIceStockCode[] arr;
             var re = prx.GetStockCodes(out arr);
             LogHelper.Instance.Info("AASDataWService:获取全市场股票代码成功,股票总数:" + arr.Length);
             codes = arr;
         }
     }
     catch (System.Exception ex)
     {
         LogHelper.Instance.Info("AASDataWService:GetStockCodes调用失败\r\n  Message:" + ex.Message);
     }
     codes = null;
     return(0);
 }
Beispiel #28
0
 public override void initiateCallback(CallbackReceiverPrx proxy, Ice.Current current)
 {
     System.Console.Out.WriteLine("initiating callback");
     try
     {
         Task.Factory.StartNew(() =>
         {
             while (true)
             {
                 proxy.callback();
                 Console.Out.WriteLine("call back");
                 Thread.Sleep(1000);
             }
         });
     }
     catch (System.Exception ex)
     {
         System.Console.Error.WriteLine(ex);
     }
 }
Beispiel #29
0
 public Ice.Instrumentation.DispatchObserver getDispatchObserver(Ice.Current c, int size)
 {
     if (_dispatch.isEnabled())
     {
         try
         {
             Ice.Instrumentation.DispatchObserver del = null;
             if (_delegate != null)
             {
                 del = _delegate.getDispatchObserver(c, size);
             }
             return(_dispatch.getObserver(new DispatchHelper(c, size), del));
         }
         catch (System.Exception ex)
         {
             _metrics.getLogger().error("unexpected exception trying to obtain observer:\n" + ex);
         }
     }
     return(null);
 }
Beispiel #30
0
        public void AddObserver(IServiceObserverPrx observer, Ice.Current current)
        {
            List <string> activeServices = new List <string>();

            //
            // Null observers and duplicate registrations are ignored
            //
            lock (this)
            {
                if (observer != null)
                {
                    try
                    {
                        _observers.Add(observer, true);
                    }
                    catch (ArgumentException)
                    {
                        return;
                    }

                    if (_traceServiceObserver >= 1)
                    {
                        _logger.trace("IceBox.ServiceObserver", $"Added service observer {observer}");
                    }

                    foreach (ServiceInfo info in _services)
                    {
                        if (info.Status == ServiceStatus.Started)
                        {
                            activeServices.Add(info.Name);
                        }
                    }
                }
            }

            if (activeServices.Count > 0)
            {
                observer !.ServicesStartedAsync(activeServices.ToArray()).ContinueWith((t) => observerCompleted(observer, t),
                                                                                       TaskScheduler.Current);
            }
        }