gpt4 book ai didi

org.apache.catalina.tribes.io.XByteBuffer.clear()方法的使用及代码示例

转载 作者:知者 更新时间:2024-03-20 16:23:40 26 4
gpt4 key购买 nike

本文整理了Java中org.apache.catalina.tribes.io.XByteBuffer.clear()方法的一些代码示例,展示了XByteBuffer.clear()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。XByteBuffer.clear()方法的具体详情如下:
包路径:org.apache.catalina.tribes.io.XByteBuffer
类名称:XByteBuffer
方法名:clear

XByteBuffer.clear介绍

[英]Resets the buffer
[中]重置缓冲区

代码示例

代码示例来源:origin: org.apache.catalina.springsource/com.springsource.org.apache.catalina.tribes.springsource

public synchronized void setMessage(byte[] data,int offset, int length) throws IOException {
  if ( data != null ) {
    current = data;
    remaining = length;
    ackbuf.clear();
    if ( writebuf != null ) writebuf.clear();
    else writebuf = getBuffer(length);
    if ( writebuf.capacity() < length ) writebuf = getBuffer(length);
    writebuf.put(data,offset,length);
    //writebuf.rewind();
    //set the limit so that we don't write non wanted data
    //writebuf.limit(length);
    writebuf.flip();
    if (isConnected()) {
      socketChannel.register(getSelector(), SelectionKey.OP_WRITE, this);
    }
  } 
}

代码示例来源:origin: codefollower/Tomcat-Research

public void reset() {
  if ( isConnected() && readbuf == null) {
    readbuf = getReadBuffer();
  }
  if ( readbuf != null ) readbuf.clear();
  if ( writebuf != null ) writebuf.clear();
  current = null;
  ackbuf.clear();
  remaining = 0;
  complete = false;
  setAttempt(0);
  setUdpBased(false);
}

代码示例来源:origin: org.apache.tomcat/tomcat-tribes

public void reset() {
  if ( isConnected() && readbuf == null) {
    readbuf = getReadBuffer();
  }
  if ( readbuf != null ) readbuf.clear();
  if ( writebuf != null ) writebuf.clear();
  current = null;
  ackbuf.clear();
  remaining = 0;
  complete = false;
  setAttempt(0);
  setUdpBased(false);
}

代码示例来源:origin: org.apache.catalina.springsource/com.springsource.org.apache.catalina.tribes.springsource

public void reset() {
  if ( isConnected() && readbuf == null) {
    readbuf = getReadBuffer();
  }
  if ( readbuf != null ) readbuf.clear();
  if ( writebuf != null ) writebuf.clear();
  current = null;
  ackbuf.clear();
  remaining = 0;
  complete = false;
  setAttempt(0);
  setRequestCount(0);
  setConnectTime(-1);
}

代码示例来源:origin: org.apache.geronimo.ext.tomcat/tribes

public synchronized void setMessage(byte[] data,int offset, int length) throws IOException {
  if ( data != null ) {
    current = data;
    remaining = length;
    ackbuf.clear();
    if ( writebuf != null ) writebuf.clear();
    else writebuf = getBuffer(length);
    if ( writebuf.capacity() < length ) writebuf = getBuffer(length);
        //TODO use ByteBuffer.wrap to avoid copying the data.
    writebuf.put(data,offset,length);
    //writebuf.rewind();
    //set the limit so that we don't write non wanted data
    //writebuf.limit(length);
    writebuf.flip();
    if (isConnected()) {
      if (isUdpBased())
        dataChannel.register(getSelector(), SelectionKey.OP_WRITE, this);
      else
        socketChannel.register(getSelector(), SelectionKey.OP_WRITE, this);
    }
  }
}

代码示例来源:origin: org.apache.geronimo.ext.tomcat/tribes

public void reset() {
  if ( isConnected() && readbuf == null) {
    readbuf = getReadBuffer();
  }
  if ( readbuf != null ) readbuf.clear();
  if ( writebuf != null ) writebuf.clear();
  current = null;
  ackbuf.clear();
  remaining = 0;
  complete = false;
  setAttempt(0);
  setRequestCount(0);
  setConnectTime(-1);
  setUdpBased(false);
}

代码示例来源:origin: codefollower/Tomcat-Research

