Merge "Issue #1654 added Adhoc and SubscriptionRequestEvent. Added AdhocDataRetrievalEvent." into development

Former-commit-id: 78c4b99f96 [formerly 907ba11370] [formerly 3f68e90b92] [formerly fed1365d50 [formerly 3f68e90b92 [formerly d18c660b2b9d1f9c679118ca46be45c69d76aea7]]]
Former-commit-id: fed1365d50
Former-commit-id: 8865a2769a423b07a46c1d515ba69f5cdc297eab [formerly 75bdec15f2]
Former-commit-id: 15f4bda876
This commit is contained in:
Richard Peter 2013-08-20 11:01:05 -05:00 committed by Gerrit Code Review
commit 115e4fba92
9 changed files with 328 additions and 6 deletions

View file

@ -0,0 +1,50 @@
package com.raytheon.uf.common.datadelivery.event.retrieval;
/**
* 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.
**/
import com.raytheon.uf.common.serialization.annotations.DynamicSerialize;
/**
* AdhocDataRetrievalEvent.
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Aug 02, 2013 1654 bgonzale Initial implementation.
*
* </pre>
*
* @author bgonzale
* @version 1.0
*/
@DynamicSerialize
public class AdhocDataRetrievalEvent extends DataRetrievalEvent {
private static final long serialVersionUID = 4929206326118854334L;
@Override
public String toString() {
return "Adhoc" + super.toString();
}
}

View file

@ -0,0 +1,46 @@
/**
* 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.datadelivery.event.retrieval;
import com.raytheon.uf.common.serialization.annotations.DynamicSerialize;
/**
*
* Event that occurs when an adhoc subscription request is made.
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Aug 08, 2012 1654 bgonzale Initial creation
*
* </pre>
*
* @author bgonzale
* @version 1.0
*/
@DynamicSerialize
public class AdhocSubscriptionRequestEvent extends SubscriptionRequestEvent {
private static final long serialVersionUID = -8049206300420972922L;
}

View file

@ -0,0 +1,115 @@
/**
* 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.datadelivery.event.retrieval;
import java.util.Map;
import com.raytheon.uf.common.serialization.annotations.DynamicSerialize;
import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement;
import com.raytheon.uf.common.stats.StatisticsEvent;
/**
*
* Event that occurs when a subscription request is made.
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Aug 08, 2013 1654 bgonzale Initial creation
*
* </pre>
*
* @author bgonzale
* @version 1.0
*/
@DynamicSerialize
public class SubscriptionRequestEvent extends StatisticsEvent {
private static final long serialVersionUID = -5302262650866371587L;
@DynamicSerializeElement
protected String owner;
@DynamicSerializeElement
protected String network;
@DynamicSerializeElement
protected String provider;
@DynamicSerializeElement
protected int numRecords = 1;
public String getOwner() {
return owner;
}
public String getNetwork() {
return network;
}
public String getProvider() {
return provider;
}
public void setOwner(String owner) {
this.owner = owner;
}
public void setNetwork(String network) {
this.network = network;
}
public void setProvider(String provider) {
this.provider = provider;
}
public int getNumRecords() {
return numRecords;
}
public void setNumRecords(int numRecords) {
this.numRecords = numRecords;
}
public void incrementNumRecords() {
++this.numRecords;
}
@Override
public String toString() {
return super.toString() + " provider: " + provider + " owner: " + owner
+ " network: " + network + " numRecords: " + numRecords;
}
@Override
protected Map<String, String> getFieldUnitMap() {
// Not Implemented.
return null;
}
@Override
public void finalizeEvent() {
// Not Implemented.
}
}

View file

