@Test public void testChannelInitNullClient() throws Exception { thrown.expect(InvalidArgumentException.class); thrown.expectMessage("Can not initialize channel without a client object."); final Channel channel = hfclient.newChannel("testChannelInitNullClient"); setField(channel, "client", null); channel.initialize(); }
public Channel initialize() throws InvalidArgumentException, TransactionException { logger.debug(format("Channel %s initialize shutdown %b", name, shutdown)); if (shutdown) { throw new InvalidArgumentException(format("Channel %s has been shutdown.", name)); } if (isNullOrEmpty(name)) { throw new InvalidArgumentException("Can not initialize channel without a valid name."); } if (client == null) { throw new InvalidArgumentException("Can not initialize channel without a client object."); } userContextCheck(client.getUserContext()); try { parseConfigBlock(); loadCACertificates(); logger.debug(format("Eventque started %s", "" + eventQueueThread)); for (EventHub eh : eventHubs) { eh.connect(getTransactionContext()); } for (Peer peer : getEventingPeers()) { peer.initiateEventing(getTransactionContext(), getPeersOptions(peer)); } logger.debug(format("%d eventhubs initialized", getEventHubs().size())); registerTransactionListenerProcessor(); logger.debug(format("Channel %s registerTransactionListenerProcessor completed", name)); startEventQue(); this.initialized = true; logger.debug(format("Channel %s initialized", name)); return this; } catch (TransactionException e) { logger.error(e.getMessage(), e); throw e; } catch (Exception e) { TransactionException exp = new TransactionException(e); logger.error(exp.getMessage(), exp); throw exp; } }
Channel implements Serializable { public Channel initialize() throws InvalidArgumentException, TransactionException { logger.debug(format("Channel %s initialize shutdown %b", name, shutdown)); if (shutdown) { throw new InvalidArgumentException(format("Channel %s has been shutdown.", name)); } if (isNullOrEmpty(name)) { throw new InvalidArgumentException("Can not initialize channel without a valid name."); } if (client == null) { throw new InvalidArgumentException("Can not initialize channel without a client object."); } userContextCheck(client.getUserContext()); try { parseConfigBlock(); loadCACertificates(); logger.debug(format("Eventque started %s", "" + eventQueueThread)); for (EventHub eh : eventHubs) { eh.connect(getTransactionContext()); } for (Peer peer : getEventingPeers()) { peer.initiateEventing(getTransactionContext(), getPeersOptions(peer)); } logger.debug(format("%d eventhubs initialized", getEventHubs().size())); registerTransactionListenerProcessor(); logger.debug(format("Channel %s registerTransactionListenerProcessor completed", name)); startEventQue(); this.initialized = true; logger.debug(format("Channel %s initialized", name)); return this; } catch (TransactionException e) { logger.error(e.getMessage(), e); throw e; } catch (Exception e) { TransactionException exp = new TransactionException(e); logger.error(exp.getMessage(), exp); throw exp; } } }
Channel implements Serializable { public Channel initialize() throws InvalidArgumentException, TransactionException { logger.debug(format("Channel %s initialize shutdown %b", name, shutdown)); if (shutdown) { throw new InvalidArgumentException(format("Channel %s has been shutdown.", name)); } if (isNullOrEmpty(name)) { throw new InvalidArgumentException("Can not initialize channel without a valid name."); } if (client == null) { throw new InvalidArgumentException("Can not initialize channel without a client object."); } userContextCheck(client.getUserContext()); try { parseConfigBlock(); loadCACertificates(); logger.debug(format("Eventque started %s", "" + eventQueueThread)); for (EventHub eh : eventHubs) { eh.connect(getTransactionContext()); } for (Peer peer : getEventingPeers()) { peer.initiateEventing(getTransactionContext(), getPeersOptions(peer)); } logger.debug(format("%d eventhubs initialized", getEventHubs().size())); registerTransactionListenerProcessor(); logger.debug(format("Channel %s registerTransactionListenerProcessor completed", name)); startEventQue(); this.initialized = true; logger.debug(format("Channel %s initialized", name)); return this; } catch (TransactionException e) { logger.error(e.getMessage(), e); throw e; } catch (Exception e) { TransactionException exp = new TransactionException(e); logger.error(exp.getMessage(), exp); throw exp; } } private  Channel(String name, HFClient hfClient, Orderer orderer, ChannelConfiguration channelConfiguration, byte[][] signers);   Channel(String name, HFClient client); private  Channel(String name, HFClient client, final boolean systemChannel); }
Channel implements Serializable { public Channel initialize() throws InvalidArgumentException, TransactionException { logger.debug(format("Channel %s initialize shutdown %b", name, shutdown)); if (shutdown) { throw new InvalidArgumentException(format("Channel %s has been shutdown.", name)); } if (isNullOrEmpty(name)) { throw new InvalidArgumentException("Can not initialize channel without a valid name."); } if (client == null) { throw new InvalidArgumentException("Can not initialize channel without a client object."); } userContextCheck(client.getUserContext()); try { parseConfigBlock(); loadCACertificates(); logger.debug(format("Eventque started %s", "" + eventQueueThread)); for (EventHub eh : eventHubs) { eh.connect(getTransactionContext()); } for (Peer peer : getEventingPeers()) { peer.initiateEventing(getTransactionContext(), getPeersOptions(peer)); } logger.debug(format("%d eventhubs initialized", getEventHubs().size())); registerTransactionListenerProcessor(); logger.debug(format("Channel %s registerTransactionListenerProcessor completed", name)); startEventQue(); this.initialized = true; logger.debug(format("Channel %s initialized", name)); return this; } catch (TransactionException e) { logger.error(e.getMessage(), e); throw e; } catch (Exception e) { TransactionException exp = new TransactionException(e); logger.error(exp.getMessage(), exp); throw exp; } } private  Channel(String name, HFClient hfClient, Orderer orderer, ChannelConfiguration channelConfiguration, byte[][] signers);   Channel(String name, HFClient client); private  Channel(String name, HFClient client, final boolean systemChannel); Collection<EventHub> getEventHubs(); void updateChannelConfiguration(UpdateChannelConfiguration updateChannelConfiguration, byte[]... signers); void updateChannelConfiguration(UpdateChannelConfiguration updateChannelConfiguration, Orderer orderer, byte[]... signers); boolean isInitialized(); String getName(); Channel addPeer(Peer peer); Channel addPeer(Peer peer, PeerOptions peerOptions); Channel joinPeer(Peer peer); Channel joinPeer(Peer peer, PeerOptions peerOptions); void removePeer(Peer peer); Channel addOrderer(Orderer orderer); PeerOptions getPeersOptions(Peer peer); Channel addEventHub(EventHub eventHub); Collection<Peer> getPeers(); Collection<Peer> getPeers(EnumSet<PeerRole> roles); Channel initialize(); boolean isShutdown(); byte[] getUpdateChannelConfigurationSignature(UpdateChannelConfiguration updateChannelConfiguration, User signer); byte[] getChannelConfigurationBytes(); Collection<Orderer> getOrderers(); Collection<ProposalResponse> sendInstantiationProposal(InstantiateProposalRequest instantiateProposalRequest); Collection<ProposalResponse> sendInstantiationProposal(InstantiateProposalRequest instantiateProposalRequest,
                                                                  Collection<Peer> peers); Collection<ProposalResponse> sendUpgradeProposal(UpgradeProposalRequest upgradeProposalRequest); Collection<ProposalResponse> sendUpgradeProposal(UpgradeProposalRequest upgradeProposalRequest, Collection<Peer> peers); BlockInfo queryBlockByHash(byte[] blockHash); BlockInfo queryBlockByHash(Peer peer, byte[] blockHash); BlockInfo queryBlockByNumber(long blockNumber); BlockInfo queryBlockByNumber(Peer peer, long blockNumber); BlockInfo queryBlockByTransactionID(String txID); BlockInfo queryBlockByTransactionID(Peer peer, String txID); BlockchainInfo queryBlockchainInfo(); BlockchainInfo queryBlockchainInfo(Peer peer); TransactionInfo queryTransactionByID(String txID); TransactionInfo queryTransactionByID(Peer peer, String txID); List<ChaincodeInfo> queryInstantiatedChaincodes(Peer peer); Collection<ProposalResponse> sendTransactionProposal(TransactionProposalRequest transactionProposalRequest); Collection<ProposalResponse> sendTransactionProposal(TransactionProposalRequest transactionProposalRequest, Collection<Peer> peers); Collection<ProposalResponse> queryByChaincode(QueryByChaincodeRequest queryByChaincodeRequest); Collection<ProposalResponse> queryByChaincode(QueryByChaincodeRequest queryByChaincodeRequest, Collection<Peer> peers); CompletableFuture<TransactionEvent> sendTransaction(Collection<ProposalResponse> proposalResponses, User userContext); CompletableFuture<TransactionEvent> sendTransaction(Collection<ProposalResponse> proposalResponses); CompletableFuture<TransactionEvent> sendTransaction(Collection<ProposalResponse> proposalResponses, Collection<Orderer> orderers); CompletableFuture<TransactionEvent> sendTransaction(Collection<ProposalResponse> proposalResponses, Collection<Orderer> orderers, User userContext); String registerBlockListener(BlockListener listener); boolean unregisterBlockListener(String handle); String registerChaincodeEventListener(Pattern chaincodeId, Pattern eventName, ChaincodeEventListener chaincodeEventListener); boolean unregisterChaincodeEventListener(String handle); synchronized void shutdown(boolean force); void serializeChannel(File file); byte[] serializeChannel(); }
