http://git-wip-us.apache.org/repos/asf/oodt/blob/abd71645/pushpull/src/main/java/org/apache/oodt/cas/pushpull/protocol/ProtocolHandler.java ---------------------------------------------------------------------- diff --git a/pushpull/src/main/java/org/apache/oodt/cas/pushpull/protocol/ProtocolHandler.java b/pushpull/src/main/java/org/apache/oodt/cas/pushpull/protocol/ProtocolHandler.java index abecbd9..1c1f243 100644 --- a/pushpull/src/main/java/org/apache/oodt/cas/pushpull/protocol/ProtocolHandler.java +++ b/pushpull/src/main/java/org/apache/oodt/cas/pushpull/protocol/ProtocolHandler.java @@ -107,10 +107,11 @@ public class ProtocolHandler { try { Protocol protocol = getAppropriateProtocol(pFile, allowReuse); if (protocol != null && navigateToPathLoc) { - if (pFile.isDir()) + if (pFile.isDir()) { this.cd(protocol, pFile); - else if (pFile.getParent() != null) + } else if (pFile.getParent() != null) { this.cd(protocol, new RemoteSiteFile(pFile.getParent(), pFile.getSite())); + } } return protocol; } catch (Exception e) { @@ -165,18 +166,20 @@ public class ProtocolHandler { + " for " + remoteSite.getURL()); } } - if (protocol == null) + if (protocol == null) { throw new ProtocolException("Failed to get appropriate protocol for " - + remoteSite); + + remoteSite); + } } else { connect(protocol = protocolFactory.newInstance(), remoteSite, false); } - if (allowReuse) + if (allowReuse) { try { this.reuseProtocols.put(remoteSite.getURL().toURI(), protocol); } catch (URISyntaxException e) { LOG.log(Level.SEVERE, "Couildn't covert URL to URI Mesage: " + e.getMessage()); } + } } } catch (URISyntaxException e) { LOG.log(Level.SEVERE, "could not convert url to uri: Message: "+e.getMessage()); @@ -220,8 +223,9 @@ public class ProtocolHandler { List<RemoteSiteFile> page = new LinkedList<RemoteSiteFile>(); int curLoc = pgInfo.getPageLoc(); for (; page.size() < pi.getPageSize() && curLoc < fileList.size(); curLoc++) { - if (filter == null || filter.accept(fileList.get(curLoc))) + if (filter == null || filter.accept(fileList.get(curLoc))) { page.add(fileList.get(curLoc)); + } } pgInfo.updatePageInfo(curLoc, fileList); @@ -266,12 +270,13 @@ public class ProtocolHandler { // delete file is specified if (delete) { - if (!this.delete(protocol, fromFile)) + if (!this.delete(protocol, fromFile)) { LOG.log(Level.WARNING, "Failed to delete file '" + fromFile - + "' from server '" + fromFile.getSite() + "'"); - else + + "' from server '" + fromFile.getSite() + "'"); + } else { LOG.log(Level.INFO, "Successfully deleted file '" + fromFile - + "' from server '" + fromFile.getSite() + "'"); + + "' from server '" + fromFile.getSite() + "'"); + } } LOG.log(Level.INFO, "Finished downloading " + fromFile + " to " + toFile); @@ -333,8 +338,9 @@ public class ProtocolHandler { + " with protocol '" + protocol.getClass().getCanonicalName() + "' and username '" + remoteSite.getUsername() + "'"); return true; - } else + } else { return false; + } } catch (Exception e) { LOG.log(Level.WARNING, "Error occurred while connecting to " @@ -354,14 +360,16 @@ public class ProtocolHandler { this.cdToHOME(protocol); RemoteSiteFile home = this.pwd(remoteSite, protocol); this.ls(remoteSite, protocol); - if (remoteSite.getCdTestDir() != null) + if (remoteSite.getCdTestDir() != null) { this.cd(protocol, new RemoteSiteFile(home, remoteSite.getCdTestDir(), true, remoteSite)); - else + } else { this.cdToROOT(protocol); + } this.cdToHOME(protocol); - if (home == null || !home.equals(this.pwd(remoteSite, protocol))) + if (home == null || !home.equals(this.pwd(remoteSite, protocol))) { throw new ProtocolException("Home directory not the same after cd"); + } } catch (Exception e) { LOG.log(Level.SEVERE, "Protocol " + protocol.getClass().getCanonicalName() @@ -404,10 +412,11 @@ public class ProtocolHandler { System.out.println("IndexOfFile: " + indexOfFile + " PageIndex: " + pgInfo.getPageLoc()); if (indexOfFile < pgInfo.getPageLoc() - || indexOfFile == fileList.size() - 1) + || indexOfFile == fileList.size() - 1) { pgInfo.updatePageInfo(pgInfo.getPageLoc() - 1, fileList); - else + } else { pgInfo.updatePageInfo(pgInfo.getPageLoc(), fileList); + } return true; } else { return false; @@ -424,8 +433,9 @@ public class ProtocolHandler { private synchronized PagingInfo getPagingInfo(RemoteSiteFile pFile) { PagingInfo pgInfo = this.pageInfos.get(pFile); - if (pgInfo == null) + if (pgInfo == null) { this.putPgInfo(pgInfo = new PagingInfo(), pFile); + } return pgInfo; } @@ -445,16 +455,18 @@ public class ProtocolHandler { public List<RemoteSiteFile> ls(RemoteSite site, Protocol protocol) throws ProtocolException { List<RemoteSiteFile> fileList = this.getDynamicFileList(site, protocol); - if (fileList == null) + if (fileList == null) { fileList = toRemoteSiteFiles(protocol.ls(), site); + } return fileList; } public List<RemoteSiteFile> ls(RemoteSite site, Protocol protocol, ProtocolFileFilter filter) throws ProtocolException { List<RemoteSiteFile> fileList = this.getDynamicFileList(site, protocol); - if (fileList == null) + if (fileList == null) { fileList = toRemoteSiteFiles(protocol.ls(filter), site); + } return fileList; }
http://git-wip-us.apache.org/repos/asf/oodt/blob/abd71645/pushpull/src/main/java/org/apache/oodt/cas/pushpull/protocol/ProtocolPath.java ---------------------------------------------------------------------- diff --git a/pushpull/src/main/java/org/apache/oodt/cas/pushpull/protocol/ProtocolPath.java b/pushpull/src/main/java/org/apache/oodt/cas/pushpull/protocol/ProtocolPath.java index 6ea4f5d..b0a8944 100644 --- a/pushpull/src/main/java/org/apache/oodt/cas/pushpull/protocol/ProtocolPath.java +++ b/pushpull/src/main/java/org/apache/oodt/cas/pushpull/protocol/ProtocolPath.java @@ -55,8 +55,9 @@ public class ProtocolPath implements Serializable { } protected String checkForDelimiters(String path) { - if (path.endsWith("/") && path.length() > 1) + if (path.endsWith("/") && path.length() > 1) { path = path.substring(0, path.length() - 1); + } relativeToHOME = !path.startsWith("/"); return path; } @@ -116,8 +117,9 @@ public class ProtocolPath implements Serializable { } public String getParentDirPath() { - if (path.length() <= 1) + if (path.length() <= 1) { return null; + } return path.substring(0, path.lastIndexOf("/")); } http://git-wip-us.apache.org/repos/asf/oodt/blob/abd71645/pushpull/src/main/java/org/apache/oodt/cas/pushpull/retrievalmethod/ListRetriever.java ---------------------------------------------------------------------- diff --git a/pushpull/src/main/java/org/apache/oodt/cas/pushpull/retrievalmethod/ListRetriever.java b/pushpull/src/main/java/org/apache/oodt/cas/pushpull/retrievalmethod/ListRetriever.java index ccf28b1..8a765e1 100644 --- a/pushpull/src/main/java/org/apache/oodt/cas/pushpull/retrievalmethod/ListRetriever.java +++ b/pushpull/src/main/java/org/apache/oodt/cas/pushpull/retrievalmethod/ListRetriever.java @@ -70,8 +70,9 @@ public class ListRetriever implements RetrievalMethod { propFile), fileMetadata); DownloadInfo di = dfi.getDownloadInfo(); if (!di.isAllowAliasOverride() - || (remoteSite = vfs.getRemoteSite()) == null) - remoteSite = di.getRemoteSite(); + || (remoteSite = vfs.getRemoteSite()) == null) { + remoteSite = di.getRemoteSite(); + } LinkedList<String> fileList = FileRestrictions.toStringList(vfs .getRootVirtualFile()); @@ -81,8 +82,9 @@ public class ListRetriever implements RetrievalMethod { linker.addPropFileToDataFileLink(propFile, file); if (!frs.addToDownloadQueue(remoteSite, file, di .getRenamingConv(), di.getStagingArea(), dfi - .getQueryMetadataElementName(), di.deleteFromServer(), fileMetadata)) - linker.eraseLinks(propFile); + .getQueryMetadataElementName(), di.deleteFromServer(), fileMetadata)) { + linker.eraseLinks(propFile); + } } catch (ToManyFailedDownloadsException e) { throw new RetrievalMethodException( "Connection appears to be down. . .unusual number of download failures. . .stopping : " http://git-wip-us.apache.org/repos/asf/oodt/blob/abd71645/pushpull/src/main/java/org/apache/oodt/cas/pushpull/retrievalmethod/RemoteCrawler.java ---------------------------------------------------------------------- diff --git a/pushpull/src/main/java/org/apache/oodt/cas/pushpull/retrievalmethod/RemoteCrawler.java b/pushpull/src/main/java/org/apache/oodt/cas/pushpull/retrievalmethod/RemoteCrawler.java index 925a65d..d3030e3 100644 --- a/pushpull/src/main/java/org/apache/oodt/cas/pushpull/retrievalmethod/RemoteCrawler.java +++ b/pushpull/src/main/java/org/apache/oodt/cas/pushpull/retrievalmethod/RemoteCrawler.java @@ -89,8 +89,9 @@ public class RemoteCrawler implements RetrievalMethod { // determine RemoteSite DownloadInfo di = dfi.getDownloadInfo(); if (!di.isAllowAliasOverride() - || (remoteSite = vfs.getRemoteSite()) == null) - remoteSite = di.getRemoteSite(); + || (remoteSite = vfs.getRemoteSite()) == null) { + remoteSite = di.getRemoteSite(); + } // modify vfs to be root based if HOME directory based if (!vfs.isRootBased()) { @@ -132,11 +133,12 @@ public class RemoteCrawler implements RetrievalMethod { }); // if directory had more children then add them - if (children.size() > 0) - files.addAll(children); - // otherwise remove the directory from the crawl list - else - files.pop(); + if (children.size() > 0) { + files.addAll(children); + }// otherwise remove the directory from the crawl list + else { + files.pop(); + } // if file, then download it } else { @@ -144,8 +146,9 @@ public class RemoteCrawler implements RetrievalMethod { if (!frs.addToDownloadQueue(files.pop(), di .getRenamingConv(), di.getStagingArea(), dfi .getQueryMetadataElementName(), di - .deleteFromServer(), fileMetadata)) - linker.eraseLinks(propFile); + .deleteFromServer(), fileMetadata)) { + linker.eraseLinks(propFile); + } } } catch (ToManyFailedDownloadsException e) { http://git-wip-us.apache.org/repos/asf/oodt/blob/abd71645/pushpull/src/main/java/org/apache/oodt/cas/pushpull/retrievalsystem/DataFileToPropFileLinker.java ---------------------------------------------------------------------- diff --git a/pushpull/src/main/java/org/apache/oodt/cas/pushpull/retrievalsystem/DataFileToPropFileLinker.java b/pushpull/src/main/java/org/apache/oodt/cas/pushpull/retrievalsystem/DataFileToPropFileLinker.java index b6b87bd..790eb1d 100644 --- a/pushpull/src/main/java/org/apache/oodt/cas/pushpull/retrievalsystem/DataFileToPropFileLinker.java +++ b/pushpull/src/main/java/org/apache/oodt/cas/pushpull/retrievalsystem/DataFileToPropFileLinker.java @@ -68,10 +68,11 @@ public class DataFileToPropFileLinker implements DownloadListener { public synchronized void markAsFailed(File propFile, String errorMsg) { String errors = this.propFileToErrorsMap.get(propFile); - if (errors == null) - this.propFileToErrorsMap.put(propFile, errorMsg); - else - this.propFileToErrorsMap.put(propFile, errors + "," + errorMsg); + if (errors == null) { + this.propFileToErrorsMap.put(propFile, errorMsg); + } else { + this.propFileToErrorsMap.put(propFile, errors + "," + errorMsg); + } } public synchronized void markAsFailed(ProtocolFile pFile, String errorMsg) { @@ -82,10 +83,11 @@ public class DataFileToPropFileLinker implements DownloadListener { File propFile = this.protocolFilePathAndPropFileMap.get(pFilePath); if (propFile != null) { String errors = this.propFileToErrorsMap.get(propFile); - if (errors == null) - this.propFileToErrorsMap.put(propFile, errorMsg); - else - this.propFileToErrorsMap.put(propFile, errors + "," + errorMsg); + if (errors == null) { + this.propFileToErrorsMap.put(propFile, errorMsg); + } else { + this.propFileToErrorsMap.put(propFile, errors + "," + errorMsg); + } } } @@ -97,11 +99,14 @@ public class DataFileToPropFileLinker implements DownloadListener { public synchronized void eraseLinks(File propFile) { LinkedList<String> keysToRemove = new LinkedList<String>(); for (Entry<String, File> entry : this.protocolFilePathAndPropFileMap - .entrySet()) - if (entry.getValue().equals(propFile)) - keysToRemove.add(entry.getKey()); - for (String key : keysToRemove) - this.protocolFilePathAndPropFileMap.remove(key); + .entrySet()) { + if (entry.getValue().equals(propFile)) { + keysToRemove.add(entry.getKey()); + } + } + for (String key : keysToRemove) { + this.protocolFilePathAndPropFileMap.remove(key); + } } public synchronized String getErrors(File propFile) { @@ -145,8 +150,9 @@ public class DataFileToPropFileLinker implements DownloadListener { File propFile, LinkedList<ProtocolFile> list) { LinkedList<ProtocolFile> returnList = new LinkedList<ProtocolFile>(); for (ProtocolFile pFile : list) { - if (this.protocolFilePathAndPropFileMap.get(pFile.getPath()) != null) - returnList.add(pFile); + if (this.protocolFilePathAndPropFileMap.get(pFile.getPath()) != null) { + returnList.add(pFile); + } } return returnList; } http://git-wip-us.apache.org/repos/asf/oodt/blob/abd71645/pushpull/src/main/java/org/apache/oodt/cas/pushpull/retrievalsystem/DownloadThreadEvaluator.java ---------------------------------------------------------------------- diff --git a/pushpull/src/main/java/org/apache/oodt/cas/pushpull/retrievalsystem/DownloadThreadEvaluator.java b/pushpull/src/main/java/org/apache/oodt/cas/pushpull/retrievalsystem/DownloadThreadEvaluator.java index 2fd093a..81ed683 100644 --- a/pushpull/src/main/java/org/apache/oodt/cas/pushpull/retrievalsystem/DownloadThreadEvaluator.java +++ b/pushpull/src/main/java/org/apache/oodt/cas/pushpull/retrievalsystem/DownloadThreadEvaluator.java @@ -57,9 +57,10 @@ public class DownloadThreadEvaluator { public synchronized void startTrackingDownloadRuntimeForFile(File file) throws ThreadEvaluatorException { long curTime = System.currentTimeMillis(); - if (++this.currentThreadCount > this.MAX_THREADS) + if (++this.currentThreadCount > this.MAX_THREADS) { throw new ThreadEvaluatorException( - "Number of threads exceeds max allows threads"); + "Number of threads exceeds max allows threads"); + } updateThreadCounts(curTime); fileAndDownloadingFileInfo.put(file, new DownloadingFileInfo(file, curTime, this.currentThreadCount)); @@ -93,10 +94,11 @@ public class DownloadThreadEvaluator { long nextTime; for (int i = 0; i < tatcList.size(); i++) { TimeAndThreadCount tatc = tatcList.get(i); - if (i + 1 >= tatcList.size()) + if (i + 1 >= tatcList.size()) { nextTime = finishTime; - else + } else { nextTime = tatcList.get(i + 1).getStartTimeInMillis(); + } long threadCountTime = nextTime - tatc.getStartTimeInMillis(); total += ((double) (tatc.getThreadCount() * threadCountTime)) / (double) runtime; @@ -107,10 +109,11 @@ public class DownloadThreadEvaluator { double downloadSpeed = (file.length() * avgThreadCountForFile) / calculateRuntime(dfi.getStartTimeInMillis()); double currentAvgSpeed = this.downloadSpeedsForEachThread[avgThreadCountForFile]; - if (currentAvgSpeed == 0) + if (currentAvgSpeed == 0) { this.downloadSpeedsForEachThread[avgThreadCountForFile] = downloadSpeed; - else + } else { this.downloadSpeedsForEachThread[avgThreadCountForFile] = (currentAvgSpeed + downloadSpeed) / 2; + } } catch (Exception e) { e.printStackTrace(); throw new ThreadEvaluatorException("Failed to register file " @@ -137,14 +140,16 @@ public class DownloadThreadEvaluator { } if (curRecThreadCount != this.MAX_THREADS - && this.downloadSpeedsForEachThread[curRecThreadCount + 1] == 0) + && this.downloadSpeedsForEachThread[curRecThreadCount + 1] == 0) { curRecThreadCount++; - else if (this.downloadSpeedsForEachThread[curRecThreadCount - 1] == 0) + } else if (this.downloadSpeedsForEachThread[curRecThreadCount - 1] == 0) { curRecThreadCount--; + } System.out.print("[ "); - for (double time : downloadSpeedsForEachThread) + for (double time : downloadSpeedsForEachThread) { System.out.print(time + " "); + } System.out.println("]"); System.out.println("Recommended Threads: " + curRecThreadCount); http://git-wip-us.apache.org/repos/asf/oodt/blob/abd71645/pushpull/src/main/java/org/apache/oodt/cas/pushpull/retrievalsystem/FileRetrievalSystem.java ---------------------------------------------------------------------- diff --git a/pushpull/src/main/java/org/apache/oodt/cas/pushpull/retrievalsystem/FileRetrievalSystem.java b/pushpull/src/main/java/org/apache/oodt/cas/pushpull/retrievalsystem/FileRetrievalSystem.java index d9ab5c5..1559069 100644 --- a/pushpull/src/main/java/org/apache/oodt/cas/pushpull/retrievalsystem/FileRetrievalSystem.java +++ b/pushpull/src/main/java/org/apache/oodt/cas/pushpull/retrievalsystem/FileRetrievalSystem.java @@ -236,8 +236,9 @@ public class FileRetrievalSystem { threadController = new ThreadPoolExecutor(this.max_sessions, this.max_sessions, EXTRA_LAZY_SESSIONS_TIMEOUT, TimeUnit.SECONDS, new LinkedBlockingQueue<Runnable>()); - if (config.useTracker()) - dtEval = new DownloadThreadEvaluator(this.absMaxAllowedSessions); + if (config.useTracker()) { + dtEval = new DownloadThreadEvaluator(this.absMaxAllowedSessions); + } } /** @@ -277,67 +278,74 @@ public class FileRetrievalSystem { public void changeToRoot(RemoteSite remoteSite) throws org.apache.oodt.cas.protocol.exceptions.ProtocolException { - if (validate(remoteSite)) - protocolHandler.cdToROOT(protocolHandler - .getAppropriateProtocolBySite(remoteSite, true)); - else - throw new ProtocolException("Not a valid remote site " + remoteSite); + if (validate(remoteSite)) { + protocolHandler.cdToROOT(protocolHandler + .getAppropriateProtocolBySite(remoteSite, true)); + } else { + throw new ProtocolException("Not a valid remote site " + remoteSite); + } } public void changeToHOME(RemoteSite remoteSite) throws ProtocolException { - if (validate(remoteSite)) - protocolHandler.cdToHOME(protocolHandler - .getAppropriateProtocolBySite(remoteSite, true)); - else - throw new ProtocolException("Not a valid remote site " + remoteSite); + if (validate(remoteSite)) { + protocolHandler.cdToHOME(protocolHandler + .getAppropriateProtocolBySite(remoteSite, true)); + } else { + throw new ProtocolException("Not a valid remote site " + remoteSite); + } } public void changeToDir(String dir, RemoteSite remoteSite) throws MalformedURLException, ProtocolException { - if (validate(remoteSite)) - this - .changeToDir(protocolHandler.getProtocolFileFor(remoteSite, - protocolHandler.getAppropriateProtocolBySite( - remoteSite, true), dir, true)); - else - throw new ProtocolException("Not a valid remote site " + remoteSite); + if (validate(remoteSite)) { + this + .changeToDir(protocolHandler.getProtocolFileFor(remoteSite, + protocolHandler.getAppropriateProtocolBySite( + remoteSite, true), dir, true)); + } else { + throw new ProtocolException("Not a valid remote site " + remoteSite); + } } public void changeToDir(RemoteSiteFile pFile) throws ProtocolException { RemoteSite remoteSite = pFile.getSite(); - if (validate(remoteSite)) - protocolHandler.cd(protocolHandler.getAppropriateProtocolBySite( - remoteSite, true), pFile); - else - throw new ProtocolException("Not a valid remote site " + remoteSite); + if (validate(remoteSite)) { + protocolHandler.cd(protocolHandler.getAppropriateProtocolBySite( + remoteSite, true), pFile); + } else { + throw new ProtocolException("Not a valid remote site " + remoteSite); + } } public ProtocolFile getHomeDir(RemoteSite remoteSite) throws ProtocolException { - if (validate(remoteSite)) - return protocolHandler.getHomeDir(remoteSite, protocolHandler - .getAppropriateProtocolBySite(remoteSite, true)); - else - throw new ProtocolException("Not a valid remote site " + remoteSite); + if (validate(remoteSite)) { + return protocolHandler.getHomeDir(remoteSite, protocolHandler + .getAppropriateProtocolBySite(remoteSite, true)); + } else { + throw new ProtocolException("Not a valid remote site " + remoteSite); + } } public ProtocolFile getProtocolFile(RemoteSite remoteSite, String file, boolean isDir) throws ProtocolException { - if (validate(remoteSite)) - return protocolHandler.getProtocolFileFor(remoteSite, protocolHandler - .getAppropriateProtocolBySite(remoteSite, true), file, - isDir); - else - throw new ProtocolException("Not a valid remote site " + remoteSite); + if (validate(remoteSite)) { + return protocolHandler.getProtocolFileFor(remoteSite, protocolHandler + .getAppropriateProtocolBySite(remoteSite, true), file, + isDir); + } else { + throw new ProtocolException("Not a valid remote site " + remoteSite); + } } public ProtocolFile getCurrentFile(RemoteSite remoteSite) throws ProtocolException { - if (validate(remoteSite)) - return protocolHandler.pwd(remoteSite, protocolHandler - .getAppropriateProtocolBySite(remoteSite, true)); - else - throw new ProtocolException("Not a valid remote site " + remoteSite); + if (validate(remoteSite)) { + return protocolHandler.pwd(remoteSite, protocolHandler + .getAppropriateProtocolBySite(remoteSite, true)); + } else { + throw new ProtocolException("Not a valid remote site " + remoteSite); + } } // returns true if download was added to queue. . .false otherwise @@ -349,14 +357,16 @@ public class FileRetrievalSystem { AlreadyInDatabaseException, UndefinedTypeException, CatalogException, IOException { if (validate(remoteSite)) { - if (!file.startsWith("/")) - file = "/" + file; + if (!file.startsWith("/")) { + file = "/" + file; + } return addToDownloadQueue(protocolHandler.getProtocolFileFor(remoteSite, protocolHandler.getAppropriateProtocolBySite(remoteSite, true), file, false), renamingString, downloadToDir, uniqueMetadataElement, deleteAfterDownload, fileMetadata); - } else - throw new ProtocolException("Not a valid remote site " + remoteSite); + } else { + throw new ProtocolException("Not a valid remote site " + remoteSite); + } } public boolean validate(RemoteSite remoteSite) { @@ -378,10 +388,11 @@ public class FileRetrievalSystem { synchronized (this) { for (int i = 0; i < 180; i++) { try { - if (this.avaliableSessions.size() == this.numberOfSessions) - return; - else - this.wait(5000); + if (this.avaliableSessions.size() == this.numberOfSessions) { + return; + } else { + this.wait(5000); + } } catch (Exception ignored) { } } @@ -401,12 +412,13 @@ public class FileRetrievalSystem { UndefinedTypeException, CatalogException, IOException { - if (this.failedDownloadList.size() > max_allowed_failed_downloads) - throw new ToManyFailedDownloadsException( - "Number of failed downloads exceeds " - + max_allowed_failed_downloads - + " . . . blocking all downloads from being added to queue . . . " - + "reset error flag in order to force allow downloads into queue"); + if (this.failedDownloadList.size() > max_allowed_failed_downloads) { + throw new ToManyFailedDownloadsException( + "Number of failed downloads exceeds " + + max_allowed_failed_downloads + + " . . . blocking all downloads from being added to queue . . . " + + "reset error flag in order to force allow downloads into queue"); + } if (this.isDownloading(file)) { LOG.log(Level.WARNING, "Skipping file '" + file + "' because it is already on the download queue"); @@ -451,8 +463,9 @@ public class FileRetrievalSystem { downloadToDir = new File(downloadToDir.isAbsolute() ? downloadToDir .getAbsolutePath() : this.config.getBaseStagingArea() + "/" + downloadToDir.getPath()); - if (!this.isStagingAreaInitialized(downloadToDir)) - this.initializeStagingArea(downloadToDir); + if (!this.isStagingAreaInitialized(downloadToDir)) { + this.initializeStagingArea(downloadToDir); + } remoteFile.addMetadata(RemoteFile.DOWNLOAD_TO_DIR, downloadToDir.getAbsolutePath()); @@ -510,9 +523,10 @@ public class FileRetrievalSystem { + " because it is already in staging area"); return false; } - } else - throw new AlreadyInDatabaseException("File " + file - + " is already the database"); + } else { + throw new AlreadyInDatabaseException("File " + file + + " is already the database"); + } } private boolean isStagingAreaInitialized(File stagingArea) { @@ -541,9 +555,10 @@ public class FileRetrievalSystem { } else { LOG.log(Level.INFO, "Staging area " + stagingArea.getAbsolutePath() + " does not exist! -- trying to create it "); - if (!stagingArea.mkdirs()) - throw new IOException("Failed to create staging area at " - + stagingArea.getAbsolutePath()); + if (!stagingArea.mkdirs()) { + throw new IOException("Failed to create staging area at " + + stagingArea.getAbsolutePath()); + } } this.stagingAreas.add(stagingArea); } @@ -560,8 +575,9 @@ public class FileRetrievalSystem { + "/" + RenamingConvention.rename(remoteFile, renamingString)); if (!newFile.getParentFile().equals( - remoteFile.getMetadata(RemoteFile.DOWNLOAD_TO_DIR))) - newFile.getParentFile().mkdirs(); + remoteFile.getMetadata(RemoteFile.DOWNLOAD_TO_DIR))) { + newFile.getParentFile().mkdirs(); + } return newFile; } } @@ -650,11 +666,12 @@ public class FileRetrievalSystem { false, /* navigate */true); } else { try { - if (file.isDir()) - protocolHandler.cd(session, file); - else - protocolHandler.cd(session, - new RemoteSiteFile(file.getParent(), file.getSite())); + if (file.isDir()) { + protocolHandler.cd(session, file); + } else { + protocolHandler.cd(session, + new RemoteSiteFile(file.getParent(), file.getSite())); + } } catch (Exception e) { e.printStackTrace(); try { @@ -711,9 +728,10 @@ public class FileRetrievalSystem { int retries = 0; Protocol curSession = session; - if (FileRetrievalSystem.this.dListener != null) - FileRetrievalSystem.this.dListener - .downloadStarted(remoteFile.getProtocolFile()); + if (FileRetrievalSystem.this.dListener != null) { + FileRetrievalSystem.this.dListener + .downloadStarted(remoteFile.getProtocolFile()); + } // try until successful or all retries have been used do { @@ -741,10 +759,11 @@ public class FileRetrievalSystem { } successful = true; - if (FileRetrievalSystem.this.dListener != null) - FileRetrievalSystem.this.dListener - .downloadFinished(remoteFile - .getProtocolFile()); + if (FileRetrievalSystem.this.dListener != null) { + FileRetrievalSystem.this.dListener + .downloadFinished(remoteFile + .getProtocolFile()); + } remoteFile.addMetadata(RemoteFile.FILE_SIZE, newFile .length() @@ -770,8 +789,9 @@ public class FileRetrievalSystem { } catch (Exception e) { // if tracker is being used cancel tracking - if (config.useTracker()) - dtEval.cancelRuntimeTracking(newFile); + if (config.useTracker()) { + dtEval.cancelRuntimeTracking(newFile); + } // delete any created file from staging area newFile.delete(); @@ -785,11 +805,12 @@ public class FileRetrievalSystem { LOG.log(Level.SEVERE, "Failed to download " + remoteFile.getProtocolFile() + " : " + e.getMessage()); - if (FileRetrievalSystem.this.dListener != null) - FileRetrievalSystem.this.dListener - .downloadFailed(remoteFile - .getProtocolFile(), e - .getMessage()); + if (FileRetrievalSystem.this.dListener != null) { + FileRetrievalSystem.this.dListener + .downloadFailed(remoteFile + .getProtocolFile(), e + .getMessage()); + } break; } else if (FileRetrievalSystem.this.failedDownloadList .size() < max_allowed_failed_downloads) { @@ -823,11 +844,12 @@ public class FileRetrievalSystem { .getProtocolFile() + " do to too many previous download failures : " + e.getMessage(), e); - if (FileRetrievalSystem.this.dListener != null) - FileRetrievalSystem.this.dListener - .downloadFailed(remoteFile - .getProtocolFile(), e - .getMessage()); + if (FileRetrievalSystem.this.dListener != null) { + FileRetrievalSystem.this.dListener + .downloadFailed(remoteFile + .getProtocolFile(), e + .getMessage()); + } break; } http://git-wip-us.apache.org/repos/asf/oodt/blob/abd71645/pushpull/src/main/java/org/apache/oodt/cas/pushpull/retrievalsystem/RemoteFile.java ---------------------------------------------------------------------- diff --git a/pushpull/src/main/java/org/apache/oodt/cas/pushpull/retrievalsystem/RemoteFile.java b/pushpull/src/main/java/org/apache/oodt/cas/pushpull/retrievalsystem/RemoteFile.java index 3847ba5..68b0dcb 100644 --- a/pushpull/src/main/java/org/apache/oodt/cas/pushpull/retrievalsystem/RemoteFile.java +++ b/pushpull/src/main/java/org/apache/oodt/cas/pushpull/retrievalsystem/RemoteFile.java @@ -80,11 +80,13 @@ public class RemoteFile implements RemoteFileMetKeys { try { SerializableMetadata sMetadata = new SerializableMetadata("UTF-8", false); - for (String metadataKey : metadataToWriteOut) + for (String metadataKey : metadataToWriteOut) { if (this.metadata.getMetadata(metadataKey) != null - && !this.metadata.getMetadata(metadataKey).equals("")) + && !this.metadata.getMetadata(metadataKey).equals("")) { sMetadata.addMetadata(metadataKey, this.metadata - .getMetadata(metadataKey)); + .getMetadata(metadataKey)); + } + } sMetadata.writeMetadataToXmlStream(new FileOutputStream(filePath)); } catch (Exception e) { throw new IOException("Failed to write metadata file for " http://git-wip-us.apache.org/repos/asf/oodt/blob/abd71645/pushpull/src/main/java/org/apache/oodt/cas/pushpull/retrievalsystem/RetrievalSetup.java ---------------------------------------------------------------------- diff --git a/pushpull/src/main/java/org/apache/oodt/cas/pushpull/retrievalsystem/RetrievalSetup.java b/pushpull/src/main/java/org/apache/oodt/cas/pushpull/retrievalsystem/RetrievalSetup.java index 3908f29..4b547be 100644 --- a/pushpull/src/main/java/org/apache/oodt/cas/pushpull/retrievalsystem/RetrievalSetup.java +++ b/pushpull/src/main/java/org/apache/oodt/cas/pushpull/retrievalsystem/RetrievalSetup.java @@ -122,8 +122,9 @@ public class RetrievalSetup { for (File propFile : propFiles) { try { if (pfi.getLocalDir().equals(pfi.getOnSuccessDir()) - || pfi.getLocalDir().equals(pfi.getOnFailDir())) - alreadyProcessedPropFiles.add(propFile); + || pfi.getLocalDir().equals(pfi.getOnFailDir())) { + alreadyProcessedPropFiles.add(propFile); + } this.movePropsFileToFinalDestination(pfi, propFile, linker.getErrorsAndEraseLinks(propFile)); } catch (Exception e) { @@ -138,8 +139,9 @@ public class RetrievalSetup { } catch (Exception e) { e.printStackTrace(); } finally { - if (dataFilesFRS != null) - dataFilesFRS.shutdown(); + if (dataFilesFRS != null) { + dataFilesFRS.shutdown(); + } alreadyProcessedPropFiles.clear(); linker.clear(); } @@ -184,8 +186,9 @@ public class RetrievalSetup { } catch (Exception e) { e.printStackTrace(); } finally { - if (frs != null) - frs.shutdown(); + if (frs != null) { + frs.shutdown(); + } RetrievalSetup.this.downloadingProps = false; } } http://git-wip-us.apache.org/repos/asf/oodt/blob/abd71645/resource/src/main/java/org/apache/oodt/cas/resource/batchmgr/XmlRpcBatchMgrProxy.java ---------------------------------------------------------------------- diff --git a/resource/src/main/java/org/apache/oodt/cas/resource/batchmgr/XmlRpcBatchMgrProxy.java b/resource/src/main/java/org/apache/oodt/cas/resource/batchmgr/XmlRpcBatchMgrProxy.java index 16eaaac..79916ad 100644 --- a/resource/src/main/java/org/apache/oodt/cas/resource/batchmgr/XmlRpcBatchMgrProxy.java +++ b/resource/src/main/java/org/apache/oodt/cas/resource/batchmgr/XmlRpcBatchMgrProxy.java @@ -117,10 +117,11 @@ public class XmlRpcBatchMgrProxy extends Thread implements Runnable { parent.jobExecuting(jobSpec); result = (Boolean) client .execute("batchstub.executeJob", argList); - if (result) - parent.jobSuccess(jobSpec); - else - throw new Exception("batchstub.executeJob returned false"); + if (result) { + parent.jobSuccess(jobSpec); + } else { + throw new Exception("batchstub.executeJob returned false"); + } } catch (Exception e) { LOG.log(Level.SEVERE, "Job execution failed for jobId '" + jobSpec.getJob().getId() + "' : " + e.getMessage(), e); parent.jobFailure(jobSpec); http://git-wip-us.apache.org/repos/asf/oodt/blob/abd71645/resource/src/main/java/org/apache/oodt/cas/resource/cli/action/GetJobInfoCliAction.java ---------------------------------------------------------------------- diff --git a/resource/src/main/java/org/apache/oodt/cas/resource/cli/action/GetJobInfoCliAction.java b/resource/src/main/java/org/apache/oodt/cas/resource/cli/action/GetJobInfoCliAction.java index a5cb480..f040a38 100644 --- a/resource/src/main/java/org/apache/oodt/cas/resource/cli/action/GetJobInfoCliAction.java +++ b/resource/src/main/java/org/apache/oodt/cas/resource/cli/action/GetJobInfoCliAction.java @@ -70,7 +70,8 @@ public class GetJobInfoCliAction extends ResourceCliAction { return "SCHEDULED"; } else if (status.equals(JobStatus.KILLED)) { return "KILLED"; - } else + } else { return null; + } } } http://git-wip-us.apache.org/repos/asf/oodt/blob/abd71645/resource/src/main/java/org/apache/oodt/cas/resource/cli/action/GetNodesInQueueCliAction.java ---------------------------------------------------------------------- diff --git a/resource/src/main/java/org/apache/oodt/cas/resource/cli/action/GetNodesInQueueCliAction.java b/resource/src/main/java/org/apache/oodt/cas/resource/cli/action/GetNodesInQueueCliAction.java index b42a0a4..20eaf61 100644 --- a/resource/src/main/java/org/apache/oodt/cas/resource/cli/action/GetNodesInQueueCliAction.java +++ b/resource/src/main/java/org/apache/oodt/cas/resource/cli/action/GetNodesInQueueCliAction.java @@ -42,8 +42,9 @@ public class GetNodesInQueueCliAction extends ResourceCliAction { List<String> nodeIds = getClient().getNodesInQueue(queueName); printer.println("Nodes in Queue '" + queueName + "':"); - for (String nodeId : nodeIds) + for (String nodeId : nodeIds) { printer.println(" - " + nodeId); + } printer.println(); } catch (Exception e) { throw new CmdLineActionException("Failed to get nodes in queue '" http://git-wip-us.apache.org/repos/asf/oodt/blob/abd71645/resource/src/main/java/org/apache/oodt/cas/resource/cli/action/GetQueuesCliAction.java ---------------------------------------------------------------------- diff --git a/resource/src/main/java/org/apache/oodt/cas/resource/cli/action/GetQueuesCliAction.java b/resource/src/main/java/org/apache/oodt/cas/resource/cli/action/GetQueuesCliAction.java index f97b2be..48d7c02 100644 --- a/resource/src/main/java/org/apache/oodt/cas/resource/cli/action/GetQueuesCliAction.java +++ b/resource/src/main/java/org/apache/oodt/cas/resource/cli/action/GetQueuesCliAction.java @@ -35,8 +35,9 @@ public class GetQueuesCliAction extends ResourceCliAction { try { List<String> queueNames = getClient().getQueues(); printer.println("Queues:"); - for (String queueName : queueNames) - printer.println(" - " + queueName); + for (String queueName : queueNames) { + printer.println(" - " + queueName); + } printer.println(); } catch (Exception e) { throw new CmdLineActionException("Failed to get queues : " http://git-wip-us.apache.org/repos/asf/oodt/blob/abd71645/resource/src/main/java/org/apache/oodt/cas/resource/cli/action/GetQueuesWithNodeCliAction.java ---------------------------------------------------------------------- diff --git a/resource/src/main/java/org/apache/oodt/cas/resource/cli/action/GetQueuesWithNodeCliAction.java b/resource/src/main/java/org/apache/oodt/cas/resource/cli/action/GetQueuesWithNodeCliAction.java index 11b59a5..e4b3e89 100644 --- a/resource/src/main/java/org/apache/oodt/cas/resource/cli/action/GetQueuesWithNodeCliAction.java +++ b/resource/src/main/java/org/apache/oodt/cas/resource/cli/action/GetQueuesWithNodeCliAction.java @@ -42,8 +42,9 @@ public class GetQueuesWithNodeCliAction extends ResourceCliAction { List<String> queueNames = getClient().getQueuesWithNode(nodeId); printer.println("Queues with node '" + nodeId + "':"); - for (String queueName : queueNames) + for (String queueName : queueNames) { printer.println(" - " + queueName); + } printer.println(); } catch (Exception e) { throw new CmdLineActionException("Failed to get queues with node '" http://git-wip-us.apache.org/repos/asf/oodt/blob/abd71645/resource/src/main/java/org/apache/oodt/cas/resource/jobqueue/JobStack.java ---------------------------------------------------------------------- diff --git a/resource/src/main/java/org/apache/oodt/cas/resource/jobqueue/JobStack.java b/resource/src/main/java/org/apache/oodt/cas/resource/jobqueue/JobStack.java index 5118a72..9312580 100644 --- a/resource/src/main/java/org/apache/oodt/cas/resource/jobqueue/JobStack.java +++ b/resource/src/main/java/org/apache/oodt/cas/resource/jobqueue/JobStack.java @@ -75,9 +75,10 @@ public class JobStack implements JobQueue { spec.getJob().setStatus(JobStatus.QUEUED); safeUpdateJob(spec); return jobId; - } else + } else { throw new JobQueueException("Reached max queue size: [" + maxQueueSize - + "]: Unable to add job: [" + spec.getJob().getId() + "]"); + + "]: Unable to add job: [" + spec.getJob().getId() + "]"); + } } /* http://git-wip-us.apache.org/repos/asf/oodt/blob/abd71645/resource/src/main/java/org/apache/oodt/cas/resource/jobrepo/MemoryJobRepository.java ---------------------------------------------------------------------- diff --git a/resource/src/main/java/org/apache/oodt/cas/resource/jobrepo/MemoryJobRepository.java b/resource/src/main/java/org/apache/oodt/cas/resource/jobrepo/MemoryJobRepository.java index b9283e6..3c4424f 100644 --- a/resource/src/main/java/org/apache/oodt/cas/resource/jobrepo/MemoryJobRepository.java +++ b/resource/src/main/java/org/apache/oodt/cas/resource/jobrepo/MemoryJobRepository.java @@ -59,8 +59,9 @@ public class MemoryJobRepository implements JobRepository { spec.getJob().setId(jobId); jobMap.put(jobId, spec); return jobId; - } else + } else { throw new JobRepositoryException("Exception persisting job: job is null!"); + } } /* http://git-wip-us.apache.org/repos/asf/oodt/blob/abd71645/resource/src/main/java/org/apache/oodt/cas/resource/jobrepo/XStreamJobRepository.java ---------------------------------------------------------------------- diff --git a/resource/src/main/java/org/apache/oodt/cas/resource/jobrepo/XStreamJobRepository.java b/resource/src/main/java/org/apache/oodt/cas/resource/jobrepo/XStreamJobRepository.java index 93ba9cc..cb6edaa 100644 --- a/resource/src/main/java/org/apache/oodt/cas/resource/jobrepo/XStreamJobRepository.java +++ b/resource/src/main/java/org/apache/oodt/cas/resource/jobrepo/XStreamJobRepository.java @@ -63,13 +63,16 @@ public class XStreamJobRepository implements JobRepository { XStream xstream = new XStream(); FileOutputStream os = null; try { - if (this.jobMap.size() >= this.maxHistory) - FileUtils.forceDelete(new File(jobMap.remove(jobPrecedence.remove(0)))); + if (this.jobMap.size() >= this.maxHistory) { + FileUtils.forceDelete(new File(jobMap.remove(jobPrecedence.remove(0)))); + } - if (spec.getJob().getId() == null) - spec.getJob().setId(UUID.randomUUID().toString()); - else if (this.jobMap.containsKey(spec.getJob().getId())) - throw new JobRepositoryException("JobId '" + spec.getJob().getId() + "' already in use -- must pick unique JobId"); + if (spec.getJob().getId() == null) { + spec.getJob().setId(UUID.randomUUID().toString()); + } else if (this.jobMap.containsKey(spec.getJob().getId())) { + throw new JobRepositoryException( + "JobId '" + spec.getJob().getId() + "' already in use -- must pick unique JobId"); + } File file = this.generateFilePath(spec.getJob().getId()); os = new FileOutputStream(file); http://git-wip-us.apache.org/repos/asf/oodt/blob/abd71645/resource/src/main/java/org/apache/oodt/cas/resource/jobrepo/XStreamJobRepositoryFactory.java ---------------------------------------------------------------------- diff --git a/resource/src/main/java/org/apache/oodt/cas/resource/jobrepo/XStreamJobRepositoryFactory.java b/resource/src/main/java/org/apache/oodt/cas/resource/jobrepo/XStreamJobRepositoryFactory.java index 9e0288c..f5a5fc0 100644 --- a/resource/src/main/java/org/apache/oodt/cas/resource/jobrepo/XStreamJobRepositoryFactory.java +++ b/resource/src/main/java/org/apache/oodt/cas/resource/jobrepo/XStreamJobRepositoryFactory.java @@ -38,13 +38,15 @@ public class XStreamJobRepositoryFactory implements JobRepositoryFactory { public XStreamJobRepository createRepository() { try { String workingDirPropVal = System.getProperty("org.apache.oodt.cas.resource.jobrepo.xstream.working.dir"); - if (workingDirPropVal == null) - return null; - else - workingDirPropVal = PathUtils.doDynamicReplacement(workingDirPropVal); + if (workingDirPropVal == null) { + return null; + } else { + workingDirPropVal = PathUtils.doDynamicReplacement(workingDirPropVal); + } File working = new File(workingDirPropVal); - if (!working.exists()) - working.mkdirs(); + if (!working.exists()) { + working.mkdirs(); + } int maxHistory = Integer.parseInt(System.getProperty("org.apache.oodt.cas.resource.jobrepo.xstream.max.history", "-1")); return new XStreamJobRepository(working, maxHistory); }catch (Exception e) { http://git-wip-us.apache.org/repos/asf/oodt/blob/abd71645/resource/src/main/java/org/apache/oodt/cas/resource/monitor/AssignmentMonitor.java ---------------------------------------------------------------------- diff --git a/resource/src/main/java/org/apache/oodt/cas/resource/monitor/AssignmentMonitor.java b/resource/src/main/java/org/apache/oodt/cas/resource/monitor/AssignmentMonitor.java index 77fb4a2..bc969b0 100644 --- a/resource/src/main/java/org/apache/oodt/cas/resource/monitor/AssignmentMonitor.java +++ b/resource/src/main/java/org/apache/oodt/cas/resource/monitor/AssignmentMonitor.java @@ -86,8 +86,9 @@ public class AssignmentMonitor implements Monitor { throws MonitorException { int load = loadMap.get(node.getNodeId()); int newVal = load - loadValue; - if (newVal < 0) + if (newVal < 0) { newVal = 0; // should not happen but just in case + } loadMap.remove(node.getNodeId()); loadMap.put(node.getNodeId(), newVal); return true; @@ -141,8 +142,9 @@ public class AssignmentMonitor implements Monitor { public void addNode(ResourceNode node) throws MonitorException { nodesMap.put(node.getNodeId(), node); - if (!loadMap.containsKey(node.getNodeId())) + if (!loadMap.containsKey(node.getNodeId())) { loadMap.put(node.getNodeId(), 0); + } } public void removeNodeById(String nodeId) throws MonitorException { http://git-wip-us.apache.org/repos/asf/oodt/blob/abd71645/resource/src/main/java/org/apache/oodt/cas/resource/monitor/ganglia/GangliaResourceMonitor.java ---------------------------------------------------------------------- diff --git a/resource/src/main/java/org/apache/oodt/cas/resource/monitor/ganglia/GangliaResourceMonitor.java b/resource/src/main/java/org/apache/oodt/cas/resource/monitor/ganglia/GangliaResourceMonitor.java index 5725a83..cb2a938 100644 --- a/resource/src/main/java/org/apache/oodt/cas/resource/monitor/ganglia/GangliaResourceMonitor.java +++ b/resource/src/main/java/org/apache/oodt/cas/resource/monitor/ganglia/GangliaResourceMonitor.java @@ -229,7 +229,9 @@ public class GangliaResourceMonitor implements Monitor { private ResourceNode nodeFromMap(Map<String, String> map) throws MalformedURLException { - if (map == null) return null; + if (map == null) { + return null; + } ResourceNode node = new ResourceNode(); System.out.println("MAP IS "+map); System.out.println("Setting hostname to "+map.get(NAME)); http://git-wip-us.apache.org/repos/asf/oodt/blob/abd71645/resource/src/main/java/org/apache/oodt/cas/resource/mux/StandardBackendManager.java ---------------------------------------------------------------------- diff --git a/resource/src/main/java/org/apache/oodt/cas/resource/mux/StandardBackendManager.java b/resource/src/main/java/org/apache/oodt/cas/resource/mux/StandardBackendManager.java index 1ccdb17..6647588 100644 --- a/resource/src/main/java/org/apache/oodt/cas/resource/mux/StandardBackendManager.java +++ b/resource/src/main/java/org/apache/oodt/cas/resource/mux/StandardBackendManager.java @@ -60,8 +60,9 @@ public class StandardBackendManager implements BackendManager { */ public Monitor getMonitor(String queue) throws QueueManagerException { BackendSet set = queueToBackend.get(queue); - if (set == null) + if (set == null) { throw new QueueManagerException("Queue '" + queue + "' does not exist"); + } return set.monitor; } /** @@ -72,8 +73,9 @@ public class StandardBackendManager implements BackendManager { */ public Batchmgr getBatchmgr(String queue) throws QueueManagerException { BackendSet set = queueToBackend.get(queue); - if (set == null) + if (set == null) { throw new QueueManagerException("Queue '" + queue + "' does not exist"); + } return set.batchmgr; } /** @@ -84,8 +86,9 @@ public class StandardBackendManager implements BackendManager { */ public Scheduler getScheduler(String queue) throws QueueManagerException { BackendSet set = queueToBackend.get(queue); - if (set == null) + if (set == null) { throw new QueueManagerException("Queue '" + queue + "' does not exist"); + } return set.scheduler; } /** http://git-wip-us.apache.org/repos/asf/oodt/blob/abd71645/resource/src/main/java/org/apache/oodt/cas/resource/mux/XmlBackendRepository.java ---------------------------------------------------------------------- diff --git a/resource/src/main/java/org/apache/oodt/cas/resource/mux/XmlBackendRepository.java b/resource/src/main/java/org/apache/oodt/cas/resource/mux/XmlBackendRepository.java index da0a82d..5ab08ff 100644 --- a/resource/src/main/java/org/apache/oodt/cas/resource/mux/XmlBackendRepository.java +++ b/resource/src/main/java/org/apache/oodt/cas/resource/mux/XmlBackendRepository.java @@ -54,8 +54,9 @@ public class XmlBackendRepository implements BackendRepository { * @param uri - uri of XML file containing mapping */ public XmlBackendRepository(String uri) { - if (uri == null) + if (uri == null) { throw new NullPointerException("URI for queue-to-backend xml file cannot be null"); + } this.uri = uri; } /* (non-Javadoc) @@ -149,8 +150,9 @@ public class XmlBackendRepository implements BackendRepository { String factory = getFactoryAttribute(queue, node, SCHEDULER); LOG.log(Level.INFO,"Loading monitor from: "+factory); Scheduler sch = GenericResourceManagerObjectFactory.getSchedulerServiceFromFactory(factory); - if (sch != null) + if (sch != null) { return sch; + } throw new RepositoryException("Could instantiate from: "+factory); } /** http://git-wip-us.apache.org/repos/asf/oodt/blob/abd71645/resource/src/main/java/org/apache/oodt/cas/resource/scheduler/QueueManager.java ---------------------------------------------------------------------- diff --git a/resource/src/main/java/org/apache/oodt/cas/resource/scheduler/QueueManager.java b/resource/src/main/java/org/apache/oodt/cas/resource/scheduler/QueueManager.java index c6a7522..c90896d 100644 --- a/resource/src/main/java/org/apache/oodt/cas/resource/scheduler/QueueManager.java +++ b/resource/src/main/java/org/apache/oodt/cas/resource/scheduler/QueueManager.java @@ -49,13 +49,15 @@ public class QueueManager { } public synchronized void addNodeToQueue(String nodeId, String queueName) throws QueueManagerException { - if (queueName == null || !this.queueToNodesMapping.containsKey(queueName)) - throw new QueueManagerException("Queue '" + queueName + "' does not exist"); + if (queueName == null || !this.queueToNodesMapping.containsKey(queueName)) { + throw new QueueManagerException("Queue '" + queueName + "' does not exist"); + } // add node to queue LinkedHashSet<String> nodes = this.queueToNodesMapping.get(queueName); - if (nodes == null) - nodes = new LinkedHashSet<String>(); + if (nodes == null) { + nodes = new LinkedHashSet<String>(); + } nodes.add(nodeId); // put node list back into map @@ -63,15 +65,17 @@ public class QueueManager { } public synchronized void addQueue(String queueName) { - if (queueName != null && !this.queueToNodesMapping.containsKey(queueName)) - this.queueToNodesMapping.put(queueName, new LinkedHashSet<String>()); + if (queueName != null && !this.queueToNodesMapping.containsKey(queueName)) { + this.queueToNodesMapping.put(queueName, new LinkedHashSet<String>()); + } } public synchronized List<String> getNodes(String queueName) throws QueueManagerException { - if (queueName != null && this.queueToNodesMapping.containsKey(queueName)) - return new Vector<String>(this.queueToNodesMapping.get(queueName)); - else - throw new QueueManagerException("Queue '" + queueName + "' does not exist"); + if (queueName != null && this.queueToNodesMapping.containsKey(queueName)) { + return new Vector<String>(this.queueToNodesMapping.get(queueName)); + } else { + throw new QueueManagerException("Queue '" + queueName + "' does not exist"); + } } public synchronized List<String> getQueues() { @@ -80,22 +84,26 @@ public class QueueManager { public synchronized List<String> getQueues(String nodeId) { Vector<String> queueNames = new Vector<String>(); - for (String queueName : this.queueToNodesMapping.keySet()) - if (this.queueToNodesMapping.get(queueName).contains(nodeId)) - queueNames.add(queueName); + for (String queueName : this.queueToNodesMapping.keySet()) { + if (this.queueToNodesMapping.get(queueName).contains(nodeId)) { + queueNames.add(queueName); + } + } return queueNames; } public synchronized void removeNodeFromQueue(String nodeId, String queueName) throws QueueManagerException { - if (queueName != null && this.queueToNodesMapping.containsKey(queueName)) - this.queueToNodesMapping.get(queueName).remove(nodeId); - else - throw new QueueManagerException("Queue '" + queueName + "' does not exist"); + if (queueName != null && this.queueToNodesMapping.containsKey(queueName)) { + this.queueToNodesMapping.get(queueName).remove(nodeId); + } else { + throw new QueueManagerException("Queue '" + queueName + "' does not exist"); + } } public synchronized void removeQueue(String queueName) { - if (queueName != null) - this.queueToNodesMapping.remove(queueName); + if (queueName != null) { + this.queueToNodesMapping.remove(queueName); + } } } http://git-wip-us.apache.org/repos/asf/oodt/blob/abd71645/resource/src/main/java/org/apache/oodt/cas/resource/system/XmlRpcResourceManager.java ---------------------------------------------------------------------- diff --git a/resource/src/main/java/org/apache/oodt/cas/resource/system/XmlRpcResourceManager.java b/resource/src/main/java/org/apache/oodt/cas/resource/system/XmlRpcResourceManager.java index e35d1d5..9157d6d 100644 --- a/resource/src/main/java/org/apache/oodt/cas/resource/system/XmlRpcResourceManager.java +++ b/resource/src/main/java/org/apache/oodt/cas/resource/system/XmlRpcResourceManager.java @@ -267,8 +267,9 @@ public class XmlRpcResourceManager { LOG.log(Level.WARNING, "Job: [" + jobId + "] not currently executing on any known node"); return ""; - } else + } else { return execNode; + } } public List<String> getQueues() throws QueueManagerException { @@ -326,8 +327,9 @@ public class XmlRpcResourceManager { this.webServer.shutdown(); this.webServer = null; return true; - } else - return false; + } else { + return false; + } } public String getNodeLoad(String nodeId) throws MonitorException{ @@ -441,11 +443,12 @@ public class XmlRpcResourceManager { new XmlRpcResourceManager(portNum); - for (;;) + for (;;) { try { Thread.currentThread().join(); } catch (InterruptedException ignore) { } + } } public boolean setNodeCapacity(String nodeId, int capacity){ http://git-wip-us.apache.org/repos/asf/oodt/blob/abd71645/resource/src/main/java/org/apache/oodt/cas/resource/system/XmlRpcResourceManagerClient.java ---------------------------------------------------------------------- diff --git a/resource/src/main/java/org/apache/oodt/cas/resource/system/XmlRpcResourceManagerClient.java b/resource/src/main/java/org/apache/oodt/cas/resource/system/XmlRpcResourceManagerClient.java index aa9181e..0c6a318 100644 --- a/resource/src/main/java/org/apache/oodt/cas/resource/system/XmlRpcResourceManagerClient.java +++ b/resource/src/main/java/org/apache/oodt/cas/resource/system/XmlRpcResourceManagerClient.java @@ -533,6 +533,8 @@ public class XmlRpcResourceManagerClient { } else if (status.equals(JobStatus.KILLED)) { return "KILLED"; } - else return null; + else { + return null; + } } } http://git-wip-us.apache.org/repos/asf/oodt/blob/abd71645/resource/src/main/java/org/apache/oodt/cas/resource/system/extern/XmlRpcBatchStub.java ---------------------------------------------------------------------- diff --git a/resource/src/main/java/org/apache/oodt/cas/resource/system/extern/XmlRpcBatchStub.java b/resource/src/main/java/org/apache/oodt/cas/resource/system/extern/XmlRpcBatchStub.java index 77d7275..9427c42 100644 --- a/resource/src/main/java/org/apache/oodt/cas/resource/system/extern/XmlRpcBatchStub.java +++ b/resource/src/main/java/org/apache/oodt/cas/resource/system/extern/XmlRpcBatchStub.java @@ -162,16 +162,18 @@ public class XmlRpcBatchStub { + "]: killed: exiting gracefully"); synchronized (jobThreadMap) { Thread endThread = (Thread) jobThreadMap.get(job.getId()); - if (endThread != null) + if (endThread != null) { endThread = null; + } } return false; } synchronized (jobThreadMap) { Thread endThread = (Thread) jobThreadMap.get(job.getId()); - if (endThread != null) + if (endThread != null) { endThread = null; + } } return runner.wasSuccessful(); @@ -198,11 +200,12 @@ public class XmlRpcBatchStub { XmlRpcBatchStub stub = new XmlRpcBatchStub(portNum); - for (;;) + for (;;) { try { Thread.currentThread().join(); } catch (InterruptedException ignore) { } + } } private class RunnableJob implements Runnable { http://git-wip-us.apache.org/repos/asf/oodt/blob/abd71645/resource/src/main/java/org/apache/oodt/cas/resource/tools/RunDirJobSubmitter.java ---------------------------------------------------------------------- diff --git a/resource/src/main/java/org/apache/oodt/cas/resource/tools/RunDirJobSubmitter.java b/resource/src/main/java/org/apache/oodt/cas/resource/tools/RunDirJobSubmitter.java index 5f32b04..d73c819 100644 --- a/resource/src/main/java/org/apache/oodt/cas/resource/tools/RunDirJobSubmitter.java +++ b/resource/src/main/java/org/apache/oodt/cas/resource/tools/RunDirJobSubmitter.java @@ -104,8 +104,9 @@ public final class RunDirJobSubmitter { try { BufferedReader in = new BufferedReader(new FileReader(inputFname)); - if (!in.ready()) + if (!in.ready()) { throw new IOException(); + } String line; String jobId; http://git-wip-us.apache.org/repos/asf/oodt/blob/abd71645/resource/src/main/java/org/apache/oodt/cas/resource/util/UlimitProperty.java ---------------------------------------------------------------------- diff --git a/resource/src/main/java/org/apache/oodt/cas/resource/util/UlimitProperty.java b/resource/src/main/java/org/apache/oodt/cas/resource/util/UlimitProperty.java index fb1a578..cffbccb 100644 --- a/resource/src/main/java/org/apache/oodt/cas/resource/util/UlimitProperty.java +++ b/resource/src/main/java/org/apache/oodt/cas/resource/util/UlimitProperty.java @@ -98,8 +98,9 @@ public class UlimitProperty { public int getIntValue() { if (isUnlimited()) { return -1; - } else + } else { return Integer.parseInt(this.value); + } } } http://git-wip-us.apache.org/repos/asf/oodt/blob/abd71645/sso/src/main/java/org/apache/oodt/security/sso/OpenSSOImpl.java ---------------------------------------------------------------------- diff --git a/sso/src/main/java/org/apache/oodt/security/sso/OpenSSOImpl.java b/sso/src/main/java/org/apache/oodt/security/sso/OpenSSOImpl.java index 318ff9d..1688d4f 100755 --- a/sso/src/main/java/org/apache/oodt/security/sso/OpenSSOImpl.java +++ b/sso/src/main/java/org/apache/oodt/security/sso/OpenSSOImpl.java @@ -68,8 +68,9 @@ public class OpenSSOImpl extends AbstractWebBasedSingleSignOn implements } return details.getAttributes().getMetadata(UID_ATTRIBUTE_NAME) != null ? details .getAttributes().getMetadata(UID_ATTRIBUTE_NAME) : UNKNOWN_USER; - } else + } else { return UNKNOWN_USER; + } } else { return new String(Base64.decodeBase64(cookieVal.getBytes())); } @@ -153,8 +154,9 @@ public class OpenSSOImpl extends AbstractWebBasedSingleSignOn implements String cookieVal = this.getCookieVal(SSO_COOKIE_KEY); if (cookieVal != null) { return cookieVal; - } else + } else { return null; + } } private String getCookieVal(String name) { http://git-wip-us.apache.org/repos/asf/oodt/blob/abd71645/sso/src/main/java/org/apache/oodt/security/sso/opensso/SSOProxy.java ---------------------------------------------------------------------- diff --git a/sso/src/main/java/org/apache/oodt/security/sso/opensso/SSOProxy.java b/sso/src/main/java/org/apache/oodt/security/sso/opensso/SSOProxy.java index 7e24413..137238d 100755 --- a/sso/src/main/java/org/apache/oodt/security/sso/opensso/SSOProxy.java +++ b/sso/src/main/java/org/apache/oodt/security/sso/opensso/SSOProxy.java @@ -183,8 +183,9 @@ public class SSOProxy implements SSOMetKeys { try { while ((line = br.readLine()) != null) { - if (line.equals(IDENTITY_DETAILS_ATTR_SKIP_LINE)) + if (line.equals(IDENTITY_DETAILS_ATTR_SKIP_LINE)) { continue; + } String key, val; if (line.startsWith(IDENTITY_DETAILS_REALM)) { // can't parse it the same way http://git-wip-us.apache.org/repos/asf/oodt/blob/abd71645/webapp/components/src/main/java/org/apache/oodt/cas/webcomponents/workflow/instance/WorkflowInstancesViewer.java ---------------------------------------------------------------------- diff --git a/webapp/components/src/main/java/org/apache/oodt/cas/webcomponents/workflow/instance/WorkflowInstancesViewer.java b/webapp/components/src/main/java/org/apache/oodt/cas/webcomponents/workflow/instance/WorkflowInstancesViewer.java index e2bb66a..dd9c50b 100644 --- a/webapp/components/src/main/java/org/apache/oodt/cas/webcomponents/workflow/instance/WorkflowInstancesViewer.java +++ b/webapp/components/src/main/java/org/apache/oodt/cas/webcomponents/workflow/instance/WorkflowInstancesViewer.java @@ -291,8 +291,9 @@ public class WorkflowInstancesViewer extends Panel { } return null; - } else - return null; + } else { + return null; + } } } http://git-wip-us.apache.org/repos/asf/oodt/blob/abd71645/webapp/components/src/main/java/org/apache/oodt/cas/webcomponents/workflow/model/WorkflowViewer.java ---------------------------------------------------------------------- diff --git a/webapp/components/src/main/java/org/apache/oodt/cas/webcomponents/workflow/model/WorkflowViewer.java b/webapp/components/src/main/java/org/apache/oodt/cas/webcomponents/workflow/model/WorkflowViewer.java index b3a22a1..969d213 100644 --- a/webapp/components/src/main/java/org/apache/oodt/cas/webcomponents/workflow/model/WorkflowViewer.java +++ b/webapp/components/src/main/java/org/apache/oodt/cas/webcomponents/workflow/model/WorkflowViewer.java @@ -136,8 +136,9 @@ public class WorkflowViewer extends Panel { if (summarizedString.length() > maxLengthTotal) { return summarizedString.substring(0, Math.min(maxLengthTotal, summarizedString.length()) - 3) + "..."; - } else - return summarizedString.toString(); + } else { + return summarizedString.toString(); + } } } http://git-wip-us.apache.org/repos/asf/oodt/blob/abd71645/webapp/components/src/main/java/org/apache/oodt/pcs/webcomponents/health/VisibilityAndSortToggler.java ---------------------------------------------------------------------- diff --git a/webapp/components/src/main/java/org/apache/oodt/pcs/webcomponents/health/VisibilityAndSortToggler.java b/webapp/components/src/main/java/org/apache/oodt/pcs/webcomponents/health/VisibilityAndSortToggler.java index 586f1c9..abfc5ed 100644 --- a/webapp/components/src/main/java/org/apache/oodt/pcs/webcomponents/health/VisibilityAndSortToggler.java +++ b/webapp/components/src/main/java/org/apache/oodt/pcs/webcomponents/health/VisibilityAndSortToggler.java @@ -111,8 +111,9 @@ class VisibilityAndSortToggler extends VisibilityToggler { PCSDaemonStatus stat2 = (PCSDaemonStatus) o2; return stat1.getStatus().compareTo(stat2.getStatus()); - } else + } else { return 0; + } } }); @@ -133,8 +134,9 @@ class VisibilityAndSortToggler extends VisibilityToggler { PCSDaemonStatus stat2 = (PCSDaemonStatus) o2; return stat1.getDaemonName().compareTo(stat2.getDaemonName()); - } else + } else { return 0; + } } }); http://git-wip-us.apache.org/repos/asf/oodt/blob/abd71645/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/data/DataDeliveryServlet.java ---------------------------------------------------------------------- diff --git a/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/data/DataDeliveryServlet.java b/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/data/DataDeliveryServlet.java index 970eff4..b29c693 100644 --- a/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/data/DataDeliveryServlet.java +++ b/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/data/DataDeliveryServlet.java @@ -114,11 +114,13 @@ public class DataDeliveryServlet extends HttpServlet implements throws ServletException, IOException { try { String productID = req.getParameter("productID"); - if (productID == null) + if (productID == null) { throw new IllegalArgumentException("productID is required"); + } String refIndex = req.getParameter("refIndex"); - if (refIndex == null) + if (refIndex == null) { refIndex = "0"; + } int index = Integer.parseInt(refIndex); String format = req.getParameter("format"); @@ -187,8 +189,9 @@ public class DataDeliveryServlet extends HttpServlet implements o2 = res.getOutputStream(); byte[] buf = new byte[512]; int n; - while ((n = in.read(buf)) != -1) + while ((n = in.read(buf)) != -1) { o2.write(buf, 0, n); + } } catch (Exception e) { e.printStackTrace(); LOG.log(Level.WARNING, "Exception delivering data!: Message: " @@ -240,8 +243,9 @@ public class DataDeliveryServlet extends HttpServlet implements OutputStream out = res.getOutputStream(); byte[] buf = new byte[512]; int n; - while ((n = in.read(buf)) != -1) + while ((n = in.read(buf)) != -1) { out.write(buf, 0, n); + } in.close(); out.close(); } http://git-wip-us.apache.org/repos/asf/oodt/blob/abd71645/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/data/DataUtils.java ---------------------------------------------------------------------- diff --git a/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/data/DataUtils.java b/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/data/DataUtils.java index d692f4a..cb2267f 100644 --- a/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/data/DataUtils.java +++ b/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/data/DataUtils.java @@ -178,28 +178,29 @@ public final class DataUtils implements DataDeliveryKeys { */ public static String guessTypeFromName(String name) { name = name.toLowerCase(); - if (name.endsWith(".jpg") || name.endsWith(".jpeg")) + if (name.endsWith(".jpg") || name.endsWith(".jpeg")) { return "image/jpeg"; - else if (name.endsWith(".png")) + } else if (name.endsWith(".png")) { return "image/png"; - else if (name.endsWith(".gif")) + } else if (name.endsWith(".gif")) { return "image/gif"; - else if (name.endsWith(".doc")) + } else if (name.endsWith(".doc")) { return "application/msword"; - else if (name.endsWith(".pdf")) + } else if (name.endsWith(".pdf")) { return "application/pdf"; - else if (name.endsWith(".rtf")) + } else if (name.endsWith(".rtf")) { return "application/rtf"; - else if (name.endsWith(".xls")) + } else if (name.endsWith(".xls")) { return "application/vnd.ms-excel"; - else if (name.endsWith(".ppt")) + } else if (name.endsWith(".ppt")) { return "application/vnd.ms-powerpoint"; - else if (name.endsWith(".html") || name.endsWith(".htm")) + } else if (name.endsWith(".html") || name.endsWith(".htm")) { return "text/html"; - else if (name.endsWith(".xml")) + } else if (name.endsWith(".xml")) { return "text/xml"; - else if (name.endsWith(".txt")) + } else if (name.endsWith(".txt")) { return "text/plain"; + } return "application/octet-stream"; } http://git-wip-us.apache.org/repos/asf/oodt/blob/abd71645/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/data/DatasetDeliveryServlet.java ---------------------------------------------------------------------- diff --git a/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/data/DatasetDeliveryServlet.java b/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/data/DatasetDeliveryServlet.java index 3f0ee6f..86ef290 100644 --- a/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/data/DatasetDeliveryServlet.java +++ b/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/data/DatasetDeliveryServlet.java @@ -194,8 +194,9 @@ public class DatasetDeliveryServlet extends HttpServlet implements o2 = res.getOutputStream(); byte[] buf = new byte[512]; int n; - while ((n = in.read(buf)) != -1) + while ((n = in.read(buf)) != -1) { o2.write(buf, 0, n); + } } catch (Exception e) { e.printStackTrace(); http://git-wip-us.apache.org/repos/asf/oodt/blob/abd71645/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/rdf/ProductTypeFilter.java ---------------------------------------------------------------------- diff --git a/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/rdf/ProductTypeFilter.java b/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/rdf/ProductTypeFilter.java index aaeab6a..ffd415a 100644 --- a/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/rdf/ProductTypeFilter.java +++ b/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/rdf/ProductTypeFilter.java @@ -43,12 +43,15 @@ public class ProductTypeFilter { public ProductTypeFilter(String filter) { this.constraints = new Properties(); - if (filter != null) + if (filter != null) { this.parse(filter); + } } public void parse(String filter) { - if(filter == null) return; + if(filter == null) { + return; + } String[] attrConstrs = filter.split(","); for (String attrConstr : attrConstrs) { String[] attrConstPair = attrConstr.split("\\:"); @@ -57,7 +60,9 @@ public class ProductTypeFilter { } public boolean filter(ProductType type) { - if(this.constraints == null) return true; + if(this.constraints == null) { + return true; + } if (type.getTypeMetadata() != null) { Metadata typeMet = type.getTypeMetadata(); for (Object constraintObj : this.constraints.keySet()) { http://git-wip-us.apache.org/repos/asf/oodt/blob/abd71645/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/rdf/RDFConfig.java ---------------------------------------------------------------------- diff --git a/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/rdf/RDFConfig.java b/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/rdf/RDFConfig.java index e62f0d4..9bf336e 100644 --- a/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/rdf/RDFConfig.java +++ b/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/rdf/RDFConfig.java @@ -175,8 +175,9 @@ public class RDFConfig { public String getKeyNs(String key) { if (this.keyNsMap != null && this.keyNsMap.containsKey(key)) { return this.keyNsMap.get(key); - } else + } else { return this.getDefaultKeyNs(); + } } /** @@ -192,8 +193,9 @@ public class RDFConfig { public String getTypeNs(String type) { if (this.typesNsMap != null && this.typesNsMap.containsKey(type)) { return this.typesNsMap.get(type); - } else + } else { return this.getDefaultTypeNs(); + } } } http://git-wip-us.apache.org/repos/asf/oodt/blob/abd71645/workflow/src/main/java/org/apache/oodt/cas/workflow/cli/action/GetWorkflowByIdCliAction.java ---------------------------------------------------------------------- diff --git a/workflow/src/main/java/org/apache/oodt/cas/workflow/cli/action/GetWorkflowByIdCliAction.java b/workflow/src/main/java/org/apache/oodt/cas/workflow/cli/action/GetWorkflowByIdCliAction.java index 690928b..655766c 100644 --- a/workflow/src/main/java/org/apache/oodt/cas/workflow/cli/action/GetWorkflowByIdCliAction.java +++ b/workflow/src/main/java/org/apache/oodt/cas/workflow/cli/action/GetWorkflowByIdCliAction.java @@ -39,7 +39,9 @@ public class GetWorkflowByIdCliAction extends WorkflowCliAction { String taskIds = ""; for (WorkflowTask wt : workflow.getTasks()) { - if (taskIds.length()>0) taskIds += ", "; + if (taskIds.length()>0) { + taskIds += ", "; + } taskIds += wt.getTaskId(); } http://git-wip-us.apache.org/repos/asf/oodt/blob/abd71645/workflow/src/main/java/org/apache/oodt/cas/workflow/cli/action/GetWorkflowsByEventCliAction.java ---------------------------------------------------------------------- diff --git a/workflow/src/main/java/org/apache/oodt/cas/workflow/cli/action/GetWorkflowsByEventCliAction.java b/workflow/src/main/java/org/apache/oodt/cas/workflow/cli/action/GetWorkflowsByEventCliAction.java index 155291a..7661cad 100644 --- a/workflow/src/main/java/org/apache/oodt/cas/workflow/cli/action/GetWorkflowsByEventCliAction.java +++ b/workflow/src/main/java/org/apache/oodt/cas/workflow/cli/action/GetWorkflowsByEventCliAction.java @@ -49,7 +49,9 @@ public class GetWorkflowsByEventCliAction extends WorkflowCliAction { String taskIds = ""; for (WorkflowTask wt : workflow.getTasks()) { - if (taskIds.length()>0) taskIds += ", "; + if (taskIds.length()>0) { + taskIds += ", "; + } taskIds += wt.getTaskId(); } http://git-wip-us.apache.org/repos/asf/oodt/blob/abd71645/workflow/src/main/java/org/apache/oodt/cas/workflow/engine/TaskQuerier.java ---------------------------------------------------------------------- diff --git a/workflow/src/main/java/org/apache/oodt/cas/workflow/engine/TaskQuerier.java b/workflow/src/main/java/org/apache/oodt/cas/workflow/engine/TaskQuerier.java index 56e6fe5..8f37643 100644 --- a/workflow/src/main/java/org/apache/oodt/cas/workflow/engine/TaskQuerier.java +++ b/workflow/src/main/java/org/apache/oodt/cas/workflow/engine/TaskQuerier.java @@ -138,8 +138,9 @@ public class TaskQuerier implements Runnable { } synchronized (runnableProcessors) { - if (running) + if (running) { runnableProcessors = processorsToRun; + } } } else { @@ -192,8 +193,9 @@ public class TaskQuerier implements Runnable { * {@link #runnableProcessors}. */ public TaskProcessor getNext() { - if (getRunnableProcessors().size() == 0) + if (getRunnableProcessors().size() == 0) { return null; + } return (TaskProcessor) getRunnableProcessors().remove(0); } http://git-wip-us.apache.org/repos/asf/oodt/blob/abd71645/workflow/src/main/java/org/apache/oodt/cas/workflow/engine/ThreadPoolWorkflowEngine.java ---------------------------------------------------------------------- diff --git a/workflow/src/main/java/org/apache/oodt/cas/workflow/engine/ThreadPoolWorkflowEngine.java b/workflow/src/main/java/org/apache/oodt/cas/workflow/engine/ThreadPoolWorkflowEngine.java index 805d782..aa096fd 100644 --- a/workflow/src/main/java/org/apache/oodt/cas/workflow/engine/ThreadPoolWorkflowEngine.java +++ b/workflow/src/main/java/org/apache/oodt/cas/workflow/engine/ThreadPoolWorkflowEngine.java @@ -118,8 +118,9 @@ public class ThreadPoolWorkflowEngine implements WorkflowEngine, WorkflowStatus workerMap = new HashMap(); - if (resUrl != null) + if (resUrl != null) { rClient = new XmlRpcResourceManagerClient(resUrl); + } } /* http://git-wip-us.apache.org/repos/asf/oodt/blob/abd71645/workflow/src/main/java/org/apache/oodt/cas/workflow/engine/processor/SequentialProcessor.java ---------------------------------------------------------------------- diff --git a/workflow/src/main/java/org/apache/oodt/cas/workflow/engine/processor/SequentialProcessor.java b/workflow/src/main/java/org/apache/oodt/cas/workflow/engine/processor/SequentialProcessor.java index 32cc608..e14336a 100755 --- a/workflow/src/main/java/org/apache/oodt/cas/workflow/engine/processor/SequentialProcessor.java +++ b/workflow/src/main/java/org/apache/oodt/cas/workflow/engine/processor/SequentialProcessor.java @@ -41,10 +41,11 @@ public class SequentialProcessor extends WorkflowProcessor { @Override public List<WorkflowProcessor> getRunnableSubProcessors() { WorkflowProcessor nextWP = this.getNext(); - if (nextWP != null) + if (nextWP != null) { return Collections.singletonList(nextWP); - else + } else { return new Vector<WorkflowProcessor>(); + } } @Override @@ -53,10 +54,12 @@ public class SequentialProcessor extends WorkflowProcessor { } private WorkflowProcessor getNext() { - for (WorkflowProcessor wp : this.getSubProcessors()) + for (WorkflowProcessor wp : this.getSubProcessors()) { if (!wp.getWorkflowInstance().getState().getCategory().getName() - .equals("done") && !wp.getWorkflowInstance().getState().getName().equals("Executing")) + .equals("done") && !wp.getWorkflowInstance().getState().getName().equals("Executing")) { return wp; + } + } return null; } http://git-wip-us.apache.org/repos/asf/oodt/blob/abd71645/workflow/src/main/java/org/apache/oodt/cas/workflow/engine/processor/TaskProcessor.java ---------------------------------------------------------------------- diff --git a/workflow/src/main/java/org/apache/oodt/cas/workflow/engine/processor/TaskProcessor.java b/workflow/src/main/java/org/apache/oodt/cas/workflow/engine/processor/TaskProcessor.java index 613eb55..0ec3744 100755 --- a/workflow/src/main/java/org/apache/oodt/cas/workflow/engine/processor/TaskProcessor.java +++ b/workflow/src/main/java/org/apache/oodt/cas/workflow/engine/processor/TaskProcessor.java @@ -89,8 +89,9 @@ public class TaskProcessor extends WorkflowProcessor { calendar.setTime(this.getWorkflowInstance().getState().getStartTime()); long elapsedTime = ((System.currentTimeMillis() - calendar .getTimeInMillis()) / 1000) / 60; - if (elapsedTime >= requiredBlockTimeElapse) + if (elapsedTime >= requiredBlockTimeElapse) { tps.add(this); + } } else if (this.isAnyState("Loaded", "Queued", "PreConditionSuccess") && !this.isAnyState("Executing") && this.passedPreConditions()){ tps.add(this); http://git-wip-us.apache.org/repos/asf/oodt/blob/abd71645/workflow/src/main/java/org/apache/oodt/cas/workflow/engine/processor/WorkflowProcessor.java ---------------------------------------------------------------------- diff --git a/workflow/src/main/java/org/apache/oodt/cas/workflow/engine/processor/WorkflowProcessor.java b/workflow/src/main/java/org/apache/oodt/cas/workflow/engine/processor/WorkflowProcessor.java index 3c4b086..2e76972 100755 --- a/workflow/src/main/java/org/apache/oodt/cas/workflow/engine/processor/WorkflowProcessor.java +++ b/workflow/src/main/java/org/apache/oodt/cas/workflow/engine/processor/WorkflowProcessor.java @@ -219,8 +219,9 @@ public abstract class WorkflowProcessor implements WorkflowProcessorListener, */ @Override public void notifyChange(WorkflowProcessor processor, ChangeType changeType) { - for (WorkflowProcessorListener listener : this.getListeners()) + for (WorkflowProcessorListener listener : this.getListeners()) { listener.notifyChange(this, changeType); + } } public synchronized List<TaskProcessor> getRunnableWorkflowProcessors() { @@ -238,8 +239,9 @@ public abstract class WorkflowProcessor implements WorkflowProcessorListener, } else if (this.isDone().getName().equals("ResultsFailure")) { // do nothing -- this workflow failed!!! } else if (this.isDone().getName().equals("ResultsBail")) { - for (WorkflowProcessor subProcessor : this.getRunnableSubProcessors()) + for (WorkflowProcessor subProcessor : this.getRunnableSubProcessors()) { runnableTasks.addAll(subProcessor.getRunnableWorkflowProcessors()); + } } else if (!this.passedPostConditions()) { for (WorkflowProcessor subProcessor : this.getPostConditions() .getRunnableSubProcessors()) { @@ -402,10 +404,11 @@ public abstract class WorkflowProcessor implements WorkflowProcessorListener, List<WorkflowProcessor> failedSubProcessors = this.helper .getWorkflowProcessorsByState(this.getSubProcessors(), "Failure"); if (this.minReqSuccessfulSubProcessors != -1 - && failedSubProcessors.size() > (this.getSubProcessors().size() - this.minReqSuccessfulSubProcessors)) + && failedSubProcessors.size() > (this.getSubProcessors().size() - this.minReqSuccessfulSubProcessors)) { return lifecycleManager.getDefaultLifecycle().createState( "ResultsFailure", "results", "More than the allowed number of sub-processors failed"); + } for (WorkflowProcessor subProcessor : failedSubProcessors) { if (!this.getExcusedSubProcessorIds().contains( subProcessor.getWorkflowInstance().getId())) { @@ -417,12 +420,13 @@ public abstract class WorkflowProcessor implements WorkflowProcessorListener, } } if (this.helper - .allProcessorsSameCategory(this.getSubProcessors(), "done")) + .allProcessorsSameCategory(this.getSubProcessors(), "done")) { return lifecycleManager.getDefaultLifecycle().createState( "ResultsSuccess", "results", "Workflow Processor: processing instance id: [" - + workflowInstance.getId() + "] is Done."); + + workflowInstance.getId() + "] is Done."); + } } return lifecycleManager.getDefaultLifecycle().createState( "ResultsBail",
