Java Code Examples for org.apache.catalina.tribes.io.XByteBuffer#toInt()

The following examples show how to use org.apache.catalina.tribes.io.XByteBuffer#toInt() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: OrderInterceptor.java    From Tomcat8-Source-Read with MIT License 6 votes vote down vote up
@Override
public void messageReceived(ChannelMessage msg) {
    if ( !okToProcess(msg.getOptions()) ) {
        super.messageReceived(msg);
        return;
    }
    int msgnr = XByteBuffer.toInt(msg.getMessage().getBytesDirect(),msg.getMessage().getLength()-4);
    msg.getMessage().trim(4);
    MessageOrder order = new MessageOrder(msgnr,(ChannelMessage)msg.deepclone());
    inLock.writeLock().lock();
    try {
        if ( processIncoming(order) ) processLeftOvers(msg.getAddress(),false);
    } finally {
        inLock.writeLock().unlock();
    }
}
 
Example 2
Source File: OrderInterceptor.java    From tomcatsrc with Apache License 2.0 6 votes vote down vote up
@Override
public void messageReceived(ChannelMessage msg) {
    if ( !okToProcess(msg.getOptions()) ) {
        super.messageReceived(msg);
        return;
    }
    int msgnr = XByteBuffer.toInt(msg.getMessage().getBytesDirect(),msg.getMessage().getLength()-4);
    msg.getMessage().trim(4);
    MessageOrder order = new MessageOrder(msgnr,(ChannelMessage)msg.deepclone());
    try {
        inLock.writeLock().lock();
        if ( processIncoming(order) ) processLeftOvers(msg.getAddress(),false);
    }finally {
        inLock.writeLock().unlock();
    }
}
 
Example 3
Source File: OrderInterceptor.java    From Tomcat7.0.67 with Apache License 2.0 6 votes vote down vote up
@Override
public void messageReceived(ChannelMessage msg) {
    if ( !okToProcess(msg.getOptions()) ) {
        super.messageReceived(msg);
        return;
    }
    int msgnr = XByteBuffer.toInt(msg.getMessage().getBytesDirect(),msg.getMessage().getLength()-4);
    msg.getMessage().trim(4);
    MessageOrder order = new MessageOrder(msgnr,(ChannelMessage)msg.deepclone());
    try {
        inLock.writeLock().lock();
        if ( processIncoming(order) ) processLeftOvers(msg.getAddress(),false);
    }finally {
        inLock.writeLock().unlock();
    }
}
 
Example 4
Source File: FragmentationInterceptor.java    From Tomcat7.0.67 with Apache License 2.0 5 votes vote down vote up
public void addMessage(ChannelMessage msg) {
    //remove the total messages
    msg.getMessage().trim(4);
    //get the msg nr
    int nr = XByteBuffer.toInt(msg.getMessage().getBytesDirect(),msg.getMessage().getLength()-4);
    //remove the msg nr
    msg.getMessage().trim(4);
    frags[nr] = msg.getMessage();
    
}
 
Example 5
Source File: FragmentationInterceptor.java    From tomcatsrc with Apache License 2.0 5 votes vote down vote up
public void addMessage(ChannelMessage msg) {
    //remove the total messages
    msg.getMessage().trim(4);
    //get the msg nr
    int nr = XByteBuffer.toInt(msg.getMessage().getBytesDirect(),msg.getMessage().getLength()-4);
    //remove the msg nr
    msg.getMessage().trim(4);
    frags[nr] = msg.getMessage();
    
}
 
Example 6
Source File: NonBlockingCoordinator.java    From Tomcat8-Source-Read with MIT License 5 votes vote down vote up
public void parse() {
    //header
    int offset = 16;
    //leader
    int ldrLen = XByteBuffer.toInt(buf.getBytesDirect(),offset);
    offset += 4;
    byte[] ldr = new byte[ldrLen];
    System.arraycopy(buf.getBytesDirect(),offset,ldr,0,ldrLen);
    leader = MemberImpl.getMember(ldr);
    offset += ldrLen;
    //source
    int srcLen = XByteBuffer.toInt(buf.getBytesDirect(),offset);
    offset += 4;
    byte[] src = new byte[srcLen];
    System.arraycopy(buf.getBytesDirect(),offset,src,0,srcLen);
    source = MemberImpl.getMember(src);
    offset += srcLen;
    //view
    int mbrCount = XByteBuffer.toInt(buf.getBytesDirect(),offset);
    offset += 4;
    view = new Member[mbrCount];
    for (int i=0; i<view.length; i++ ) {
        int mbrLen = XByteBuffer.toInt(buf.getBytesDirect(),offset);
        offset += 4;
        byte[] mbr = new byte[mbrLen];
        System.arraycopy(buf.getBytesDirect(), offset, mbr, 0, mbrLen);
        view[i] = MemberImpl.getMember(mbr);
        offset += mbrLen;
    }
    //id
    this.id = new UniqueId(buf.getBytesDirect(),offset,16);
    offset += 16;
    type = new byte[16];
    System.arraycopy(buf.getBytesDirect(), offset, type, 0, type.length);
    offset += 16;

}
 