public void setMessage(byte[] data,int offset, int length) throws IOException {
  if (data != null) {
    synchronized (this) {
      current = data;
      remaining = length;
      ackbuf.clear();
      if (writebuf != null) {
        writebuf.clear();
      } else {
        writebuf = getBuffer(length);
      }
      if (writebuf.capacity() < length) {
        writebuf = getBuffer(length);
      }
      // TODO use ByteBuffer.wrap to avoid copying the data.
      writebuf.put(data,offset,length);
      writebuf.flip();
      if (isConnected()) {
        if (isUdpBased())
          dataChannel.register(getSelector(), SelectionKey.OP_WRITE, this);
        else
          socketChannel.register(getSelector(), SelectionKey.OP_WRITE, this);
      }
    }
  }
}

代码示例来源:origin: org.apache.tomcat/tomcat-tribes

public void setMessage(byte[] data,int offset, int length) throws IOException {
  if (data != null) {
    synchronized (this) {
      current = data;
      remaining = length;
      ackbuf.clear();
      if (writebuf != null) {
        writebuf.clear();
      } else {
        writebuf = getBuffer(length);
      }
      if (writebuf.capacity() < length) {
        writebuf = getBuffer(length);
      }
      // TODO use ByteBuffer.wrap to avoid copying the data.
      writebuf.put(data,offset,length);
      writebuf.flip();
      if (isConnected()) {
        if (isUdpBased())
          dataChannel.register(getSelector(), SelectionKey.OP_WRITE, this);
        else
          socketChannel.register(getSelector(), SelectionKey.OP_WRITE, this);
      }
    }
  }
}

代码示例来源:origin: org.apache.geronimo.ext.tomcat/tribes

boolean ackReceived = false;
boolean failAckReceived = false;
ackbuf.clear();
int bytesRead = 0;
int i = soIn.read();
ackbuf.clear();

代码示例来源:origin: codefollower/Tomcat-Research

boolean ackReceived = false;
boolean failAckReceived = false;
ackbuf.clear();
int bytesRead = 0;
int i = soIn.read();
ackbuf.clear();

代码示例来源:origin: org.apache.catalina.springsource/com.springsource.org.apache.catalina.tribes.springsource

boolean ackReceived = false;
boolean failAckReceived = false;
ackbuf.clear();
int bytesRead = 0;
int i = soIn.read();
ackbuf.clear();

代码示例来源:origin: org.apache.tomcat/tomcat-tribes

boolean ackReceived = false;
boolean failAckReceived = false;
ackbuf.clear();
int bytesRead = 0;
int i = soIn.read();
ackbuf.clear();

代码示例来源:origin: org.apache.tomcat/tomcat-tribes

@Override
public void messageReceived(ChannelMessage msg) {
  try {
    byte[] data = msg.getMessage().getBytes();
    data = encryptionManager.decrypt(data);
    XByteBuffer xbb = msg.getMessage();
    // Completely replace the message with the decrypted one
    xbb.clear();
    xbb.append(data, 0, data.length);
    super.messageReceived(msg);
  } catch (GeneralSecurityException gse) {
    log.error(sm.getString("encryptInterceptor.decrypt.failed"), gse);
  }
}

代码示例来源:origin: org.apache.tomcat/tomcat-tribes

@Override
public void sendMessage(Member[] destination, ChannelMessage msg, InterceptorPayload payload)
    throws ChannelException {
  try {
    byte[] data = msg.getMessage().getBytes();
    // See #encrypt(byte[]) for an explanation of the return value
    byte[][] bytes = encryptionManager.encrypt(data);
    XByteBuffer xbb = msg.getMessage();
    // Completely replace the message
    xbb.clear();
    xbb.append(bytes[0], 0, bytes[0].length);
    xbb.append(bytes[1], 0, bytes[1].length);
    super.sendMessage(destination, msg, payload);
  } catch (GeneralSecurityException gse) {
    log.error(sm.getString("encryptInterceptor.encrypt.failed"));
    throw new ChannelException(gse);
  }
}

代码示例来源:origin: org.apache.geronimo.ext.tomcat/tribes

public void frag(Member[] destination, ChannelMessage msg, InterceptorPayload payload) throws ChannelException {
  int size = msg.getMessage().getLength();
  int count = ((size / maxSize )+(size%maxSize==0?0:1));
  ChannelMessage[] messages = new ChannelMessage[count];
  int remaining = size;
  for ( int i=0; i<count; i++ ) {
    ChannelMessage tmp = (ChannelMessage)msg.clone();
    int offset = (i*maxSize);
    int length = Math.min(remaining,maxSize);
    tmp.getMessage().clear();
    tmp.getMessage().append(msg.getMessage().getBytesDirect(),offset,length);
    //add the msg nr
    //tmp.getMessage().append(XByteBuffer.toBytes(i),0,4);
    tmp.getMessage().append(i);
    //add the total nr of messages
    //tmp.getMessage().append(XByteBuffer.toBytes(count),0,4);
    tmp.getMessage().append(count);
    //add true as the frag flag
    //byte[] flag = XByteBuffer.toBytes(true);
    //tmp.getMessage().append(flag,0,flag.length);
    tmp.getMessage().append(true);
    messages[i] = tmp;
    remaining -= length;
    
  }
  for ( int i=0; i<messages.length; i++ ) {
    super.sendMessage(destination,messages[i],payload);
  }
}

