Issue #2228 use TMemoryInputTransport for slight efficiency improvement

Change-Id: I280dacdd48f5e092b312a80916db6202a1138ebf

Former-commit-id: 963119e0f3 [formerly d4590cbf5e] [formerly 963119e0f3 [formerly d4590cbf5e] [formerly 842f15ae12 [formerly 3f3afa1fe36da04ce47b9af1e8bd34746b75e68f]]]
Former-commit-id: 842f15ae12
Former-commit-id: 584a17828a [formerly 7d17d965a3]
Former-commit-id: 0abec57d0d
This commit is contained in:
Nate Jensen 2013-08-06 09:52:02 -05:00
parent 18dad40473
commit 6585abee8e
15 changed files with 140 additions and 158 deletions

View file

@ -20,7 +20,6 @@
package com.raytheon.uf.viz.core.comm;
import java.io.ByteArrayInputStream;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.List;
@ -35,8 +34,8 @@ import com.raytheon.uf.common.message.response.ResponseMessageCatalog;
import com.raytheon.uf.common.message.response.ResponseMessageError;
import com.raytheon.uf.common.message.response.ResponseMessageGeneric;
import com.raytheon.uf.common.serialization.DynamicSerializationManager;
import com.raytheon.uf.common.serialization.SerializationException;
import com.raytheon.uf.common.serialization.DynamicSerializationManager.SerializationType;
import com.raytheon.uf.common.serialization.SerializationException;
import com.raytheon.uf.viz.core.exception.VizException;
import com.raytheon.uf.viz.core.exception.VizServerSideException;
@ -51,6 +50,7 @@ import com.raytheon.uf.viz.core.exception.VizServerSideException;
* ------------ ---------- ----------- --------------------------
* Sep 11, 2006 chammack Initial Creation.
* 09May2007 TO7 njensen Fixed XML responses.
* Aug 06, 2013 2228 njensen Use deserialize(byte[])
*
* </pre>
*
@ -84,8 +84,7 @@ public class MessageMarshaller {
DynamicSerializationManager dsm = DynamicSerializationManager
.getManager(SerializationType.Thrift);
Object rawMsg = dsm.deserialize(new ByteArrayInputStream(message));
Object rawMsg = dsm.deserialize(message);
if (!(rawMsg instanceof Message))
throw new VizException(

View file

@ -19,7 +19,6 @@
**/
package com.raytheon.uf.viz.core.notification;
import java.io.ByteArrayInputStream;
import java.util.ArrayList;
import java.util.Enumeration;
import java.util.List;
@ -44,6 +43,7 @@ import com.raytheon.uf.viz.core.exception.VizException;
* Sep 2, 2008 1448 chammack Initial creation
* Oct 4, 2010 7193 cjeanbap Added a new method, isNotExpired().
* Feb 1, 2011 7193 cjeanbap Added a new method, getPublishedTime().
* Aug 6, 2013 2228 njensen Use deserialize(byte[])
* </pre>
*
* @author chammack
@ -98,12 +98,10 @@ public class NotificationMessage {
throw new NotificationException(
"Message payload terminated early. Expected: "
+ length + ". Got: " + readLength);
ByteArrayInputStream bais = new ByteArrayInputStream(
data);
this.unmarshalledObject = DynamicSerializationManager
.getManager(SerializationType.Thrift)
.deserialize(bais);
.deserialize(data);
} else if (this.jmsMessage instanceof TextMessage) {
TextMessage textMessage = (TextMessage) this.jmsMessage;
this.unmarshalledObject = SerializationUtil
@ -180,7 +178,8 @@ public class NotificationMessage {
public boolean isNotExpired() throws NotificationException {
try {
long currentTime = System.currentTimeMillis();
return (currentTime < this.jmsMessage.getJMSExpiration() ? true : false);
return (currentTime < this.jmsMessage.getJMSExpiration() ? true
: false);
} catch (JMSException e) {
throw new NotificationException(
"Error retrieving source information", e);
@ -188,8 +187,8 @@ public class NotificationMessage {
}
/**
* Returns the time as a long when the message was handled off to the provider to
* be sent.
* Returns the time as a long when the message was handled off to the
* provider to be sent.
*
* @return long, the time as in milliseconds.
* @throws NotificationException

View file

@ -19,7 +19,6 @@
**/
package com.raytheon.uf.common.dataplugin.cwat;
import java.io.ByteArrayInputStream;
import java.util.HashMap;
import javax.persistence.Access;
@ -74,11 +73,12 @@ import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement;
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* 06/03/09 2037 D. Hladky Initial release
* Apr 4, 2013 1846 bkowal Added an index on refTime and forecastTime
* Apr 04, 2013 1846 bkowal Added an index on refTime and forecastTime
* 04/08/13 1293 bkowal Removed references to hdffileid.
* Apr 12, 2013 1857 bgonzale Added SequenceGenerator annotation.
* May 07, 2013 1869 bsteffen Remove dataURI column from
* PluginDataObject.
* Aug 06, 2013 2228 njensen Use deserialize(byte[])
*
* </pre>
*
@ -92,17 +92,13 @@ import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement;
* Both refTime and forecastTime are included in the refTimeIndex since
* forecastTime is unlikely to be used.
*/
@org.hibernate.annotations.Table(
appliesTo = "cwat",
indexes = {
@Index(name = "cwat_refTimeIndex", columnNames = { "refTime", "forecastTime" } )
}
)
@org.hibernate.annotations.Table(appliesTo = "cwat", indexes = { @Index(name = "cwat_refTimeIndex", columnNames = {
"refTime", "forecastTime" }) })
@XmlRootElement
@XmlAccessorType(XmlAccessType.NONE)
@DynamicSerialize
public class CWATRecord extends PersistablePluginDataObject
implements IPersistable, ISpatialEnabled {
public class CWATRecord extends PersistablePluginDataObject implements
IPersistable, ISpatialEnabled {
private static final long serialVersionUID = 76774564365671L;
@ -476,10 +472,9 @@ public class CWATRecord extends PersistablePluginDataObject
if (getThreats().size() < 1) {
ByteDataRecord byteData = (ByteDataRecord) dataStore.retrieve(
getDataURI(), THREATS, Request.ALL);
ByteArrayInputStream bais = new ByteArrayInputStream(
byteData.getByteData());
Object o = DynamicSerializationManager.getManager(
SerializationType.Thrift).deserialize(bais);
SerializationType.Thrift).deserialize(
byteData.getByteData());
setThreats((HashMap<ThreatLocation, ThreatReport>) o);
}
} catch (Throwable e) {

View file

@ -19,7 +19,6 @@
**/
package com.raytheon.uf.common.dataplugin.preciprate;
import java.io.ByteArrayInputStream;
import java.io.FileNotFoundException;
import java.util.Map;
@ -76,11 +75,12 @@ import com.raytheon.uf.common.status.UFStatus.Priority;
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* 01/25/10 3796 D. Hladky Initial release
* Apr 4, 2013 1846 bkowal Added an index on refTime and forecastTime
* Apr 04, 2013 1846 bkowal Added an index on refTime and forecastTime
* 04/08/13 1293 bkowal Removed references to hdffileid.
* Apr 12, 2013 1857 bgonzale Added SequenceGenerator annotation.
* May 07, 2013 1869 bsteffen Remove dataURI column from
* PluginDataObject.
* Aug 06, 2013 2228 njensen Use deserialize(byte[])
*
* </pre>
*
@ -94,17 +94,13 @@ import com.raytheon.uf.common.status.UFStatus.Priority;
* Both refTime and forecastTime are included in the refTimeIndex since
* forecastTime is unlikely to be used.
*/
@org.hibernate.annotations.Table(
appliesTo = "preciprate",
indexes = {
@Index(name = "preciprate_refTimeIndex", columnNames = { "refTime", "forecastTime" } )
}
)
@org.hibernate.annotations.Table(appliesTo = "preciprate", indexes = { @Index(name = "preciprate_refTimeIndex", columnNames = {
"refTime", "forecastTime" }) })
@XmlRootElement
@XmlAccessorType(XmlAccessType.NONE)
@DynamicSerialize
public class PrecipRateRecord extends PersistablePluginDataObject
implements IMonitorProcessing {
public class PrecipRateRecord extends PersistablePluginDataObject implements
IMonitorProcessing {
private static final transient IUFStatusHandler statusHandler = UFStatus
.getHandler(PrecipRateRecord.class);
@ -342,10 +338,9 @@ public class PrecipRateRecord extends PersistablePluginDataObject
} else if (dataRec[i].getName().equals("DHRMap")) {
try {
ByteDataRecord byteData = (ByteDataRecord) dataRec[i];
ByteArrayInputStream bais = new ByteArrayInputStream(
byteData.getByteData());
Object o = DynamicSerializationManager.getManager(
SerializationType.Thrift).deserialize(bais);
SerializationType.Thrift).deserialize(
byteData.getByteData());
setDhrMap((Map<DHRValues, Double>) o);
} catch (SerializationException e) {
e.printStackTrace();

View file

@ -19,7 +19,6 @@
**/
package com.raytheon.uf.common.dataplugin.radar.util;
import java.io.ByteArrayInputStream;
import java.io.FileNotFoundException;
import java.util.HashMap;
import java.util.Map;
@ -55,6 +54,7 @@ import com.raytheon.uf.common.serialization.SerializationException;
* Feb 21, 2011 mschenke Initial creation
* Mar 18, 2013 1804 bsteffen Remove AlphanumericValues from radar
* HDF5.
* Aug 06, 2013 2228 njensen Use deserialize(byte[])
*
* </pre>
*
@ -97,66 +97,58 @@ public class RadarDataRetriever {
} else if (record.getName().equals(
RadarStoredData.GRAPHIC_BLOCK_ID)) {
ByteDataRecord byteData = (ByteDataRecord) record;
ByteArrayInputStream bais = new ByteArrayInputStream(
byteData.getByteData());
Object o = DynamicSerializationManager.getManager(
SerializationType.Thrift).deserialize(bais);
SerializationType.Thrift).deserialize(
byteData.getByteData());
radarData.setGraphicBlock((GraphicBlock) o);
} else if (record.getName()
.equals(RadarStoredData.SYM_BLOCK_ID)) {
ByteDataRecord byteData = (ByteDataRecord) record;
ByteArrayInputStream bais = new ByteArrayInputStream(
byteData.getByteData());
Object o = DynamicSerializationManager.getManager(
SerializationType.Thrift).deserialize(bais);
SerializationType.Thrift).deserialize(
byteData.getByteData());
radarData.setSymbologyBlock((SymbologyBlock) o);
} else if (record.getName().equals(RadarStoredData.SYM_DATA_ID)) {
ByteDataRecord byteData = (ByteDataRecord) record;
ByteArrayInputStream bais = new ByteArrayInputStream(
byteData.getByteData());
Object o = DynamicSerializationManager.getManager(
SerializationType.Thrift).deserialize(bais);
SerializationType.Thrift).deserialize(
byteData.getByteData());
radarData
.setSymbologyData((HashMap<RadarDataKey, RadarDataPoint>) o);
} else if (record.getName().equals(
RadarStoredData.PRODUCT_VALS_ID)) {
ByteDataRecord byteData = (ByteDataRecord) record;
ByteArrayInputStream bais = new ByteArrayInputStream(
byteData.getByteData());
Object o = DynamicSerializationManager.getManager(
SerializationType.Thrift).deserialize(bais);
SerializationType.Thrift).deserialize(
byteData.getByteData());
radarData
.setProductVals((HashMap<RadarConstants.MapValues, Map<String, Map<RadarConstants.MapValues, String>>>) o);
} else if (record.getName().equals(
RadarStoredData.RECORD_VALS_ID)) {
ByteDataRecord byteData = (ByteDataRecord) record;
ByteArrayInputStream bais = new ByteArrayInputStream(
byteData.getByteData());
Object o = DynamicSerializationManager.getManager(
SerializationType.Thrift).deserialize(bais);
SerializationType.Thrift).deserialize(
byteData.getByteData());
radarData
.setMapRecordVals((HashMap<RadarConstants.MapValues, Map<RadarConstants.MapValues, String>>) o);
} else if (record.getName().equals(RadarStoredData.GSM_ID)) {
ByteDataRecord byteData = (ByteDataRecord) record;
ByteArrayInputStream bais = new ByteArrayInputStream(
byteData.getByteData());
Object o = DynamicSerializationManager.getManager(
SerializationType.Thrift).deserialize(bais);
SerializationType.Thrift).deserialize(
byteData.getByteData());
radarData.setGsmMessage((GSMMessage) o);
} else if (record.getName()
.equals(RadarStoredData.STORM_IDS_ID)) {
ByteDataRecord byteData = (ByteDataRecord) record;
ByteArrayInputStream bais = new ByteArrayInputStream(
byteData.getByteData());
Object o = DynamicSerializationManager.getManager(
SerializationType.Thrift).deserialize(bais);
SerializationType.Thrift).deserialize(
byteData.getByteData());
radarData.setStormIDs((Map<String, RadarDataKey>) o);
} else if (record.getName().equals(RadarStoredData.AAP_ID)) {
ByteDataRecord byteData = (ByteDataRecord) record;
ByteArrayInputStream bais = new ByteArrayInputStream(
byteData.getByteData());
Object o = DynamicSerializationManager.getManager(
SerializationType.Thrift).deserialize(bais);
SerializationType.Thrift).deserialize(
byteData.getByteData());
radarData.setAapMessage((AlertAdaptationParameters) o);
} else if (record.getName().equals(
RadarStoredData.THRESHOLDS_ID)) {
@ -170,10 +162,9 @@ public class RadarDataRetriever {
} else if (record.getName().equals(
RadarStoredData.ALERT_MESSAGE_ID)) {
ByteDataRecord byteData = (ByteDataRecord) record;
ByteArrayInputStream bais = new ByteArrayInputStream(
byteData.getByteData());
Object o = DynamicSerializationManager.getManager(
SerializationType.Thrift).deserialize(bais);
SerializationType.Thrift).deserialize(
byteData.getByteData());
radarData.setAlertMessage((AlertMessage) o);
} else {
size -= record.getSizeInBytes();

View file

@ -19,7 +19,6 @@
**/
package com.raytheon.uf.common.dataplugin.scan;
import java.io.ByteArrayInputStream;
import java.util.Date;
import java.util.Set;
@ -71,11 +70,12 @@ import com.raytheon.uf.common.status.UFStatus.Priority;
* 03/17/10 2521 D. Hladky Initial release
* 02/01/13 1649 D. Hladky better logging,
* Feb 28, 2013 1731 bsteffen Optimize construction of scan resource.
* Apr 4, 2013 1846 bkowal Added an index on refTime and forecastTime
* Apr 8, 2013 1293 bkowal Removed references to hdffileid.
* Apr 04, 2013 1846 bkowal Added an index on refTime and forecastTime
* Apr 08, 2013 1293 bkowal Removed references to hdffileid.
* Apr 12, 2013 1857 bgonzale Added SequenceGenerator annotation.
* May 07, 2013 1869 bsteffen Remove dataURI column from
* PluginDataObject.
* Aug 06, 2013 2228 njensen Use deserialize(byte[])
*
* </pre>
*
@ -90,12 +90,8 @@ import com.raytheon.uf.common.status.UFStatus.Priority;
* Both refTime and forecastTime are included in the refTimeIndex since
* forecastTime is unlikely to be used.
*/
@org.hibernate.annotations.Table(
appliesTo = "scan",
indexes = {
@Index(name = "scan_refTimeIndex", columnNames = { "refTime", "forecastTime" } )
}
)
@org.hibernate.annotations.Table(appliesTo = "scan", indexes = { @Index(name = "scan_refTimeIndex", columnNames = {
"refTime", "forecastTime" }) })
@XmlRootElement
@XmlAccessorType(XmlAccessType.NONE)
@DynamicSerialize
@ -297,10 +293,8 @@ public class ScanRecord extends PersistablePluginDataObject {
*/
public void setTableData(ByteDataRecord byteData)
throws SerializationException {
ByteArrayInputStream bais = new ByteArrayInputStream(
byteData.getByteData());
Object o = DynamicSerializationManager.getManager(
SerializationType.Thrift).deserialize(bais);
SerializationType.Thrift).deserialize(byteData.getByteData());
setTableData((ScanTableData<?>) o);
}
@ -316,7 +310,8 @@ public class ScanRecord extends PersistablePluginDataObject {
getDataURI(), getType(), Request.ALL);
setTableData(byteData);
} catch (Throwable e) {
statusHandler.handle(Priority.ERROR, "Couldn't load Table data!" + getDataURI());
statusHandler.handle(Priority.ERROR, "Couldn't load Table data!"
+ getDataURI());
}
}
@ -329,13 +324,13 @@ public class ScanRecord extends PersistablePluginDataObject {
try {
ByteDataRecord byteData = (ByteDataRecord) dataStore.retrieve(
getDataURI(), getType() + "/sounding", Request.ALL);
ByteArrayInputStream bais = new ByteArrayInputStream(
byteData.getByteData());
Object o = DynamicSerializationManager.getManager(
SerializationType.Thrift).deserialize(bais);
SerializationType.Thrift).deserialize(
byteData.getByteData());
setSoundingData((SoundingData) o);
} catch (Throwable e) {
statusHandler.handle(Priority.ERROR, "Couldn't load Sounding data!" + getDataURI());
statusHandler.handle(Priority.ERROR, "Couldn't load Sounding data!"
+ getDataURI());
}
}
@ -348,13 +343,13 @@ public class ScanRecord extends PersistablePluginDataObject {
try {
ByteDataRecord byteData = (ByteDataRecord) dataStore.retrieve(
getDataURI(), getType() + "/model", Request.ALL);
ByteArrayInputStream bais = new ByteArrayInputStream(
byteData.getByteData());
Object o = DynamicSerializationManager.getManager(
SerializationType.Thrift).deserialize(bais);
SerializationType.Thrift).deserialize(
byteData.getByteData());
setModelData((ModelData) o);
} catch (Throwable e) {
statusHandler.handle(Priority.ERROR, "Couldn't load Model data!" + getDataURI());
statusHandler.handle(Priority.ERROR, "Couldn't load Model data!"
+ getDataURI());
}
}

