Java Code Examples for io.netty.buffer.ByteBuf.readLong()

The following are Jave code examples for showing how to use readLong() of the io.netty.buffer.ByteBuf class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
Example 1
Project: fastdfs-spring-boot   File: ReplierSupport.java   Source Code and License Vote up 6 votes
private void readHead(ByteBuf in) {
    if (in.readableBytes() < FastdfsConstants.FDFS_HEAD_LEN) {
        return;
    }
    length = in.readLong();
    byte cmd = in.readByte();
    byte errno = in.readByte();
    if (errno != 0) {
        if (errno == FastDFSResponseCode.ERR_NO_ENOENT)
        {
            throw new FastdfsNotFoundException();
        }
        throw new FastdfsException("Fastdfs responsed with an error, errno is " + errno);
    }
    if (cmd != RESP) {
        throw new FastdfsException("Expect response command code error : " + cmd);
    }
    long expectLength = expectLength();
    if (expectLength >= 0 && length != expectLength) {
        throw new FastdfsException("Expect response length : " + expectLength + " , but reply length : " + length);
    }
    atHead = false;
}
 
Example 2
Project: MeeCreeps   File: ActionOptions.java   Source Code and License Vote up 5 votes
public ActionOptions(ByteBuf buf) {
    int size = buf.readInt();
    actionOptions = new ArrayList<>();
    while (size > 0) {
        actionOptions.add(new MeeCreepActionType(NetworkTools.readStringUTF8(buf)));
        size--;
    }
    size = buf.readInt();
    maybeActionOptions = new ArrayList<>();
    while (size > 0) {
        maybeActionOptions.add(new MeeCreepActionType(NetworkTools.readStringUTF8(buf)));
        size--;
    }
    targetPos = NetworkTools.readPos(buf);
    targetSide = EnumFacing.VALUES[buf.readByte()];
    dimension = buf.readInt();
    if (buf.readBoolean()) {
        playerId = new UUID(buf.readLong(), buf.readLong());
    } else {
        playerId = null;
    }
    actionId = buf.readInt();
    timeout = buf.readInt();
    stage = Stage.values()[buf.readByte()];
    if (buf.readBoolean()) {
        task = new MeeCreepActionType(NetworkTools.readStringUTF8(buf));
    }
    furtherQuestionId = NetworkTools.readStringUTF8(buf);
    paused = buf.readBoolean();

    // Drops not needed on client so no persistance
}
 
Example 3
Project: angel   File: ArrayPartitionAggrResult.java   Source Code and License Vote up 5 votes
@Override
public void deserialize(ByteBuf buf) {
  int resultSize = buf.readInt();
  result = new double[resultSize];
  for (int i = 0; i < resultSize; i++) {
    result[i] = buf.readDouble();
  }

  int colSize = buf.readInt();
  cols = new long[colSize];
  for (int i = 0; i < colSize; i++) {
    cols[i] = buf.readLong();
  }
}
 
Example 4
Project: LagGoggles   File: ScanResult.java   Source Code and License Vote up 5 votes
@Override
public void fromBytes(ByteBuf buf) {
    worldID = buf.readInt();
    nanos = buf.readLong();
    name = ByteBufUtils.readUTF8String(buf);
    className = ByteBufUtils.readUTF8String(buf);
    isTileEntity = buf.readBoolean();
    if(isTileEntity){
        x = buf.readInt();
        y = buf.readInt();
        z = buf.readInt();
    }else {
        id = UUID.fromString(ByteBufUtils.readUTF8String(buf));
    }
}
 
Example 5
Project: minebox   File: HandshakePhase.java   Source Code and License Vote up 5 votes
private void receiveHandshakeOption(ChannelHandlerContext ctx, ByteBuf message) throws IOException {

        final long ihaveopt = message.readLong();
        if (ihaveopt != Protocol.IHAVEOPT)
            throw new IllegalArgumentException("Invalid negotiation magic != 'IHAVEOPT'");

        int option = message.readInt();
        long optionLen = message.readUnsignedInt();

        currentOption = option;
        currentOptionLen = optionLen;
        LOGGER.debug("currentOption {} currentOptionLen {}", currentOption, currentOptionLen);
        state = State.HS_OPTION_DATA;
    }
 
Example 6
Project: LibraSock   File: UserInfo.java   Source Code and License Vote up 5 votes
public static UserInfo decode(ByteBuf in) {
	UserInfo userInfo = new UserInfo();
	userInfo.uid = in.readLong();
	userInfo.cid = in.readInt();
	userInfo.eid = in.readInt();
	return userInfo;
}
 
