本文整理匯總了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();
}
}
示例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));
}
}
示例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));
}
}
示例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));
}
}
}