Issue #1310: Fix automated tropical testing support code after Data Delivery and Unified Grid

baseline merges.

Change-Id: Ia134ecd68c1468b281e7dca6e56f5cbc20047583

Former-commit-id: 0f13b5d0b1 [formerly 0c3a35f339819afc5ed79202c95215ed90890df8]
Former-commit-id: ec7a7c1373
This commit is contained in:
David Gillingham 2012-11-02 15:09:27 -05:00
parent 8da303506f
commit f998d419d9
11 changed files with 287 additions and 59 deletions

View file

@ -0,0 +1,78 @@
/**
* This software was developed and / or modified by Raytheon Company,
* pursuant to Contract DG133W-05-CQ-1067 with the US Government.
*
* U.S. EXPORT CONTROLLED TECHNICAL DATA
* This software product contains export-restricted data whose
* export/transfer/disclosure is restricted by U.S. law. Dissemination
* to non-U.S. persons whether in the United States or abroad requires
* an export license or other authorization.
*
* Contractor Name: Raytheon Company
* Contractor Address: 6825 Pine Street, Suite 340
* Mail Stop B8
* Omaha, NE 68106
* 402.291.0100
*
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
* further licensing information.
**/
package com.raytheon.uf.common.dataplugin.grid.request;
import com.raytheon.uf.common.serialization.annotations.DynamicSerialize;
import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement;
import com.raytheon.uf.common.serialization.comm.IServerRequest;
/**
* Request object used to delete all stored data for the specified model name.
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Nov 2, 2012 dgilling Initial creation
*
* </pre>
*
* @author dgilling
* @version 1.0
*/
@DynamicSerialize
public class DeleteAllGridDataRequest implements IServerRequest {
@DynamicSerializeElement
private String modelName;
public DeleteAllGridDataRequest() {
this(null);
}
public DeleteAllGridDataRequest(String modelName) {
this.modelName = modelName;
}
public String getModelName() {
return modelName;
}
public void setModelName(String modelName) {
this.modelName = modelName;
}
/*
* (non-Javadoc)
*
* @see java.lang.Object#toString()
*/
@Override
public String toString() {
StringBuilder builder = new StringBuilder();
builder.append("DeleteAllGridDataRequest [modelName=");
builder.append(modelName);
builder.append("]");
return builder.toString();
}
}

View file

