Returns unique connection information as a byte array.

@param writeBuffer
ByteBuffer to write ConnectionHandle bytes into.
359793
public void putBytes(ByteBuffer writeBuffer) {

        if (writeBuffer.remaining() < CONNECTION_ID_LENGTH) {
            throw new IllegalArgumentException("Could not add ConnectionHandle to byte buffer: not enough space.");
        }

        writeBuffer.putLong(this.connID);
        writeBuffer.putInt(this.seqNum);
        writeBuffer.put(this.connHandleCreatorId);
        writeBuffer.put(this.myFlags);
        writeBuffer.put(this.myType);
        writeBuffer.put((byte) 0xFF); // place holder - empty flag
    }
1372173
public static <T extends Writable> byte[] writableToByteArray(T writable)
      throws IOException {
    ByteArrayOutputStream bos = new ByteArrayOutputStream();
    DataOutputStream dos = new DataOutputStream(bos);
    writable.write(dos);
    dos.flush();
    return bos.toByteArray();
  }
273298
public void writeBytes(byte[] buffer)
        throws IOException
    {
        if (buffer == null) {
            if (SIZE < _offset + 16)
                flushBuffer();

            _buffer[_offset++] = 'N';
        }
        else
            writeBytes(buffer, 0, buffer.length);
    }
973096
@Override
  public int write(ByteBuffer src) {
    int toTransfer = Math.min(src.remaining(), data.length - offset);
    src.get(data, offset, toTransfer);
    offset += toTransfer;
    return toTransfer;
  }
942804
private ByteBuf writeResponse(ByteBuf buffer, Object request, ThreadContext context) {
    context.serializer().writeObject(request, OUTPUT.get().setByteBuf(buffer));
    return buffer;
  }
565593
@Override
  public void write(Buffer buffer, boolean isEnd)
    throws IOException
  {
    if (_s == null) {
      buffer.free();
      return;
    }
    
    try {
      _needsFlush = true;
      
      if (buffer.isDirect()) {
        _totalWriteBytes += buffer.length(); 
        _s.write(buffer.direct());
        return;
      }
      
      _totalWriteBytes += buffer.length();
      
      while (buffer.length() > 0) {
        _writeBuffer.clear();
        
        buffer.read(_writeBuffer);
        _writeBuffer.flip();
        
        _s.write(_writeBuffer);
      }
    } catch (IOException e) {
      IOException exn = ClientDisconnectException.create(this + ":" + e, e);
      
      try {
        close();
      } catch (IOException e1) {
      }

      throw exn;
    } finally {
      buffer.free();
    }
  }
1277707
public ByteBuffer serializeToByteBuffer() throws IOException {
    final ByteArrayOutputStream stream = new ByteArrayOutputStream();
    final Encoder encoder = EncoderFactory.get().binaryEncoder(stream, null);
    final DatumWriter writer = new GenericDatumWriter<GenericRecord>();
    writer.setSchema(createAvroSchema());
    final AvroParquetReader<GenericRecord> reader = createAvroReader();

    GenericRecord record = reader.read();
    while (record != null) {
      writer.write(record, encoder);
      record = reader.read();
    }

    try {
      reader.close();
    } catch (IOException ex){
      LOG.log(Level.SEVERE, ex.getMessage());
      throw ex;
    }

    encoder.flush();
    final ByteBuffer buf = ByteBuffer.wrap(stream.toByteArray());
    buf.order(ByteOrder.LITTLE_ENDIAN);
    return buf;
  }
1041182
private void writeConnection(Definition def, Writer out, int indent) throws IOException
   {
      writeWithIndent(out, indent, "/**\n");
      writeWithIndent(out, indent, " * Gets a connection to an EIS instance. \n");
      writeWithIndent(out, indent, " *\n");
      writeWithIndent(out, indent, " * @return Connection instance the EIS instance.\n");
      writeWithIndent(out, indent, " * @throws ResourceException Failed to get a connection to\n");
      writeWithIndent(out, indent, " */\n");

      writeWithIndent(out, indent, "@Override\n");
      writeWithIndent(out, indent, "public Connection getConnection() throws ResourceException");
      writeLeftCurlyBracket(out, indent);

      writeWithIndent(out, indent + 1,
            "return new " + def.getMcfDefs().get(getNumOfMcf()).getCciConnClass() + "(new " + def.getMcfDefs()
                  .get(getNumOfMcf()).getConnSpecClass() + "());");
      writeRightCurlyBracket(out, indent);
      writeEol(out);

      writeWithIndent(out, indent, "/**\n");
      writeWithIndent(out, indent, " * Gets a connection to an EIS instance. \n");
      writeWithIndent(out, indent, " *\n");
      writeWithIndent(out, indent, " * @param connSpec Connection parameters and security information specified as "
            + "ConnectionSpec instance\n");
      writeWithIndent(out, indent, " * @return Connection instance the EIS instance.\n");
      writeWithIndent(out, indent, " * @throws ResourceException Failed to get a connection to\n");
      writeWithIndent(out, indent, " */\n");

      writeWithIndent(out, indent, "@Override\n");
      writeWithIndent(out, indent, "public Connection getConnection(ConnectionSpec connSpec) throws ResourceException");
      writeLeftCurlyBracket(out, indent);

      writeWithIndent(out, indent + 1,
            "return new " + def.getMcfDefs().get(getNumOfMcf()).getCciConnClass() + "(connSpec);");
      writeRightCurlyBracket(out, indent);
      writeEol(out);
   }
