Пример #1
0
        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
        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
        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);
        }
Пример #8
0
        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
        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;
            }
        }