private static int readDSFIDHeader(final DataInput in, DSCODE dscode) throws IOException { switch (dscode) { case DS_FIXED_ID_BYTE: return in.readByte(); case DS_FIXED_ID_SHORT: return in.readShort(); case DS_FIXED_ID_INT: return in.readInt(); default: throw new IllegalStateException("unexpected byte: " + dscode + " while reading dsfid"); } }
@Override public void readFields(DataInput in) throws IOException { super.readFields(in); int length = (int) in.readByte(); actions = EnumSet.noneOf(Action.class); if (length > 0) { for (int i = 0; i < length; i++) { byte b = in.readByte(); Action action = ACTION_BY_CODE.get(b); if (action == null) { throw new IOException("Unknown action code '" + Bytes.toStringBinary(new byte[] { b }) + "' in input"); } actions.add(action); } } scope = SCOPE_BY_CODE.get(in.readByte()); }
public void readFrom(DataInput in) throws Exception { int len=in.readByte(); if(len > 0 && (len != Global.IPV4_SIZE && len != Global.IPV6_SIZE)) throw new IOException("length has to be " + Global.IPV4_SIZE + " or " + Global.IPV6_SIZE + " bytes (was " + len + " bytes)"); byte[] a = new byte[len]; // 4 bytes (IPv4) or 16 bytes (IPv6) in.readFully(a); if(len == Global.IPV6_SIZE) { int scope_id=in.readInt(); this.ip_addr=Inet6Address.getByAddress(null, a, scope_id); } else { this.ip_addr=InetAddress.getByAddress(a); } // changed from readShort(): we need the full 65535, with a short we'd only get up to 32K ! port=in.readUnsignedShort(); }
public DataStructure looseUnmarshalNestedObject(DataInput dis) throws IOException { if (dis.readBoolean()) { byte dataType = dis.readByte(); DataStreamMarshaller dsm = dataMarshallers[dataType & 0xFF]; if (dsm == null) { throw new IOException("Unknown data type: " + dataType); } DataStructure data = dsm.createObject(); dsm.looseUnmarshal(this, data, dis); return data; } else { return null; } }
public DataStructure tightUnmarshalNestedObject(DataInput dis, BooleanStream bs) throws IOException { if (bs.readBoolean()) { byte dataType = dis.readByte(); DataStreamMarshaller dsm = dataMarshallers[dataType & 0xFF]; if (dsm == null) { throw new IOException("Unknown data type: " + dataType); } DataStructure data = dsm.createObject(); if (data.isMarshallAware() && bs.readBoolean()) { dis.readInt(); dis.readByte(); BooleanStream bs2 = new BooleanStream(); bs2.unmarshal(dis); dsm.tightUnmarshal(this, data, dis, bs2); // TODO: extract the sequence from the dis and associate it. // MarshallAware ma = (MarshallAware)data // ma.setCachedMarshalledForm(this, sequence); } else { dsm.tightUnmarshal(this, data, dis, bs); } return data; } else { return null; } }
info.setBrowser(bs.readBoolean()); info.setDestination((org.apache.activemq.command.ActiveMQDestination) tightUnmarsalCachedObject(wireFormat, dataIn, bs)); info.setPrefetchSize(dataIn.readInt()); info.setMaximumPendingMessageLimit(dataIn.readInt()); info.setDispatchAsync(bs.readBoolean()); info.setSelector(tightUnmarshalString(dataIn, bs)); info.setSubscriptionName(tightUnmarshalString(dataIn, bs)); info.setNoLocal(bs.readBoolean()); info.setExclusive(bs.readBoolean()); info.setRetroactive(bs.readBoolean()); info.setPriority(dataIn.readByte()); if (bs.readBoolean()) { short size = dataIn.readShort(); org.apache.activemq.command.BrokerId value[] = new org.apache.activemq.command.BrokerId[size]; for( int i=0; i < size; i++ ) { if (bs.readBoolean()) { short size = dataIn.readShort(); org.apache.activemq.command.ConsumerId value[] = new org.apache.activemq.command.ConsumerId[size]; for( int i=0; i < size; i++ ) {
public static <T extends Object> T objectFromStream(DataInput in, ClassLoader loader) throws Exception { if(in == null) return null; byte b=in.readByte(); return (T)tmp.readObject(); case TYPE_BOOLEAN: return (T)(Boolean)in.readBoolean(); case TYPE_BYTE: return (T)(Byte)in.readByte(); case TYPE_CHAR: return (T)(Character)in.readChar(); case TYPE_DOUBLE: return (T)(Double)in.readDouble(); case TYPE_FLOAT: return (T)(Float)in.readFloat(); case TYPE_INT: return (T)(Integer)in.readInt(); case TYPE_LONG: return (T)(Long)in.readLong(); case TYPE_SHORT: return (T)(Short)in.readShort(); case TYPE_STRING: int str_len=in.readInt(); if(str_len == 0) return (T)""; byte[] tmp=new byte[str_len]; for(int i=0; i < str_len; i++) { tmp[i]=in.readByte(); return (T)in.readUTF(); case TYPE_BYTEARRAY: int len=in.readInt(); byte[] tmpbuf=new byte[len]; in.readFully(tmpbuf,0,tmpbuf.length);
@Override public void fromData(DataInput in) throws IOException, ClassNotFoundException { this.memberId = new InternalDistributedMember(); InternalDataSerializer.invokeFromData(this.memberId, in); this.prType = in.readInt(); this.isPersistent = in.readBoolean(); this.cacheLoaderWriterByte = in.readByte(); this.serialNumber = in.readInt(); }
public void readFrom(DataInput in) throws Exception { type=in.readByte(); switch(type) { case DATA: seqno=Bits.readLong(in); conn_id=in.readShort(); first=in.readBoolean(); break; case ACK: seqno=Bits.readLong(in); conn_id=in.readShort(); timestamp=Bits.readInt(in); break; case SEND_FIRST_SEQNO: timestamp=Bits.readInt(in); break; case XMIT_REQ: break; case CLOSE: conn_id=in.readShort(); break; } } }
static OfYear readFrom(DataInput in) throws IOException { return new OfYear((char)in.readUnsignedByte(), (int)in.readUnsignedByte(), (int)in.readByte(), (int)in.readUnsignedByte(), in.readBoolean(), (int)readMillis(in)); }
/** * Un-marshal an object instance from the data input stream * * @param o the object to un-marshal * @param dataIn the data input stream to build the object from * @throws IOException */ public void tightUnmarshal(OpenWireFormat wireFormat, Object o, DataInput dataIn, BooleanStream bs) throws IOException { super.tightUnmarshal(wireFormat, o, dataIn, bs); DestinationInfo info = (DestinationInfo)o; info.setConnectionId((org.apache.activemq.command.ConnectionId) tightUnmarsalCachedObject(wireFormat, dataIn, bs)); info.setDestination((org.apache.activemq.command.ActiveMQDestination) tightUnmarsalCachedObject(wireFormat, dataIn, bs)); info.setOperationType(dataIn.readByte()); info.setTimeout(tightUnmarshalLong(wireFormat, dataIn, bs)); if (bs.readBoolean()) { short size = dataIn.readShort(); org.apache.activemq.command.BrokerId value[] = new org.apache.activemq.command.BrokerId[size]; for( int i=0; i < size; i++ ) { value[i] = (org.apache.activemq.command.BrokerId) tightUnmarsalNestedObject(wireFormat,dataIn, bs); } info.setBrokerPath(value); } else { info.setBrokerPath(null); } }
/** * Un-marshal an object instance from the data input stream * * @param o the object to un-marshal * @param dataIn the data input stream to build the object from * @throws IOException */ public void tightUnmarshal(OpenWireFormat wireFormat, Object o, DataInput dataIn, BooleanStream bs) throws IOException { super.tightUnmarshal(wireFormat, o, dataIn, bs); JournalTransaction info = (JournalTransaction)o; info.setTransactionId((org.apache.activemq.command.TransactionId) tightUnmarsalNestedObject(wireFormat, dataIn, bs)); info.setType(dataIn.readByte()); info.setWasPrepared(bs.readBoolean()); }
@Override public void handle(DataInput input, final int correlationId) throws IOException { log.trace("SetKeyPair"); byte paramType = input.readByte(); if (paramType != STRING) { throw new IOException("Unexpected paramType"); } String name = input.readUTF(); paramType = input.readByte(); if (paramType != STRING) { throw new IOException("Unexpected paramType"); } String value = input.readUTF(); keyPairs.put(name, value); writeResponse(SET_KEY_PAIR, correlationId); } }
@Override public void readFields(DataInput in) throws IOException { int ver = in.readInt(); if (ver > 0) { // old unversioned format this.nbHash = ver; this.hashType = Hash.JENKINS_HASH; } else if (ver == VERSION) { this.nbHash = in.readInt(); this.hashType = in.readByte(); } else { throw new IOException("Unsupported version: " + ver); } this.vectorSize = in.readInt(); this.hash = new HashFunction(this.vectorSize, this.nbHash, this.hashType); } }//end class
info.setBrowser(bs.readBoolean()); info.setDestination((org.apache.activemq.command.ActiveMQDestination) tightUnmarsalCachedObject(wireFormat, dataIn, bs)); info.setPrefetchSize(dataIn.readInt()); info.setMaximumPendingMessageLimit(dataIn.readInt()); info.setDispatchAsync(bs.readBoolean()); info.setSelector(tightUnmarshalString(dataIn, bs)); info.setSubscriptionName(tightUnmarshalString(dataIn, bs)); info.setNoLocal(bs.readBoolean()); info.setExclusive(bs.readBoolean()); info.setRetroactive(bs.readBoolean()); info.setPriority(dataIn.readByte()); if (bs.readBoolean()) { short size = dataIn.readShort(); org.apache.activemq.command.BrokerId value[] = new org.apache.activemq.command.BrokerId[size]; for( int i=0; i < size; i++ ) { if (bs.readBoolean()) { short size = dataIn.readShort(); org.apache.activemq.command.ConsumerId value[] = new org.apache.activemq.command.ConsumerId[size]; for( int i=0; i < size; i++ ) {
public void fromDataPre_GEODE_1_9_0_0(DataInput in) throws IOException, ClassNotFoundException { version = in.readShort(); this.isInitialized = true; this.action = in.readInt(); this.numberOfParts = in.readInt(); // this._id = in.readUTF(); if (version < 0x11 && (in instanceof InputStream) && InternalDataSerializer.getVersionForDataStream(in) == Version.CURRENT) { in = new VersionedDataInputStream((InputStream) in, Version.GFE_701); } this.id = (EventID) DataSerializer.readObject(in); // TODO:Asif ; Check if this violates Barry's logic of not assiging VM // specific Token.FROM_GATEWAY // and retain the serialized Token.FROM_GATEWAY // this._id.setFromGateway(false); this.regionPath = DataSerializer.readString(in); this.valueIsObject = in.readByte(); deserializeKey(in); this.value = DataSerializer.readByteArray(in); this.callbackArgument = (GatewaySenderEventCallbackArgument) DataSerializer.readObject(in); this.possibleDuplicate = in.readBoolean(); this.creationTime = in.readLong(); this.bucketId = in.readInt(); this.shadowKey = in.readLong(); this.versionTimeStamp = in.readLong(); // TODO should this call initializeKey()? }
/** * read the bits from an input stream * * @param dataIn * @throws IOException */ public void readFromStream(DataInput dataIn) throws IOException { length = dataIn.readByte(); if (length <= BYTE_SIZE) { bits = dataIn.readByte(); } else if (length <= SHORT_SIZE) { bits = dataIn.readShort(); } else if (length <= INT_SIZE) { bits = dataIn.readInt(); } else { bits = dataIn.readLong(); } } }
public void readFrom(DataInput in) throws Exception { type=Type.values()[in.readByte()]; lock_name=Bits.readString(in); lock_id=in.readInt(); owner=Util.readStreamable(Owner::new, in); timeout=in.readLong(); is_trylock=in.readBoolean(); info_rsp=Util.readStreamable(LockInfoResponse::new, in); sender=Util.readAddress(in); }