Package java.nio

Examples of java.nio.ByteBuffer.capacity()


                    /* we need more data */
                    done = true;
                    break;
                case BUFFER_OVERFLOW:
                    /* resize output buffer */
                    appBuffer = ByteBuffer.allocateDirect(appBuffer.capacity() * 2);
                    break;
                case OK:
                    if ((handshakeStatus == HandshakeStatus.NOT_HANDSHAKING) && (result.bytesProduced() > 0)) {
                        appBuffer.flip();
                        session.processMessageReceived(appBuffer);
View Full Code Here


            case NEED_WRAP:
                result = sslEngine.wrap(EMPTY_BUFFER, appBuffer);
                handshakeStatus = result.getHandshakeStatus();
                switch (result.getStatus()) {
                case BUFFER_OVERFLOW:
                    appBuffer = ByteBuffer.allocateDirect(appBuffer.capacity() * 2);
                    break;
                case BUFFER_UNDERFLOW:
                    done = true;
                    break;
                case CLOSED:
View Full Code Here

                SSLEngineResult result = sslEngine.wrap(buf, appBuffer);

                switch (result.getStatus()) {
                case BUFFER_OVERFLOW:
                    // Increase the buffer size as needed
                    appBuffer = ByteBuffer.allocate(appBuffer.capacity() + 4096);
                    break;

                case BUFFER_UNDERFLOW:
                case CLOSED:
                    break;
View Full Code Here

   
    final protected void check(Block block)
    {
        check(block.getId()) ;
        ByteBuffer bb = block.getByteBuffer() ;
        if ( bb.capacity() != blockSize )
            throw new BlockException(format("BlockMgrFile: Wrong size block.  Expected=%d : actual=%d", blockSize, bb.capacity())) ;
        if ( bb.order() != SystemTDB.NetworkOrder )
            throw new BlockException("BlockMgrFile: Wrong byte order") ;
    }
View Full Code Here

    final protected void check(Block block)
    {
        check(block.getId()) ;
        ByteBuffer bb = block.getByteBuffer() ;
        if ( bb.capacity() != blockSize )
            throw new BlockException(format("BlockMgrFile: Wrong size block.  Expected=%d : actual=%d", blockSize, bb.capacity())) ;
        if ( bb.order() != SystemTDB.NetworkOrder )
            throw new BlockException("BlockMgrFile: Wrong byte order") ;
    }

    protected void force()
View Full Code Here

        // decompression.
        InputStream is = this.compressAlgo.createDecompressionStream(
          new BoundedRangeFileInputStream(this.istream, offset, compressedSize),
          decompressor, 0);
        buf = ByteBuffer.allocate(decompressedSize);
        IOUtils.readFully(is, buf.array(), 0, buf.capacity());
        is.close();       
      } finally {
        if (null != decompressor) {
          this.compressAlgo.returnDecompressor(decompressor);         
        }
View Full Code Here

        if (senseData != null) senseData.serialize(buffer, SENSE_LENGTH_FIELD_LENGTH);

        // write and SCSI response data
        if (responseData != null) responseData.serialize(buffer, SENSE_LENGTH_FIELD_LENGTH + senseLength);

        if (allocationLength > 0 && buffer.capacity() > allocationLength) {
            /*
             * If the allocation length variable is valid and the response data segment is larger than the data-in
             * buffer allocated by the initiator, limit the number of bytes returned.
             */
            buffer.position(0);
View Full Code Here

      //to distinguish between a finalized ByteBuffer (limit <= capacity - 1) and a ByteBuffer
      //being written to (limit == capacity)
      final int maxFindBufferIter = 3;
      int findBufferIter = 0;
      for (;
           findBufferIter < maxFindBufferIter && buffer.capacity() - 1 -
               _currentWritePosition.bufferOffset() < dbusEventSize;
           ++findBufferIter)
      {
        if (isDebugEnabled)
          _log.debug("skipping buffer " + _currentWritePosition.bufferIndex() +
View Full Code Here

           ++findBufferIter)
      {
        if (isDebugEnabled)
          _log.debug("skipping buffer " + _currentWritePosition.bufferIndex() +
                    ": " + buffer +
                    ": insufficient capacity " + (buffer.capacity() -
                        _currentWritePosition.bufferOffset()) + " < " + dbusEventSize);
        final long newWritePos =
            _bufferPositionParser.incrementIndex(_currentWritePosition.getPosition(), _buffers);

        // ensureFreeSpace will call moveHead, which also resets limit to capacity
View Full Code Here

                  }
                  break;
                }
                case PARTIAL_EVENT:
                {
                  final int curCapacity = readBuffer.capacity();
                  if (logDebugEnabled)
                    _log.debug("partial event at " + readPos);
                  if (0 != readPos.getReadStart())
                  {
                    //compact stg buffer and try to read more data from the network
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.