Package java.io

Examples of java.io.DataOutputStream.writeShort()


         ByteArrayOutputStream bos = new ByteArrayOutputStream((int)fileHeader.getWorkSize());
         DataOutputStream os = new DataOutputStream(bos);

         // Write out the Values
         for ( int i = 0; i < values.length; i++ ) {
            os.writeShort(values[i].getLength());
            values[i].streamTo(os);
         }

         // Write out the pointers
         for ( int i = 0; i < ptrs.length; i++ )
View Full Code Here


      BlockType bt = BlockType.values()[blockTypeOrdinal];
      DataOutputStream dos = hbw.startWriting(bt);
      int size = rand.nextInt(500);
      for (int j = 0; j < size; ++j) {
        // This might compress well.
        dos.writeShort(i + 1);
        dos.writeInt(j + 1);
      }

      if (expectedOffsets != null)
        expectedOffsets.add(os.getPos());
View Full Code Here

  static ByteBuffer toByteBuffer(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());
      record.write(dataOutput);
      dataOutput.flush();
      // TODO toByteArray does an unneeded copy
      return ByteBuffer.wrap(byteOutput.toByteArray());
View Full Code Here

  }
  private DataInput toDataInput(int header, TransactionEventRecord record) throws IOException {
    ByteArrayOutputStream byteOutput = new ByteArrayOutputStream();
    DataOutputStream dataOutput = new DataOutputStream(byteOutput);
    dataOutput.writeInt(header);
    dataOutput.writeShort(record.getRecordType());
    dataOutput.writeLong(record.getTransactionID());
    record.write(dataOutput);
    ByteArrayInputStream byteInput = new ByteArrayInputStream(byteOutput.toByteArray());
    DataInputStream dataInput = new DataInputStream(byteInput);
    return dataInput;
View Full Code Here

       
        BinaryMessage m = new BinaryMessage(fromHostPort.length() * 2 + 10);
       
        DataOutputStream os = m.getOs();
        os.writeInt(BinaryMessage.TYPE_MSGCONTROL);
        os.writeShort(controlType);
        os.writeUTF(fromHostPort);
        os.flush();
       
        msgList.add(m);
    }
View Full Code Here

            DataOutputStream out=new DataOutputStream(out_stream);
            try {
                if(obj instanceof MethodCall) {
                    out.writeByte(METHOD_CALL);
                    MethodCall call=(MethodCall)obj;
                    out.writeShort(call.getId());
                    Object[] args=call.getArgs();
                    if(args == null || args.length == 0) {
                        out.writeShort(0);
                    }
                    else {
View Full Code Here

                    out.writeByte(METHOD_CALL);
                    MethodCall call=(MethodCall)obj;
                    out.writeShort(call.getId());
                    Object[] args=call.getArgs();
                    if(args == null || args.length == 0) {
                        out.writeShort(0);
                    }
                    else {
                        out.writeShort(args.length);
                        for(int i=0; i < args.length; i++) {
                            Util.objectToStream(args[i], out);
View Full Code Here

                    Object[] args=call.getArgs();
                    if(args == null || args.length == 0) {
                        out.writeShort(0);
                    }
                    else {
                        out.writeShort(args.length);
                        for(int i=0; i < args.length; i++) {
                            Util.objectToStream(args[i], out);
                        }
                    }
                }
View Full Code Here

      try {
        blockSender = new BlockSender(namespaceId, block, startOffset, length,
            datanode.ignoreChecksumWhenRead, true, true, false, datanode,
            clientTraceFmt);
     } catch(IOException e) {
        out.writeShort(DataTransferProtocol.OP_STATUS_ERROR);
        throw e;
      }
      if (ClientTraceLog.isInfoEnabled()) {
        ClientTraceLog.info("Sending blocks. namespaceId: "
            + namespaceId + " block: " + block + " to " + remoteAddress);
View Full Code Here

      if (ClientTraceLog.isInfoEnabled()) {
        ClientTraceLog.info("Sending blocks. namespaceId: "
            + namespaceId + " block: " + block + " to " + remoteAddress);
      }

      out.writeShort(DataTransferProtocol.OP_STATUS_SUCCESS); // send op status
      long read = blockSender.sendBlock(out, baseStream, null); // send data

      boolean isBlockFinalized = datanode.data.isBlockFinalized(namespaceId, block);
      long blockLength = datanode.data.getVisibleLength(namespaceId, block);
      out.writeBoolean(isBlockFinalized);
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.