13.5.2-12 baseline

Former-commit-id: 845d49e370 [formerly e2b9baf2ed] [formerly a532896473] [formerly bcb531e671 [formerly a532896473 [formerly 7918a1bb18c212f8a3b84edec932880126d351be]]]
Former-commit-id: bcb531e671
Former-commit-id: 7b3329db475d8a4c9b900f448656bc46192af5e3 [formerly b70ec5732d]
Former-commit-id: 15d9848170
This commit is contained in:
Steve Harris 2013-10-25 09:59:15 -04:00
parent a18eb8fe83
commit 2e6e031198
14 changed files with 653 additions and 326 deletions

View file

@ -161,4 +161,10 @@
install-size="0"
version="0.0.0"/>
<plugin
id="org.apache.commons.io"
download-size="0"
install-size="0"
version="0.0.0"/>
</feature>

View file

@ -36,12 +36,6 @@
version="0.0.0"
unpack="false"/>
<plugin
id="org.apache.commons.io"
download-size="0"
install-size="0"
version="0.0.0"/>
<plugin
id="org.eclipse.core.runtime"
download-size="0"

View file

@ -485,4 +485,10 @@
install-size="0"
version="0.0.0"/>
<plugin
id="org.apache.commons.io"
download-size="0"
install-size="0"
version="0.0.0"/>
</feature>

View file