1245857
private void writeBufferToFile() throws IOException {
        if (_bufferOffset > 0) {
            List<ByteBuffer> payload = new ArrayList<ByteBuffer>(1);
            payload.add(ByteBuffer.wrap(_buffer, 0, _bufferOffset));
            NfsWriteResponse response = _nfsFile.write(_currentOffset, payload, _syncType);
            int bytesWritten = response.getCount();
            _currentOffset += bytesWritten;
            _bufferOffset -= bytesWritten;
            if (0 != _bufferOffset) { // Everything was not written.
                // _bufferOffset should be the number of unwritten bytes.
                // Copy the unwritten bytes to the beginning of the buffer.
                System.arraycopy(_buffer, bytesWritten, _buffer, 0, _bufferOffset);
            }
        }
    }
329737
public ByteBuffer toByteBuffer() {
    // Allow room for encoded message, plus the type byte
    ByteBuf buf = Unpooled.buffer(encodedLength() + 1);
    buf.writeByte(type().id);
    encode(buf);
    assert buf.writableBytes() == 0 : "Writable bytes remain: " + buf.writableBytes();
    return buf.nioBuffer();
  }
188497
protected synchronized boolean write(byte[] bytes) {
        mConnectionLock.readLock().lock();
        boolean success = true;
        try {
            if(isConnected()) {
                Log.v(TAG, "Writing " + bytes.length + " to socket");
                mOutStream.write(bytes);
            } else {
                Log.w(TAG, "No connection established, could not send anything.");
                success = false;
            }
        } catch(IOException e) {
            Log.w(TAG, "Unable to write CAN message to Network. Error: " + e.toString());
            success = false;
        } finally {
            mConnectionLock.readLock().unlock();
        }
        return success;
    }
168141
@Override
    public int write(ByteBuffer outAppBuf, Callback callback) throws IOException {
        if (!initialHSComplete) {
            IllegalStateException ex = new IllegalStateException("The initial handshake is not complete.");
            callback.failed(ex);
            throw ex;
        }

        int ret = 0;
        if (!outAppBuf.hasRemaining()) {
            callback.succeeded();
            return ret;
        }

        final int remain = outAppBuf.remaining();
        int packetBufferSize = sslEngine.getSession().getPacketBufferSize();
        List<ByteBuffer> pocketBuffers = new ArrayList<>();
        boolean closeOutput = false;

        outer:
        while (ret < remain) {
            ByteBuffer packetBuffer = newBuffer(packetBufferSize);

            wrap:
            while (true) {
                SSLEngineResult result = wrap(outAppBuf, packetBuffer);
                ret += result.bytesConsumed();

                switch (result.getStatus()) {
                    case OK: {
                        if (result.getHandshakeStatus() == SSLEngineResult.HandshakeStatus.NEED_TASK) {
                            doTasks();
                        }

                        packetBuffer.flip();
                        if (packetBuffer.hasRemaining()) {
                            pocketBuffers.add(packetBuffer);
                        }
                    }
                    break wrap;

                    case BUFFER_OVERFLOW: {
                        packetBufferSize = sslEngine.getSession().getPacketBufferSize();
                        ByteBuffer b = newBuffer(packetBuffer.position() + packetBufferSize);
                        packetBuffer.flip();
                        b.put(packetBuffer);
                        packetBuffer = b;
                    }
                    break; // retry the operation.

                    case CLOSED: {
                        log.info("Session {} SSLEngine will close", session.getSessionId());
                        packetBuffer.flip();
                        if (packetBuffer.hasRemaining()) {
                            pocketBuffers.add(packetBuffer);
                        }
                        closeOutput = true;
                    }
                    break outer;

                    default: {
                        SecureNetException ex = new SecureNetException(StringUtils.replace("Session {} SSLEngine writes data exception. status -> {}", session.getSessionId(), result.getStatus()));
                        callback.failed(ex);
                        throw ex;
                    }
                }
            }
        }

        session.write(pocketBuffers, callback);
        if (closeOutput) {
            closeOutbound();
        }
        return ret;
    }
885796
public static ByteBuf copiedBuffer(ByteBuffer buffer) {
        int length = buffer.remaining();
        if (length == 0) {
            return EMPTY_BUFFER;
        }
        byte[] copy = PlatformDependent.allocateUninitializedArray(length);
        // Duplicate the buffer so we not adjust the position during our get operation.
        // See https://github.com/netty/netty/issues/3896
        ByteBuffer duplicate = buffer.duplicate();
        duplicate.get(copy);
        return wrappedBuffer(copy).order(duplicate.order());
    }
