Fetch the input channel from the runtime.

@param inputChannelName
of the (parent) channel requested.
@param chain
in which channel is running.
@return Channel requested, or null if not found.
963697
public synchronized Channel getRunningChannel(String inputChannelName, Chain chain) {
        if (inputChannelName == null || chain == null) {
            return null;
        }

        Channel channel = null;
        // Ensure the chain is running.
        if (null != this.chainRunningMap.get(chain.getName())) {
            ChannelData[] channels = chain.getChannelsData();
            for (int index = 0; index < channels.length; index++) {
                if (channels[index].getExternalName().equals(inputChannelName)) {
                    channel = chain.getChannels()[index];
                    break;
                }
            }
        }
        return channel;
    }
785475
AsteriskQueueEntryImpl getEntry(String channelName)
    {
        synchronized (entries)
        {
            for (AsteriskQueueEntryImpl entry : entries)
            {
                if (entry.getChannel().getName().equals(channelName))
                {
                    return entry;
                }
            }
        }
        return null;
    }
1357892
Channel loadChannel(HFClient client, String channelName) throws NetworkConfigurationException {
        return loadChannel(client, channelName, networkConfigAddPeerHandlerDefault, networkConfigAddOrdererHandlerDefault);
    }
1121045
public static channel[] get(nitro_service service) throws Exception{
		channel obj = new channel();
		channel[] response = (channel[])obj.get_resources(service);
		return response;
	}
110154
protected Channel awaitChannel() throws IOException {
        Channel channel = this.channel;
        if(channel != null) {
            return channel;
        }
        synchronized (lock) {
            for(;;) {
                if(state == State.CLOSED) {
                    throw ProtocolLogger.ROOT_LOGGER.channelClosed();
                }
                channel = this.channel;
                if(channel != null) {
                    return channel;
                }
                if(state == State.CLOSING) {
                    throw ProtocolLogger.ROOT_LOGGER.channelClosed();
                }
                try {
                    lock.wait();
                } catch (InterruptedException e) {
                    throw new IOException(e);
                }
            }
        }
    }
68085
protected MessageChannel getDestinationChannel(TestContext context) {
        if (endpointConfiguration.getChannel() != null) {
            return endpointConfiguration.getChannel();
        } else if (StringUtils.hasText(endpointConfiguration.getChannelName())) {
            return resolveChannelName(endpointConfiguration.getChannelName(), context);
        } else {
            throw new CitrusRuntimeException("Neither channel name nor channel object is set - " +
                    "please specify destination channel");
        }
    }
817657
synchronized void stopChainInternal(Chain chain, long millisec) throws ChannelException, ChainException {
        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) {
            Tr.entry(tc, "stopChainInternal: " + chain.getName() + ", time=" + millisec);
        }

        RuntimeState chainState = chain.getState();
        Channel[] chainChannels = chain.getChannels();
        if ((RuntimeState.STARTED == chainState) || (RuntimeState.QUIESCED == chainState)) {
            // Check if this is just a quiesce
            if (millisec > 0L) {
                if (RuntimeState.QUIESCED == chainState) {
                    // Due to timing windows (i.e. multiple channel providers going away), there is
                    // a race to stop chains. This is not a notable condition: the chain can only be stopped
                    // once.
                    if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) {
                        Tr.exit(tc, "stopChain " + chain.getName(), "chain already quiesced");
                    }
                    return;
                }

                if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                    Tr.debug(tc, "Quiescing chain: " + chain.getName());
                }

                int i = 0;
                try {
                    // In start state. Just a quiesce. Iterate the channels and send a
                    // stop warning
                    for (i = 0; i < chainChannels.length; ++i) {
                        // Only alert channels that are active only for this chain.
                        // Otherwise a future stop will never take affect anyhow
                        if (getNumStartedChainsUsingChannel(chainChannels[i].getName()) == 1) {
                            if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                                Tr.debug(tc, "Quiescing channel: " + chainChannels[i].getName());
                            }
                            chainChannels[i].stop(millisec);
                            // Update the state of the channel.
                            setChannelState(chainChannels[i].getName(), RuntimeState.QUIESCED);
                        }
                    }
                    // Start the timer for when the stop will be asserted.
                    StopChainTask task = new StopChainTask(chain.getName(), this);
                    chain.setStopTask(task);
                    // Update the state of the chain.
                    chain.quiesce();
                    this.stopTimer.schedule(task, millisec);
                } catch (ChannelException e) {
                    FFDCFilter.processException(e, getClass().getName() + ".stopChainInternal", "2711", this, new Object[] { chain, this });
                    Tr.error(tc, "chain.stop.error", new Object[] { chain.getName(), e.toString() });
                    // Need to undo channels stopped so far.
                    for (int j = 0; j < i; j++) {
                        chainChannels[j].start();
                        // Update the state of the channel.
                        setChannelState(chainChannels[j].getName(), RuntimeState.STARTED);
                    }
                    throw e;
                }
            } else {
                if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                    Tr.debug(tc, "Stopping chain: " + chain.getName());
                }

                if (RuntimeState.QUIESCED == chainState) {
                    // A stop is being requested while a stop task is in place. Need to
                    // cancel it first.
                    StopChainTask task = chain.getStopTask();
                    if (task != null) {
                        task.cancel();
                        chain.setStopTask(null);
                    }
                }
                // Disable the channels from the device side up to the application side.
                List<Channel> channelsToStop = new ArrayList<Channel>(chainChannels.length);
                for (int i = 0; i < chainChannels.length; ++i) {
                    // Only stop a channel if it is in use by just this chain.
                    if (getNumStartedChainsUsingChannel(chainChannels[i].getName()) <= 1) {
                        if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                            Tr.debug(tc, "Placing channel in list to stop: " + chainChannels[i].getName());
                        }
                        if (chain.getChainData().getType().equals(FlowType.OUTBOUND)) {
                            channelsToStop.add(chainChannels[i]);
                        } else if (disableChannelInChain(chainChannels[i], chain)) {
                            channelsToStop.add(chainChannels[i]);
                        }
                    }
                }
                int i = 0;
                try {
                    // Stop the channels from the application side to the device side.
                    for (i = channelsToStop.size() - 1; i >= 0; i--) {
                        stopChannel(channelsToStop.get(i));
                    }
                    chain.stop();
                } catch (ChannelException e) {
                    FFDCFilter.processException(e, getClass().getName() + ".stopChainInternal", "2763", this, new Object[] { chain, this });
                    Tr.error(tc, "chain.stop.error", new Object[] { chain.getName(), e.toString() });
                    // Need to restart channels that were stopped thus far.
                    if (FlowType.INBOUND.equals(chain.getChainData().getType())) {
                        // Re-enable the channel
                        ((InboundChain) chain).setupDiscProcess();
                    }
                    for (int j = 0; j < i; j++) {
                        startChannelInChain(channelsToStop.get(j), chain);
                    }
                    // Alert the caller.
                    throw e;
                }
            }
        } else if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
            // Due to timing windows (i.e. multiple channel providers going away), there is
            // a race to stop chains. This is not a notable condition: the chain can only be stopped
            // once.
            Tr.debug(tc, "stopChainInternal " + chain.getName(), "chain is not running");
        }

        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) {
            Tr.exit(tc, "stopChainInternal");
        }
    }
285175
protected Channel getConsumerChannel() throws IOException, TimeoutException {
        if (consumerChannel == null) {
            synchronized (this) {
                if (consumerChannel == null) {
                    consumerChannel = createChannel();
                }
            }
        }
        return consumerChannel;
    }
1311984
@Override
    public synchronized ChainData[] initChainGroup(String groupName) throws ChannelException, ChainException, ChainGroupException {
        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) {
            Tr.entry(tc, "initChainGroup: " + groupName);
        }
        if (null == groupName) {
            throw new ChainGroupException("Null chain group");
        }

        // Verify the group exists in the framework.
        ChainGroupData groupData = this.chainGroups.get(groupName);
        if (null == groupData) {
            throw new ChainGroupException("Unable to find group: " + groupName);
        }

        List<ChainData> changedChains = new ArrayList<ChainData>();
        ChainData[] chainDataArray = groupData.getChains();
        StringBuilder sbErrors = new StringBuilder();
        boolean errorOccurred = false;

        String chainName = null;
        Chain chain = null;
        // Loop through all the chain names in the list and init them.
        for (int i = 0; i < chainDataArray.length; i++) {
            chainName = chainDataArray[i].getName();
            if (chainDataArray[i].getType().equals(FlowType.OUTBOUND)) {
                if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                    Tr.debug(tc, "Chain " + chainName + " is outbound so no action being taken.");
                }
                continue;
            }
            try {
                // See if the chain is already in the runtime.
                chain = getRunningChain(chainName);
                if (null == chain) {
                    if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                        Tr.debug(tc, "Initialize the chain, " + chainName);
                    }
                    initChainInternal(chainDataArray[i]);
                    changedChains.add(chainDataArray[i]);
                } else {
                    if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                        Tr.debug(tc, "Chain already in initialized state, " + chainName);
                    }
                }
            } catch (Exception e) {
                String errorString = "Error initializing chain " + chainName + " in group " + groupName + ", exception=" + e;
                // No FFDC Needed.
                if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                    Tr.debug(tc, errorString);
                }
                // Note the error so an exception can be thrown later with a list of
                // chains that couldn't starte.
                errorOccurred = true;
                FFDCFilter.processException(e, getClass().getName() + ".initChainGroup", "3327", this, new Object[] { chainName, groupName });
                sbErrors.append("\r\n");
                sbErrors.append(errorString);
                // Get through as many chains as possible as opposed to fail fast.
                continue;
            }
        }

        // Handle any errors if they occurred.
        if (errorOccurred) {
            throw new ChainGroupException(sbErrors.toString());
        }

        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) {
            Tr.exit(tc, "initChainGroup");
        }
        return changedChains.toArray(new ChainData[changedChains.size()]);
    }
