From: <st...@us...> - 2008-09-30 14:07:09
|
Revision: 7093 http://smartfrog.svn.sourceforge.net/smartfrog/?rev=7093&view=rev Author: steve_l Date: 2008-09-30 14:06:07 +0000 (Tue, 30 Sep 2008) Log Message: ----------- SFOS-454 Make RPM code in avalanche self contained component, and production ready Modified Paths: -------------- trunk/core/components/rpmtools/src/org/smartfrog/services/rpm/manager/AbstractRpmManager.java trunk/core/components/rpmtools/src/org/smartfrog/services/rpm/manager/local/AbstractLocalRpmManager.java trunk/core/components/rpmtools/src/org/smartfrog/services/rpm/manager/local/ArtifactCheckingManagerImpl.java Added Paths: ----------- trunk/core/components/rpmtools/src/org/smartfrog/services/rpm/manager/local/AbstractLocalRpmExecutor.java trunk/core/components/rpmtools/src/org/smartfrog/services/rpm/manager/local/LocalRpmManagerImpl.java trunk/core/components/rpmtools/src/org/smartfrog/services/rpm/manager/local/LocalRpmQueryCheckerImpl.java Removed Paths: ------------- trunk/core/components/rpmtools/src/org/smartfrog/services/rpm/manager/local/LocalRpmQueryCheckerImpl.java Modified: trunk/core/components/rpmtools/src/org/smartfrog/services/rpm/manager/AbstractRpmManager.java =================================================================== --- trunk/core/components/rpmtools/src/org/smartfrog/services/rpm/manager/AbstractRpmManager.java 2008-09-30 13:46:12 UTC (rev 7092) +++ trunk/core/components/rpmtools/src/org/smartfrog/services/rpm/manager/AbstractRpmManager.java 2008-09-30 14:06:07 UTC (rev 7093) @@ -22,6 +22,7 @@ import org.smartfrog.sfcore.common.SmartFrogException; import org.smartfrog.sfcore.common.SmartFrogLivenessException; import org.smartfrog.sfcore.prim.Liveness; +import org.smartfrog.sfcore.prim.TerminationRecord; import org.smartfrog.sfcore.workflow.eventbus.EventPrimImpl; import org.smartfrog.sfcore.utils.ComponentHelper; import org.smartfrog.sfcore.utils.WorkflowThread; @@ -37,9 +38,61 @@ public class AbstractRpmManager extends EventPrimImpl implements RpmManager, Iterable<RpmFile> { private ArrayList<RpmFile> rpms = new ArrayList<RpmFile>(1); + /** + * Install the RPMs on startup + */ + private boolean install; + + /** + * uninstall the RPMs on termination? + */ + private boolean uninstallOnTermination; + + /** + * uninstall the RPMs on termination? + */ + private boolean uninstallOnStartup; + + /** + * Ping for managed files during a liveness check? + */ private boolean probeOnLiveness; + + /** + * Ping for managed files during a liveness check? + */ private boolean probeOnStartup; + /** + * Should we apply in bulk? That is, group apply everything in one go? + */ + private boolean bulkOperation; + + /** + * How to handle a failure to install + */ + private boolean failOnInstallError; + + /** + * How to handle a failure to uninstall. Only relevent in a startup uninstall + */ + private boolean failOnUninstallError; + + /** + * Should scripts be skipped during installation? + */ + private boolean installSkipScripts; + + /** + * Should scripts be skipped during uninstallation? + */ + private boolean uninstallSkipScripts; + + /** + * Should dependencies be ignored during uninstallation? + */ + private boolean uninstallIgnoreDependencies; + public AbstractRpmManager() throws RemoteException { } @@ -54,13 +107,81 @@ super.sfStart(); probeOnStartup = sfResolve(ATTR_PROBE_ON_STARTUP, true, true); probeOnLiveness = sfResolve(ATTR_PROBE_ON_LIVENESS, true, true); + install = sfResolve(ATTR_INSTALL, true, true); + uninstallOnTermination = sfResolve(ATTR_UNINSTALL_ON_TERMINATION, true, true); + uninstallOnStartup = sfResolve(ATTR_UNINSTALL_ON_STARTUP, true, true); + uninstallIgnoreDependencies = sfResolve(ATTR_UNINSTALL_IGNORE_DEPENDENCIES, true, true); + uninstallSkipScripts = sfResolve(ATTR_UNINSTALL_NO_SCRIPTS, true, true); + if (uninstallOnStartup) { + uninstallOnStartup(); + } + if (install) { + installOnStartup(); + } if (probeOnStartup) { - probeAllFiles(); + probeOnStartup(); } triggerWorkflowTerminationInStartup(); } /** + * Deregisters from all current registrations. + * + * @param status Record having termination details of the component + */ + public synchronized void sfTerminateWith(TerminationRecord status) { + super.sfTerminateWith(status); + if (uninstallOnTermination) { + try { + uninstallOnTermination(); + } catch (SmartFrogException e) { + sfLog().error("When terminating: " + e, e); + } catch (RemoteException e) { + sfLog().error("When terminating: " + e, e); + } + } + } + + + /** + * Override point: place to implement something + * + * @throws SmartFrogException failure while starting + * @throws RemoteException In case of network/rmi error + */ + protected void installOnStartup() throws SmartFrogException, RemoteException { + } + + + /** + * Override point: place to implement something + * + * @throws SmartFrogException failure while starting + * @throws RemoteException In case of network/rmi error + */ + protected void uninstallOnStartup() throws SmartFrogException, RemoteException { + } + + /** + * Override point: place to implement something + * + * @throws SmartFrogException failure while starting + * @throws RemoteException In case of network/rmi error + */ + protected void uninstallOnTermination() throws SmartFrogException, RemoteException { + } + + /** + * Override point: probe on startup. Any installation will already have executed + * + * @throws SmartFrogException failure while starting + * @throws RemoteException In case of network/rmi error + */ + protected void probeOnStartup() throws SmartFrogException, RemoteException { + probeAllFiles(); + } + + /** * Override point */ protected void triggerWorkflowTerminationInStartup() { @@ -68,6 +189,7 @@ new ComponentHelper(this).sfSelfDetachAndOrTerminate(null, null, null, null); } + /** * Returns an iterator over the rpms * @@ -81,8 +203,9 @@ * Add another file to the list of RPMs that need managing * * @param rpm the RPM to manage + * * @throws SmartFrogException if unable to manage this file - * @throws RemoteException network problems + * @throws RemoteException network problems */ public void manage(RpmFile rpm) throws SmartFrogException, RemoteException { rpms.add(rpm); @@ -90,7 +213,7 @@ } /** - * Notification of a new artifact added, it is already on the rpms list at this point. + * Override point: notification of a new artifact added, it is already on the rpms list at this point. * * @param rpm the newly added RPM */ @@ -102,16 +225,21 @@ * Liveness call in to check if this component is still alive. * * @param source source of call + * * @throws SmartFrogLivenessException component is terminated - * @throws RemoteException for consistency with the {@link Liveness} interface + * @throws RemoteException for consistency with the {@link Liveness} interface */ public void sfPing(Object source) throws SmartFrogLivenessException, RemoteException { super.sfPing(source); - if(probeOnLiveness) { - probeAllFiles(); + if (probeOnLiveness) { + probeOnLiveness(); } } + private void probeOnLiveness() throws SmartFrogLivenessException, RemoteException { + probeAllFiles(); + } + protected void probeAllFiles() throws SmartFrogLivenessException, RemoteException { for (RpmFile rpm : this) { probe(rpm); @@ -122,8 +250,9 @@ * Override point: ping the file * * @param rpm the file to ping + * * @throws SmartFrogLivenessException component is terminated - * @throws RemoteException for consistency with the {@link Liveness} interface + * @throws RemoteException for consistency with the {@link Liveness} interface */ protected void probe(RpmFile rpm) throws SmartFrogLivenessException, RemoteException { Added: trunk/core/components/rpmtools/src/org/smartfrog/services/rpm/manager/local/AbstractLocalRpmExecutor.java =================================================================== --- trunk/core/components/rpmtools/src/org/smartfrog/services/rpm/manager/local/AbstractLocalRpmExecutor.java (rev 0) +++ trunk/core/components/rpmtools/src/org/smartfrog/services/rpm/manager/local/AbstractLocalRpmExecutor.java 2008-09-30 14:06:07 UTC (rev 7093) @@ -0,0 +1,81 @@ +/* (C) Copyright 2008 Hewlett-Packard Development Company, LP + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + For more information: www.smartfrog.org + + */ + + +package org.smartfrog.services.rpm.manager.local; + +import org.smartfrog.sfcore.utils.Executable; +import org.smartfrog.sfcore.utils.ListUtils; +import org.smartfrog.sfcore.utils.SmartFrogThread; +import org.smartfrog.sfcore.utils.WorkflowThread; +import org.smartfrog.sfcore.common.SmartFrogResolutionException; +import org.smartfrog.sfcore.common.SmartFrogLivenessException; +import org.smartfrog.sfcore.reference.Reference; +import org.smartfrog.sfcore.prim.Liveness; +import org.smartfrog.sfcore.prim.TerminationRecord; +import org.smartfrog.services.rpm.manager.RpmManagedFile; + +import java.rmi.RemoteException; +import java.util.List; + +/** + * + */ +public abstract class AbstractLocalRpmExecutor extends AbstractLocalRpmManager implements Executable { + + protected String executable; + protected List<String> arguments; + List<RpmManagedFile> files; + protected WorkflowThread worker; + protected String command; + + protected AbstractLocalRpmExecutor() throws RemoteException { + } + + protected void readSettings() throws SmartFrogResolutionException, RemoteException { + executable = sfResolve(ATTR_EXECUTABLE, "", true); + command = sfResolve(ATTR_COMMAND, "", true); + arguments = ListUtils.resolveStringList(this, new Reference(ATTR_ARGUMENTS), true); + } + + /** + * Liveness call in to check if this component is still alive. + * + * @param source source of call + * @throws SmartFrogLivenessException component is terminated + * @throws RemoteException for consistency with the {@link Liveness} interface + */ + public void sfPing(Object source) throws SmartFrogLivenessException, RemoteException { + super.sfPing(source); + SmartFrogThread.ping(worker); + } + + /** + * Deregisters from all current registrations. + * + * @param status Record having termination details of the component + */ + public synchronized void sfTerminateWith(TerminationRecord status) { + super.sfTerminateWith(status); + SmartFrogThread.requestThreadTermination(worker); + } + + public abstract void execute() throws Throwable; +} Modified: trunk/core/components/rpmtools/src/org/smartfrog/services/rpm/manager/local/AbstractLocalRpmManager.java =================================================================== --- trunk/core/components/rpmtools/src/org/smartfrog/services/rpm/manager/local/AbstractLocalRpmManager.java 2008-09-30 13:46:12 UTC (rev 7092) +++ trunk/core/components/rpmtools/src/org/smartfrog/services/rpm/manager/local/AbstractLocalRpmManager.java 2008-09-30 14:06:07 UTC (rev 7093) @@ -21,8 +21,11 @@ import org.smartfrog.services.rpm.manager.AbstractRpmManager; import org.smartfrog.services.rpm.manager.RpmManager; +import org.smartfrog.services.rpm.manager.RpmFile; +import org.smartfrog.sfcore.common.SmartFrogLivenessException; import java.rmi.RemoteException; +import java.io.FileNotFoundException; /** * <p/> @@ -32,4 +35,29 @@ protected AbstractLocalRpmManager() throws RemoteException { } + + /** + * Check the files in the RPM exist, throw a LivenessException if not + * @param rpm rpm to check + * @throws SmartFrogLivenessException missing file. + */ + protected void verifyFiles(RpmFile rpm) throws SmartFrogLivenessException { + try { + rpm.verifyAllManagedFilesExist(); + } catch (FileNotFoundException e) { + throw new SmartFrogLivenessException(e); + } + } + + /** + * Override point: probe the file + * + * @param rpm the file to probe + * @throws SmartFrogLivenessException component is terminated + * @throws RemoteException for network problems + */ + @Override + protected void probe(RpmFile rpm) throws SmartFrogLivenessException, RemoteException { + verifyFiles(rpm); + } } Modified: trunk/core/components/rpmtools/src/org/smartfrog/services/rpm/manager/local/ArtifactCheckingManagerImpl.java =================================================================== --- trunk/core/components/rpmtools/src/org/smartfrog/services/rpm/manager/local/ArtifactCheckingManagerImpl.java 2008-09-30 13:46:12 UTC (rev 7092) +++ trunk/core/components/rpmtools/src/org/smartfrog/services/rpm/manager/local/ArtifactCheckingManagerImpl.java 2008-09-30 14:06:07 UTC (rev 7093) @@ -37,49 +37,10 @@ * Created 14-Apr-2008 17:11:58 */ -public class ArtifactCheckingManagerImpl extends AbstractRpmManager implements RpmManager { +public class ArtifactCheckingManagerImpl extends AbstractLocalRpmManager implements RpmManager { public ArtifactCheckingManagerImpl() throws RemoteException { } - /** - * start up may trigger a shutdown - * - * @throws SmartFrogException failure while starting - * @throws RemoteException In case of network/rmi error - */ - @Override - public synchronized void sfStart() throws SmartFrogException, RemoteException { - super.sfStart(); - } - - /** - * Override point: probe the file - * - * @param rpm the file to probe - * @throws SmartFrogLivenessException component is terminated - * @throws RemoteException for network problems - */ - @Override - protected void probe(RpmFile rpm) throws SmartFrogLivenessException, RemoteException { - try { - rpm.verifyAllManagedFilesExist(); - } catch (FileNotFoundException e) { - throw new SmartFrogLivenessException(e); - } - } - - /** - * Liveness call in to check if this component is still alive. - * - * @param source source of call - * @throws SmartFrogLivenessException component is terminated - * @throws RemoteException for consistency with the {@link Liveness} interface - */ - @Override - public void sfPing(Object source) throws SmartFrogLivenessException, RemoteException { - super.sfPing(source); - - } } Added: trunk/core/components/rpmtools/src/org/smartfrog/services/rpm/manager/local/LocalRpmManagerImpl.java =================================================================== --- trunk/core/components/rpmtools/src/org/smartfrog/services/rpm/manager/local/LocalRpmManagerImpl.java (rev 0) +++ trunk/core/components/rpmtools/src/org/smartfrog/services/rpm/manager/local/LocalRpmManagerImpl.java 2008-09-30 14:06:07 UTC (rev 7093) @@ -0,0 +1,37 @@ +/* (C) Copyright 2008 Hewlett-Packard Development Company, LP + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + For more information: www.smartfrog.org + + */ + + +package org.smartfrog.services.rpm.manager.local; + +import java.rmi.RemoteException; + +/** + * A component that issues all the local RPM install/uninstall/upgrade commands + */ +public class LocalRpmManagerImpl extends AbstractLocalRpmExecutor implements LocalRpmManager { + + public LocalRpmManagerImpl() throws RemoteException { + } + + public void execute() throws Throwable { + + } +} Deleted: trunk/core/components/rpmtools/src/org/smartfrog/services/rpm/manager/local/LocalRpmQueryCheckerImpl.java =================================================================== --- trunk/core/components/rpmtools/src/org/smartfrog/services/rpm/manager/local/LocalRpmQueryCheckerImpl.java 2008-09-30 13:46:12 UTC (rev 7092) +++ trunk/core/components/rpmtools/src/org/smartfrog/services/rpm/manager/local/LocalRpmQueryCheckerImpl.java 2008-09-30 14:06:07 UTC (rev 7093) @@ -1,166 +0,0 @@ -/* (C) Copyright 2008 Hewlett-Packard Development Company, LP - -This library is free software; you can redistribute it and/or -modify it under the terms of the GNU Lesser General Public -License as published by the Free Software Foundation; either -version 2.1 of the License, or (at your option) any later version. - -This library is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -Lesser General Public License for more details. - -You should have received a copy of the GNU Lesser General Public -License along with this library; if not, write to the Free Software -Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -For more information: www.smartfrog.org - -*/ -package org.smartfrog.services.rpm.manager.local; - -import org.smartfrog.sfcore.common.SmartFrogException; -import org.smartfrog.sfcore.common.SmartFrogLivenessException; -import org.smartfrog.sfcore.utils.ListUtils; -import org.smartfrog.sfcore.utils.WorkflowThread; -import org.smartfrog.sfcore.utils.Executable; -import org.smartfrog.sfcore.utils.SmartFrogThread; -import org.smartfrog.sfcore.reference.Reference; -import org.smartfrog.sfcore.prim.Liveness; -import org.smartfrog.sfcore.prim.TerminationRecord; -import org.smartfrog.services.rpm.manager.RpmFile; -import org.smartfrog.services.rpm.manager.RpmManager; -import org.smartfrog.services.rpm.manager.RpmManagedFile; -import org.smartfrog.services.shellscript.Cmd; -import org.smartfrog.services.shellscript.RunProcessImpl; -import org.smartfrog.services.shellscript.RunProcess; - -import java.rmi.RemoteException; -import java.util.List; -import java.util.ArrayList; -import java.io.FileNotFoundException; - -/** - * this checker - * Created 10-Jun-2008 17:13:23 - * - */ - -public class LocalRpmQueryCheckerImpl extends AbstractLocalRpmManager implements RpmManager,Executable { - - protected String executable; - protected List<String> arguments; - List<RpmManagedFile> files; - - protected WorkflowThread worker; - private String command; - - public LocalRpmQueryCheckerImpl() throws RemoteException { - } - - - /** - * start up may trigger a shutdown - * - * @throws SmartFrogException failure while starting - * @throws RemoteException In case of network/rmi error - */ - public synchronized void sfStart() throws SmartFrogException, RemoteException { - super.sfStart(); - executable = sfResolve(ATTR_EXECUTABLE, "", true); - command = sfResolve(ATTR_COMMAND, "", true); - arguments = ListUtils.resolveStringList(this, new Reference(ATTR_ARGUMENTS), true); - } - - /** - * build the list of files - * @throws SmartFrogLivenessException problems - * @throws RemoteException In case of network/rmi error - */ - protected void probeAllFiles() throws SmartFrogLivenessException, RemoteException { - files = new ArrayList<RpmManagedFile>(); - for (RpmFile rpm : this) { - List<String> rpmfiles = rpm.getManagedFiles(); - for(String f:rpmfiles) { - files.add(new RpmManagedFile(f,rpm)); - } - } - new WorkflowThread(this, this, true); - } - - /** - * Override point: probe the file - * - * @param rpm the file to probe - * @throws SmartFrogLivenessException component is terminated - * @throws RemoteException for network problems - */ - @Override - protected void probe(RpmFile rpm) throws SmartFrogLivenessException, RemoteException { - try { - rpm.verifyAllManagedFilesExist(); - } catch (FileNotFoundException e) { - throw new SmartFrogLivenessException(e); - } - } - - /** - * Liveness call in to check if this component is still alive. - * - * @param source source of call - * @throws SmartFrogLivenessException component is terminated - * @throws RemoteException for consistency with the {@link Liveness} interface - */ - public void sfPing(Object source) throws SmartFrogLivenessException, RemoteException { - super.sfPing(source); - SmartFrogThread.ping(worker); - } - - /** - * Deregisters from all current registrations. - * - * @param status Record having termination details of the component - */ - public synchronized void sfTerminateWith(TerminationRecord status) { - super.sfTerminateWith(status); - SmartFrogThread.requestThreadTermination(worker); - } - - /** - * Entry point for worker thread; this runs through the list of files and validates them - * @throws Throwable - */ - public void execute() throws Throwable { - - for (RpmManagedFile managedFile : files) { - //executable+args+filename and check for error/valid strings; make those options - queryOneFile(managedFile); - } - } - - /** - * run a query against one file - * @param managedFile the file to look at - * @throws SmartFrogException trouble - */ - private void queryOneFile(RpmManagedFile managedFile) throws SmartFrogException { - String filename=managedFile.getFilename(); - String packageName = managedFile.getRpm().getRpmPackageName(); - List<String> commands=new ArrayList<String>(arguments.size()+2); - commands.add(command); - commands.addAll(arguments); - commands.add(filename); - Cmd rpmcommand=new Cmd(); - rpmcommand.setTerminate(false); - rpmcommand.setDetach(false); - rpmcommand.setCmdArray((String[]) commands.toArray()); - RunProcess process = new RunProcessImpl("rpm", rpmcommand, this); - process.run(); - int exitValue = process.getExitValue(); - if (exitValue != 0) { - throw new SmartFrogLivenessException("Failed to validate " + managedFile); - } - } - - -} Added: trunk/core/components/rpmtools/src/org/smartfrog/services/rpm/manager/local/LocalRpmQueryCheckerImpl.java =================================================================== --- trunk/core/components/rpmtools/src/org/smartfrog/services/rpm/manager/local/LocalRpmQueryCheckerImpl.java (rev 0) +++ trunk/core/components/rpmtools/src/org/smartfrog/services/rpm/manager/local/LocalRpmQueryCheckerImpl.java 2008-09-30 14:06:07 UTC (rev 7093) @@ -0,0 +1,123 @@ +/* (C) Copyright 2008 Hewlett-Packard Development Company, LP + +This library is free software; you can redistribute it and/or +modify it under the terms of the GNU Lesser General Public +License as published by the Free Software Foundation; either +version 2.1 of the License, or (at your option) any later version. + +This library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public +License along with this library; if not, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +For more information: www.smartfrog.org + +*/ +package org.smartfrog.services.rpm.manager.local; + +import org.smartfrog.sfcore.common.SmartFrogException; +import org.smartfrog.sfcore.common.SmartFrogLivenessException; +import org.smartfrog.sfcore.common.SmartFrogResolutionException; +import org.smartfrog.sfcore.utils.ListUtils; +import org.smartfrog.sfcore.utils.WorkflowThread; +import org.smartfrog.sfcore.utils.Executable; +import org.smartfrog.sfcore.utils.SmartFrogThread; +import org.smartfrog.sfcore.reference.Reference; +import org.smartfrog.sfcore.prim.Liveness; +import org.smartfrog.sfcore.prim.TerminationRecord; +import org.smartfrog.services.rpm.manager.RpmFile; +import org.smartfrog.services.rpm.manager.RpmManager; +import org.smartfrog.services.rpm.manager.RpmManagedFile; +import org.smartfrog.services.shellscript.Cmd; +import org.smartfrog.services.shellscript.RunProcessImpl; +import org.smartfrog.services.shellscript.RunProcess; + +import java.rmi.RemoteException; +import java.util.List; +import java.util.ArrayList; +import java.io.FileNotFoundException; + +/** + * this checker Created 10-Jun-2008 17:13:23 + */ + +public class LocalRpmQueryCheckerImpl extends AbstractLocalRpmExecutor implements RpmManager { + + public LocalRpmQueryCheckerImpl() throws RemoteException { + } + + + /** + * start up may trigger a shutdown + * + * @throws SmartFrogException failure while starting + * @throws RemoteException In case of network/rmi error + */ + public synchronized void sfStart() throws SmartFrogException, RemoteException { + super.sfStart(); + readSettings(); + } + + /** + * build the list of files + * + * @throws SmartFrogLivenessException problems + * @throws RemoteException In case of network/rmi error + */ + protected void probeAllFiles() throws SmartFrogLivenessException, RemoteException { + files = new ArrayList<RpmManagedFile>(); + for (RpmFile rpm : this) { + List<String> rpmfiles = rpm.getManagedFiles(); + for (String f : rpmfiles) { + files.add(new RpmManagedFile(f, rpm)); + } + } + worker = new WorkflowThread(this, this, true); + } + + /** + * Entry point for worker thread; this runs through the list of files and validates them + * + * @throws Throwable + */ + public void execute() throws Throwable { + + for (RpmManagedFile managedFile : files) { + //executable+args+filename and check for error/valid strings; make those options + queryOneFile(managedFile); + } + } + + /** + * run a query against one file + * + * @param managedFile the file to look at + * + * @throws SmartFrogException trouble + */ + private void queryOneFile(RpmManagedFile managedFile) throws SmartFrogException { + String filename = managedFile.getFilename(); + String packageName = managedFile.getRpm().getRpmPackageName(); + List<String> commands = new ArrayList<String>(arguments.size() + 2); + commands.add(executable); + commands.add(command); + commands.addAll(arguments); + commands.add(filename); + Cmd rpmcommand = new Cmd(); + rpmcommand.setTerminate(false); + rpmcommand.setDetach(false); + rpmcommand.setCmdArray((String[]) commands.toArray()); + RunProcess process = new RunProcessImpl("rpm", rpmcommand, this); + process.run(); + int exitValue = process.getExitValue(); + if (exitValue != 0) { + throw new SmartFrogLivenessException("Failed to validate " + managedFile); + } + } + + +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |