Java Code Examples for java.io.ObjectInput#readFully()

The following examples show how to use java.io.ObjectInput#readFully() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ReplicationData.java    From gemfirexd-oss with Apache License 2.0 6 votes vote down vote up
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
    int num;
    type=in.readInt();
    if((num=in.readInt()) > 0) {
        data=new byte[num];
        in.readFully(data, 0, num);
    }
    if(in.readBoolean()) {
        transaction=new Xid();
        transaction.readExternal(in);
    }
    use_locks=in.readBoolean();
    if(use_locks) {
        if((num=in.readInt()) > 0) {
            lock_info=new byte[num];
            in.readFully(lock_info, 0, num);
        }
        lock_acquisition_timeout=in.readLong();
        lock_lease_timeout=in.readLong();        
    }
}
 
Example 2
Source File: JGroupMember.java    From gemfirexd-oss with Apache License 2.0 6 votes vote down vote up
/**
   * For Externalizable
   * 
   * @see java.io.Externalizable
   */
  public void readExternal(ObjectInput in) throws IOException,
          ClassNotFoundException {
//    ipAddr = new IpAddress();
//    ipAddr.readExternal(in);
    // do it the way we like
    int len = in.readInt(); // IPv6 compatible
    byte addr[] = new byte[len];
    in.readFully(addr);
    InetAddress ia = InetAddress.getByAddress(addr);
    int port = in.readInt();
    byte flags = in.readByte();
    ipAddr = new IpAddress(ia, port);
    ipAddr.setFlags(flags);
    ipAddr.readVersion(flags, in);
    len = in.readInt();
    if (len != 0) {
      byte bytes[] = new byte[len];
      in.readFully(bytes);
      GFJGBasicAdapter.insertGemFireAttributes(ipAddr, new MemberAttributes(bytes));
    }
  }
 
Example 3
Source File: DistributedCheckTableJob.java    From spliceengine with GNU Affero General Public License v3.0 6 votes vote down vote up
@Override
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
    txn = SIDriver.driver().getOperationFactory().readTxn(in);
    ah = (ActivationHolder) in.readObject();
    schemaName = in.readUTF();
    tableName = in.readUTF();
    int iSize = in.readInt();
    tentativeIndexList = new ArrayList<>(iSize);
    for (int i = 0; i< iSize; i++) {
        byte[] message = new byte[in.readInt()];
        in.readFully(message);
        tentativeIndexList.add(DDLMessage.TentativeIndex.parseFrom(message));
    }
    fix = in.readBoolean();
    jobGroup = in.readUTF();
}
 
Example 4
Source File: ForwardedMessage.java    From protect with MIT License 6 votes vote down vote up
@Override
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
	super.readExternal(in);

	byte[] serReq = new byte[in.readInt()];
	in.readFully(serReq);

	request = TOMMessage.bytesToMessage(serReq);
	request.serializedMessage = serReq;

	boolean signed = in.readBoolean();

	if (signed) {

		byte[] serReqSign = new byte[in.readInt()];
		in.readFully(serReqSign);
		request.serializedMessageSignature = serReqSign;

	}
}
 
Example 5
Source File: SQLBinary.java    From gemfirexd-oss with Apache License 2.0 6 votes vote down vote up
/** 
 * delegated to bit 
 *
 * @exception IOException			io exception
 * @exception ClassNotFoundException	class not found
*/
public final void readExternal(ObjectInput in) throws IOException
{
	// need to clear stream first, in case this object is reused, and
	// stream is set by previous use.  Track 3794.
	//stream = null;
	//streamValueLength = -1;
       _blobValue = null;


	int len = SQLBinary.readBinaryLength(in);

	if (len != 0)
	{
		dataValue = new byte[len];
		in.readFully(dataValue);
	}
	else
	{
		readFromStream((InputStream) in);
	}
}
 
Example 6
Source File: ReplicationData.java    From gemfirexd-oss with Apache License 2.0 6 votes vote down vote up
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
    int num;
    type=in.readInt();
    if((num=in.readInt()) > 0) {
        data=new byte[num];
        in.readFully(data, 0, num);
    }
    if(in.readBoolean()) {
        transaction=new Xid();
        transaction.readExternal(in);
    }
    use_locks=in.readBoolean();
    if(use_locks) {
        if((num=in.readInt()) > 0) {
            lock_info=new byte[num];
            in.readFully(lock_info, 0, num);
        }
        lock_acquisition_timeout=in.readLong();
        lock_lease_timeout=in.readLong();        
    }
}
 
Example 7
Source File: ByteSlice.java    From spliceengine with GNU Affero General Public License v3.0 6 votes vote down vote up
@Override
public void readExternal(ObjectInput in) throws IOException,ClassNotFoundException {
    offset = in.readInt();
    length = in.readInt();
    buffer = new byte[length];
    if(length > 0) {
        in.readFully(buffer);
    }
    hashSet = false;
    if (buffer.length > 0) {
        assertLengthCorrect(buffer, offset, length);
    } else {
        // If there's nothing in the buffer, reset offset and length
        // to prevent ArrayIndexOutOfBoundsException
        offset = length = 0;
    }
}
 
