当前位置: 首页>>代码示例>>Java>>正文


Java Channel.isOpen方法代码示例

本文整理汇总了Java中org.jboss.netty.channel.Channel.isOpen方法的典型用法代码示例。如果您正苦于以下问题:Java Channel.isOpen方法的具体用法?Java Channel.isOpen怎么用?Java Channel.isOpen使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.jboss.netty.channel.Channel的用法示例。


在下文中一共展示了Channel.isOpen方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: close

import org.jboss.netty.channel.Channel; //导入方法依赖的package包/类
public synchronized void close() {
    List<ChannelFuture> futures = new ArrayList<>();
    for (Channel channel : allChannels) {
        try {
            if (channel != null && channel.isOpen()) {
                futures.add(channel.close());
            }
        } catch (Exception e) {
            //ignore
        }
    }
    for (ChannelFuture future : futures) {
        future.awaitUninterruptibly();
    }
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:16,代码来源:NettyTransport.java

示例2: sendLsp

import org.jboss.netty.channel.Channel; //导入方法依赖的package包/类
/**
 * Sends LS PDU message to channel.
 *
 * @param lsp     LS PDU message instance
 * @param channel channel instance
 */
private void sendLsp(LsPdu lsp, Channel channel) {
    byte[] lspBytes = lsp.asBytes();
    lspBytes = IsisUtil.addLengthAndMarkItInReserved(lspBytes, IsisConstants.LENGTHPOSITION,
                                                     IsisConstants.LENGTHPOSITION + 1,
                                                     IsisConstants.RESERVEDPOSITION);
    lspBytes = IsisUtil.addChecksum(lspBytes, IsisConstants.CHECKSUMPOSITION,
                                    IsisConstants.CHECKSUMPOSITION + 1);
    //write to the channel
    if (channel != null && channel.isConnected() && channel.isOpen()) {
        channel.write(IsisUtil.framePacket(lspBytes, interfaceIndex));
    }
}
 
开发者ID:shlee89,项目名称:athena,代码行数:19,代码来源:DefaultIsisInterface.java

示例3: sendPsnPduMessage

import org.jboss.netty.channel.Channel; //导入方法依赖的package包/类
/**
 * Sends the partial sequence number PDU.
 *
 * @param lspEntryRequestList list of lsp entry request
 * @param isisPduType         intermediate system PDU type
 * @param channel             netty channel instance
 */
private void sendPsnPduMessage(List<LspEntry> lspEntryRequestList, IsisPduType isisPduType, Channel channel) {
    IsisHeader isisHeader = new LspGenerator().getHeader(isisPduType);
    Psnp psnp = new Psnp(isisHeader);
    psnp.setSourceId(lspKeyP2P(this.systemId));
    TlvHeader tlvHeader = new TlvHeader();
    tlvHeader.setTlvType(TlvType.LSPENTRY.value());
    tlvHeader.setTlvLength(0);
    LspEntriesTlv lspEntriesTlv = new LspEntriesTlv(tlvHeader);
    for (LspEntry lspEntry : lspEntryRequestList) {
        lspEntry.setLspChecksum(0);
        lspEntry.setLspSequenceNumber(0);
        lspEntry.setRemainingTime(0);
        lspEntriesTlv.addLspEntry(lspEntry);
    }
    psnp.addTlv(lspEntriesTlv);
    //write it to channel buffer.
    byte[] psnpBytes = psnp.asBytes();
    psnpBytes = IsisUtil.addLengthAndMarkItInReserved(psnpBytes, IsisConstants.LENGTHPOSITION,
                                                      IsisConstants.LENGTHPOSITION + 1,
                                                      IsisConstants.RESERVEDPOSITION);
    flagValue = false;
    //write to the channel
    if (channel != null && channel.isConnected() && channel.isOpen()) {
        channel.write(IsisUtil.framePacket(psnpBytes, interfaceIndex));
    }
}
 
开发者ID:shlee89,项目名称:athena,代码行数:34,代码来源:DefaultIsisInterface.java

示例4: processLsPduMessage

import org.jboss.netty.channel.Channel; //导入方法依赖的package包/类
/**
 * Processes LS PDU message.
 *
 * @param isisMessage LS pdu message instance
 * @param channel     channel instance
 */
public void processLsPduMessage(IsisMessage isisMessage, Channel channel) {
    log.debug("Enters processLsPduMessage ...!!!");
    IsisNeighbor neighbor = neighbouringRouter(isisMessage.sourceMac());
    if (networkType == IsisNetworkType.BROADCAST && neighbor == null) {
        return;
    }

    LsPdu lsPdu = (LsPdu) isisMessage;
    LspWrapper wrapper = isisLsdb.findLsp(lsPdu.isisPduType(), lsPdu.lspId());
    if (wrapper == null || isisLsdb.isNewerOrSameLsp(lsPdu, wrapper.lsPdu()).equalsIgnoreCase("latest")) {
        if (wrapper != null) {               // verify if the LSA - is your own LSA - get system ID and compare LSP
            String lspKey = isisLsdb.lspKey(systemId);
            if (lsPdu.lspId().equals(lspKey)) {
                lsPdu.setSequenceNumber(lsPdu.sequenceNumber() + 1);
                if (lsPdu.pduType() == IsisPduType.L1LSPDU.value()) {
                    // setting the ls sequence number
                    isisLsdb.setL1LspSeqNo(lsPdu.sequenceNumber());
                } else if (lsPdu.pduType() == IsisPduType.L2LSPDU.value()) {
                    // setting the ls sequence number
                    isisLsdb.setL2LspSeqNo(lsPdu.sequenceNumber());
                }
                isisLsdb.addLsp(lsPdu, true, this);
                sendLsp(lsPdu, channel);
            } else {
                isisLsdb.addLsp(lsPdu, false, this);
            }


        } else {
            //not exist in the database or latest, then add it in database
            isisLsdb.addLsp(lsPdu, false, this);
        }
    }

    //If network type is P2P, acknowledge with a PSNP
    if (networkType() == IsisNetworkType.P2P) {
        IsisPduType psnpType = null;
        if (IsisPduType.get(lsPdu.pduType()) == IsisPduType.L1LSPDU) {
            psnpType = IsisPduType.L1PSNP;
        } else if (IsisPduType.get(lsPdu.pduType()) == IsisPduType.L2LSPDU) {
            psnpType = IsisPduType.L2PSNP;
        }
        IsisHeader isisHeader = new LspGenerator().getHeader(psnpType);
        Psnp psnp = new Psnp(isisHeader);
        psnp.setSourceId(lspKeyP2P(this.systemId));
        TlvHeader tlvHeader = new TlvHeader();
        tlvHeader.setTlvType(TlvType.LSPENTRY.value());
        tlvHeader.setTlvLength(0);
        LspEntriesTlv lspEntriesTlv = new LspEntriesTlv(tlvHeader);
        LspEntry lspEntry = new LspEntry();
        lspEntry.setLspChecksum(lsPdu.checkSum());
        lspEntry.setLspId(lsPdu.lspId());
        lspEntry.setLspSequenceNumber(lsPdu.sequenceNumber());
        lspEntry.setRemainingTime(lsPdu.remainingLifeTime());
        lspEntriesTlv.addLspEntry(lspEntry);
        psnp.addTlv(lspEntriesTlv);

        //write it to channel buffer.
        byte[] psnpBytes = psnp.asBytes();
        psnpBytes = IsisUtil.addLengthAndMarkItInReserved(psnpBytes, IsisConstants.LENGTHPOSITION,
                                                          IsisConstants.LENGTHPOSITION + 1,
                                                          IsisConstants.RESERVEDPOSITION);
        flagValue = false;
        //write to the channel
        if (channel != null && channel.isConnected() && channel.isOpen()) {
            channel.write(IsisUtil.framePacket(psnpBytes, interfaceIndex));
        }
    }
}
 
开发者ID:shlee89,项目名称:athena,代码行数:76,代码来源:DefaultIsisInterface.java


注:本文中的org.jboss.netty.channel.Channel.isOpen方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。