View file

@ -20,16 +20,13 @@
package com.raytheon.uf.common.localization.msgs;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import javax.xml.bind.JAXBException;
import com.raytheon.uf.common.localization.exception.LocalizationException;
import com.raytheon.uf.common.serialization.DynamicSerializationManager;
import com.raytheon.uf.common.serialization.DynamicSerializationManager.SerializationType;
import com.raytheon.uf.common.serialization.SerializationException;
import com.raytheon.uf.common.serialization.SerializationUtil;
import com.raytheon.uf.common.serialization.DynamicSerializationManager.SerializationType;
/**
* Utility class for converting and constructing localization messages
@ -184,22 +181,12 @@ public class UtilityMessageMarshaller {
private static Object deserializeBinary(byte[] message, Class<?> c)
throws LocalizationException {
ByteArrayInputStream bais = null;
try {
DynamicSerializationManager mgr = DynamicSerializationManager
.getManager(SerializationType.Thrift);
bais = new ByteArrayInputStream(message);
return mgr.deserialize(bais);
return mgr.deserialize(message);
} catch (SerializationException e) {
throw new LocalizationException("Unable to deserialize: ", e);
} finally {
try {
if (bais != null)
bais.close();
} catch (IOException e) {
// ignore
}
}
}

View file

@ -1,11 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>com.raytheon.uf.common.qpf</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
</buildSpec>
<natures>
</natures>
</projectDescription>

View file

@ -91,6 +91,7 @@ import com.vividsolutions.jts.geom.Geometry;
* serialization adapter is encoded
* in serialization stream.
* Nov 02, 2012 1302 djohnson Remove field level adapters, they break python serialization.
* Aug 06, 2013 2228 njensen Added deserialize(byte[])
*
* </pre>
*
@ -256,7 +257,6 @@ public class DynamicSerializationManager {
Object obj = deserialize(ctx);
ctx.readMessageEnd();
return obj;
}
/**
@ -273,6 +273,22 @@ public class DynamicSerializationManager {
return ((ThriftSerializationContext) ctx).deserializeMessage();
}
/**
* Deserialize an object from a byte[]
*
* @param data
* @return
* @throws SerializationException
*/
public Object deserialize(byte[] data) throws SerializationException {
IDeserializationContext ctx = this.builder.buildDeserializationContext(
data, this);
ctx.readMessageStart();
Object obj = deserialize(ctx);
ctx.readMessageEnd();
return obj;
}
public static <T> void registerAdapter(Class<? extends T> clazz,
ISerializationTypeAdapter<T> adapter) {
SerializationMetadata md = new SerializationMetadata();

View file

@ -31,6 +31,7 @@ import java.io.OutputStream;
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Aug 12, 2008 chammack Initial creation
* Aug 06, 2013 2228 njensen Added buildDeserializationContext(byte[], dsm)
*
* </pre>
*
@ -63,4 +64,16 @@ public interface ISerializationContextBuilder {
public IDeserializationContext buildDeserializationContext(
InputStream data, DynamicSerializationManager manager);
/**
* Build a deserialization context
*
* @param data
* the bytes of the data
* @param manager
* the serialization manager
* @return a deserialization context
*/
public IDeserializationContext buildDeserializationContext(byte[] data,
DynamicSerializationManager manager);
}

View file

@ -19,9 +19,7 @@
**/
package com.raytheon.uf.common.serialization;
import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.List;
@ -47,6 +45,7 @@ import com.raytheon.uf.common.util.ServiceLoaderUtil;
* Feb 07, 2013 1543 djohnson Use ServiceLoader to find how to load jaxbable classes, defaulting to SerializableManager.
* Mar 21, 2013 1794 djohnson ServiceLoaderUtil now requires the requesting class.
* May 01, 2013 1968 djohnson Prevent deadlock due to SerializableManager threads needing to serialize things.
* Aug 06, 2013 2228 njensen More efficient transformFromThrift(Class, byte[])
*
* </pre>
*
@ -351,20 +350,10 @@ public final class SerializationUtil {
throws SerializationException {
DynamicSerializationManager dsm = DynamicSerializationManager
.getManager(SerializationType.Thrift);
ByteArrayInputStream bais = null;
try {
bais = new ByteArrayInputStream(bytes);
return clazz.cast(dsm.deserialize(bais));
return clazz.cast(dsm.deserialize(bytes));
} catch (ClassCastException cce) {
throw new SerializationException(cce);
} finally {
if (bais != null) {
try {
bais.close();
} catch (IOException e) {
// ignore
}
}
}
}

View file

@ -58,6 +58,8 @@ import org.apache.thrift.transport.TTransport;
* Jun 12, 2013 2102 njensen Added max read length to prevent out
* of memory errors due to bad stream
* Jul 23, 2013 2215 njensen Updated for thrift 0.9.0
* Aug 06, 2013 2228 njensen Overrode readBinary() to ensure it
* doesn't read too much
*
* </pre>
*
@ -99,6 +101,15 @@ public class SelfDescribingBinaryProtocol extends TBinaryProtocol {
this.setReadLength(MAX_READ_LENGTH);
}
@Override
public ByteBuffer readBinary() throws TException {
int size = readI32();
checkReadLength(size);
byte[] buf = new byte[size];
trans_.readAll(buf, 0, size);
return ByteBuffer.wrap(buf);
}
/*
* (non-Javadoc)
*

View file

@ -23,6 +23,7 @@ import java.io.InputStream;
import java.io.OutputStream;
import org.apache.thrift.transport.TIOStreamTransport;
import org.apache.thrift.transport.TMemoryInputTransport;
import org.apache.thrift.transport.TTransport;
import com.raytheon.uf.common.serialization.DynamicSerializationManager;
@ -39,6 +40,7 @@ import com.raytheon.uf.common.serialization.ISerializationContextBuilder;
* ------------ ---------- ----------- --------------------------
* Aug 12, 2008 chammack Initial creation
* Jul 23, 2013 2215 njensen Updated for thrift 0.9.0
* Aug 06, 2013 2228 njensen Added buildDeserializationContext(byte[], dsm)
*
* </pre>
*
@ -83,4 +85,15 @@ public class ThriftSerializationContextBuilder implements
return new ThriftSerializationContext(proto, manager);
}
@Override
public IDeserializationContext buildDeserializationContext(byte[] data,
DynamicSerializationManager manager) {
TTransport transport = new TMemoryInputTransport(data);
SelfDescribingBinaryProtocol proto = new SelfDescribingBinaryProtocol(
transport);
return new ThriftSerializationContext(proto, manager);
}
}

View file

@ -1,4 +1,3 @@
package gov.noaa.nws.ncep.edex.plugin.mosaic.common;
import gov.noaa.nws.ncep.edex.plugin.mosaic.util.MosaicConstants;
@ -8,7 +7,6 @@ import gov.noaa.nws.ncep.edex.plugin.mosaic.util.level3.SymbologyBlock;
import gov.noaa.nws.ncep.edex.plugin.mosaic.util.level3.SymbologyPacket;
import gov.noaa.nws.ncep.edex.plugin.mosaic.util.level3.SymbologyPoint;
import java.io.ByteArrayInputStream;
import java.io.FileNotFoundException;
import java.util.ArrayList;
import java.util.Calendar;
@ -71,6 +69,7 @@ import com.vividsolutions.jts.geom.Coordinate;
* Apr 12, 2013 1857 bgonzale Added SequenceGenerator annotation.
* May 07, 2013 1869 bsteffen Remove dataURI column from
* PluginDataObject.
* Aug 06, 2013 2228 njensen Use deserialize(byte[])
*
* </pre>
*
@ -80,7 +79,6 @@ import com.vividsolutions.jts.geom.Coordinate;
* @version 1.0
*/
@Entity
@SequenceGenerator(initialValue = 1, name = PluginDataObject.ID_GEN, sequenceName = "mosaicseq")
@Table(name = "mosaic", uniqueConstraints = { @UniqueConstraint(columnNames = { "dataURI" }) })
@ -88,12 +86,8 @@ import com.vividsolutions.jts.geom.Coordinate;
* Both refTime and forecastTime are included in the refTimeIndex since
* forecastTime is unlikely to be used.
*/
@org.hibernate.annotations.Table(
appliesTo = "mosaic",
indexes = {
@Index(name = "mosaic_refTimeIndex", columnNames = { "refTime", "forecastTime" } )
}
)
@org.hibernate.annotations.Table(appliesTo = "mosaic", indexes = { @Index(name = "mosaic_refTimeIndex", columnNames = {
"refTime", "forecastTime" }) })
@Cache(usage = CacheConcurrencyStrategy.TRANSACTIONAL)
@XmlRootElement
@XmlAccessorType(XmlAccessType.NONE)
@ -272,10 +266,9 @@ public class MosaicRecord extends PersistablePluginDataObject implements
// getDataURI(), "Symbology");
ByteDataRecord byteData = (ByteDataRecord) dataStore.retrieve(
getDataURI(), "Symbology", Request.ALL);
ByteArrayInputStream bais = new ByteArrayInputStream(
byteData.getByteData());
Object o = DynamicSerializationManager.getManager(
SerializationType.Thrift).deserialize(bais);
SerializationType.Thrift).deserialize(
byteData.getByteData());
setSymbologyBlock((SymbologyBlock) o);
} catch (Throwable e) {
setSymbologyBlock(null);
@ -284,10 +277,9 @@ public class MosaicRecord extends PersistablePluginDataObject implements
try {
ByteDataRecord byteData = (ByteDataRecord) dataStore.retrieve(
getDataURI(), "ProductVals", Request.ALL);
ByteArrayInputStream bais = new ByteArrayInputStream(
byteData.getByteData());
Object o = DynamicSerializationManager.getManager(
SerializationType.Thrift).deserialize(bais);
SerializationType.Thrift).deserialize(
byteData.getByteData());
setProductVals((HashMap<MosaicConstants.MapValues, Map<String, Map<MosaicConstants.MapValues, String>>>) o);
} catch (Throwable e) {
setProductVals(null);

View file

@ -19,7 +19,6 @@
**/
package com.raytheon.uf.common.message;
import java.io.ByteArrayInputStream;
import java.net.InetAddress;
import java.net.UnknownHostException;
import java.util.Random;
@ -89,8 +88,7 @@ public class TestWsIdAdapter {
Test outTest = null;
try {
ByteArrayInputStream bais = new ByteArrayInputStream(bdata);
outTest = (Test) dmgr.deserialize(bais);
outTest = (Test) dmgr.deserialize(bdata);
} catch (Throwable e) {
e.printStackTrace();
Assert.fail(e.getMessage());