示例#1
0
文件: Lookup.cs 项目: tchernobog/ice
        internal void AdapterRequestException(AdapterRequest request, System.Exception ex)
        {
            lock (this)
            {
                if (!_adapterRequests.TryGetValue(request.GetId(), out AdapterRequest r) || r != request)
                {
                    return;
                }

                if (request.Exception())
                {
                    if (_warnOnce)
                    {
                        var s = new StringBuilder();
                        s.Append("failed to lookup adapter `");
                        s.Append(request.GetId());
                        s.Append("' with lookup proxy `");
                        s.Append(_lookup);
                        s.Append("':\n");
                        s.Append(ex.ToString());
                        _lookup.Communicator.Logger.Warning(s.ToString());
                        _warnOnce = false;
                    }
                    _timer.Cancel(request);
                    _adapterRequests.Remove(request.GetId());
                }
            }
        }
示例#2
0
文件: Lookup.cs 项目: tchernobog/ice
        internal Task <IObjectPrx> FindAdapter(string adapterId)
        {
            lock (this)
            {
                if (!_adapterRequests.TryGetValue(adapterId, out AdapterRequest request))
                {
                    request = new AdapterRequest(this, adapterId, _retryCount);
                    _adapterRequests.Add(adapterId, request);
                }

                var task = new TaskCompletionSource <Ice.IObjectPrx>();
                if (request.AddCallback(task))
                {
                    try
                    {
                        request.Invoke(_domainId, _lookups);
                        _timer.Schedule(request, _timeout);
                    }
                    catch (LocalException)
                    {
                        request.Finished(null);
                        _adapterRequests.Remove(adapterId);
                    }
                }
                return(task.Task);
            }
        }
示例#3
0
文件: Lookup.cs 项目: tchernobog/ice
        internal void AdapterRequestTimedOut(AdapterRequest request)
        {
            lock (this)
            {
                if (!_adapterRequests.TryGetValue(request.GetId(), out AdapterRequest r) || r != request)
                {
                    return;
                }

                if (request.Retry())
                {
                    try
                    {
                        request.Invoke(_domainId, _lookups);
                        _timer.Schedule(request, _timeout);
                        return;
                    }
                    catch (LocalException)
                    {
                    }
                }

                request.Finished(null);
                _adapterRequests.Remove(request.GetId());
                _timer.Cancel(request);
            }
        }
示例#4
0
        public async Task <Response <AdapterInfo> > GetAdapterInfoAsync(string adapterName)
        {
            var endpoint = ConcatBaseAdressWithEndpoint("api/management/adapters/info");
            var payload  = new AdapterRequest(adapterName);
            var response = await RequestHelper.SendGetAsync <AdapterRequest, Response <AdapterInfo> >(endpoint,
                                                                                                      payload,
                                                                                                      _authorizationScheme,
                                                                                                      _apiKey);

            return(response);
        }
示例#5
0
        public async Task <Response <string> > MarkTransactionAsConfirmed(IEnumerable <string> ids, string adapterName)
        {
            var endpoint    = ConcatBaseAdressWithEndpoint("api/management/addresses/setprocessed");
            var getPayload  = new AdapterRequest(adapterName);
            var postPayload = new SetProcessedRequest
            {
                Ids = ids.ToList()
            };
            var response =
                await RequestHelper.SendPostWithMixedPayloadAsync <AdapterRequest, SetProcessedRequest, Response <string> >(endpoint,
                                                                                                                            getPayload, postPayload, _authorizationScheme, _apiKey);

            return(response);
        }
示例#6
0
        public async Task <Response <IEnumerable <TransactionInfo> > > GetTransactionHistoryAsync(string adapterName, int?userId = null)
        {
            var endpoint   = ConcatBaseAdressWithEndpoint("api/management/addresses/gettransactions");
            var getPayload = new AdapterRequest(adapterName);
            var response   =
                await RequestHelper.SendGetAsync <AdapterRequest, Response <IEnumerable <TransactionInfo> > >(endpoint, getPayload,
                                                                                                              _authorizationScheme, _apiKey);

            if (userId.HasValue)
            {
                response.Value = response.Value.Where(x => x.UserId == userId);
            }
            return(response);
        }