303858
@Override
	public void writeTo(ByteBuffer buffer) {
	//field->id
	int id=0;
	id=getId();
	buffer.writeInt(id);
	//field->name
	String name=null;
	name=getName();
	if (name!=null){
	buffer.writeBoolean(true);
	buffer.writeUTF(name);
	}else{	buffer.writeBoolean(false);}
	//field->time
	Date time=null;
	time=getTime();
	if (time!=null){
	buffer.writeBoolean(true);
	buffer.writeLong(time.getTime());
	}else{	buffer.writeBoolean(false);}
	//field->age
	Integer age=null;
	age=getAge();
	if (age!=null){
	buffer.writeBoolean(true);
	buffer.writeInt(age);
	}else{	buffer.writeBoolean(false);}
	//field->array
	int[] array=null;
	array=getArray();
	if (array!=null){
	buffer.writeBoolean(true);
	int array_l=array.length;
	buffer.writeInt(array_l);
	for(int array_i=0;array_i<array_l;array_i++){
	int array_d=array[array_i];
	buffer.writeInt(array_d);
	}
	}else{	buffer.writeBoolean(false);}
	//field->listArray
	List<int[]> listArray=null;
	listArray=getListArray();
	if (listArray!=null){
	buffer.writeBoolean(true);
	int listArray_ls=listArray.size();
	buffer.writeInt(listArray_ls);
	for(int[] listArray_lv:listArray){
	int listArray_lv_l=listArray_lv.length;
	buffer.writeInt(listArray_lv_l);
	for(int listArray_lv_i=0;listArray_lv_i<listArray_lv_l;listArray_lv_i++){
	int listArray_lv_d=listArray_lv[listArray_lv_i];
	buffer.writeInt(listArray_lv_d);
	}
	}
	}else{	buffer.writeBoolean(false);}
	//field->setArray
	Set<java.lang.Integer[]> setArray=null;
	setArray=getSetArray();
	if (setArray!=null){
	buffer.writeBoolean(true);
	int setArray_ls=setArray.size();
	buffer.writeInt(setArray_ls);
	for(Integer[] setArray_lv:setArray){
	int setArray_lv_l=setArray_lv.length;
	buffer.writeInt(setArray_lv_l);
	for(int setArray_lv_i=0;setArray_lv_i<setArray_lv_l;setArray_lv_i++){
	Integer setArray_lv_d=setArray_lv[setArray_lv_i];
	buffer.writeInt(setArray_lv_d);
	}
	}
	}else{	buffer.writeBoolean(false);}
	//field->queues
	Queue<java.lang.Byte[]> queues=null;
	queues=getQueues();
	if (queues!=null){
	buffer.writeBoolean(true);
	int queues_ls=queues.size();
	buffer.writeInt(queues_ls);
	for(Byte[] queues_lv:queues){
	int queues_lv_l=queues_lv.length;
	buffer.writeInt(queues_lv_l);
	for(int queues_lv_i=0;queues_lv_i<queues_lv_l;queues_lv_i++){
	Byte queues_lv_d=queues_lv[queues_lv_i];
	buffer.writeByte(queues_lv_d);
	}
	}
	}else{	buffer.writeBoolean(false);}
	//field->map
	Map<java.util.List<int[]>,java.util.Set<java.lang.Integer>> map=null;
	map=getMap();
	if (map!=null){
	buffer.writeBoolean(true);
	int map_ms=map.size();
	buffer.writeInt(map_ms);
	for(List<int[]> map_mk:map.keySet()){
	Set<java.lang.Integer> map_mv=map.get(map_mk);
	int map_mk_ls=map_mk.size();
	buffer.writeInt(map_mk_ls);
	for(int[] map_mk_lv:map_mk){
	int map_mk_lv_l=map_mk_lv.length;
	buffer.writeInt(map_mk_lv_l);
	for(int map_mk_lv_i=0;map_mk_lv_i<map_mk_lv_l;map_mk_lv_i++){
	int map_mk_lv_d=map_mk_lv[map_mk_lv_i];
	buffer.writeInt(map_mk_lv_d);
	}
	}
	int map_mv_ls=map_mv.size();
	buffer.writeInt(map_mv_ls);
	for(Integer map_mv_lv:map_mv){
	buffer.writeInt(map_mv_lv);
	}
	}
	}else{	buffer.writeBoolean(false);}
	}
416848
public static Persistable persistable(final ByteBuffer buffer) {
        return new Persistable() {

            @Override
            public int size() {
                return buffer.limit();
            }

            @Override
            public void write(ByteBuffer buffer1) {
                buffer1.put(buffer);
                buffer1.flip();
            }

            @Override
            public void read(ByteBuffer buffer1) {
                buffer.rewind();
                buffer.put(buffer1);
                buffer.rewind();
            }

        };
    }
567791
public static byte[] toBytes(ByteBuffer bb) {
    int length = bb.limit();
    byte [] result = new byte[length];
    System.arraycopy(bb.array(), bb.arrayOffset(), result, 0, length);
    return result;
  }
1260636
private void writeBuffer() throws IOException {
    for (int pos = 0; pos < currentBufferSize; pos++) {
      if (isByte[pos]) {
        aFile.write((byte) buffer[pos]);
      } else {
        aFile.write(buffer[pos]);
      }
    }
  }