Channel implements Serializable { public Channel initialize() throws InvalidArgumentException, TransactionException { logger.debug(format("Channel %s initialize shutdown %b", name, shutdown)); if (shutdown) { throw new InvalidArgumentException(format("Channel %s has been shutdown.", name)); } if (isNullOrEmpty(name)) { throw new InvalidArgumentException("Can not initialize channel without a valid name."); } if (client == null) { throw new InvalidArgumentException("Can not initialize channel without a client object."); } userContextCheck(client.getUserContext()); try { parseConfigBlock(); loadCACertificates(); logger.debug(format("Eventque started %s", "" + eventQueueThread)); for (EventHub eh : eventHubs) { eh.connect(getTransactionContext()); } for (Peer peer : getEventingPeers()) { peer.initiateEventing(getTransactionContext(), getPeersOptions(peer)); } logger.debug(format("%d eventhubs initialized", getEventHubs().size())); registerTransactionListenerProcessor(); logger.debug(format("Channel %s registerTransactionListenerProcessor completed", name)); startEventQue(); this.initialized = true; logger.debug(format("Channel %s initialized", name)); return this; } catch (TransactionException e) { logger.error(e.getMessage(), e); throw e; } catch (Exception e) { TransactionException exp = new TransactionException(e); logger.error(exp.getMessage(), exp); throw exp; } } private  Channel(String name, HFClient hfClient, Orderer orderer, ChannelConfiguration channelConfiguration, byte[][] signers);   Channel(String name, HFClient client); private  Channel(String name, HFClient client, final boolean systemChannel); Collection<EventHub> getEventHubs(); void updateChannelConfiguration(UpdateChannelConfiguration updateChannelConfiguration, byte[]... signers); void updateChannelConfiguration(UpdateChannelConfiguration updateChannelConfiguration, Orderer orderer, byte[]... signers); boolean isInitialized(); String getName(); Channel addPeer(Peer peer); Channel addPeer(Peer peer, PeerOptions peerOptions); Channel joinPeer(Peer peer); Channel joinPeer(Peer peer, PeerOptions peerOptions); void removePeer(Peer peer); Channel addOrderer(Orderer orderer); PeerOptions getPeersOptions(Peer peer); Channel addEventHub(EventHub eventHub); Collection<Peer> getPeers(); Collection<Peer> getPeers(EnumSet<PeerRole> roles); Channel initialize(); boolean isShutdown(); byte[] getUpdateChannelConfigurationSignature(UpdateChannelConfiguration updateChannelConfiguration, User signer); byte[] getChannelConfigurationBytes(); Collection<Orderer> getOrderers(); Collection<ProposalResponse> sendInstantiationProposal(InstantiateProposalRequest instantiateProposalRequest); Collection<ProposalResponse> sendInstantiationProposal(InstantiateProposalRequest instantiateProposalRequest,
                                                                  Collection<Peer> peers); Collection<ProposalResponse> sendUpgradeProposal(UpgradeProposalRequest upgradeProposalRequest); Collection<ProposalResponse> sendUpgradeProposal(UpgradeProposalRequest upgradeProposalRequest, Collection<Peer> peers); BlockInfo queryBlockByHash(byte[] blockHash); BlockInfo queryBlockByHash(Peer peer, byte[] blockHash); BlockInfo queryBlockByNumber(long blockNumber); BlockInfo queryBlockByNumber(Peer peer, long blockNumber); BlockInfo queryBlockByTransactionID(String txID); BlockInfo queryBlockByTransactionID(Peer peer, String txID); BlockchainInfo queryBlockchainInfo(); BlockchainInfo queryBlockchainInfo(Peer peer); TransactionInfo queryTransactionByID(String txID); TransactionInfo queryTransactionByID(Peer peer, String txID); List<ChaincodeInfo> queryInstantiatedChaincodes(Peer peer); Collection<ProposalResponse> sendTransactionProposal(TransactionProposalRequest transactionProposalRequest); Collection<ProposalResponse> sendTransactionProposal(TransactionProposalRequest transactionProposalRequest, Collection<Peer> peers); Collection<ProposalResponse> queryByChaincode(QueryByChaincodeRequest queryByChaincodeRequest); Collection<ProposalResponse> queryByChaincode(QueryByChaincodeRequest queryByChaincodeRequest, Collection<Peer> peers); CompletableFuture<TransactionEvent> sendTransaction(Collection<ProposalResponse> proposalResponses, User userContext); CompletableFuture<TransactionEvent> sendTransaction(Collection<ProposalResponse> proposalResponses); CompletableFuture<TransactionEvent> sendTransaction(Collection<ProposalResponse> proposalResponses, Collection<Orderer> orderers); CompletableFuture<TransactionEvent> sendTransaction(Collection<ProposalResponse> proposalResponses, Collection<Orderer> orderers, User userContext); String registerBlockListener(BlockListener listener); boolean unregisterBlockListener(String handle); String registerChaincodeEventListener(Pattern chaincodeId, Pattern eventName, ChaincodeEventListener chaincodeEventListener); boolean unregisterChaincodeEventListener(String handle); synchronized void shutdown(boolean force); void serializeChannel(File file); byte[] serializeChannel();  }