Example 7
Project: spark_deep   File: TransportFrameDecoder.java   Source Code and License Vote up 5 votes
private long decodeFrameSize() {
  if (nextFrameSize != UNKNOWN_FRAME_SIZE || totalSize < LENGTH_SIZE) {
    return nextFrameSize;
  }

  // We know there's enough data. If the first buffer contains all the data, great. Otherwise,
  // hold the bytes for the frame length in a composite buffer until we have enough data to read
  // the frame size. Normally, it should be rare to need more than one buffer to read the frame
  // size.
  ByteBuf first = buffers.getFirst();
  if (first.readableBytes() >= LENGTH_SIZE) {
    nextFrameSize = first.readLong() - LENGTH_SIZE;
    totalSize -= LENGTH_SIZE;
    if (!first.isReadable()) {
      buffers.removeFirst().release();
    }
    return nextFrameSize;
  }

  while (frameLenBuf.readableBytes() < LENGTH_SIZE) {
    ByteBuf next = buffers.getFirst();
    int toRead = Math.min(next.readableBytes(), LENGTH_SIZE - frameLenBuf.readableBytes());
    frameLenBuf.writeBytes(next, toRead);
    if (!next.isReadable()) {
      buffers.removeFirst().release();
    }
  }

  nextFrameSize = frameLenBuf.readLong() - LENGTH_SIZE;
  totalSize -= LENGTH_SIZE;
  frameLenBuf.clear();
  return nextFrameSize;
}
 
Example 8
Project: API   File: PacketDropItem.java   Source Code and License Vote up 5 votes
@Override
public void fromBuffer(ByteBuf buf) throws IOException{
    this.playerId = new UUID(buf.readLong(), buf.readLong());

    DataSet set = new DataSet();
    NetUtil.readSetFromBuffer(set, buf);
    this.instance = ItemInstance.load(set);
}
 
Example 9
Project: Bewitchment   File: BrewMessage.java   Source Code and License Vote up 5 votes
@Override
public void fromBytes(ByteBuf buf) {
	target = new UUID(buf.readLong(), buf.readLong());
	int size = buf.readInt();

	effects = new LinkedHashMap<>(size);

	for (int i = 0; i < size; i++) {
		IBrew brew = BrewRegistry.getBrew(buf.readInt());
		effects.put(brew, new BrewEffect(brew, buf.readInt(), buf.readInt()));
	}
}
 
Example 10
Project: tools   File: OperationParameters.java   Source Code and License Vote up 5 votes
private OperationParameters(ByteBuf message) {
    cmdFlags = message.readShort();
    cmdType = message.readShort();
    cmdHandle = message.readLong();
    cmdOffset = message.readLong();
    cmdLength = message.readUnsignedInt();
    state = State.TM_RECEIVE_CMD_DATA;
}
 
Example 11
Project: sstable-adaptor   File: QueryOptions.java   Source Code and License Vote up 4 votes
public QueryOptions decode(ByteBuf body, ProtocolVersion version)
{
    ConsistencyLevel consistency = CBUtil.readConsistencyLevel(body);
    EnumSet<Flag> flags = Flag.deserialize(version.isGreaterOrEqualTo(ProtocolVersion.V5)
                                           ? (int)body.readUnsignedInt()
                                           : (int)body.readByte());

    List<ByteBuffer> values = Collections.<ByteBuffer>emptyList();
    List<String> names = null;
    if (flags.contains(Flag.VALUES))
    {
        if (flags.contains(Flag.NAMES_FOR_VALUES))
        {
            Pair<List<String>, List<ByteBuffer>> namesAndValues = CBUtil.readNameAndValueList(body, version);
            names = namesAndValues.left;
            values = namesAndValues.right;
        }
        else
        {
            values = CBUtil.readValueList(body, version);
        }
    }

    boolean skipMetadata = flags.contains(Flag.SKIP_METADATA);
    flags.remove(Flag.VALUES);
    flags.remove(Flag.SKIP_METADATA);

    SpecificOptions options = SpecificOptions.DEFAULT;
    if (!flags.isEmpty())
    {
        int pageSize = flags.contains(Flag.PAGE_SIZE) ? body.readInt() : -1;
        PagingState pagingState = flags.contains(Flag.PAGING_STATE) ? PagingState.deserialize(CBUtil.readValue(body), version) : null;
        ConsistencyLevel serialConsistency = flags.contains(Flag.SERIAL_CONSISTENCY) ? CBUtil.readConsistencyLevel(body) : ConsistencyLevel.SERIAL;
        long timestamp = Long.MIN_VALUE;
        if (flags.contains(Flag.TIMESTAMP))
        {
            long ts = body.readLong();
            if (ts == Long.MIN_VALUE)
                throw new ProtocolException(String.format("Out of bound timestamp, must be in [%d, %d] (got %d)", Long.MIN_VALUE + 1, Long.MAX_VALUE, ts));
            timestamp = ts;
        }

        options = new SpecificOptions(pageSize, pagingState, serialConsistency, timestamp);
    }
    DefaultQueryOptions opts = new DefaultQueryOptions(consistency, values, skipMetadata, options, version);
    return names == null ? opts : new OptionsWithNames(opts, names);
}
 