1236107
public synchronized Channel findOrCreateChannel(ChannelData channelData) throws ChannelException {
        String channelName = channelData.getName();
        Channel ret = this.existingChannels.get(channelName);
        if (ret == null) {
            // Create the new channel with the input configuration
            ret = new JFapChannelInbound(_channelFactoryData, channelData);
            this.existingChannels.put(channelName, ret);
        }
        return ret;
    }
525192
@Override
    public synchronized ChannelData[] getRunningChannels() {
        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) {
            Tr.entry(tc, "getRunningChannels");
        }

        // Note, runtime has child data objects so duplicates may be found.
        List<ChannelData> list = new ArrayList<ChannelData>();
        for (ChannelContainer channel : this.channelRunningMap.values()) {
            list.add(channel.getChannelData().getParent());
        }

        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) {
            Tr.exit(tc, "getRunningChannels");
        }
        return list.toArray(new ChannelData[list.size()]);
    }
877894
private synchronized VirtualConnectionFactory getOutboundVCFactory(List<OutboundChannelDefinition> channelDefs) throws ChannelFrameworkException {

        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            Tr.entry(tc, "getOutboundVCFactory");

        ChainDataImpl chainData = null;
        boolean found = false;
        int hashKey = 0;

        // Build a hash key based on names of channel factories.
        for (OutboundChannelDefinition def : channelDefs) {
            hashKey += def.getOutboundFactory().hashCode();
        }

        // See if the key already exists in the current set of outbound chains.
        OutboundVirtualConnectionFactoryImpl vcf = null;
        Iterator<OutboundVirtualConnectionFactoryImpl> vcfs = this.outboundVCFactories.values().iterator();
        while (vcfs.hasNext()) {
            vcf = vcfs.next();
            chainData = (ChainDataImpl) vcf.getChain().getChainData();
            if (hashKey == chainData.getChannelFactoryHash()) {
                if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                    Tr.debug(tc, "Found matching hash keys");
                }
                // Handle tiny case where two chains hash to same value.
                // Verify the channel factories, factory props, and channel
                // props are the same.
                ChannelData channelDataList[] = chainData.getChannelList();
                if (channelDataList.length == channelDefs.size()) {
                    if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                        Tr.debug(tc, "Found matching number of channels");
                    }
                    // Assume a match.
                    found = true;
                    ChannelData existingDef;
                    ChannelFactoryData existingFactoryData;
                    OutboundChannelDefinition inputDef;
                    // Loop through all the channels in the chain data.
                    for (int i = 0; i < channelDataList.length; i++) {
                        // Extract the current/existing channel def.
                        existingDef = channelDataList[i];
                        existingFactoryData = getChannelFactory(existingDef.getFactoryType());
                        // Extract the new channel def.
                        inputDef = channelDefs.get(i);
                        // Compare the existing and new channel defs.
                        if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                            Tr.debug(tc, "Comparing existing def " + existingDef.getFactoryType() + "to new def " + inputDef.getOutboundFactory());
                        }
                        boolean sameFactoryType = (existingDef.getFactoryType() == inputDef.getOutboundFactory());
                        boolean sameChannelProps = propertiesIncluded(inputDef.getOutboundChannelProperties(), existingDef.getPropertyBag());
                        boolean sameFactoryProps = propertiesIncluded(inputDef.getOutboundFactoryProperties(), existingFactoryData.getProperties());

                        if (!sameFactoryType || !sameChannelProps || !sameFactoryProps) {
                            // Found a mismatch.
                            if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                                Tr.debug(tc, "Keys matched, but factories didn't");
                            }
                            found = false;
                            // Break out of this inner loop.
                            break;
                        }
                    }
                    if (found) {
                        // Break out of outer loop.
                        break;
                    }
                }
            }
        } // factory loop

        if (!found) {
            // Couldn't find a match. Need to create a one.
            if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                Tr.debug(tc, "No existing VCF, create one.");
            }
            // We may be able to reuse existing chain or channel data objects.
            // However, the hit in searching probably isn't worth it.
            // For now, create them all from scratch.
            String channelNameList[] = new String[channelDefs.size()];
            String channelName = null;
            int i = 0;
            for (OutboundChannelDefinition def : channelDefs) {
                channelName = "channel_" + channelNameCounter.getAndIncrement();
                channelNameList[i++] = channelName;
                addChannel(channelName, def.getOutboundFactory(), def.getOutboundChannelProperties());
            }
            String chainName = "chain_" + chainNameCounter.getAndIncrement();
            addChain(chainName, FlowType.OUTBOUND, channelNameList);
            vcf = (OutboundVirtualConnectionFactoryImpl) getOutboundVCFactory(chainName);
        } else if (null != vcf) {
            vcf.incrementRefCount();
            if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                Tr.debug(tc, "Found an existing vcf " + vcf.hashCode());
            }
        }

        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) {
            Tr.exit(tc, "getOutboundVCFactory");
        }
        return vcf;
    }