Example 7
Source File: NonBlockingCoordinator.java    From Tomcat7.0.67 with Apache License 2.0 5 votes vote down vote up
public void parse() {
    //header
    int offset = 16;
    //leader
    int ldrLen = XByteBuffer.toInt(buf.getBytesDirect(),offset);
    offset += 4;
    byte[] ldr = new byte[ldrLen];
    System.arraycopy(buf.getBytesDirect(),offset,ldr,0,ldrLen);
    leader = MemberImpl.getMember(ldr);
    offset += ldrLen;
    //source
    int srcLen = XByteBuffer.toInt(buf.getBytesDirect(),offset);
    offset += 4;
    byte[] src = new byte[srcLen];
    System.arraycopy(buf.getBytesDirect(),offset,src,0,srcLen);
    source = MemberImpl.getMember(src);
    offset += srcLen;
    //view
    int mbrCount = XByteBuffer.toInt(buf.getBytesDirect(),offset);
    offset += 4;
    view = new MemberImpl[mbrCount];
    for (int i=0; i<view.length; i++ ) {
        int mbrLen = XByteBuffer.toInt(buf.getBytesDirect(),offset);
        offset += 4;
        byte[] mbr = new byte[mbrLen];
        System.arraycopy(buf.getBytesDirect(), offset, mbr, 0, mbrLen);
        view[i] = MemberImpl.getMember(mbr);
        offset += mbrLen;
    }
    //id
    this.id = new UniqueId(buf.getBytesDirect(),offset,16);
    offset += 16;
    type = new byte[16];
    System.arraycopy(buf.getBytesDirect(), offset, type, 0, type.length);
    offset += 16;
    
}
 
Example 8
Source File: FragmentationInterceptor.java    From Tomcat8-Source-Read with MIT License 5 votes vote down vote up
public void addMessage(ChannelMessage msg) {
    //remove the total messages
    msg.getMessage().trim(4);
    //get the msg nr
    int nr = XByteBuffer.toInt(msg.getMessage().getBytesDirect(),msg.getMessage().getLength()-4);
    //remove the msg nr
    msg.getMessage().trim(4);
    frags[nr] = msg.getMessage();

}
 
Example 9
Source File: TestUdpPackages.java    From Tomcat8-Source-Read with MIT License 4 votes vote down vote up
public int getNumber() {
    if (!hasNr) return -1;
    return XByteBuffer.toInt(this.data, 0);
}
 
Example 10
Source File: TestMulticastPackages.java    From Tomcat8-Source-Read with MIT License 4 votes vote down vote up
public int getNumber() {
    if (!hasNr) return -1;
    return XByteBuffer.toInt(this.data, 0);
}
 
Example 11
Source File: FragmentationInterceptor.java    From Tomcat7.0.67 with Apache License 2.0 4 votes vote down vote up
public FragCollection(ChannelMessage msg) {
    //get the total messages
    int count = XByteBuffer.toInt(msg.getMessage().getBytesDirect(),msg.getMessage().getLength()-4);
    frags = new XByteBuffer[count];
    this.msg = msg;
}
 
Example 12
Source File: FragmentationInterceptor.java    From Tomcat8-Source-Read with MIT License 4 votes vote down vote up
@Override
public int hashCode() {
    return XByteBuffer.toInt(uniqueId,0);
}
 
Example 13
Source File: FragmentationInterceptor.java    From Tomcat7.0.67 with Apache License 2.0 4 votes vote down vote up
@Override
public int hashCode() {
    return XByteBuffer.toInt(uniqueId,0);
}
 
Example 14
Source File: TestMulticastPackages.java    From Tomcat7.0.67 with Apache License 2.0 4 votes vote down vote up
public int getNumber() {
    if (!hasNr) return -1;
    return XByteBuffer.toInt(this.data, 0);
}
 
Example 15
Source File: TestUdpPackages.java    From Tomcat7.0.67 with Apache License 2.0 4 votes vote down vote up
public int getNumber() {
    if (!hasNr) return -1;
    return XByteBuffer.toInt(this.data, 0);
}
 
Example 16
Source File: TestUdpPackages.java    From tomcatsrc with Apache License 2.0 4 votes vote down vote up
public int getNumber() {
    if (!hasNr) return -1;
    return XByteBuffer.toInt(this.data, 0);
}
 
Example 17
Source File: FragmentationInterceptor.java    From tomcatsrc with Apache License 2.0 4 votes vote down vote up
public FragCollection(ChannelMessage msg) {
    //get the total messages
    int count = XByteBuffer.toInt(msg.getMessage().getBytesDirect(),msg.getMessage().getLength()-4);
    frags = new XByteBuffer[count];
    this.msg = msg;
}
 
Example 18
Source File: FragmentationInterceptor.java    From Tomcat8-Source-Read with MIT License 4 votes vote down vote up
public FragCollection(ChannelMessage msg) {
    //get the total messages
    int count = XByteBuffer.toInt(msg.getMessage().getBytesDirect(),msg.getMessage().getLength()-4);
    frags = new XByteBuffer[count];
    this.msg = msg;
}
 
Example 19
Source File: FragmentationInterceptor.java    From tomcatsrc with Apache License 2.0 4 votes vote down vote up
@Override
public int hashCode() {
    return XByteBuffer.toInt(uniqueId,0);
}
 
Example 20
Source File: TestMulticastPackages.java    From tomcatsrc with Apache License 2.0 4 votes vote down vote up
public int getNumber() {
    if (!hasNr) return -1;
    return XByteBuffer.toInt(this.data, 0);
}