public void Shutdown(bool force) { if (IS_TRACE_LEVEL) { logger.Trace("%s shutdown called force: %b, shutdown: %b, managedChannel: %s"); } if (shutdown) { return; } shutdown = true; Channel lchannel = managedChannel; // let all referenced resource finalize managedChannel = null; ecl = null; dfs = null; if (lchannel == null) { return; } if (force) { try { lchannel.ShutdownAsync().Wait(); } catch (Exception e) { logger.WarnException(e.Message, e); } } else { bool isTerminated = false; try { isTerminated = lchannel.ShutdownAsync().Wait(3 * 1000); } catch (Exception e) { logger.DebugException(e.Message, e); //best effort } if (!isTerminated) { try { lchannel.ShutdownAsync().Wait(); } catch (Exception e) { logger.WarnException(e.Message, e); } } } }
/** * Construct client for accessing Peer server using the existing channel. * * @param channelBuilder The ChannelBuilder to build the endorser client */ public EndorserClient(string channelName, string name, Endpoint endpoint) { managedChannel = endpoint.BuildChannel(); ecl = new Endorser.EndorserClient(managedChannel); dfs = new Protos.Discovery.Discovery.DiscoveryClient(managedChannel); toString = $"EndorserClient{{id: {Config.Instance.GetNextID()}, channel: {channelName}, name:{name}, url: {endpoint.Url}}}"; logger.Trace("Created " + this); }