Example 12
Project: spark_deep   File: StreamResponse.java   Source Code and License Vote up 4 votes
public static org.apache.spark.network.protocol.StreamResponse decode(ByteBuf buf) {
  String streamId = Encoders.Strings.decode(buf);
  long byteCount = buf.readLong();
  return new org.apache.spark.network.protocol.StreamResponse(streamId, byteCount, null);
}
 
Example 13
Project: spark_deep   File: RpcFailure.java   Source Code and License Vote up 4 votes
public static org.apache.spark.network.protocol.RpcFailure decode(ByteBuf buf) {
  long requestId = buf.readLong();
  String errorString = Encoders.Strings.decode(buf);
  return new org.apache.spark.network.protocol.RpcFailure(requestId, errorString);
}
 
Example 14
Project: spark_deep   File: RpcRequest.java   Source Code and License Vote up 4 votes
public static org.apache.spark.network.protocol.RpcRequest decode(ByteBuf buf) {
  long requestId = buf.readLong();
  // See comment in encodedLength().
  buf.readInt();
  return new org.apache.spark.network.protocol.RpcRequest(requestId, new NettyManagedBuffer(buf.retain()));
}
 
Example 15
Project: FlexMC   File: MessageC01Ping.java   Source Code and License Vote up 4 votes
@Override
public void read( ByteBuf buf ) throws IOException {
    payload = buf.readLong();
}
 
Example 16
Project: Randores2   File: RandoresDefineBySeedRequest.java   Source Code and License Vote up 4 votes
@Override
public void fromBytes(ByteBuf buf) {
    this.seed = buf.readLong();
}
 
Example 17
Project: LagGoggles   File: TeleportRequest.java   Source Code and License Vote up 4 votes
@Override
public void fromBytes(ByteBuf buf){
    long most = buf.readLong();
    long least = buf.readLong();
    uuid = new UUID(most, least);
}
 
Example 18
Project: redis-cluster-watchdog   File: ClusterMessageDecoder.java   Source Code and License Vote up 4 votes
protected void decodeMessageV1(ClusterMessage hdr, ByteBuf in) {
    hdr.port = in.readUnsignedShort();
    hdr.type = in.readUnsignedShort();
    hdr.count = in.readUnsignedShort();
    hdr.currentEpoch = in.readLong();
    hdr.configEpoch = in.readLong();
    hdr.offset = in.readLong();
    hdr.name = truncate(in, CLUSTER_NODE_NULL_NAME);
    in.readBytes(hdr.slots);
    hdr.master = truncate(in, CLUSTER_NODE_NULL_NAME);
    hdr.ip = truncate(in, CLUSTER_NODE_NULL_IP);
    in.skipBytes(34);
    hdr.busPort = in.readUnsignedShort();
    hdr.flags = in.readUnsignedShort();
    hdr.state = valueOf(in.readByte());
    in.readBytes(hdr.messageFlags);
    switch (hdr.type) {
        case CLUSTERMSG_TYPE_PING:
        case CLUSTERMSG_TYPE_PONG:
        case CLUSTERMSG_TYPE_MEET:
            for (int i = 0; i < hdr.count; i++) {
                ClusterMessageDataGossip gossip = new ClusterMessageDataGossip();
                gossip.name = truncate(in, CLUSTER_NODE_NULL_NAME);
                gossip.pingTime = in.readInt() * 1000L;
                gossip.pongTime = in.readInt() * 1000L;
                gossip.ip = truncate(in, CLUSTER_NODE_NULL_IP);
                gossip.port = in.readUnsignedShort();
                gossip.busPort = in.readUnsignedShort();
                gossip.flags = in.readUnsignedShort();
                in.skipBytes(4);
                hdr.data.gossips.add(gossip);
            }
            break;
        case CLUSTERMSG_TYPE_FAIL:
            hdr.data.fail.name = truncate(in, CLUSTER_NODE_NULL_NAME);
            break;
        case CLUSTERMSG_TYPE_PUBLISH:
            hdr.data.publish.channelLength = in.readInt();
            hdr.data.publish.messageLength = in.readInt();
            in.readBytes(hdr.data.publish.bulkData);
            break;
        case CLUSTERMSG_TYPE_UPDATE:
            hdr.data.config.configEpoch = in.readLong();
            hdr.data.config.name = truncate(in, CLUSTER_NODE_NULL_NAME);
            in.readBytes(hdr.data.config.slots);
            break;
        default:
            break;
    }
}
 
Example 19
Project: API   File: WorldInfo.java   Source Code and License Vote up 4 votes
@ApiInternal
public void fromBuffer(ByteBuf buf){
    this.seed = buf.readLong();
    this.totalTimeInWorld = buf.readInt();
    this.currentWorldTime = buf.readInt();
}
 
Example 20
Project: Randores2   File: RandoresBeginDataTransferRequest.java   Source Code and License Vote up 4 votes
@Override
public void fromBytes(ByteBuf buf) {
    this.id = new UUID(buf.readLong(), buf.readLong());
}