Issue #1322 Common baseline changes to support BandwidthManager
Amend: Revert EDEXLocalizationAdapter and duplicate getPath() in test version. Change-Id: I72205aadeba1f894ee49cb4d146519df10d941f8 Former-commit-id:f1cfa9a60d
[formerlyafd9a767ea
] [formerly7d9e7567bd
] [formerly7c59f9ea41
[formerly7d9e7567bd
[formerly 07aeec469a83ce07286bc27ea3e6bda41909be8d]]] Former-commit-id:7c59f9ea41
Former-commit-id: caae98dd9803817a99d22d4cbbe38eccdaeff2f9 [formerlyc0c60c2488
] Former-commit-id:5d410ff934
This commit is contained in:
parent
3e5220d216
commit
21dc859b85
12 changed files with 333 additions and 6 deletions
|
@ -8,7 +8,7 @@
|
|||
<classpathentry exported="true" kind="lib" path="activemq-jaas-5.3.0.jar"/>
|
||||
<classpathentry exported="true" kind="lib" path="activemq-pool-5.3.0.jar"/>
|
||||
<classpathentry exported="true" kind="lib" path="activemq-web-5.3.0.jar"/>
|
||||
<classpathentry exported="true" kind="lib" path="backport-util-concurrent-2.1.jar"/>
|
||||
<classpathentry kind="lib" path="backport-util-concurrent-2.1.jar"/>
|
||||
<classpathentry exported="true" kind="lib" path="geronimo-j2ee-management_1.0_spec-1.0.jar"/>
|
||||
<classpathentry exported="true" kind="lib" path="geronimo-jta_1.0.1B_spec-1.0.1.jar"/>
|
||||
<classpathentry exported="true" kind="lib" path="jencks-amqpool-2.0.jar"/>
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
<classpath>
|
||||
<classpathentry exported="true" kind="lib" path="com.springsource.org.aopalliance-1.0.0.jar" sourcepath="spring-framework-2.5.6.zip"/>
|
||||
<classpathentry exported="true" kind="lib" path="antlr-2.7.6.jar" sourcepath="spring-framework-2.5.6.zip"/>
|
||||
<classpathentry exported="true" kind="lib" path="backport-util-concurrent.jar" sourcepath="spring-framework-2.5.6.zip"/>
|
||||
<classpathentry kind="lib" path="backport-util-concurrent.jar" sourcepath="spring-framework-2.5.6.zip"/>
|
||||
<classpathentry exported="true" kind="lib" path="quartz-all-1.6.1.jar" sourcepath="spring-framework-2.5.6.zip"/>
|
||||
<classpathentry exported="true" kind="lib" path="spring-aop.jar" sourcepath="spring-framework-2.5.6.zip"/>
|
||||
<classpathentry exported="true" kind="lib" path="spring-beans.jar" sourcepath="spring-framework-2.5.6.zip"/>
|
||||
|
|
|
@ -14,6 +14,17 @@
|
|||
<param name="FileNamePattern" value="${edex.home}/logs/edex-${edex.run.mode}-harvester-%d{yyyyMMdd}.log"/>
|
||||
</rollingPolicy>
|
||||
|
||||
<layout class="org.apache.log4j.PatternLayout">
|
||||
<param name="ConversionPattern" value="%-5p %d [%t] %c{1}: %m%n"/>
|
||||
</layout>
|
||||
</appender>
|
||||
|
||||
<!-- BandwidthManager log -->
|
||||
<appender name="BandwidthManagerLog" class="org.apache.log4j.rolling.RollingFileAppender">
|
||||
<rollingPolicy class="org.apache.log4j.rolling.TimeBasedRollingPolicy">
|
||||
<param name="FileNamePattern" value="${edex.home}/logs/edex-${edex.run.mode}-bandwidth-%d{yyyyMMdd}.log"/>
|
||||
</rollingPolicy>
|
||||
|
||||
<layout class="org.apache.log4j.PatternLayout">
|
||||
<param name="ConversionPattern" value="%-5p %d [%t] %c{1}: %m%n"/>
|
||||
</layout>
|
||||
|
@ -116,6 +127,16 @@
|
|||
<level value="INFO"/>
|
||||
<appender-ref ref="RegistryLog"/>
|
||||
</logger>
|
||||
|
||||
<logger name="com.raytheon.uf.common.datadelivery.bandwidth" additivity="false">
|
||||
<level value="INFO"/>
|
||||
<appender-ref ref="BandwidthManagerLog"/>
|
||||
</logger>
|
||||
|
||||
<logger name="com.raytheon.uf.edex.datadelivery.bandwidth" additivity="false">
|
||||
<level value="INFO"/>
|
||||
<appender-ref ref="BandwidthManagerLog"/>
|
||||
</logger>
|
||||
|
||||
<logger name="com.raytheon.uf.edex.ebxml" additivity="false">
|
||||
<level value="INFO"/>
|
||||
|
|
|
@ -275,6 +275,8 @@
|
|||
<mode name="datadeliverytemplate" template="true">
|
||||
<include>.*datadelivery.*</include>
|
||||
<include>.*bandwidth.*</include>
|
||||
<!-- Exclude the inmemory versions of Spring files -->
|
||||
<exclude>.*bandwidth.*-inmemory.*.xml</exclude>
|
||||
<include>time-common.xml</include>
|
||||
<include>grib-common.xml</include>
|
||||
<include>grid-common.xml</include>
|
||||
|
|
|
@ -57,6 +57,7 @@ import javax.xml.bind.JAXBException;
|
|||
import org.apache.commons.lang.builder.HashCodeBuilder;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.springframework.context.ConfigurableApplicationContext;
|
||||
|
||||
import com.raytheon.uf.common.serialization.SerializationException;
|
||||
import com.raytheon.uf.common.serialization.SerializationUtil;
|
||||
|
@ -76,6 +77,7 @@ import com.raytheon.uf.common.util.ConvertUtil;
|
|||
* 10Apr2008 1068 MW Fegan Remove redundant memory reporting.
|
||||
* 15Jul2008 1014 MW Fegan Improved logging of JiBX marshaling errors.
|
||||
* Aug 20, 2008 dglazesk Added functions for handling JaXB marshalling
|
||||
* Nov 09, 2012 1322 djohnson Add close for Spring context.
|
||||
* </pre>
|
||||
*
|
||||
* @author mfegan
|
||||
|
@ -1348,4 +1350,22 @@ public final class Util {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Performs a safe-close on a {@link ConfigurableApplicationContext}.
|
||||
*
|
||||
* @param ctx
|
||||
* the context
|
||||
*/
|
||||
public static String close(final ConfigurableApplicationContext ctx) {
|
||||
// Just adapt to a normal Java closeable
|
||||
return close(new Closeable() {
|
||||
@Override
|
||||
public void close() throws IOException {
|
||||
if (ctx != null) {
|
||||
ctx.close();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -7,5 +7,8 @@ Bundle-Vendor: RAYTHEON
|
|||
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
|
||||
Require-Bundle: org.apache.http,
|
||||
com.raytheon.uf.common.status,
|
||||
com.raytheon.uf.common.util
|
||||
com.raytheon.uf.common.util,
|
||||
com.raytheon.uf.common.auth;bundle-version="1.12.1174",
|
||||
com.raytheon.uf.common.serialization;bundle-version="1.12.1174",
|
||||
com.raytheon.uf.common.serialization.comm;bundle-version="1.12.1174"
|
||||
Export-Package: com.raytheon.uf.common.comm
|
||||
|
|
|
@ -0,0 +1,126 @@
|
|||
/**
|
||||
* 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.comm;
|
||||
|
||||
import java.rmi.RemoteException;
|
||||
|
||||
import com.raytheon.uf.common.auth.req.AbstractPrivilegedRequest;
|
||||
import com.raytheon.uf.common.auth.user.IUser;
|
||||
import com.raytheon.uf.common.serialization.ExceptionWrapper;
|
||||
import com.raytheon.uf.common.serialization.SerializationException;
|
||||
import com.raytheon.uf.common.serialization.SerializationUtil;
|
||||
import com.raytheon.uf.common.serialization.comm.response.ServerErrorResponse;
|
||||
|
||||
/**
|
||||
* Performs a thrift communication with the server.
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Sep 27, 2012 1187 djohnson Moved from ThriftRegistryHandler.
|
||||
* Nov 09, 2012 1286 djohnson Move out of registry code.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author djohnson
|
||||
* @version 1.0
|
||||
*/
|
||||
|
||||
public class ThriftCommunicator<REQUEST extends AbstractPrivilegedRequest, RESPONSE> {
|
||||
|
||||
/**
|
||||
* Provides the configuration required to communicate via thrift.
|
||||
*/
|
||||
public static interface IThriftCommunicatorConfiguration {
|
||||
IUser getUser();
|
||||
|
||||
String getServer();
|
||||
}
|
||||
|
||||
private final IThriftCommunicatorConfiguration config;
|
||||
|
||||
private ThriftCommunicator(IThriftCommunicatorConfiguration configuration) {
|
||||
this.config = configuration;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sends a request via thrift.
|
||||
*
|
||||
* @param request
|
||||
* @throws RemoteException
|
||||
* on error communicating with the server
|
||||
* @throws SerializationException
|
||||
* on error serializing the request
|
||||
* @throws ClassCastException
|
||||
* on receiving a response object that is neither a
|
||||
* {@link ServerErrorResponse} nor of type RESPONSE
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public RESPONSE sendRequestViaThrift(REQUEST request)
|
||||
throws RemoteException,
|
||||
SerializationException {
|
||||
String httpAddress = config.getServer();
|
||||
if (httpAddress == null) {
|
||||
throw new IllegalStateException(
|
||||
"The thrift url is null, please verify proper configuration!");
|
||||
}
|
||||
|
||||
request.setUser(config.getUser());
|
||||
byte[] message = SerializationUtil.transformToThrift(request);
|
||||
byte[] response = null;
|
||||
try {
|
||||
response = HttpClient.getInstance()
|
||||
.postBinary(httpAddress, message);
|
||||
} catch (Exception e) {
|
||||
throw new RemoteException("Error communicating with the server.", e);
|
||||
}
|
||||
Object rval = null;
|
||||
if (response != null) {
|
||||
rval = SerializationUtil
|
||||
.transformFromThrift(Object.class, response);
|
||||
}
|
||||
if (rval instanceof ServerErrorResponse) {
|
||||
ServerErrorResponse resp = (ServerErrorResponse) rval;
|
||||
Throwable serverException = ExceptionWrapper.unwrapThrowable(resp
|
||||
.getException());
|
||||
throw new RemoteException(
|
||||
"Trapped throwable communicating with server.",
|
||||
serverException);
|
||||
}
|
||||
|
||||
return (RESPONSE) rval;
|
||||
}
|
||||
|
||||
/**
|
||||
* Static method to retrieve an instance. Used to simplify generics, and
|
||||
* allow for implementation class changes later.
|
||||
*
|
||||
* @param config
|
||||
* the configuration object
|
||||
* @return the thrift communicator
|
||||
*/
|
||||
public static <REQUEST extends AbstractPrivilegedRequest, RESPONSE> ThriftCommunicator<REQUEST, RESPONSE> newInstance(
|
||||
IThriftCommunicatorConfiguration config) {
|
||||
return new ThriftCommunicator<REQUEST, RESPONSE>(config);
|
||||
}
|
||||
}
|
|
@ -54,6 +54,7 @@ import com.raytheon.uf.common.status.UFStatus.Priority;
|
|||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* 02/12/2008 chammack Initial Creation.
|
||||
* Oct 23, 2012 1322 djohnson Allow test code in the same package to clear fileCache.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -62,10 +63,11 @@ import com.raytheon.uf.common.status.UFStatus.Priority;
|
|||
*/
|
||||
|
||||
public class PathManager implements IPathManager {
|
||||
private static transient IUFStatusHandler statusHandler = UFStatus
|
||||
private static final IUFStatusHandler statusHandler = UFStatus
|
||||
.getHandler(PathManager.class, "Localization");
|
||||
|
||||
private static final Map<LocalizationFileKey, LocalizationFile> fileCache = new ConcurrentHashMap<LocalizationFileKey, LocalizationFile>();
|
||||
// @VisibleForTesting
|
||||
static final Map<LocalizationFileKey, LocalizationFile> fileCache = new ConcurrentHashMap<LocalizationFileKey, LocalizationFile>();
|
||||
|
||||
final ILocalizationAdapter adapter;
|
||||
|
||||
|
@ -145,6 +147,7 @@ public class PathManager implements IPathManager {
|
|||
return file != null ? file.getFile() : null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<LocalizationLevel, LocalizationFile> getTieredLocalizationFile(
|
||||
LocalizationType type, String name) {
|
||||
Map<LocalizationLevel, LocalizationFile> map = new HashMap<LocalizationLevel, LocalizationFile>();
|
||||
|
@ -277,6 +280,7 @@ public class PathManager implements IPathManager {
|
|||
* .edex.utility.LocalizationContext[], java.lang.String,
|
||||
* java.lang.String[])
|
||||
*/
|
||||
@Override
|
||||
public LocalizationFile[] listFiles(LocalizationContext[] contexts,
|
||||
String name, String[] filter, boolean recursive, boolean filesOnly) {
|
||||
try {
|
||||
|
|
|
@ -39,6 +39,7 @@ import com.raytheon.uf.common.time.SimulatedTime;
|
|||
* ------------ ---------- ----------- --------------------------
|
||||
* Feb 02, 2009 njensen Initial creation
|
||||
* Sep 11, 2012 1154 djohnson Add MILLIS constants and isNewerDay().
|
||||
* Nov 09, 2012 1322 djohnson Add SECONDS_PER_MINUTE.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -96,6 +97,8 @@ public class TimeUtil {
|
|||
|
||||
public static final long MILLIS_PER_YEAR = 3600 * 24 * 1000 * 365;
|
||||
|
||||
public static final int SECONDS_PER_MINUTE = 60;
|
||||
|
||||
// create instance of simple date format on class load, as instantiating it
|
||||
// is expensive the SimpleDateFormat class is not thread-safe,
|
||||
// so calling methods use synchronized
|
||||
|
|
|
@ -21,6 +21,7 @@ package com.raytheon.uf.common.util;
|
|||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.net.URL;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Enumeration;
|
||||
|
@ -29,7 +30,7 @@ import java.util.jar.JarEntry;
|
|||
import java.util.jar.JarFile;
|
||||
|
||||
/**
|
||||
* TODO Add Description
|
||||
* Utilities for working with Jar files.
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
|
@ -38,6 +39,7 @@ import java.util.jar.JarFile;
|
|||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Jan 28, 2011 njensen Initial creation
|
||||
* Nov 09, 2012 1322 djohnson Add getResResourcePath.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -179,4 +181,24 @@ public class JarUtil {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Attempts to find the specified resource on the classpath. First it
|
||||
* searches for the provided string resource path, if that fails, returns
|
||||
* the string prepended with "/res" since that is where the "res" resources
|
||||
* are placed in the jar files. This is required because in Eclipse the
|
||||
* Spring files are not prepended with "res" as they are in jar files.
|
||||
*
|
||||
* @param resourcePath
|
||||
* the resource path
|
||||
* @return the String resource path to use
|
||||
*/
|
||||
public static String getResResourcePath(String resourcePath) {
|
||||
URL url = JarUtil.class.getResource(resourcePath);
|
||||
if (url != null) {
|
||||
return resourcePath;
|
||||
} else {
|
||||
return "/res" + resourcePath;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,74 @@
|
|||
/**
|
||||
* 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.util;
|
||||
|
||||
import com.raytheon.uf.common.status.IUFStatusHandler;
|
||||
import com.raytheon.uf.common.status.UFStatus.Priority;
|
||||
|
||||
/**
|
||||
* Utilities for logging.
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Oct 26, 2012 1322 djohnson Initial creation
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author djohnson
|
||||
* @version 1.0
|
||||
*/
|
||||
|
||||
public final class LogUtil {
|
||||
|
||||
private LogUtil() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Logs the message, then each iterable to the output with a new line
|
||||
* separator between each iterable.
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* Example:
|
||||
*
|
||||
* This would be the message:
|
||||
* iterable1
|
||||
* iterable2
|
||||
* </pre>
|
||||
*
|
||||
* @param statusHandler
|
||||
* the status handler
|
||||
* @param priority
|
||||
* the priority
|
||||
* @param message
|
||||
* the message
|
||||
* @param iterable
|
||||
* the iterables
|
||||
*/
|
||||
public static <T> void logIterable(IUFStatusHandler statusHandler,
|
||||
Priority priority, String message, Iterable<T> iterables) {
|
||||
String msg = StringUtil.createMessage(message, iterables, 3);
|
||||
statusHandler.handle(priority, msg);
|
||||
}
|
||||
}
|
|
@ -21,6 +21,7 @@ package com.raytheon.uf.common.util;
|
|||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
|
@ -36,6 +37,7 @@ import org.apache.commons.lang.StringUtils;
|
|||
* ------------ ---------- ----------- --------------------------
|
||||
* Oct 20, 2011 rferrel Initial creation
|
||||
* Jul 13, 2012 740 djohnson Add join.
|
||||
* Nov 09, 2012 1322 djohnson Add NEWLINE, createMessage.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -44,6 +46,8 @@ import org.apache.commons.lang.StringUtils;
|
|||
*/
|
||||
public final class StringUtil {
|
||||
|
||||
public static final String NEWLINE = System.getProperty("line.separator");
|
||||
|
||||
private StringUtil() {
|
||||
|
||||
}
|
||||
|
@ -133,4 +137,52 @@ public final class StringUtil {
|
|||
|
||||
return stringBuilder.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a message based on the preamble and the provided iterables, each
|
||||
* iterable will be displayed on its own line.
|
||||
*
|
||||
* @param preamble
|
||||
* the preamble message, such as
|
||||
* <code>String preamble = "The following are numbers:"</code>
|
||||
* @param iterables
|
||||
* the iterable to retrieve items from, such as<br>
|
||||
* <code>List<String> iterables = Arrays.asList("one", "two");</code>
|
||||
* @return the message
|
||||
*/
|
||||
public static String createMessage(String preamble, Iterable<?> iterables) {
|
||||
return createMessage(preamble, iterables, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a message based on the preamble and the provided iterables, each
|
||||
* iterable will be displayed on its own line.
|
||||
*
|
||||
* @param preamble
|
||||
* the preamble message, such as
|
||||
* <code>String preamble = "The following are numbers:"</code>
|
||||
* @param iterables
|
||||
* the iterable to retrieve items from, such as<br>
|
||||
* <code>List<String> iterables = Arrays.asList("one", "two");</code>
|
||||
* @param iterableIndent
|
||||
* the number of spaces to indent each iterable
|
||||
* @return the message
|
||||
*/
|
||||
public static String createMessage(String preamble, Iterable<?> iterables,
|
||||
int iterableIndent) {
|
||||
StringBuilder msg = new StringBuilder(preamble)
|
||||
.append(StringUtil.NEWLINE);
|
||||
for (Iterator<?> iter = iterables.iterator(); iter.hasNext();) {
|
||||
for (int i = 0; i < iterableIndent; i++) {
|
||||
msg.append(' ');
|
||||
}
|
||||
msg.append(iter.next());
|
||||
|
||||
if (iter.hasNext()) {
|
||||
msg.append(StringUtil.NEWLINE);
|
||||
}
|
||||
}
|
||||
|
||||
return msg.toString();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue