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

baseline merges.

Change-Id: Ia134ecd68c1468b281e7dca6e56f5cbc20047583

Former-commit-id: 251f41414a [formerly 0f13b5d0b1] [formerly ec7a7c1373 [formerly 0c3a35f339819afc5ed79202c95215ed90890df8]]
Former-commit-id: ec7a7c1373
Former-commit-id: f998d419d9
This commit is contained in:
David Gillingham 2012-11-02 15:09:27 -05:00
parent ed53a921a6
commit a82f811659
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.Envelope;
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
@ -95,6 +92,8 @@ import com.vividsolutions.jts.geom.Polygon;
* Oct 08, 2012 #1251 dgilling Ensure type registered with
* serialization adapter is encoded
* in serialization stream.
* Nov 02, 2012 1310 djohnson Remove field level adapters, they
* break python serialization.
*
* </pre>
*
@ -125,7 +124,8 @@ public class DynamicSerializationManager {
// TODO: Can the registration of adapters that require dependencies be
// moved to a separate plugin somehow?
registerAdapter(GregorianCalendar.class, new CalendarSerializer());
registerAdapter(XMLGregorianCalendarImpl.class, new BuiltInTypeSupport.XMLGregorianCalendarSerializer());
registerAdapter(XMLGregorianCalendarImpl.class,
new BuiltInTypeSupport.XMLGregorianCalendarSerializer());
registerAdapter(Date.class, new DateSerializer());
registerAdapter(Timestamp.class, new TimestampSerializer());
registerAdapter(java.sql.Date.class,
@ -137,17 +137,16 @@ public class DynamicSerializationManager {
registerAdapter(BigInteger.class,
new BuiltInTypeSupport.BigIntegerSerializer());
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(GridGeometry2D.class, new GridGeometry2DAdapter());
registerAdapter(GeneralGridGeometry.class, new GridGeometryAdapter());
registerAdapter(EnumSet.class, new EnumSetAdapter());
registerAdapter(StackTraceElement.class, new StackTraceElementAdapter());
registerAdapter(Duration.class, new BuiltInTypeSupport.DurationSerializer());
registerAdapter(Duration.class,
new BuiltInTypeSupport.DurationSerializer());
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
registerAdapter(ByteBuffer.class, new ByteBufferAdapter());
registerAdapter(FloatBuffer.class, new FloatBufferAdapter());
@ -277,7 +276,7 @@ public class DynamicSerializationManager {
throws SerializationException {
return ((ThriftSerializationContext) ctx).deserializeMessage();
}
public static <T> void registerAdapter(Class<? extends T> clazz,
ISerializationTypeAdapter<T> adapter) {
SerializationMetadata md = new SerializationMetadata();
@ -290,7 +289,7 @@ public class DynamicSerializationManager {
}
serializedAttributes.put(md.adapterStructName, md);
}
/**
* Inspect a class and return the metadata for the object
*
@ -302,7 +301,6 @@ public class DynamicSerializationManager {
* the class
* @return the metadata
*/
@SuppressWarnings("rawtypes")
public static SerializationMetadata inspect(Class<?> c) {
// Check for base types
@ -392,30 +390,17 @@ public class DynamicSerializationManager {
if (annotation != null) {
String fieldName = field.getName();
attribs.serializedAttributes.add(fieldName);
// Can be specified at field or class level
Class<? extends ISerializationTypeAdapter> fieldAdapter = null;
attribs.serializedAttributes.add(field.getName());
if (serializeAdapterTag == null) {
// Adapter specified at field level
if (annotation.value() != ISerializationTypeAdapter.class) {
fieldAdapter = annotation.value();
} else {
// Adapter specified at class level
serializeAdapterTag = field
.getType()
serializeAdapterTag = field.getType()
.getAnnotation(
DynamicSerializeTypeAdapter.class);
if (serializeAdapterTag != null) {
fieldAdapter = serializeAdapterTag
.factory();
}
}
}
if (fieldAdapter != null) {
if (serializeAdapterTag != null) {
try {
attribs.attributesWithFactories.put(fieldName,
fieldAdapter.newInstance());
serializeAdapterTag.factory()
.newInstance());
} catch (Exception e) {
throw new RuntimeException(
"Factory could not be instantiated", e);
@ -514,5 +499,4 @@ public class DynamicSerializationManager {
return sm;
}
}

View file

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

View file

@ -58,13 +58,14 @@ import com.raytheon.uf.common.serialization.SerializationException;
*
* <pre>
* SOFTWARE HISTORY
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Aug 12, 2008 #1448 chammack Initial creation
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Aug 12, 2008 #1448 chammack Initial creation
* Jun 17, 2010 #5091 njensen Optimized primitive arrays
* Mar 01, 2011 njensen Restructured deserializeArray()
* 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.
* Nov 02, 2012 1310 djohnson No more field level adapters.
*
* </pre>
*
@ -717,10 +718,7 @@ public class ThriftSerializationContext extends BaseSerializationContext {
field.name = keyStr;
protocol.writeFieldBegin(field);
if (adapter != null) {
// If there is an adapter, use it to serialize
adapter.serialize(this, val);
} else if (type != TType.VOID) {
if (type != TType.VOID) {
// Otherwise, as long as it's not void, use basic type serialization
serializeType(val, valClass, type);
}
@ -849,9 +847,6 @@ public class ThriftSerializationContext extends BaseSerializationContext {
FastClass fc, BeanMap bm) throws TException, SerializationException {
TField field = protocol.readFieldBegin();
// System.out.println(field.type);
ISerializationTypeAdapter factory = md.attributesWithFactories
.get(field.name);
Object obj = null;
if (field.type == TType.STOP) {
@ -859,12 +854,8 @@ public class ThriftSerializationContext extends BaseSerializationContext {
}
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);
}
if (field.type == TType.STRING) {
Class<?> fieldClass = findFieldClass(o.getClass(), field.name);
if (fieldClass != null && fieldClass.isEnum()) {

View file

@ -12,5 +12,11 @@
<constructor-arg ref="gridTreeHandler" />
</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>

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
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 UsageArgumentParser
@ -63,13 +64,20 @@ def main():
client = ThriftClient.ThriftClient(options.host, options.port)
for model in options.models:
logger.info("Deleting all data for model [" + model + "]...")
try:
logger.info("Deleting all data for model [" + model + "]...")
req = DeleteAllModelDataRequest(model)
client.sendRequest(req)
logger.info("Model data for model [" + model + "] successfully deleted...")
logger.info("Grib data for model [" + model + "] successfully deleted...")
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.")

View file

@ -22,7 +22,8 @@
__all__ = [
'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