1360369
protected Channel provideChannel() throws IOException {
        if (channel == null || !channel.isOpen()) {
            Connection connection = connectionFactory.newConnection();
            channel = connection.createChannel();
        }
        return channel;
    }
1114964
public void setInputChannels(java.util.Collection<Integer> inputChannels) {
        if (inputChannels == null) {
            this.inputChannels = null;
            return;
        }

        this.inputChannels = new java.util.ArrayList<Integer>(inputChannels);
    }
645962
@Override
    public synchronized ChannelData removeChannel(String channelName) throws ChannelException, ChainException {
        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) {
            Tr.entry(tc, "removeChannel: " + channelName);
        }
        if (null == channelName) {
            throw new InvalidChannelNameException("Input channel name is null");
        }

        // Fetch the channel data from the framework.
        ChannelDataImpl channelData = (ChannelDataImpl) channelDataMap.get(channelName);
        if (null == channelData) {
            if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) {
                // Due to timing windows (i.e. multiple channel providers going away), there is
                // a race to stop and/or clean up chains. This is not a notable condition: the chain can only be removed
                // once.
                Tr.exit(tc, "removeChannel: " + channelName, "Channel not found");
            }
            return null;
        }

        // Channel configs can only be removed if they are not in use by the
        // runtime.
        if (0 != channelData.getNumChildren()) {
            throw new ChannelException("Can't remove channel config " + channelName + " in runtime.  Destroy must happen first. ");
        }

        // Remove the chain config from the framework's map.
        this.channelDataMap.remove(channelName);

        // iterating chain configs will clear out live chains/channelRunningMap
        // Remove any chain configurations that refer to this channel.
        // Get a temp array so we can release the lock needed by removeChain.
        // This isn't a clone, but we should be okay holding the references.
        Object[] chainDataArray = this.chainDataMap.values().toArray();
        ChainDataImpl chainData = null;
        for (int i = 0; i < chainDataArray.length; i++) {
            chainData = (ChainDataImpl) chainDataArray[i];
            if (chainData.containsChannel(channelName)) {
                // Found reference to channel config. Remove chain config.
                // This ripples into the chain groups and cleans them up too.
                removeChain(chainData.getName());
            }
        }

        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) {
            Tr.exit(tc, "removeChannel");
        }
        return channelData;
    }
1199730
public static FastByteArrayOutputStream read(ReadableByteChannel channel) throws IORuntimeException {
		final FastByteArrayOutputStream out = new FastByteArrayOutputStream();
		copy(channel, Channels.newChannel(out));
		return out;
	}
451388
public com.google.api.ads.adwords.axis.v201809.cm.ShoppingProductChannel getChannel() {
        return channel;
    }