代码示例来源:origin: org.apache.tomcat/tomcat-tribes

public void frag(Member[] destination, ChannelMessage msg, InterceptorPayload payload) throws ChannelException {
  int size = msg.getMessage().getLength();
  int count = ((size / maxSize )+(size%maxSize==0?0:1));
  ChannelMessage[] messages = new ChannelMessage[count];
  int remaining = size;
  for ( int i=0; i<count; i++ ) {
    ChannelMessage tmp = (ChannelMessage)msg.clone();
    int offset = (i*maxSize);
    int length = Math.min(remaining,maxSize);
    tmp.getMessage().clear();
    tmp.getMessage().append(msg.getMessage().getBytesDirect(),offset,length);
    //add the msg nr
    //tmp.getMessage().append(XByteBuffer.toBytes(i),0,4);
    tmp.getMessage().append(i);
    //add the total nr of messages
    //tmp.getMessage().append(XByteBuffer.toBytes(count),0,4);
    tmp.getMessage().append(count);
    //add true as the frag flag
    //byte[] flag = XByteBuffer.toBytes(true);
    //tmp.getMessage().append(flag,0,flag.length);
    tmp.getMessage().append(true);
    messages[i] = tmp;
    remaining -= length;
  }
  for ( int i=0; i<messages.length; i++ ) {
    super.sendMessage(destination,messages[i],payload);
  }
}

代码示例来源:origin: org.apache.catalina.springsource/com.springsource.org.apache.catalina.tribes.springsource

public void frag(Member[] destination, ChannelMessage msg, InterceptorPayload payload) throws ChannelException {
  int size = msg.getMessage().getLength();
  int count = ((size / maxSize )+(size%maxSize==0?0:1));
  ChannelMessage[] messages = new ChannelMessage[count];
  int remaining = size;
  for ( int i=0; i<count; i++ ) {
    ChannelMessage tmp = (ChannelMessage)msg.clone();
    int offset = (i*maxSize);
    int length = Math.min(remaining,maxSize);
    tmp.getMessage().clear();
    tmp.getMessage().append(msg.getMessage().getBytesDirect(),offset,length);
    //add the msg nr
    //tmp.getMessage().append(XByteBuffer.toBytes(i),0,4);
    tmp.getMessage().append(i);
    //add the total nr of messages
    //tmp.getMessage().append(XByteBuffer.toBytes(count),0,4);
    tmp.getMessage().append(count);
    //add true as the frag flag
    //byte[] flag = XByteBuffer.toBytes(true);
    //tmp.getMessage().append(flag,0,flag.length);
    tmp.getMessage().append(true);
    messages[i] = tmp;
    remaining -= length;
    
  }
  for ( int i=0; i<messages.length; i++ ) {
    super.sendMessage(destination,messages[i],payload);
  }
}

代码示例来源:origin: codefollower/Tomcat-Research

public void frag(Member[] destination, ChannelMessage msg, InterceptorPayload payload) throws ChannelException {
  int size = msg.getMessage().getLength();
  int count = ((size / maxSize )+(size%maxSize==0?0:1));
  ChannelMessage[] messages = new ChannelMessage[count];
  int remaining = size;
  for ( int i=0; i<count; i++ ) {
    ChannelMessage tmp = (ChannelMessage)msg.clone();
    int offset = (i*maxSize);
    int length = Math.min(remaining,maxSize);
    tmp.getMessage().clear();
    tmp.getMessage().append(msg.getMessage().getBytesDirect(),offset,length);
    //add the msg nr
    //tmp.getMessage().append(XByteBuffer.toBytes(i),0,4);
    tmp.getMessage().append(i);
    //add the total nr of messages
    //tmp.getMessage().append(XByteBuffer.toBytes(count),0,4);
    tmp.getMessage().append(count);
    //add true as the frag flag
    //byte[] flag = XByteBuffer.toBytes(true);
    //tmp.getMessage().append(flag,0,flag.length);
    tmp.getMessage().append(true);
    messages[i] = tmp;
    remaining -= length;
  }
  for ( int i=0; i<messages.length; i++ ) {
    super.sendMessage(destination,messages[i],payload);
  }
}

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com