@ -95,6 +95,9 @@ import com.raytheon.viz.gfe.ui.zoneselector.ZoneSelector;
* Changes for non-blocking ZoneColorEditorDlg.
* Mar 14, 2013 1794 djohnson Consolidate common FilenameFilter implementations.
* Sep 05, 2013 2329 randerso Removed obsolete methods, added ApplyZoneCombo method
* Oct 17, 2013 2481 randerso Fixed regression which cause configured level combinations
* files to not be found. Removed message when combinations file
* not found to match A1.
*
* </pre>
*
@ -781,7 +784,7 @@ public class ZoneCombinerComp extends Composite implements
colorMap = getColorsFromFile();
String comboName = theFile;
if (comboName == null || comboName.isEmpty()) {
if ((comboName == null) || comboName.isEmpty()) {
comboName = getCombinationsFileName();
}
Map<String, Integer> comboDict = loadCombinationsFile(comboName);
@ -911,18 +914,16 @@ public class ZoneCombinerComp extends Composite implements
public Map<String, Integer> loadCombinationsFile(String comboName) {
Map<String, Integer> dict = new HashMap<String, Integer>();
try {
IPathManager pm = PathManagerFactory.getPathManager();
LocalizationContext ctx = pm.getContext(
LocalizationType.CAVE_STATIC, LocalizationLevel.SITE);
File localFile = pm.getFile(ctx, FileUtil.join(
CombinationsFileUtil.COMBO_DIR_PATH, comboName + ".py"));
File localFile = PathManagerFactory.getPathManager().getStaticFile(
FileUtil.join(CombinationsFileUtil.COMBO_DIR_PATH,
comboName + ".py"));
List<List<String>> combolist = new ArrayList<List<String>>();
if (localFile != null && localFile.exists()) {
if ((localFile != null) && localFile.exists()) {
combolist = CombinationsFileUtil.init(comboName);
} else {
statusHandler.error("Combinations file does not found: "
+ comboName);
// statusHandler
// .error("Combinations file not found: " + comboName);
}
// reformat combinations into combo dictionary
@ -1004,7 +1005,7 @@ public class ZoneCombinerComp extends Composite implements
@Override
public void applyButtonState(final boolean enabled) {
if (this.applyZoneComboBtn != null
if ((this.applyZoneComboBtn != null)
&& !this.applyZoneComboBtn.isDisposed()) {
VizApp.runAsync(new Runnable() {
@Override
@ -1017,7 +1018,7 @@ public class ZoneCombinerComp extends Composite implements
private boolean buttonState() {
final boolean[] state = { false };
if (this.applyZoneComboBtn != null
if ((this.applyZoneComboBtn != null)
&& !this.applyZoneComboBtn.isDisposed()) {
VizApp.runSync(new Runnable() {
@Override

View file

@ -89,6 +89,7 @@ import com.raytheon.uf.edex.site.notify.SendSiteActivationNotifications;
* Mar 20, 2013 #1774 randerso Changed to use GFED2DDao
* May 02, 2013 #1969 randerso Moved updateDbs method into IFPGridDatabase
* Sep 13, 2013 2368 rjpeter Used durable jms settings.
* Oct 16, 2013 #2475 dgilling Better error handling for IRT activation.
* </pre>
*
* @author njensen
@ -370,6 +371,7 @@ public class GFESiteActivation implements ISiteActivationListener {
// Doesn't need to be cluster locked
statusHandler.handle(Priority.EVENTA, "Checking ISC configuration...");
boolean isIscActivated = false;
if (config.requestISC()) {
String host = InetAddress.getLocalHost().getCanonicalHostName();
String gfeHost = config.getServerHost();
@ -382,7 +384,15 @@ public class GFESiteActivation implements ISiteActivationListener {
if (host.contains(hostNameToCompare)
&& System.getProperty("edex.run.mode").equals("request")) {
statusHandler.handle(Priority.EVENTA, "Enabling ISC...");
IRTManager.getInstance().enableISC(siteID, config.getMhsid());
try {
IRTManager.getInstance().enableISC(siteID,
config.getMhsid());
isIscActivated = true;
} catch (Exception e) {
statusHandler
.error("Error starting GFE ISC. ISC functionality will be unavailable!!",
e);
}
} else {
statusHandler.handle(Priority.EVENTA,
"ISC Enabled but will use another EDEX instance");
@ -491,7 +501,7 @@ public class GFESiteActivation implements ISiteActivationListener {
};
postActivationTaskExecutor.submit(smartInit);
if (config.tableFetchTime() > 0) {
if (config.tableFetchTime() > 0 && isIscActivated) {
Runnable activateFetchAT = new Runnable() {
@Override

View file

@ -33,10 +33,10 @@ import jep.JepException;
import com.raytheon.edex.plugin.gfe.config.GridDbConfig;
import com.raytheon.edex.plugin.gfe.config.IFPServerConfig;
import com.raytheon.edex.plugin.gfe.config.IFPServerConfigManager;
import com.raytheon.edex.plugin.gfe.exception.GfeConfigurationException;
import com.raytheon.edex.plugin.gfe.server.GridParmManager;
import com.raytheon.uf.common.dataplugin.gfe.db.objects.DatabaseID;
import com.raytheon.uf.common.dataplugin.gfe.db.objects.GridLocation;
import com.raytheon.uf.common.dataplugin.gfe.exception.GfeException;
import com.raytheon.uf.common.dataplugin.gfe.python.GfePyIncludeUtil;
import com.raytheon.uf.common.localization.IPathManager;
import com.raytheon.uf.common.localization.LocalizationContext;
@ -47,6 +47,7 @@ import com.raytheon.uf.common.python.PyUtil;
import com.raytheon.uf.common.python.PythonScript;
import com.raytheon.uf.common.status.IUFStatusHandler;
import com.raytheon.uf.common.status.UFStatus;
import com.raytheon.uf.common.time.util.TimeUtil;
import com.raytheon.uf.common.util.FileUtil;
/**
@ -60,6 +61,8 @@ import com.raytheon.uf.common.util.FileUtil;
* ------------ ---------- ----------- --------------------------
* 07/14/09 1995 bphillip Initial creation
* Mar 14, 2013 1794 djohnson FileUtil.listFiles now returns List.
* Oct 16, 2013 2475 dgilling Move logic previously in IrtServer.py
* into this class to avoid Jep memory leak.
*
* </pre>
*
@ -72,14 +75,29 @@ public class GfeIRT extends Thread {
private static final transient IUFStatusHandler statusHandler = UFStatus
.getHandler(GfeIRT.class);
private static final String PYTHON_INSTANCE = "irt";
/** The site ID associated with this IRT thread */
private final String siteID;
/** The MHS ID associated with this IRT thread */
private final String mhsID;
/** The script file name */
private final String scriptFile;
private final String serverHost;
private final long serverPort;
private final long serverProtocol;
private List<String> parmsWanted;
private final List<Integer> gridDims;
private final String gridProj;
private final List<Double> gridBoundBox;
private List<String> iscWfosWanted;
/** The Python script object */
private PythonScript script;
@ -94,20 +112,83 @@ public class GfeIRT extends Thread {
*
* @param siteID
* The site ID to create the GfeIRT object for
* @throws GfeException
* @throws GfeConfigurationException
* If the GFE configuration for the specified site could not be
* loaded.
*/
public GfeIRT(String mhsid, String siteid) throws GfeException {
public GfeIRT(String mhsid, String siteid) throws GfeConfigurationException {
this.setDaemon(true);
this.siteID = siteid;
this.mhsID = mhsid;
IPathManager pathMgr = PathManagerFactory.getPathManager();
LocalizationContext cx = pathMgr.getContext(
LocalizationType.EDEX_STATIC, LocalizationLevel.BASE);
scriptFile = pathMgr
.getLocalizationFile(cx,
"gfe/isc" + File.separator + "IrtServer.py").getFile()
.getPath();
IFPServerConfig config = IFPServerConfigManager.getServerConfig(siteID);
this.serverHost = config.getServerHost();
this.serverPort = config.getRpcPort();
this.serverProtocol = config.getProtocolVersion();
GridLocation domain = config.dbDomain();
this.gridProj = domain.getProjection().getProjectionID().toString();
this.gridDims = new ArrayList<Integer>(2);
this.gridDims.add(domain.getNy());
this.gridDims.add(domain.getNx());
this.gridBoundBox = new ArrayList<Double>(4);
this.gridBoundBox.add(domain.getOrigin().x);
this.gridBoundBox.add(domain.getOrigin().y);
this.gridBoundBox.add(domain.getExtent().x);
this.gridBoundBox.add(domain.getExtent().y);
this.parmsWanted = config.requestedISCparms();
if (this.parmsWanted.isEmpty()) {
List<DatabaseID> dbs = GridParmManager.getDbInventory(this.siteID)
.getPayload();
for (DatabaseID dbId : dbs) {
if ((dbId.getModelName().equals("ISC"))
&& (dbId.getDbType().equals(""))
&& (dbId.getSiteId().equals(this.siteID))) {
GridDbConfig gdc = config.gridDbConfig(dbId);
this.parmsWanted = gdc.parmAndLevelList();
}
}
config.setRequestedISCparms(this.parmsWanted);
}
statusHandler.info("ParmsWanted: " + this.parmsWanted);
this.iscWfosWanted = config.requestedISCsites();
if (this.iscWfosWanted.isEmpty()) {
List<String> knownSites = config.allSites();
IPathManager pathMgr = PathManagerFactory.getPathManager();
LocalizationContext commonStaticConfig = pathMgr.getContext(
LocalizationType.COMMON_STATIC,
LocalizationLevel.CONFIGURED);
commonStaticConfig.setContextName(this.siteID);
File editAreaDir = pathMgr.getFile(commonStaticConfig,
"gfe/editAreas");
FilenameFilter filter = new FilenameFilter() {
@Override
public boolean accept(File dir, String name) {
return name.trim().matches("ISC_\\p{Alnum}{3}\\.xml");
}
};
List<File> editAreas = FileUtil.listFiles(editAreaDir, filter,
false);
this.iscWfosWanted = new ArrayList<String>();
for (File f : editAreas) {
String name = f.getName().replace("ISC_", "")
.replace(".xml", "");
if (knownSites.contains(name)) {
iscWfosWanted.add(name);
}
}
config.setRequestedISCsites(this.iscWfosWanted);
}
Thread hook = new Thread() {
@Override
public void run() {
@ -123,111 +204,97 @@ public class GfeIRT extends Thread {
@Override
public void run() {
try {
IPathManager pathMgr = PathManagerFactory.getPathManager();
LocalizationContext cx = pathMgr.getContext(
LocalizationType.EDEX_STATIC, LocalizationLevel.BASE);
String scriptPath = pathMgr
.getLocalizationFile(cx, "gfe/isc/IrtAccess.py").getFile()
.getPath();
String includePath = PyUtil.buildJepIncludePath(
GfePyIncludeUtil.getCommonPythonIncludePath(),
GfePyIncludeUtil.getIscScriptsIncludePath(),
GfePyIncludeUtil.getGfeConfigIncludePath(siteID));
script = new PythonScript(scriptFile, includePath);
Map<String, Object> args = new HashMap<String, Object>();
GfePyIncludeUtil.getGfeConfigIncludePath(this.siteID));
this.script = new PythonScript(scriptPath, includePath, getClass()
.getClassLoader());
IFPServerConfig config = IFPServerConfigManager
.getServerConfig(siteID);
GridLocation domain = config.dbDomain();
String site = config.getSiteID().get(0);
List<Integer> gridDims = new ArrayList<Integer>();
gridDims.add(domain.getNy());
gridDims.add(domain.getNx());
List<Double> gridBoundBox = new ArrayList<Double>();
gridBoundBox.add(domain.getOrigin().x);
gridBoundBox.add(domain.getOrigin().y);
gridBoundBox.add(domain.getExtent().x);
gridBoundBox.add(domain.getExtent().y);
// determine which parms are wanted
List<String> parmsWanted = config.requestedISCparms();
if (parmsWanted.isEmpty()) {
List<DatabaseID> dbs = GridParmManager.getDbInventory(site)
.getPayload();
for (int i = 0; i < dbs.size(); i++) {
if (dbs.get(i).getModelName().equals("ISC")
&& dbs.get(i).getDbType().equals("")
&& dbs.get(i).getSiteId().equals(site)) {
GridDbConfig gdc = config.gridDbConfig(dbs.get(i));
parmsWanted = gdc.parmAndLevelList();
}
}
}
statusHandler.info("ParmsWanted: " + parmsWanted);
// reset them to actual values
config.setRequestedISCparms(parmsWanted);
// determine isc areas that are wanted
List<String> iscWfosWanted = config.requestedISCsites();
if (iscWfosWanted.isEmpty()) {
List<String> knownSites = config.allSites();
IPathManager pathMgr = PathManagerFactory.getPathManager();
LocalizationContext commonStaticConfig = pathMgr.getContext(
LocalizationType.COMMON_STATIC,
LocalizationLevel.CONFIGURED);
commonStaticConfig.setContextName(site);
File editAreaDir = pathMgr.getFile(commonStaticConfig,
"gfe/editAreas");
FilenameFilter filter = new FilenameFilter() {
@Override
public boolean accept(File dir, String name) {
return name.trim().matches("ISC_\\p{Alnum}{3}\\.xml");
}
};
List<File> editAreas = FileUtil.listFiles(editAreaDir,
filter, false);
String name = "";
for (File f : editAreas) {
name = f.getName().replace("ISC_", "").replace(".xml", "");
if (knownSites.contains(name)) {
iscWfosWanted.add(name);
}
}
config.setRequestedISCsites(iscWfosWanted);
}
args.put("ancfURL", config.iscRoutingTableAddress().get("ANCF"));
args.put("bncfURL", config.iscRoutingTableAddress().get("BNCF"));
args.put("mhsid", config.getMhsid());
args.put("serverHost", config.getServerHost());
args.put("serverPort", config.getRpcPort());
args.put("serverProtocol", config.getProtocolVersion());
args.put("site", site);
args.put("parmsWanted", config.requestedISCparms());
args.put("gridDims", gridDims);
args.put("gridProj", domain.getProjection().getProjectionID()
.toString());
args.put("gridBoundBox", gridBoundBox);
args.put("iscWfosWanted", iscWfosWanted);
boolean regSuccess = (Boolean) script.execute("irtReg", args);
if (!regSuccess) {
statusHandler
.error("Error registering site with IRT server. ISC functionality will be unavailable. Check config and IRT connectivity.");
removeShutdownHook(this.mhsID, this.siteID);
}
Map<String, Object> initArgs = new HashMap<String, Object>(2, 1f);
initArgs.put("ancfURL", config.iscRoutingTableAddress().get("ANCF"));
initArgs.put("bncfURL", config.iscRoutingTableAddress().get("BNCF"));
this.script.instantiatePythonClass(PYTHON_INSTANCE, "IrtAccess",
initArgs);
} catch (GfeConfigurationException e) {
throw new RuntimeException("Could not load GFE configuration", e);
} catch (JepException e) {
statusHandler
.fatal("Error starting GFE ISC. ISC functionality will be unavailable!!",
e);
} catch (GfeException e) {
statusHandler
.fatal("Unable to get Mhs ID. ISC functionality will be unavailable!!",
e);
throw new RuntimeException(
"Could not instantiate IRT python script instance", e);
}
try {
// upon any overall failure, start thread over
while (IRTManager.getInstance().isRegistered(mhsID, siteID)) {
try {
// do initial registration, keep trying until successful
while (IRTManager.getInstance().isRegistered(mhsID, siteID)) {
statusHandler
.info("performing initial IRT registration.");
Map<String, Object> args = new HashMap<String, Object>(
10, 1f);
args.put("mhsid", mhsID);
args.put("serverHost", serverHost);
args.put("serverPort", serverPort);
args.put("serverProtocol", serverProtocol);
args.put("site", siteID);
args.put("parmsWanted", parmsWanted);
args.put("gridDims", gridDims);
args.put("gridProj", gridProj);
args.put("gridBoundBox", gridBoundBox);
args.put("iscWfosWanted", iscWfosWanted);
Boolean okay = (Boolean) script.execute("register",
PYTHON_INSTANCE, args);
if (okay) {
break;
} else if (!IRTManager.getInstance().isRegistered(
mhsID, siteID)) {
break; // exit processing loop
} else {
sleep(3 * TimeUtil.MILLIS_PER_SECOND);
}
}
// if we are here, we had a successful registration, check
// for re-register every few seconds, check the StopIRT flag
// every few seconds
statusHandler.info("initial IRT registration complete.");
while (IRTManager.getInstance().isRegistered(mhsID, siteID)) {
sleep(3 * TimeUtil.MILLIS_PER_SECOND); // wait 3 seconds
Boolean status1 = (Boolean) script.execute(
"checkForReregister", PYTHON_INSTANCE, null);
if (!status1) {
statusHandler.error("FAIL on checkForRegister().");
break; // break out of rereg loop, to cause another
// reg
}
}
} catch (Throwable t) {
statusHandler.error("Exception in IRT register thread.", t);
}
}
// if we get here, we have been told to stop IRT, so we unregister.
// We try only once.
statusHandler.info("FINAL IRT unregister.");
try {
script.execute("unregister", PYTHON_INSTANCE, null);
} catch (JepException e) {
statusHandler.error("Exception unregister IRT.", e);
}
statusHandler.info("FINAL -- exiting IRT registration thread.");
} finally {
if (script != null) {
script.dispose();

View file

@ -44,12 +44,11 @@ from com.raytheon.edex.plugin.gfe.isc import IRTManager
# to interact better with IscScript.
# 05/22/13 1759 dgilling Add missing import to
# makeISCrequest().
# 10/16/13 2475 dgilling Remove unneeded code to handle
# registration with IRT.
#
#
#
# starts the IRT thread and registers.
StopIRT = 0 #flag to shut down the 2nd thread
IRTthread = None #flag to hold the IRTthread object
def logEvent(*msg):
iscUtil.getLogger("irtServer").info(iscUtil.tupleToString(*msg))
@ -188,51 +187,6 @@ def putVTECActiveTable(strTable, xmlPacket):
except:
logProblem("Error executing ingestAT: ", traceback.format_exc())
logEvent("ingesAT command output: ", output)
def initIRT(ancfURL, bncfURL, mhsid, serverHost, serverPort, serverProtocol,
site, parmsWanted, gridDims, gridProj, gridBoundBox, iscWfosWanted):
global IRTthread
import threading
IRTthread = threading.Thread(target=irtReg, args=[ancfURL, bncfURL, mhsid,
serverHost, serverPort, serverProtocol, site, parmsWanted, gridDims,
gridProj, gridBoundBox, iscWfosWanted])
IRTthread.setDaemon(True)
IRTthread.start()
# IRT registration thread
def irtReg(ancfURL, bncfURL, mhsid, serverHost, serverPort, serverProtocol,
site, parmsWanted, gridDims, gridProj, gridBoundBox, iscWfosWanted):
import IrtAccess, threading
irt = IrtAccess.IrtAccess(ancfURL, bncfURL)
# do initial registration, keep trying until successful
while True:
okay = irt.register(mhsid, serverHost, serverPort, serverProtocol,
site, parmsWanted, gridDims, gridProj, gridBoundBox, iscWfosWanted)
if okay:
break
elif StopIRT:
return False#stop this thread
else:
return False
# if we are here, we had a successful registration, check for re-register
# every few seconds, check the StopIRT flag every few seconds
while IRTManager.getInstance().isRegistered(mhsid,site) == True:
time.sleep(3.0) #wait 3 seconds
irt.checkForReregister()
# if we get here, we have been told to stop IRT, so we unregister. We
# try only once.
irt.unregister()
return True
# call from C++ to Python to tell IRT thread to shut itself down
def irtStop():
global StopIRT
StopIRT = True #tells irt thread to exit
if IRTthread:
IRTthread.join() #wait till thread returns then return to caller
# get servers direct call for IRT
def irtGetServers(ancfURL, bncfURL, iscWfosWanted):

View file

@ -399,4 +399,10 @@
install-size="0"
version="0.0.0"/>
<plugin
id="org.apache.commons.io"
download-size="0"
install-size="0"
version="0.0.0"/>
</feature>

View file

@ -8,7 +8,8 @@ Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Require-Bundle: org.junit;bundle-version="1.0.0",
org.apache.commons.beanutils;bundle-version="1.8.3",
com.raytheon.uf.common.status;bundle-version="1.12.1174",
org.apache.commons.lang;bundle-version="2.3.0"
org.apache.commons.lang;bundle-version="2.3.0",
org.apache.commons.io;bundle-version="2.4.0"
Export-Package: com.raytheon.uf.common.util,
com.raytheon.uf.common.util.algorithm,
com.raytheon.uf.common.util.cache,

View file

@ -30,13 +30,14 @@ import java.io.FilenameFilter;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.nio.channels.FileChannel;
import java.util.ArrayList;
import java.util.List;
import java.util.regex.Pattern;
import java.util.zip.GZIPInputStream;
import java.util.zip.GZIPOutputStream;
import org.apache.commons.io.IOUtils;
/**
* Contains common file utilities. Methods are generally static to use without a
* class instance. Methods in class should not log directly; rather they should
@ -54,11 +55,13 @@ import java.util.zip.GZIPOutputStream;
* Jun 28, 2012 0819 djohnson Add write method.
* Jul 06, 2012 798 jkorman Added more robust {@link #copyFile}. Added methods
* to create temporary directories and files.
* 02/15/2013 #1597 randerso Fixed error when copying empty files
* Feb 15, 2013 1597 randerso Fixed error when copying empty files
* Feb 15, 2013 1638 mschenke Moved EOL field from edex.common Util
* Mar 11, 2013 1645 djohnson Added file modification watcher.
* Mar 14, 2013 1794 djohnson FileUtil.listFiles now returns List.
* May 16, 2013 1966 rferrel Add sizeOfDirectory and listDirFiles method.
* Oct 9, 2013 2467 randerso Change coypFile to use apache instead of FileChannel
* to improve memory utilization
*
* </pre>
*
@ -74,6 +77,9 @@ public class FileUtil {
private static final Pattern VALID_FILENAME = Pattern
.compile("^[A-Za-z0-9._\\- ]+$");
/**
* regex to match both Linux and Windows file separators
*/
public final static String fileSeparatorRegex = "[/\\\\]";
/**
@ -134,7 +140,7 @@ public class FileUtil {
File entry = entries[i];
// If there is no filter or the filter accepts the
// file / directory, add it to the list
if (filter == null || filter.accept(directory, entry.getName())) {
if ((filter == null) || filter.accept(directory, entry.getName())) {
files.add(entry);
}
@ -152,9 +158,12 @@ public class FileUtil {
* List files/directories that match a FileFilter.
*
* @param directory
* source directory
* @param filter
* file filter
* @param recurse
* @return
* true to recursively walk the directory tree
* @return list of files in directory matching filter
*/
public static List<File> listDirFiles(File directory, FileFilter filter,
boolean recurse) {
@ -171,7 +180,7 @@ public class FileUtil {
// Go over entries
for (File entry : entries) {
files.add(entry);
if (recurse && filter != null && entry.isDirectory()) {
if (recurse && (filter != null) && entry.isDirectory()) {
files.addAll(listDirFiles(entry, filter, recurse));
}
}
@ -241,19 +250,7 @@ public class FileUtil {
file));
}
} else {
InputStream in = new FileInputStream(source);
OutputStream out = new FileOutputStream(destination);
byte[] buf = new byte[1024];
int len;
while ((len = in.read(buf)) > 0) {
out.write(buf, 0, len);
}
in.close();
out.close();
copyFile(source, destination);
}
}
@ -361,24 +358,13 @@ public class FileUtil {
}
/**
* Copy a file to a another file.
* Read the contents of a file into a string
*
* @param fileToCopy
* The source file. This file reference must exist.
* @param outputFile
* The destination file. This file may exist, if so it will be
* overwritten.
* @param file
* file to be read
* @return string containing the file contents
* @throws IOException
* An error occurred while copying the data.
* @throws NullPointerException
* Either the source or target file references are null.
*/
public static void copyFile(File fileToCopy, File outputFile)
throws IOException {
// Copy the entire file.
copyFile(fileToCopy, outputFile, 0);
}
public static String file2String(File file) throws IOException {
return new String(file2bytes(file));
}
@ -415,8 +401,9 @@ public class FileUtil {
// Read in the bytes
int offset = 0;
int numRead = 0;
while (offset < bytes.length
&& (numRead = is.read(bytes, offset, bytes.length - offset)) >= 0) {
while ((offset < bytes.length)
&& ((numRead = is
.read(bytes, offset, bytes.length - offset)) >= 0)) {
offset += numRead;
}
@ -500,9 +487,9 @@ public class FileUtil {
// Read in the bytes
int offset = 0;
int numRead = 0;
while (offset < bytes.length
&& (numRead = is.read(bytes, offset, bytes.length
- offset)) >= 0) {
while ((offset < bytes.length)
&& ((numRead = is.read(bytes, offset, bytes.length
- offset)) >= 0)) {
offset += numRead;
}
@ -546,6 +533,8 @@ public class FileUtil {
* The data to store
* @param outFile
* The file to write this data
* @param compress
* if true file will be compressed using gzip
* @throws IOException
*/
public static void bytes2File(byte[] outBytes, File outFile,
@ -564,7 +553,7 @@ public class FileUtil {
// only write out buffer at a time
for (int counter = 0; counter < outBytes.length; counter += buffer) {
if ((outBytes.length - counter) - buffer >= 0) {
if (((outBytes.length - counter) - buffer) >= 0) {
out.write(outBytes, counter, buffer);
} else {
out.write(outBytes, counter, (outBytes.length - counter));
@ -627,7 +616,7 @@ public class FileUtil {
String replacement = (File.separatorChar == '\\') ? "\\\\"
: File.separator;
if (aPath != null && aPath.length() > 0) {
if ((aPath != null) && (aPath.length() > 0)) {
return aPath.replaceAll(fileSeparatorRegex, replacement);
} else {
return aPath;
@ -643,9 +632,9 @@ public class FileUtil {
*/
public static String edexPath(String aPath) {
if (aPath != null && aPath.length() > 0) {
if ((aPath != null) && (aPath.length() > 0)) {
// Remove drive letter
if (aPath.length() > 1 && aPath.charAt(1) == ':') {
if ((aPath.length() > 1) && (aPath.charAt(1) == ':')) {
aPath = aPath.substring(2);
}
return aPath.replace("\\", "/");
@ -683,92 +672,68 @@ public class FileUtil {
}
/**
* Copy a file from one location to another. The file copy may begin at some
* specified position within the source file.
* Copy a file to another file.
*
* @param source
* The source file. This file reference must exist.
* @param target
* @param destination
* The destination file. This file may exist, if so it will be
* overwritten.
* @param position
* The start position within the source file where the copy
* operation will begin. The position must be greater than or
* equal to zero, and less than the file length of the source.
* @return Was the required data copied to the target file.
* @throws IOException
* An error occurred while copying the data.
* @throws IllegalArgumentException
* The position is less than zero or greater than the length of
* the source file or either of the source, target files are
* null.
* Either the source or target file references are null.
*/
public static boolean copyFile(File source, File target, int position)
public static void copyFile(File source, File destination)
throws IOException {
boolean status = false;
if (source != null) {
if (target != null) {
if ((position >= 0) && (position <= source.length())) {
FileInputStream fis = null;
FileOutputStream fos = null;
try {
fis = new FileInputStream(source);
FileChannel fci = fis.getChannel();
fos = new FileOutputStream(target);
FileChannel fco = fos.getChannel();
long count = source.length() - position;
long transfered = fci.transferTo(position, count, fco);
// ensure we copied all of the data.
status = (transfered == count);
} finally {
String cause = null;
try {
close(fis);
} catch (IOException e) {
cause = String.format(
"copyFile.source.close[%s][%s]", e
.getClass().getName(), e
.getMessage());
}
try {
close(fos);
} catch (IOException e) {
if (cause == null) {
cause = String.format(
"copyFile.target.close[%s][%s]", e
.getClass().getName(), e
.getMessage());
} else {
cause = String.format(
"%s copyFile.target.close[%s][%s]",
cause, e.getClass().getName(),
e.getMessage());
}
}
// One or more closes failed. Construct and throw an
// exception.
if (cause != null) {
throw new IOException(cause);
}
}
} else {
String msg = String.format(
"position [%d] is out of range. Max is [%d]",
position, source.length());
throw new IllegalArgumentException(msg);
}
} else {
throw new IllegalArgumentException(
"target file reference is null");
}
} else {
if (source == null) {
throw new IllegalArgumentException("source file reference is null");
}
return status;
if (destination == null) {
throw new IllegalArgumentException("target file reference is null");
}
FileInputStream fis = null;
FileOutputStream fos = null;
IOException exception = null;
try {
fis = new FileInputStream(source);
fos = new FileOutputStream(destination);
IOUtils.copyLarge(fis, fos);
} catch (IOException e) {
// close the output stream ignoring any exceptions
close(fos);
fos = null;
// remove the invalid destination file
destination.delete();
exception = new IOException(String.format("Error copying %s to %s",
source.getCanonicalPath(), destination.getCanonicalPath()),
e);
} finally {
// close destination and source files reporting first exception
IOException e = close(fos);
if ((exception == null) && (e != null)) {
exception = new IOException(String.format("Error closing %s",
destination.getCanonicalPath()), e);
}
e = close(fis);
if ((exception == null) && (e != null)) {
exception = new IOException(String.format("Error closing %s",
source.getCanonicalPath()), e);
}
if (exception != null) {
throw exception;
}
}
}
/**
@ -887,13 +852,17 @@ public class FileUtil {
*
* @param c
* An object that needs to be closed.
* @throws IOException
* An error occurred attempting to close the object.
* @return IOException if one occurs or null
*/
public static void close(Closeable c) throws IOException {
private static IOException close(Closeable c) {
if (c != null) {
c.close();
try {
c.close();
} catch (IOException e) {
return e;
}
}
return null;
}
/**

View file

@ -31,10 +31,4 @@
version="0.0.0"
unpack="false"/>
<plugin
id="org.apache.commons.io"
download-size="0"
install-size="0"
version="0.0.0"/>
</feature>

View file

@ -85,7 +85,6 @@ if [ "${2}" = "-nobinlightning" ]; then
fi
if [ "${1}" = "-python-qpid" ]; then
buildRPM "awips2"
buildRPM "awips2-python-qpid"
buildRPM "awips2-python"
buildRPM "awips2-python-cherrypy"
@ -116,15 +115,6 @@ if [ "${1}" = "-python-qpid" ]; then
exit 1
fi
#buildRPM "awips2-ant"
#unpackHttpdPypies
if [ $? -ne 0 ]; then
exit 1
fi
#buildRPM "awips2-httpd-pypies"
#buildRPM "awips2-java"
#buildRPM "awips2-ldm"
#buildRPM "awips2-tools"
buildRPM "awips2-python-shapely"
exit 0
@ -157,7 +147,6 @@ if [ "${1}" = "-delta" ]; then
exit 1
fi
buildRPM "awips2"
buildRPM "awips2-ncep-database"
buildRPM "awips2-gfesuite-client"
buildRPM "awips2-gfesuite-server"
@ -173,7 +162,6 @@ if [ "${1}" = "-delta" ]; then
buildRPM "awips2-database-server-configuration"
buildRPM "awips2-database-standalone-configuration"
buildRPM "awips2-data.hdf5-gfe.climo"
buildRPM "awips2-hydroapps-shared"
buildRPM "awips2-localapps-environment"
buildRPM "awips2-maps-database"
buildRPM "awips2-notification"
@ -181,7 +169,6 @@ if [ "${1}" = "-delta" ]; then
buildRPM "awips2-data.hdf5-topo"
buildRPM "awips2-data.gfe"
buildRPM "awips2-rcm"
buildRPM "awips2-edex-environment"
buildLocalizationRPMs
if [ $? -ne 0 ]; then
exit 1
@ -222,8 +209,8 @@ if [ "${1}" = "-full" ]; then
buildRPM "awips2-python-werkzeug"
buildRPM "awips2-python-pygtk"
buildRPM "awips2-python-pycairo"
buildRPM "awips2-python-shapely"
buildRPM "awips2"
buildRPM "awips2-adapt-native"
buildRPM "awips2-aviation-shared"
buildRPM "awips2-cli"
@ -260,14 +247,11 @@ if [ "${1}" = "-full" ]; then
buildRPM "awips2-httpd-pypies"
buildJava
buildRPM "awips2-groovy"
#buildRPM "awips2-ldm"
buildRPM "awips2-postgres"
buildRPM "awips2-pgadmin3"
buildRPM "awips2-tools"
buildRPM "awips2-edex-environment"
buildRPM "awips2-openfire"
buildRPM "awips2-httpd-collaboration"
buildRPM "awips2-python-shapely"
exit 0
fi
@ -347,9 +331,6 @@ if [ "${1}" = "-ade" ]; then
fi
if [ "${1}" = "-viz" ]; then
buildRPM "awips2-common-base"
buildRPM "awips2-rcm"
buildRPM "awips2-hydroapps-shared"
buildCAVE
if [ $? -ne 0 ]; then
exit 1
@ -360,13 +341,9 @@ if [ "${1}" = "-viz" ]; then
fi
if [ "${1}" = "-edex" ]; then
buildRPM "awips2-common-base"
buildRPM "awips2-adapt-native"
buildRPM "awips2-gfesuite-client"
buildRPM "awips2-gfesuite-server"
buildRPM "awips2-edex-environment"
# buildRPM "awips2-ncep-database"
# buildRPM "awips2-python-dynamicserialize"
buildEDEX
if [ $? -ne 0 ]; then
exit 1
@ -415,6 +392,11 @@ if [ "${1}" = "-custom" ]; then
buildRPM "awips2-httpd-pypies"
buildRPM "awips2-adapt-native"
buildRPM "awips2-hydroapps-shared"
buildRPM "awips2-common-base"
buildRPM "awips2-rcm"
#buildRPM "awips2-ant"
#buildRPM "awips2-java"
#buildRPM "awips2-tools"
exit 0
fi

View file

@ -247,6 +247,7 @@ fi
if [ "${1}" = "-edex" ]; then
buildRPM "awips2-common-base"
buildRPM "awips2-edex-environment"
buildEDEX
if [ $? -ne 0 ]; then
exit 1
@ -286,6 +287,9 @@ if [ "${1}" = "-custom" ]; then
buildRPM "awips2-httpd-pypies"
buildRPM "awips2-adapt-native"
buildRPM "awips2-hydroapps-shared"
#buildRPM "awips2-ant"
#buildRPM "awips2-java"
#buildRPM "awips2-tools"
exit 0
fi

View file

@ -0,0 +1,333 @@
#!/bin/bash
function buildRPM()
{
# Arguments:
# ${1} == the name of the rpm.
lookupRPM "${1}"
if [ $? -ne 0 ]; then
echo "ERROR: '${1}' is not a recognized AWIPS II RPM."
exit 1
fi
/usr/bin/rpmbuild -ba \
--define '_topdir %(echo ${AWIPSII_TOP_DIR})' \
--define '_baseline_workspace %(echo ${WORKSPACE})' \
--define '_uframe_eclipse %(echo ${UFRAME_ECLIPSE})' \
--define '_awipscm_share %(echo ${AWIPSCM_SHARE})' \
--define '_build_root %(echo ${AWIPSII_BUILD_ROOT})' \
--define '_component_version %(echo ${AWIPSII_VERSION})' \
--define '_component_release %(echo ${AWIPSII_RELEASE})' \
--define '_component_build_date %(echo ${COMPONENT_BUILD_DATE})' \
--define '_component_build_time %(echo ${COMPONENT_BUILD_TIME})' \
--define '_component_build_system %(echo ${COMPONENT_BUILD_SYSTEM})' \
--buildroot ${AWIPSII_BUILD_ROOT} \
${RPM_SPECIFICATION}/component.spec
if [ $? -ne 0 ]; then
echo "ERROR: Failed to build RPM ${1}."
exit 1
fi
return 0
}
# This script will build all of the 64-bit rpms.
# Ensure that we are on a machine with the correct architecture.
architecture=`uname -i`
if [ ! "${architecture}" = "x86_64" ]; then
echo "ERROR: This build can only be performed on a 64-bit Operating System."
exit 1
fi
# Determine which directory we are running from.
path_to_script=`readlink -f $0`
dir=$(dirname $path_to_script)
common_dir=`cd ${dir}/../common; pwd;`
if [ $? -ne 0 ]; then
echo "ERROR: Unable to find the common functions directory."
exit 1
fi
# source the common functions.
source ${common_dir}/lookupRPM.sh
if [ $? -ne 0 ]; then
echo "ERROR: Unable to source the common functions."
exit 1
fi
source ${common_dir}/usage.sh
if [ $? -ne 0 ]; then
echo "ERROR: Unable to source the common functions."
exit 1
fi
source ${common_dir}/rpms.sh
if [ $? -ne 0 ]; then
echo "ERROR: Unable to source the common functions."
exit 1
fi
source ${common_dir}/systemInfo.sh
if [ $? -ne 0 ]; then
echo "ERROR: Unable to retrieve the system information."
exit 1
fi
# prepare the build environment.
source ${dir}/buildEnvironment.sh
if [ $? -ne 0 ]; then
echo "ERROR: Unable to prepare the build environment."
exit 1
fi
export LIGHTNING=true
# Determine if the optional '-nobinlightning' argument has been specified.
if [ "${2}" = "-nobinlightning" ]; then
LIGHTNING=false
fi
if [ "${1}" = "-64bit" ]; then
buildRPM "awips2-common-base"
buildCAVE
if [ $? -ne 0 ]; then
exit 1
fi
buildRPM "awips2-alertviz"
if [ $? -ne 0 ]; then
exit 1
fi
buildRPM "awips2-python"
buildRPM "awips2-python-cherrypy"
buildRPM "awips2-python-dynamicserialize"
buildRPM "awips2-python-h5py"
buildRPM "awips2-python-jimporter"
buildRPM "awips2-python-matplotlib"
buildRPM "awips2-python-nose"
buildRPM "awips2-python-numpy"
buildRPM "awips2-python-pil"
buildRPM "awips2-python-pmw"
buildRPM "awips2-python-pupynere"
buildRPM "awips2-python-qpid"
buildRPM "awips2-python-scientific"
buildRPM "awips2-python-scipy"
buildRPM "awips2-python-tables"
buildRPM "awips2-python-thrift"
buildRPM "awips2-python-tpg"
buildRPM "awips2-python-ufpy"
buildRPM "awips2-python-werkzeug"
buildRPM "awips2-python-pygtk"
buildRPM "awips2-python-pycairo"
buildJava
buildRPM "awips2-python-shapely"
buildRPM "awips2-notification"
exit 0
fi
if [ "${1}" = "-postgres" ]; then
buildRPM "awips2-postgres"
buildRPM "awips2-database-server-configuration"
buildRPM "awips2-database-standalone-configuration"
buildRPM "awips2-database"
buildRPM "awips2-maps-database"
buildRPM "awips2-ncep-database"
buildRPM "awips2-pgadmin3"
exit 0
fi
if [ "${1}" = "-delta" ]; then
buildRPM "awips2-common-base"
buildCAVE
if [ $? -ne 0 ]; then
exit 1
fi
buildRPM "awips2-alertviz"
buildEDEX
if [ $? -ne 0 ]; then
exit 1
fi
buildRPM "awips2-python-dynamicserialize"
buildRPM "awips2-python-ufpy"
buildRPM "awips2-cli"
buildRPM "awips2-data.hdf5-gfe.climo"
buildRPM "awips2-gfesuite-client"
buildRPM "awips2-gfesuite-server"
buildRPM "awips2-localapps-environment"
buildRPM "awips2-data.hdf5-topo"
buildRPM "awips2-data.gfe"
buildLocalizationRPMs
if [ $? -ne 0 ]; then
exit 1
fi
buildRPM "awips2-edex-environment"
buildRPM "awips2-notification"
exit 0
fi
if [ "${1}" = "-full" ]; then
buildRPM "awips2-common-base"
buildCAVE
if [ $? -ne 0 ]; then
exit 1
fi
buildRPM "awips2-alertviz"
buildEDEX
if [ $? -ne 0 ]; then
exit 1
fi
buildRPM "awips2-python"
buildRPM "awips2-python-cherrypy"
buildRPM "awips2-python-dynamicserialize"
buildRPM "awips2-python-h5py"
buildRPM "awips2-python-jimporter"
buildRPM "awips2-python-matplotlib"
buildRPM "awips2-python-nose"
buildRPM "awips2-python-numpy"
buildRPM "awips2-python-pil"
buildRPM "awips2-python-pmw"
buildRPM "awips2-python-pupynere"
buildRPM "awips2-python-qpid"
buildRPM "awips2-python-scientific"
buildRPM "awips2-python-scipy"
buildRPM "awips2-python-tables"
buildRPM "awips2-python-thrift"
buildRPM "awips2-python-tpg"
buildRPM "awips2-python-ufpy"
buildRPM "awips2-python-werkzeug"
buildRPM "awips2-python-pygtk"
buildRPM "awips2-python-pycairo"
buildRPM "awips2-cli"
buildRPM "awips2-data.hdf5-gfe.climo"
buildRPM "awips2-gfesuite-client"
buildRPM "awips2-gfesuite-server"
buildRPM "awips2-localapps-environment"
buildRPM "awips2-data.hdf5-topo"
buildRPM "awips2-data.gfe"
unpackHttpdPypies
if [ $? -ne 0 ]; then
exit 1
fi
buildRPM "awips2-httpd-pypies"
buildJava
buildRPM "awips2-groovy"
buildLocalizationRPMs
if [ $? -ne 0 ]; then
exit 1
fi
buildRPM "awips2-edex-environment"
buildRPM "awips2-notification"
buildRPM "awips2-python-shapely"
buildRPM "awips2-postgres"
buildRPM "awips2-database"
buildRPM "awips2-maps-database"
buildRPM "awips2-ncep-database"
buildRPM "awips2-pgadmin3"
buildRPM "awips2-ldm"
exit 0
fi
if [ "${1}" = "-ade" ]; then
echo "INFO: AWIPS II currently does not support a 64-bit version of the ADE."
exit 0
buildRPM "awips2-eclipse"
exit 0
fi
if [ "${1}" = "-viz" ]; then
buildRPM "awips2-common-base"
buildCAVE
if [ $? -ne 0 ]; then
exit 1
fi
buildRPM "awips2-alertviz"
exit 0
fi
if [ "${1}" = "-edex" ]; then
buildRPM "awips2-common-base"
buildEDEX
if [ $? -ne 0 ]; then
exit 1
fi
exit 0
fi
if [ "${1}" = "-qpid" ]; then
buildQPID
if [ $? -ne 0 ]; then
exit 1
fi
exit 0
fi
if [ "${1}" = "-ldm" ]; then
buildRPM "awips2-ldm"
exit 0
fi
if [ "${1}" = "-awips2" ]; then
buildRPM "awips2"
exit 0
fi
# Use the custom flag for selecting specific rpms to build
if [ "${1}" = "-custom" ]; then
unpackHttpdPypies
if [ $? -ne 0 ]; then
exit 1
fi
buildRPM "awips2-httpd-pypies"
buildRPM "awips2-adapt-native"
buildRPM "awips2-hydroapps-shared"
exit 0
fi
if [ "${1}" = "-package" ]; then
repository_directory="awips2-repository-${AWIPSII_VERSION}-${AWIPSII_RELEASE}"
if [ -d ${WORKSPACE}/${repository_directory} ]; then
rm -rf ${WORKSPACE}/${repository_directory}
if [ $? -ne 0 ]; then
exit 1
fi
fi
mkdir -p ${WORKSPACE}/${repository_directory}/${AWIPSII_VERSION}-${AWIPSII_RELEASE}
if [ $? -ne 0 ]; then
exit 1
fi
cp -r ${AWIPSII_TOP_DIR}/RPMS/* \
${WORKSPACE}/${repository_directory}/${AWIPSII_VERSION}-${AWIPSII_RELEASE}
if [ $? -ne 0 ]; then
exit 1
fi
rpms_directory="${WORKSPACE}/rpms"
comps_xml="${rpms_directory}/common/yum/arch.x86_64/comps.xml"
cp -v ${comps_xml} ${WORKSPACE}/${repository_directory}
if [ $? -ne 0 ]; then
exit 1
fi
pushd . > /dev/null
cd ${WORKSPACE}
tar -cvf ${repository_directory}.tar ${repository_directory}
RC=$?
popd > /dev/null
if [ ${RC} -ne 0 ]; then
exit 1
fi
exit 0
fi
usage
exit 0