示例#7
0
        public async Task <Response <AddressInfo> > GenerateRefillAddressAsync(string adapterName, int userId, string tag, bool isNewRequired)
        {
            var endpoint    = ConcatBaseAdressWithEndpoint("/api/management/addresses/create");
            var getPayload  = new AdapterRequest(adapterName);
            var postPayload = new AddressRequest
            {
                UserId      = userId,
                Tag         = tag,
                GenerateNew = isNewRequired
            };
            var response = await RequestHelper.SendPostWithMixedPayloadAsync <AdapterRequest, AddressRequest, Response <AddressInfo> >(
                endpoint,
                getPayload,
                postPayload,
                _authorizationScheme,
                _apiKey);

            return(response);
        }
        private Request GetAdapterRequest(Reference reference)
        {
            if (reference.GetCommunicator().TraceLevels.location >= 1)
            {
                Communicator communicator = reference.GetCommunicator();
                var          s            = new System.Text.StringBuilder();
                s.Append("searching for adapter by id\nadapter = ");
                s.Append(reference.GetAdapterId());
                communicator.Logger.Trace(communicator.TraceLevels.locationCat, s.ToString());
            }

            lock (this)
            {
                if (_adapterRequests.TryGetValue(reference.GetAdapterId(), out Request request))
                {
                    return(request);
                }

                request = new AdapterRequest(this, reference);
                _adapterRequests.Add(reference.GetAdapterId(), request);
                return(request);
            }
        }
示例#9
0
        getAdapterRequest(Reference @ref)
        {
            if (@ref.getInstance().traceLevels().location >= 1)
            {
                Instance instance           = @ref.getInstance();
                System.Text.StringBuilder s = new System.Text.StringBuilder();
                s.Append("searching for adapter by id\nadapter = ");
                s.Append(@ref.getAdapterId());
                instance.initializationData().logger.trace(instance.traceLevels().locationCat, s.ToString());
            }

            lock (this)
            {
                Request request;
                if (_adapterRequests.TryGetValue(@ref.getAdapterId(), out request))
                {
                    return(request);
                }

                request = new AdapterRequest(this, @ref);
                _adapterRequests.Add(@ref.getAdapterId(), request);
                return(request);
            }
        }
示例#10
0
文件: LocatorInfo.cs 项目: motuii/ice
        getAdapterRequest(Reference reference)
        {
            if (reference.getCommunicator().traceLevels().location >= 1)
            {
                var communicator            = reference.getCommunicator();
                System.Text.StringBuilder s = new System.Text.StringBuilder();
                s.Append("searching for adapter by id\nadapter = ");
                s.Append(reference.getAdapterId());
                communicator.initializationData().logger.trace(communicator.traceLevels().locationCat, s.ToString());
            }

            lock (this)
            {
                Request request;
                if (_adapterRequests.TryGetValue(reference.getAdapterId(), out request))
                {
                    return(request);
                }

                request = new AdapterRequest(this, reference);
                _adapterRequests.Add(reference.getAdapterId(), request);
                return(request);
            }
        }
示例#11
0
        getAdapterRequest(Reference @ref)
        {
            if(@ref.getInstance().traceLevels().location >= 1)
            {
                Instance instance = @ref.getInstance();
                System.Text.StringBuilder s = new System.Text.StringBuilder();
                s.Append("searching for adapter by id\nadapter = ");
                s.Append(@ref.getAdapterId());
                instance.initializationData().logger.trace(instance.traceLevels().locationCat, s.ToString());
            }

            lock(this)
            {
                Request request;
                if(_adapterRequests.TryGetValue(@ref.getAdapterId(), out request))
                {
                    return request;
                }
                
                request = new AdapterRequest(this, @ref);
                _adapterRequests.Add(@ref.getAdapterId(), request);
                return request;
            }
        }