private synchronized OrdererClient getOrdererClient() { OrdererClient localOrdererClient = ordererClient; if (localOrdererClient == null || !localOrdererClient.isChannelActive()) { logger.trace(format("Channel %s creating new orderer client %s", channelName, this.toString())); localOrdererClient = new OrdererClient(this, Endpoint.createEndpoint(url, properties).getChannelBuilder(), properties); ordererClient = localOrdererClient; } return localOrdererClient; }
synchronized void setTLSCertificateKeyPair(TLSCertificateKeyPair tlsCertificateKeyPair) { if (properties == null) { properties = new Properties(); } properties.put("clientKeyBytes", tlsCertificateKeyPair.getKeyPemBytes()); properties.put("clientCertBytes", tlsCertificateKeyPair.getCertPEMBytes()); Endpoint endpoint = Endpoint.createEndpoint(url, properties); foundClientTLSCertificateDigest = true; clientTLSCertificateDigest = endpoint.getClientTLSCertificateDigest(); removeEndorserClient(true); endorserClent = new EndorserClient(channelName, name, url, endpoint.getChannelBuilder()); }
private synchronized EndorserClient getEndorserClient() { EndorserClient localEndorserClient = endorserClent; //work off thread local copy. if (null == localEndorserClient || !localEndorserClient.isChannelActive()) { if (IS_TRACE_LEVEL) { logger.trace(format("Channel %s creating new endorser client %s", channelName, toString())); } Endpoint endpoint = Endpoint.createEndpoint(url, properties); foundClientTLSCertificateDigest = true; clientTLSCertificateDigest = endpoint.getClientTLSCertificateDigest(); localEndorserClient = new EndorserClient(channelName, name, url, endpoint.getChannelBuilder()); if (IS_DEBUG_LEVEL) { logger.debug(format("%s created new %s", toString(), localEndorserClient.toString())); } endorserClent = localEndorserClient; } return localEndorserClient; }
/** * Construct client for accessing Peer eventing service using the existing managedChannel. */ PeerEventServiceClient(Peer peer, Endpoint endpoint, Properties properties, PeerOptions peerOptions) { this.channelBuilder = endpoint.getChannelBuilder(); this.filterBlock = peerOptions.isRegisterEventsForFilteredBlocks(); this.peer = peer; name = peer.getName(); url = peer.getUrl(); channelName = peer.getChannel().getName(); toString = "PeerEventServiceClient{" + "id: " + config.getNextID() + ", channel: " + channelName + ", peerName: " + name + ", url: " + url + "}"; this.peerOptions = peerOptions; clientTLSCertificateDigest = endpoint.getClientTLSCertificateDigest(); this.channelEventQue = peer.getChannel().getChannelEventQue(); if (null == properties) { peerEventRegistrationWaitTimeMilliSecs = PEER_EVENT_REGISTRATION_WAIT_TIME; } else { String peerEventRegistrationWaitTime = properties.getProperty("peerEventRegistrationWaitTime", Long.toString(PEER_EVENT_REGISTRATION_WAIT_TIME)); long tempPeerWaitTimeMilliSecs = PEER_EVENT_REGISTRATION_WAIT_TIME; try { tempPeerWaitTimeMilliSecs = Long.parseLong(peerEventRegistrationWaitTime); } catch (NumberFormatException e) { logger.warn(format("Peer event service registration %s wait time %s not parsable.", toString, peerEventRegistrationWaitTime), e); } peerEventRegistrationWaitTimeMilliSecs = tempPeerWaitTimeMilliSecs; } }
managedChannel = endpoint.getChannelBuilder().build();
private synchronized OrdererClient getOrdererClient() { OrdererClient localOrdererClient = ordererClient; if (localOrdererClient == null || !localOrdererClient.isChannelActive()) { logger.trace(format("Channel %s creating new orderer client %s", channelName, this.toString())); localOrdererClient = new OrdererClient(this, Endpoint.createEndpoint(url, properties).getChannelBuilder(), properties); ordererClient = localOrdererClient; } return localOrdererClient; }
synchronized void setTLSCertificateKeyPair(TLSCertificateKeyPair tlsCertificateKeyPair) { if (properties == null) { properties = new Properties(); } properties.put("clientKeyBytes", tlsCertificateKeyPair.getKeyPemBytes()); properties.put("clientCertBytes", tlsCertificateKeyPair.getCertPEMBytes()); Endpoint endpoint = Endpoint.createEndpoint(url, properties); foundClientTLSCertificateDigest = true; clientTLSCertificateDigest = endpoint.getClientTLSCertificateDigest(); removeEndorserClient(true); endorserClent = new EndorserClient(channelName, name, url, endpoint.getChannelBuilder()); }
DeliverResponse[] sendDeliver(Common.Envelope transaction) throws TransactionException { if (shutdown) { throw new TransactionException(format("Orderer %s was shutdown.", name)); } OrdererClient localOrdererClient = ordererClient; logger.debug(format("Order.sendDeliver name: %s, url: %s", name, url)); if (localOrdererClient == null || !localOrdererClient.isChannelActive()) { localOrdererClient = new OrdererClient(this, new Endpoint(url, properties).getChannelBuilder(), properties); ordererClient = localOrdererClient; } try { return localOrdererClient.sendDeliver(transaction); } catch (Throwable t) { ordererClient = null; throw t; } }
private synchronized EndorserClient getEndorserClient() { EndorserClient localEndorserClient = endorserClent; //work off thread local copy. if (null == localEndorserClient || !localEndorserClient.isChannelActive()) { if (IS_TRACE_LEVEL) { logger.trace(format("Channel %s creating new endorser client %s", channelName, toString())); } Endpoint endpoint = Endpoint.createEndpoint(url, properties); foundClientTLSCertificateDigest = true; clientTLSCertificateDigest = endpoint.getClientTLSCertificateDigest(); localEndorserClient = new EndorserClient(channelName, name, url, endpoint.getChannelBuilder()); if (IS_DEBUG_LEVEL) { logger.debug(format("%s created new %s", toString(), localEndorserClient.toString())); } endorserClent = localEndorserClient; } return localEndorserClient; }
ListenableFuture<FabricProposalResponse.ProposalResponse> sendProposalAsync(FabricProposal.SignedProposal proposal) throws PeerException, InvalidArgumentException { checkSendProposal(proposal); logger.debug(format("peer.sendProposalAsync name: %s, url: %s", name, url)); EndorserClient localEndorserClient = endorserClent; //work off thread local copy. if (null == localEndorserClient || !localEndorserClient.isChannelActive()) { endorserClent = new EndorserClient(new Endpoint(url, properties).getChannelBuilder()); localEndorserClient = endorserClent; } try { return localEndorserClient.sendProposalAsync(proposal); } catch (Throwable t) { endorserClent = null; throw t; } }
/** * Send transaction to Order * * @param transaction transaction to be sent */ Ab.BroadcastResponse sendTransaction(Common.Envelope transaction) throws Exception { if (shutdown) { throw new TransactionException(format("Orderer %s was shutdown.", name)); } logger.debug(format("Order.sendTransaction name: %s, url: %s", name, url)); OrdererClient localOrdererClient = ordererClient; if (localOrdererClient == null || !localOrdererClient.isChannelActive()) { ordererClient = new OrdererClient(this, new Endpoint(url, properties).getChannelBuilder(), properties); localOrdererClient = ordererClient; } try { return localOrdererClient.sendTransaction(transaction); } catch (Throwable t) { ordererClient = null; throw t; } }
/** * Construct client for accessing Peer eventing service using the existing managedChannel. */ PeerEventServiceClient(Peer peer, Endpoint endpoint, Properties properties, PeerOptions peerOptions) { this.channelBuilder = endpoint.getChannelBuilder(); this.filterBlock = peerOptions.isRegisterEventsForFilteredBlocks(); this.peer = peer; name = peer.getName(); url = peer.getUrl(); channelName = peer.getChannel().getName(); this.peerOptions = peerOptions; clientTLSCertificateDigest = endpoint.getClientTLSCertificateDigest(); this.channelEventQue = peer.getChannel().getChannelEventQue(); if (null == properties) { peerEventRegistrationWaitTimeMilliSecs = PEER_EVENT_REGISTRATION_WAIT_TIME; } else { this.properties = properties; String peerEventRegistrationWaitTime = properties.getProperty("peerEventRegistrationWaitTime", Long.toString(PEER_EVENT_REGISTRATION_WAIT_TIME)); long tempPeerWaitTimeMilliSecs = PEER_EVENT_REGISTRATION_WAIT_TIME; try { tempPeerWaitTimeMilliSecs = Long.parseLong(peerEventRegistrationWaitTime); } catch (NumberFormatException e) { logger.warn(format("Peer event service registration %s wait time %s not parsable.", name, peerEventRegistrationWaitTime), e); } peerEventRegistrationWaitTimeMilliSecs = tempPeerWaitTimeMilliSecs; } }
managedChannel = endpoint.getChannelBuilder().build();
/** * Construct client for accessing Peer eventing service using the existing managedChannel. */ PeerEventServiceClient(Peer peer, Endpoint endpoint, Properties properties, PeerOptions peerOptions) { this.channelBuilder = endpoint.getChannelBuilder(); this.filterBlock = peerOptions.isRegisterEventsForFilteredBlocks(); this.peer = peer; name = peer.getName(); url = peer.getUrl(); channelName = peer.getChannel().getName(); toString = "PeerEventServiceClient{" + "id: " + config.getNextID() + ", channel: " + channelName + ", peerName: " + name + ", url: " + url + "}"; this.peerOptions = peerOptions; clientTLSCertificateDigest = endpoint.getClientTLSCertificateDigest(); this.channelEventQue = peer.getChannel().getChannelEventQue(); if (null == properties) { peerEventRegistrationWaitTimeMilliSecs = PEER_EVENT_REGISTRATION_WAIT_TIME; } else { String peerEventRegistrationWaitTime = properties.getProperty("peerEventRegistrationWaitTime", Long.toString(PEER_EVENT_REGISTRATION_WAIT_TIME)); long tempPeerWaitTimeMilliSecs = PEER_EVENT_REGISTRATION_WAIT_TIME; try { tempPeerWaitTimeMilliSecs = Long.parseLong(peerEventRegistrationWaitTime); } catch (NumberFormatException e) { logger.warn(format("Peer event service registration %s wait time %s not parsable.", toString, peerEventRegistrationWaitTime), e); } peerEventRegistrationWaitTimeMilliSecs = tempPeerWaitTimeMilliSecs; } }
managedChannel = endpoint.getChannelBuilder().build();