Example 8
Source File: JGroupMember.java    From gemfirexd-oss with Apache License 2.0 6 votes vote down vote up
/**
   * For Externalizable
   * 
   * @see java.io.Externalizable
   */
  public void readExternal(ObjectInput in) throws IOException,
          ClassNotFoundException {
//    ipAddr = new IpAddress();
//    ipAddr.readExternal(in);
    // do it the way we like
    int len = in.readInt(); // IPv6 compatible
    byte addr[] = new byte[len];
    in.readFully(addr);
    InetAddress ia = InetAddress.getByAddress(addr);
    int port = in.readInt();
    byte flags = in.readByte();
    ipAddr = new IpAddress(ia, port);
    ipAddr.setFlags(flags);
    ipAddr.readVersion(flags, in);
    len = in.readInt();
    if (len != 0) {
      byte bytes[] = new byte[len];
      in.readFully(bytes);
      GFJGBasicAdapter.insertGemFireAttributes(ipAddr, new MemberAttributes(bytes));
    }
  }
 
Example 9
Source File: MimeType.java    From jdk1.8-source-analysis with Apache License 2.0 5 votes vote down vote up
/**
     * The object implements the readExternal method to restore its
     * contents by calling the methods of DataInput for primitive
     * types and readObject for objects, strings and arrays.  The
     * readExternal method must read the values in the same sequence
     * and with the same types as were written by writeExternal.
     * @exception ClassNotFoundException If the class for an object being
     *              restored cannot be found.
     */
    public void readExternal(ObjectInput in) throws IOException,
ClassNotFoundException {
        String s = in.readUTF();
        if (s == null || s.length() == 0) { // long mime type
            byte[] ba = new byte[in.readInt()];
            in.readFully(ba);
            s = new String(ba);
        }
        try {
            parse(s);
        } catch(MimeTypeParseException e) {
            throw new IOException(e.toString());
        }
    }
 
Example 10
Source File: SpliceSequence.java    From spliceengine with GNU Affero General Public License v3.0 5 votes vote down vote up
@Override
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException{
    super.readExternal(in);
    int size=in.readInt();
    sysColumnsRow=new byte[size];
    in.readFully(sysColumnsRow);
}
 
Example 11
Source File: ByteArray.java    From gemfirexd-oss with Apache License 2.0 5 votes vote down vote up
/**
 * Read this object from a stream of stored objects.
 *
 * @param in read this.
 *
 * @exception IOException					thrown on error
 */
public void readExternal( ObjectInput in ) throws IOException
{
	int len = length = in.readInt();
	offset = 0; 
	array = new byte[len];

	in.readFully(array, 0, len);
}
 
Example 12
Source File: LocalTx.java    From reladomo with Apache License 2.0 5 votes vote down vote up
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException
{
    int len = in.readByte();
    this.globalId = new byte[len];
    in.readFully(this.globalId);
    len = in.readByte();
    this.branchId = new byte[len];
    in.readFully(this.branchId);
}
 
Example 13
Source File: MimeType.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
/**
     * The object implements the readExternal method to restore its
     * contents by calling the methods of DataInput for primitive
     * types and readObject for objects, strings and arrays.  The
     * readExternal method must read the values in the same sequence
     * and with the same types as were written by writeExternal.
     * @exception ClassNotFoundException If the class for an object being
     *              restored cannot be found.
     */
    public void readExternal(ObjectInput in) throws IOException,
ClassNotFoundException {
        String s = in.readUTF();
        if (s == null || s.length() == 0) { // long mime type
            byte[] ba = new byte[in.readInt()];
            in.readFully(ba);
            s = new String(ba);
        }
        try {
            parse(s);
        } catch(MimeTypeParseException e) {
            throw new IOException(e.toString());
        }
    }
 
Example 14
Source File: ByteMessage.java    From tomcatsrc with Apache License 2.0 5 votes vote down vote up
/**
 * @see java.io.Externalizable#readExternal
 * @param in ObjectInput
 * @throws IOException
 */
@Override
public void readExternal(ObjectInput in ) throws IOException {
    int length = in.readInt();
    message = new byte[length];
    in.readFully(message);
}
 
Example 15
Source File: MimeType.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
/**
     * The object implements the readExternal method to restore its
     * contents by calling the methods of DataInput for primitive
     * types and readObject for objects, strings and arrays.  The
     * readExternal method must read the values in the same sequence
     * and with the same types as were written by writeExternal.
     * @exception ClassNotFoundException If the class for an object being
     *              restored cannot be found.
     */
    public void readExternal(ObjectInput in) throws IOException,
ClassNotFoundException {
        String s = in.readUTF();
        if (s == null || s.length() == 0) { // long mime type
            byte[] ba = new byte[in.readInt()];
            in.readFully(ba);
            s = new String(ba);
        }
        try {
            parse(s);
        } catch(MimeTypeParseException e) {
            throw new IOException(e.toString());
        }
    }
 