@ -75,9 +75,6 @@ import com.sun.org.apache.xerces.internal.jaxp.datatype.XMLGregorianCalendarImpl
import com.vividsolutions.jts.geom.Coordinate; import com.vividsolutions.jts.geom.Coordinate;
import com.vividsolutions.jts.geom.Envelope; import com.vividsolutions.jts.geom.Envelope;
import com.vividsolutions.jts.geom.Geometry; import com.vividsolutions.jts.geom.Geometry;
import com.vividsolutions.jts.geom.MultiPolygon;
import com.vividsolutions.jts.geom.Point;
import com.vividsolutions.jts.geom.Polygon;
/** /**
* Dynamic Serialization Manager provides a serialization capability that runs * Dynamic Serialization Manager provides a serialization capability that runs
@ -95,6 +92,8 @@ import com.vividsolutions.jts.geom.Polygon;
* Oct 08, 2012 #1251 dgilling Ensure type registered with * Oct 08, 2012 #1251 dgilling Ensure type registered with
* serialization adapter is encoded * serialization adapter is encoded
* in serialization stream. * in serialization stream.
* Nov 02, 2012 1310 djohnson Remove field level adapters, they
* break python serialization.
* *
* </pre> * </pre>
* *
@ -125,7 +124,8 @@ public class DynamicSerializationManager {
// TODO: Can the registration of adapters that require dependencies be // TODO: Can the registration of adapters that require dependencies be
// moved to a separate plugin somehow? // moved to a separate plugin somehow?
registerAdapter(GregorianCalendar.class, new CalendarSerializer()); registerAdapter(GregorianCalendar.class, new CalendarSerializer());
registerAdapter(XMLGregorianCalendarImpl.class, new BuiltInTypeSupport.XMLGregorianCalendarSerializer()); registerAdapter(XMLGregorianCalendarImpl.class,
new BuiltInTypeSupport.XMLGregorianCalendarSerializer());
registerAdapter(Date.class, new DateSerializer()); registerAdapter(Date.class, new DateSerializer());
registerAdapter(Timestamp.class, new TimestampSerializer()); registerAdapter(Timestamp.class, new TimestampSerializer());
registerAdapter(java.sql.Date.class, registerAdapter(java.sql.Date.class,
@ -137,17 +137,16 @@ public class DynamicSerializationManager {
registerAdapter(BigInteger.class, registerAdapter(BigInteger.class,
new BuiltInTypeSupport.BigIntegerSerializer()); new BuiltInTypeSupport.BigIntegerSerializer());
registerAdapter(Geometry.class, new GeometryTypeAdapter()); registerAdapter(Geometry.class, new GeometryTypeAdapter());
registerAdapter(Polygon.class, new GeometryTypeAdapter());
registerAdapter(MultiPolygon.class, new GeometryTypeAdapter());
registerAdapter(Point.class, new GeometryTypeAdapter());
registerAdapter(Envelope.class, new JTSEnvelopeAdapter()); registerAdapter(Envelope.class, new JTSEnvelopeAdapter());
registerAdapter(GridGeometry2D.class, new GridGeometry2DAdapter()); registerAdapter(GridGeometry2D.class, new GridGeometry2DAdapter());
registerAdapter(GeneralGridGeometry.class, new GridGeometryAdapter()); registerAdapter(GeneralGridGeometry.class, new GridGeometryAdapter());
registerAdapter(EnumSet.class, new EnumSetAdapter()); registerAdapter(EnumSet.class, new EnumSetAdapter());
registerAdapter(StackTraceElement.class, new StackTraceElementAdapter()); registerAdapter(StackTraceElement.class, new StackTraceElementAdapter());
registerAdapter(Duration.class, new BuiltInTypeSupport.DurationSerializer()); registerAdapter(Duration.class,
new BuiltInTypeSupport.DurationSerializer());
registerAdapter(QName.class, new BuiltInTypeSupport.QNameSerializer()); registerAdapter(QName.class, new BuiltInTypeSupport.QNameSerializer());
registerAdapter(Throwable.class, new BuiltInTypeSupport.ThrowableSerializer()); registerAdapter(Throwable.class,
new BuiltInTypeSupport.ThrowableSerializer());
// These two are OBE by BufferAdapter and should be deleted sometime // These two are OBE by BufferAdapter and should be deleted sometime
registerAdapter(ByteBuffer.class, new ByteBufferAdapter()); registerAdapter(ByteBuffer.class, new ByteBufferAdapter());
registerAdapter(FloatBuffer.class, new FloatBufferAdapter()); registerAdapter(FloatBuffer.class, new FloatBufferAdapter());
@ -302,7 +301,6 @@ public class DynamicSerializationManager {
* the class * the class
* @return the metadata * @return the metadata
*/ */
@SuppressWarnings("rawtypes")
public static SerializationMetadata inspect(Class<?> c) { public static SerializationMetadata inspect(Class<?> c) {
// Check for base types // Check for base types
@ -392,30 +390,17 @@ public class DynamicSerializationManager {
if (annotation != null) { if (annotation != null) {
String fieldName = field.getName(); String fieldName = field.getName();
attribs.serializedAttributes.add(fieldName); attribs.serializedAttributes.add(field.getName());
// Can be specified at field or class level
Class<? extends ISerializationTypeAdapter> fieldAdapter = null;
if (serializeAdapterTag == null) { if (serializeAdapterTag == null) {
// Adapter specified at field level serializeAdapterTag = field.getType()
if (annotation.value() != ISerializationTypeAdapter.class) {
fieldAdapter = annotation.value();
} else {
// Adapter specified at class level
serializeAdapterTag = field
.getType()
.getAnnotation( .getAnnotation(
DynamicSerializeTypeAdapter.class); DynamicSerializeTypeAdapter.class);
}
if (serializeAdapterTag != null) { if (serializeAdapterTag != null) {
fieldAdapter = serializeAdapterTag
.factory();
}
}
}
if (fieldAdapter != null) {
try { try {
attribs.attributesWithFactories.put(fieldName, attribs.attributesWithFactories.put(fieldName,
fieldAdapter.newInstance()); serializeAdapterTag.factory()
.newInstance());
} catch (Exception e) { } catch (Exception e) {
throw new RuntimeException( throw new RuntimeException(
"Factory could not be instantiated", e); "Factory could not be instantiated", e);
@ -514,5 +499,4 @@ public class DynamicSerializationManager {
return sm; return sm;
} }
} }

View file

@ -38,22 +38,22 @@ import com.raytheon.uf.common.serialization.ISerializationTypeAdapter;
* factory will be used to serialize/deserialize the value. * factory will be used to serialize/deserialize the value.
* *
* <pre> * <pre>
*
* SOFTWARE HISTORY * SOFTWARE HISTORY
*
* Date Ticket# Engineer Description * Date Ticket# Engineer Description
* ------------ ---------- ----------- -------------------------- * ------------ ---------- ----------- --------------------------
* Aug 07, 2008 chammack Initial creation * Aug 07, 2008 chammack Initial creation
* Sep 28, 2012 1195 djohnson Add value() to specify a type adapter. * Sep 28, 2012 1195 djohnson Add value() to specify a type adapter.
* Nov 02, 2012 1302 djohnson No more field level adapters.
* *
* </pre> * </pre>
* *
* @author chammack * @author dgilling
* @version 1.0 * @version 1.0
*/ */
@Retention(RetentionPolicy.RUNTIME) @Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.FIELD) @Target(ElementType.FIELD)
@Documented @Documented
public @interface DynamicSerializeElement { public @interface DynamicSerializeElement {
@SuppressWarnings("rawtypes")
Class<? extends ISerializationTypeAdapter> value() default ISerializationTypeAdapter.class;
} }

View file

@ -65,6 +65,7 @@ import com.raytheon.uf.common.serialization.SerializationException;
* Mar 01, 2011 njensen Restructured deserializeArray() * Mar 01, 2011 njensen Restructured deserializeArray()
* Sep 14, 2012 #1169 djohnson Add ability to write another object into the stream directly. * Sep 14, 2012 #1169 djohnson Add ability to write another object into the stream directly.
* Sep 28, 2012 #1195 djohnson Add ability to specify adapter at field level. * Sep 28, 2012 #1195 djohnson Add ability to specify adapter at field level.
* Nov 02, 2012 1310 djohnson No more field level adapters.
* *
* </pre> * </pre>
* *
@ -717,10 +718,7 @@ public class ThriftSerializationContext extends BaseSerializationContext {
field.name = keyStr; field.name = keyStr;
protocol.writeFieldBegin(field); protocol.writeFieldBegin(field);
if (adapter != null) { if (type != TType.VOID) {
// If there is an adapter, use it to serialize
adapter.serialize(this, val);
} else if (type != TType.VOID) {
// Otherwise, as long as it's not void, use basic type serialization // Otherwise, as long as it's not void, use basic type serialization
serializeType(val, valClass, type); serializeType(val, valClass, type);
} }
@ -849,9 +847,6 @@ public class ThriftSerializationContext extends BaseSerializationContext {
FastClass fc, BeanMap bm) throws TException, SerializationException { FastClass fc, BeanMap bm) throws TException, SerializationException {
TField field = protocol.readFieldBegin(); TField field = protocol.readFieldBegin();
// System.out.println(field.type);
ISerializationTypeAdapter factory = md.attributesWithFactories
.get(field.name);
Object obj = null; Object obj = null;
if (field.type == TType.STOP) { if (field.type == TType.STOP) {
@ -859,12 +854,8 @@ public class ThriftSerializationContext extends BaseSerializationContext {
} }
if (field.type != TType.VOID) { if (field.type != TType.VOID) {
if (factory != null) {
obj = factory.deserialize(this);
} else {
obj = deserializeType(field.type, o.getClass(), fc, field.name, obj = deserializeType(field.type, o.getClass(), fc, field.name,
EnclosureType.FIELD); EnclosureType.FIELD);
}
if (field.type == TType.STRING) { if (field.type == TType.STRING) {
Class<?> fieldClass = findFieldClass(o.getClass(), field.name); Class<?> fieldClass = findFieldClass(o.getClass(), field.name);
if (fieldClass != null && fieldClass.isEnum()) { if (fieldClass != null && fieldClass.isEnum()) {

View file

@ -12,5 +12,11 @@
<constructor-arg ref="gridTreeHandler" /> <constructor-arg ref="gridTreeHandler" />
</bean> </bean>
<bean id="deleteAllDataHandler"
class="com.raytheon.uf.edex.plugin.grid.handler.DeleteAllGridDataHandler" />
<bean factory-bean="handlerRegistry" factory-method="register">
<constructor-arg
value="com.raytheon.uf.common.dataplugin.grid.request.DeleteAllGridDataRequest" />
<constructor-arg ref="deleteAllDataHandler" />
</bean>
</beans> </beans>

View file

@ -0,0 +1,72 @@
/**
* This software was developed and / or modified by Raytheon Company,
* pursuant to Contract DG133W-05-CQ-1067 with the US Government.
*
* U.S. EXPORT CONTROLLED TECHNICAL DATA
* This software product contains export-restricted data whose
* export/transfer/disclosure is restricted by U.S. law. Dissemination
* to non-U.S. persons whether in the United States or abroad requires
* an export license or other authorization.
*
* Contractor Name: Raytheon Company
* Contractor Address: 6825 Pine Street, Suite 340
* Mail Stop B8
* Omaha, NE 68106
* 402.291.0100
*
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
* further licensing information.
**/
package com.raytheon.uf.edex.plugin.grid.handler;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import com.raytheon.uf.common.dataplugin.grid.request.DeleteAllGridDataRequest;
import com.raytheon.uf.common.serialization.comm.IRequestHandler;
import com.raytheon.uf.edex.plugin.grid.dao.GridDao;
/**
* Request handler for <code>DeleteAllGridDataRequest</code>.
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Nov 2, 2012 dgilling Initial creation
*
* </pre>
*
* @author dgilling
* @version 1.0
*/
public class DeleteAllGridDataHandler implements
IRequestHandler<DeleteAllGridDataRequest> {
/*
* (non-Javadoc)
*
* @see
* com.raytheon.uf.common.serialization.comm.IRequestHandler#handleRequest
* (com.raytheon.uf.common.serialization.comm.IServerRequest)
*/
@Override
public Integer handleRequest(DeleteAllGridDataRequest request)
throws Exception {
Map<String, String> productKeys = new HashMap<String, String>();
productKeys.put("info.datasetId", request.getModelName());
GridDao dao = new GridDao();
List<Date> times = dao.getRefTimesForCriteria(productKeys);
int recsDeleted = 0;
for (Date time : times) {
recsDeleted += dao.purgeDataByRefTime(time, productKeys);
}
return recsDeleted;
}
}

View file

@ -23,6 +23,7 @@
import logging import logging
from dynamicserialize.dstypes.com.raytheon.uf.common.dataplugin.grib.request import DeleteAllModelDataRequest from dynamicserialize.dstypes.com.raytheon.uf.common.dataplugin.grib.request import DeleteAllModelDataRequest
from dynamicserialize.dstypes.com.raytheon.uf.common.dataplugin.grid.request import DeleteAllGridDataRequest
from ufpy import ThriftClient from ufpy import ThriftClient
from ufpy import UsageArgumentParser from ufpy import UsageArgumentParser
@ -63,13 +64,20 @@ def main():
client = ThriftClient.ThriftClient(options.host, options.port) client = ThriftClient.ThriftClient(options.host, options.port)
for model in options.models: for model in options.models:
try:
logger.info("Deleting all data for model [" + model + "]...") logger.info("Deleting all data for model [" + model + "]...")
try:
req = DeleteAllModelDataRequest(model) req = DeleteAllModelDataRequest(model)
client.sendRequest(req) client.sendRequest(req)
logger.info("Model data for model [" + model + "] successfully deleted...") logger.info("Grib data for model [" + model + "] successfully deleted...")
except Exception: except Exception:
logger.exception("Could not purge data for model [" + model + "]:") logger.exception("Could not purge grib data for model [" + model + "]:")
try:
req = DeleteAllGridDataRequest(model)
client.sendRequest(req)
logger.info("Grid data for model [" + model + "] successfully deleted...")
except Exception:
logger.exception("Could not purge grid data for model [" + model + "]:")
logger.info("purgeAllModelData is complete.") logger.info("purgeAllModelData is complete.")

View file

@ -22,7 +22,8 @@
__all__ = [ __all__ = [
'gfe', 'gfe',
'grib' 'grib',
'grid'
] ]

View file

@ -0,0 +1,27 @@
##
# This software was developed and / or modified by Raytheon Company,
# pursuant to Contract DG133W-05-CQ-1067 with the US Government.
#
# U.S. EXPORT CONTROLLED TECHNICAL DATA
# This software product contains export-restricted data whose
# export/transfer/disclosure is restricted by U.S. law. Dissemination
# to non-U.S. persons whether in the United States or abroad requires
# an export license or other authorization.
#
# Contractor Name: Raytheon Company
# Contractor Address: 6825 Pine Street, Suite 340
# Mail Stop B8
# Omaha, NE 68106
# 402.291.0100
#
# See the AWIPS II Master Rights File ("Master Rights File.pdf") for
# further licensing information.
##
# File auto-generated by PythonFileGenerator
__all__ = [
'request'
]

View file

@ -0,0 +1,33 @@
##
# This software was developed and / or modified by Raytheon Company,
# pursuant to Contract DG133W-05-CQ-1067 with the US Government.
#
# U.S. EXPORT CONTROLLED TECHNICAL DATA
# This software product contains export-restricted data whose
# export/transfer/disclosure is restricted by U.S. law. Dissemination
# to non-U.S. persons whether in the United States or abroad requires
# an export license or other authorization.
#
# Contractor Name: Raytheon Company
# Contractor Address: 6825 Pine Street, Suite 340
# Mail Stop B8
# Omaha, NE 68106
# 402.291.0100
#
# See the AWIPS II Master Rights File ("Master Rights File.pdf") for
# further licensing information.
##
# File auto-generated against equivalent DynamicSerialize Java class
class DeleteAllGridDataRequest(object):
def __init__(self, modelName=None):
self.modelName = modelName
def getModelName(self):
return self.modelName
def setModelName(self, modelName):
self.modelName = modelName

View file

@ -0,0 +1,28 @@
##
# This software was developed and / or modified by Raytheon Company,
# pursuant to Contract DG133W-05-CQ-1067 with the US Government.
#
# U.S. EXPORT CONTROLLED TECHNICAL DATA
# This software product contains export-restricted data whose
# export/transfer/disclosure is restricted by U.S. law. Dissemination
# to non-U.S. persons whether in the United States or abroad requires
# an export license or other authorization.
#
# Contractor Name: Raytheon Company
# Contractor Address: 6825 Pine Street, Suite 340
# Mail Stop B8
# Omaha, NE 68106
# 402.291.0100
#
# See the AWIPS II Master Rights File ("Master Rights File.pdf") for
# further licensing information.
##
# File auto-generated by PythonFileGenerator
__all__ = [
'DeleteAllGridDataRequest'
]
from DeleteAllGridDataRequest import DeleteAllGridDataRequest