@ -40,6 +40,7 @@ import com.raytheon.uf.common.stats.StatisticsEvent;
* ------------ ---------- ----------- --------------------------
* Oct 25, 2012 #1340 dhladky Initial creation
*
*
* </pre>
*
* @author dhladky
@ -55,7 +56,6 @@ public class RegistryStatisticsEvent extends StatisticsEvent {
public RegistryStatisticsEvent(String type, String status, String owner,
long duration) {
this.setDate(Calendar.getInstance(TimeZone.getTimeZone("GMT")));
this.setType(getParsedString(type));
this.setStatus(getParsedString(status));

View file

@ -38,4 +38,5 @@ Export-Package: com.raytheon.uf.edex.datadelivery.bandwidth,
com.raytheon.uf.edex.datadelivery.bandwidth.retrieval,
com.raytheon.uf.edex.datadelivery.bandwidth.util
Import-Package: com.raytheon.uf.common.datadelivery.event.retrieval,
com.raytheon.uf.common.datadelivery.registry
com.raytheon.uf.common.datadelivery.registry,
com.raytheon.uf.common.stats

View file

@ -5,8 +5,10 @@ import java.util.Arrays;
import java.util.Calendar;
import java.util.Collections;
import java.util.Date;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.SortedSet;
import java.util.TreeSet;
@ -24,6 +26,8 @@ import com.raytheon.uf.common.datadelivery.bandwidth.IBandwidthRequest.RequestTy
import com.raytheon.uf.common.datadelivery.bandwidth.IProposeScheduleResponse;
import com.raytheon.uf.common.datadelivery.bandwidth.ProposeScheduleResponse;
import com.raytheon.uf.common.datadelivery.bandwidth.data.BandwidthGraphData;
import com.raytheon.uf.common.datadelivery.event.retrieval.AdhocSubscriptionRequestEvent;
import com.raytheon.uf.common.datadelivery.event.retrieval.SubscriptionRequestEvent;
import com.raytheon.uf.common.datadelivery.registry.AdhocSubscription;
import com.raytheon.uf.common.datadelivery.registry.DataType;
import com.raytheon.uf.common.datadelivery.registry.Network;
@ -32,6 +36,7 @@ import com.raytheon.uf.common.datadelivery.registry.SiteSubscription;
import com.raytheon.uf.common.datadelivery.registry.Subscription;
import com.raytheon.uf.common.datadelivery.registry.Time;
import com.raytheon.uf.common.datadelivery.registry.handlers.DataDeliveryHandlers;
import com.raytheon.uf.common.event.EventBus;
import com.raytheon.uf.common.registry.handler.RegistryHandlerException;
import com.raytheon.uf.common.serialization.SerializationException;
import com.raytheon.uf.common.status.IPerformanceStatusHandler;
@ -109,6 +114,7 @@ import com.raytheon.uf.edex.registry.ebxml.exception.EbxmlRegistryException;
* Jul 10, 2013 2106 djohnson Move EDEX instance specific code into its own class.
* Jul 11, 2013 2106 djohnson Propose changing available bandwidth returns subscription names.
* Jul 18, 2013 1653 mpduff Added case GET_SUBSCRIPTION_STATUS.
* Aug 06, 2013 1654 bgonzale Added SubscriptionRequestEvents.
* </pre>
*
* @author dhladky
@ -897,8 +903,42 @@ public abstract class BandwidthManager extends
Set<BandwidthAllocation> unscheduledAllocations = new HashSet<BandwidthAllocation>();
Map<String, SubscriptionRequestEvent> subscriptionEventsMap = new HashMap<String, SubscriptionRequestEvent>();
for (Subscription subscription : subscriptions) {
unscheduledAllocations.addAll(subscriptionUpdated(subscription));
List<BandwidthAllocation> unscheduled = subscriptionUpdated(subscription);
unscheduledAllocations.addAll(unscheduled);
/*
* Create a subscription event or increment an existing event's
* count.
*/
String key = new StringBuilder(subscription.getId())
.append(subscription.getOwner())
.append(subscription.getRoute().toString())
.append(subscription.getProvider()).toString();
SubscriptionRequestEvent event = subscriptionEventsMap.get(key);
if (event == null) {
if (subscription instanceof AdhocSubscription) {
event = new AdhocSubscriptionRequestEvent();
} else {
event = new SubscriptionRequestEvent();
}
event.setId(subscription.getId());
event.setOwner(subscription.getOwner());
event.setNetwork(subscription.getRoute().toString());
event.setProvider(subscription.getProvider());
subscriptionEventsMap.put(key, event);
} else {
event.incrementNumRecords();
}
}
/*
* publish the subscription events.
*/
for (SubscriptionRequestEvent event : subscriptionEventsMap.values()) {
EventBus.publish(event);
}
for (BandwidthAllocation allocation : unscheduledAllocations) {

View file

@ -26,10 +26,12 @@ import java.util.Map;
import java.util.Map.Entry;
import com.google.common.collect.Maps;
import com.raytheon.uf.common.datadelivery.event.retrieval.AdhocDataRetrievalEvent;
import com.raytheon.uf.common.datadelivery.event.retrieval.DataRetrievalEvent;
import com.raytheon.uf.common.datadelivery.registry.Provider.ServiceType;
import com.raytheon.uf.common.datadelivery.retrieval.util.DataSizeUtils;
import com.raytheon.uf.common.datadelivery.retrieval.xml.Retrieval;
import com.raytheon.uf.common.datadelivery.retrieval.xml.Retrieval.SubscriptionType;
import com.raytheon.uf.common.datadelivery.retrieval.xml.RetrievalAttribute;
import com.raytheon.uf.common.dataplugin.PluginDataObject;
import com.raytheon.uf.common.event.EventBus;
@ -60,6 +62,7 @@ import com.raytheon.uf.edex.datadelivery.retrieval.util.RetrievalPersistUtil;
* Feb 12, 2013 1543 djohnson Now handles the retrieval responses directly.
* Feb 15, 2013 1543 djohnson Retrieve the retrieval attributes from the database.
* Aug 09, 2013 1822 bgonzale Added parameters to processRetrievedPluginDataObjects.
* Aug 06, 2013 1654 bgonzale Added AdhocDataRetrievalEvent.
*
* </pre>
*
@ -162,7 +165,11 @@ public class StoreRetrievedData implements IRetrievalPluginDataObjectsProcessor
statusHandler.info("Successfully processed: " + records.length
+ " : " + serviceType + " Plugin : " + pluginName);
DataRetrievalEvent event = new DataRetrievalEvent();
boolean isAdhoc = retrieval.getSubscriptionType() != null
&& retrieval.getSubscriptionType().equals(
SubscriptionType.AD_HOC);
DataRetrievalEvent event = isAdhoc ? new AdhocDataRetrievalEvent()
: new DataRetrievalEvent();
event.setId(retrieval.getSubscriptionName());
event.setOwner(retrieval.getOwner());
event.setNetwork(retrieval.getNetwork().name());

View file

@ -27,4 +27,34 @@
<statisticsAggregate field="numRecords"
displayName="Number of Records Downloaded" displayUnit="Count" />
</statisticsEvent>
<statisticsEvent type="com.raytheon.uf.common.datadelivery.event.retrieval.AdhocDataRetrievalEvent"
displayName="Adhoc Data Retrieval" category="Data Delivery">
<statisticsGroup name="plugin" displayName="Data Type" />
<statisticsGroup name="provider" displayName="Data Provider" />
<statisticsGroup name="owner" displayName="Owner" />
<statisticsGroup name="network" displayName="Network Route" />
<!--
Display unit options are bytes, KB, MB, GB
-->
<statisticsAggregate field="bytes"
displayName="Amount of Data Downloaded" displayUnit="MB" />
<statisticsAggregate field="numRecords"
displayName="Number of Records Downloaded" displayUnit="Count" />
</statisticsEvent>
<statisticsEvent type="com.raytheon.uf.common.datadelivery.event.retrieval.SubscriptionRequestEvent"
displayName="Subscription Requests" category="Data Delivery">
<statisticsGroup name="provider" displayName="Data Provider" />
<statisticsGroup name="owner" displayName="Owner" />
<statisticsGroup name="network" displayName="Network Route" />
<statisticsAggregate field="numRecords"
displayName="Number of Subscription Requests" displayUnit="Count" />
</statisticsEvent>
<statisticsEvent type="com.raytheon.uf.common.datadelivery.event.retrieval.AdhocSubscriptionRequestEvent"
displayName="Adhoc Subscription Requests" category="Data Delivery">
<statisticsGroup name="provider" displayName="Data Provider" />
<statisticsGroup name="owner" displayName="Owner" />
<statisticsGroup name="network" displayName="Network Route" />
<statisticsAggregate field="numRecords"
displayName="Number of Adhoc Subscription Requests" displayUnit="Count" />
</statisticsEvent>
</statisticsConfig>

View file

@ -64,6 +64,7 @@ import com.raytheon.uf.common.util.ReflectionUtil;
* Mar 27, 2013 1834 mpduff Filter for xml files on localization file read, wrap unmarshall and
* log error if one occurs
* May 22, 2013 1917 rjpeter Updated validate to save typeClass back to StatisticsEventConfig.
* Aug 06, 2013 1654 bgonzale Enable statistics xml config files to reference fields in superclasses.
* </pre>
*
* @author jsanchez
@ -235,8 +236,7 @@ public class ConfigLoader {
String aggregateField = aggregate.getField();
try {
Field field = clazz
.getDeclaredField(aggregateField);
Field field = getField(clazz, aggregateField);
if (field.getType().isPrimitive()) {
if (!currentFields.contains(aggregateField)) {
try {
@ -299,4 +299,37 @@ public class ConfigLoader {
}
}
}
/**
* Find Field in class. Can be in superclass.
*
* @param clazz
* @param fieldToFind
* @return Field found.
* @throws SecurityException
* @throws NoSuchFieldException
*/
private static Field getField(Class<?> clazz, String fieldToFind)
throws SecurityException, NoSuchFieldException {
Class<?> type = clazz;
Field field = null;
do {
Field[] fields = type.getDeclaredFields();
for (Field f : fields) {
boolean isFieldFound = f.getName().equals(fieldToFind);
if (isFieldFound) {
field = type.getDeclaredField(fieldToFind);
break;
}
}
if (field == null) {
type = type.getSuperclass();
if (type == null) {
throw new NoSuchFieldException(fieldToFind
+ " not found in Class " + clazz.getCanonicalName());
}
}
} while (field == null);
return field;
}
}