Example 16
Source File: UnsafeRow.java    From indexr with Apache License 2.0 5 votes vote down vote up
@Override
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
    this.baseOffset = Platform.BYTE_ARRAY_OFFSET;
    this.sizeInBytes = in.readInt();
    this.numFields = in.readInt();
    this.baseObject = new byte[sizeInBytes];
    in.readFully((byte[]) baseObject);
}
 
Example 17
Source File: SimpleTxnOperationFactory.java    From spliceengine with GNU Affero General Public License v3.0 5 votes vote down vote up
@Override
public TxnView readTxn(ObjectInput oi) throws IOException{
    int size=oi.readInt();
    byte[] txnData=new byte[size];
    oi.readFully(txnData);

    return decode(txnData,0,txnData.length);
}
 
Example 18
Source File: AtomicBlockAppendProc.java    From database with GNU General Public License v2.0 4 votes vote down vote up
@Override
public void readExternal(final ObjectInput in) throws IOException,
        ClassNotFoundException {

    id = in.readUTF();

    version = in.readInt();

    off = 0; // Note: offset always zero when de-serialized.

    len = in.readInt();

    b = new byte[len];

    in.readFully(b);

}
 
Example 19
Source File: InternalDistributedMember.java    From gemfirexd-oss with Apache License 2.0 4 votes vote down vote up
/**
 * For Externalizable
 *
 * @see Externalizable
 */
public void readExternal(ObjectInput in)
throws IOException, ClassNotFoundException {
  // do it the way we like
  int len = in.readInt(); // IPv6 compatible
  byte addr[] = new byte[len];
  in.readFully(addr);
  InetAddress inetAddr = InetAddress.getByAddress(addr);
  int port = in.readInt();
  
  this.hostName = DataSerializer.readString(in);

  int flags = in.readUnsignedByte();
  boolean sbEnabled = (flags & SB_ENABLED_MASK) != 0;
  boolean elCoord = (flags & COORD_ENABLED_MASK) != 0;
  this.isPartial = (flags & PARTIAL_ID_MASK) != 0;
  
  this.dcPort = in.readInt();
  this.vmPid = in.readInt();
  this.vmKind = in.readInt();
  this.vmViewId = in.readInt();
  this.groups = DataSerializer.readStringArray(in);

  this.name = DataSerializer.readString(in);
  this.uniqueTag = DataSerializer.readString(in);
  String durableId = DataSerializer.readString(in);
  int durableTimeout = DataSerializer.readInteger(in).intValue();
  this.durableClientAttributes = new DurableClientAttributes(durableId, durableTimeout);

  readVersion(flags, in);

  ipAddr = MemberFactory.newNetMember(inetAddr, port, sbEnabled, elCoord,
      new MemberAttributes(dcPort, vmPid, vmKind, vmViewId, name, groups, durableClientAttributes));
  ((JGroupMember)ipAddr).getAddress().setVersionOrdinal(this.version);

  Assert.assertTrue(this.vmKind > 0);
  // [sumedh] loner VMs will have port as zero if no GFE client is connected
  // e.g. with GFXD clients
  Assert.assertTrue(vmKind == DistributionManager.LONER_DM_TYPE
      || getPort() > 0);
}
 
Example 20
Source File: LocalPartitionMetadata.java    From database with GNU General Public License v2.0 2 votes vote down vote up
public void readExternal(final ObjectInput in) throws IOException,
            ClassNotFoundException {

        final short version = ShortPacker.unpackShort(in);

        switch (version) {
        case VERSION0:
        case VERSION1:
        case VERSION2:
            break;
        default:
            throw new IOException("Unknown version: " + version);
        }

        if (version < VERSION2) {
            partitionId = (int) LongPacker.unpackLong(in);
        } else {
            partitionId = in.readInt();
        }

        sourcePartitionId = in.readInt(); // MAY be -1.
        
        final int nresources = ShortPacker.unpackShort(in);
        
        final int leftLen = (int) LongPacker.unpackLong(in);

        final int rightLen = (int) LongPacker.unpackLong(in);

        leftSeparatorKey = new byte[leftLen];

        in.readFully(leftSeparatorKey);

        if (rightLen != 0) {

            rightSeparatorKey = new byte[rightLen];

            in.readFully(rightSeparatorKey);

        } else {

            rightSeparatorKey = null;

        }

        cause = (IndexPartitionCause)in.readObject();
        
        if (version < VERSION2) {
            /* history = */in.readUTF();
        }
        
        resources = nresources>0 ? new IResourceMetadata[nresources] : null;

        for (int j = 0; j < nresources; j++) {

            final boolean isIndexSegment = in.readBoolean();
            
            final String filename = in.readUTF();

//            long nbytes = LongPacker.unpackLong(in);

            final UUID uuid = new UUID(in.readLong()/*MSB*/,in.readLong()/*LSB*/);

            final long createTime = in.readLong();
            
            long commitTime = 0L;
            if (version >= VERSION1 && !isIndexSegment) {

                commitTime = in.readLong();
                
            }
            
            resources[j] = (isIndexSegment //
                    ? new SegmentMetadata(filename, /*nbytes,*/ uuid, createTime) //
                    : new JournalMetadata(filename, /*nbytes,*/ uuid, createTime, commitTime) //
                    );

        }
                
    }