Package java.io

Examples of java.io.DataOutputStream.writeShort()


  static ByteBuffer toByteBufferV2(TransactionEventRecord record) {
    ByteArrayOutputStream byteOutput = new ByteArrayOutputStream(512);
    DataOutputStream dataOutput = new DataOutputStream(byteOutput);
    try {
      dataOutput.writeInt(MAGIC_HEADER);
      dataOutput.writeShort(record.getRecordType());
      dataOutput.writeLong(record.getTransactionID());
      dataOutput.writeLong(record.getLogWriteOrderID());
      record.write(dataOutput);
      dataOutput.flush();
      // TODO toByteArray does an unneeded copy
View Full Code Here


    if (_subMessages != null && includeSubMessages) {
      for (Message _subMessage : _subMessages) {
        byte[] temp = _subMessage.encodeToPacket(false, true);
        try {
          dos.writeShort(temp.length);
          dos.write(temp);
        } catch (IOException e) {
          e.printStackTrace();
          throw new IllegalStateException(e.getMessage());
        }
View Full Code Here

                        localDataOutputStream = getDataOutputStream();
                     // now localDataOutputStream cannot be null from here down.

                     //===================================================
                     // Do the write ... first the size
                     localDataOutputStream.writeShort( size );
                     rawByteCount += 2; // sizeof short
                     if (size == -1)
                     {
                        localDataOutputStream.writeInt(size = messageBytes.length);
                        rawByteCount += 4; // sizeof int
View Full Code Here

        final ByteArrayOutputStream boas = new ByteArrayOutputStream();
        final DataOutputStream dos = new DataOutputStream(boas);

        try {
            dos.writeByte(command);
            dos.writeShort(deviceToken.length);
            dos.write(deviceToken);
            dos.writeShort(payload.length);
            dos.write(payload);
            return boas.toByteArray();
        } catch (final IOException e) {
View Full Code Here

        try {
            dos.writeByte(command);
            dos.writeShort(deviceToken.length);
            dos.write(deviceToken);
            dos.writeShort(payload.length);
            dos.write(payload);
            return boas.toByteArray();
        } catch (final IOException e) {
            throw new AssertionError();
        }
View Full Code Here

        try {
            dos.writeByte(command);
            dos.writeInt(identifier);
            dos.writeInt(expiryTime);
            dos.writeShort(deviceToken.length);
            dos.write(deviceToken);
            dos.writeShort(payload.length);
            dos.write(payload);
            return boas.toByteArray();
        } catch (final IOException e) {
View Full Code Here

            dos.writeByte(command);
            dos.writeInt(identifier);
            dos.writeInt(expiryTime);
            dos.writeShort(deviceToken.length);
            dos.write(deviceToken);
            dos.writeShort(payload.length);
            dos.write(payload);
            return boas.toByteArray();
        } catch (final IOException e) {
            throw new AssertionError();
        }
View Full Code Here

        socket.getOutputStream());
    for (Entry<byte[], Date> entry : inactiveDevices.entrySet()) {
      int time = (int) (entry.getValue().getTime() / 1000L);
      dataStream.writeInt(time);
      byte[] bytes = entry.getKey();
      dataStream.writeShort(bytes.length);
      dataStream.write(bytes);
    }
    dataStream.close();
  }
}
View Full Code Here

        DatanodeInfo srcNode = new DatanodeInfo(dnRegistration);

        //
        // Header info
        //
        out.writeShort(DataTransferProtocol.DATA_TRANSFER_VERSION);
        out.writeByte(DataTransferProtocol.OP_WRITE_BLOCK);
        out.writeLong(b.getBlockId());
        out.writeLong(b.getGenerationStamp());
        out.writeInt(0);           // no pipelining
        out.writeBoolean(false);   // not part of recovery
View Full Code Here

      Socket s = new Socket(target.getAddress(), target.getPort());
        //write the header.
      DataOutputStream out = new DataOutputStream(
          s.getOutputStream());

      out.writeShort( DataTransferProtocol.DATA_TRANSFER_VERSION );
      out.write( DataTransferProtocol.OP_WRITE_BLOCK );
      out.writeLong( block.getBlock().getBlockId());
      out.writeLong( block.getBlock().getGenerationStamp() );
      out.writeInt(1);
      out.writeBoolean( false );       // recovery flag
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.