the scheduler installs itself silently now on startup, if it has not
been installed before
This commit is contained in:
parent
401ac3ab9a
commit
61895eff7f
11 changed files with 234 additions and 29 deletions
|
@ -22,7 +22,7 @@
|
|||
|
||||
|
||||
Author : $Author: maroy $
|
||||
Version : $Revision: 1.1 $
|
||||
Version : $Revision: 1.2 $
|
||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/core/include/LiveSupport/Core/Installable.h,v $
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
|
@ -83,7 +83,7 @@ namespace Core {
|
|||
* facilities.
|
||||
*
|
||||
* @author $Author: maroy $
|
||||
* @version $Revision: 1.1 $
|
||||
* @version $Revision: 1.2 $
|
||||
*/
|
||||
class Installable
|
||||
{
|
||||
|
@ -100,6 +100,17 @@ class Installable
|
|||
install(void) throw (std::exception)
|
||||
= 0;
|
||||
|
||||
/**
|
||||
* Check to see if the component has already been installed.
|
||||
*
|
||||
* @return true if the component is properly installed,
|
||||
* false otherwise
|
||||
* @exception std::exception on generic problems
|
||||
*/
|
||||
virtual bool
|
||||
isInstalled(void) throw (std::exception)
|
||||
= 0;
|
||||
|
||||
/**
|
||||
* Uninstall the component.
|
||||
* Removes all the resources created in the install step.
|
||||
|
|
|
@ -21,8 +21,8 @@
|
|||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
|
||||
Author : $Author: fgerlits $
|
||||
Version : $Revision: 1.1 $
|
||||
Author : $Author: maroy $
|
||||
Version : $Revision: 1.2 $
|
||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/PlayLogFactory.cxx,v $
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
|
@ -129,6 +129,20 @@ PlayLogFactory :: install(void) throw (std::exception)
|
|||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Check to see if the factory has already been installed.
|
||||
*----------------------------------------------------------------------------*/
|
||||
bool
|
||||
PlayLogFactory :: isInstalled(void) throw (std::exception)
|
||||
{
|
||||
if (!playLog) {
|
||||
throw std::logic_error("PlayLogFactory not yet configured");
|
||||
}
|
||||
|
||||
return playLog->isInstalled();
|
||||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Uninstall the play log factory.
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
|
|
@ -21,8 +21,8 @@
|
|||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
|
||||
Author : $Author: fgerlits $
|
||||
Version : $Revision: 1.1 $
|
||||
Author : $Author: maroy $
|
||||
Version : $Revision: 1.2 $
|
||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/PlayLogFactory.h,v $
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
|
@ -85,8 +85,8 @@ using namespace LiveSupport::Core;
|
|||
* For details on the <postgreslPlayLog> element, see the
|
||||
* PostgresqlPlayLog documentation.
|
||||
*
|
||||
* @author $Author: fgerlits $
|
||||
* @version $Revision: 1.1 $
|
||||
* @author $Author: maroy $
|
||||
* @version $Revision: 1.2 $
|
||||
* @see PostgresqlPlayLog
|
||||
*/
|
||||
class PlayLogFactory : virtual public Configurable,
|
||||
|
@ -171,6 +171,16 @@ class PlayLogFactory : virtual public Configurable,
|
|||
virtual void
|
||||
install(void) throw (std::exception);
|
||||
|
||||
/**
|
||||
* Check to see if the component has already been installed.
|
||||
*
|
||||
* @return true if the component is properly installed,
|
||||
* false otherwise
|
||||
* @exception std::exception on generic problems
|
||||
*/
|
||||
virtual bool
|
||||
isInstalled(void) throw (std::exception);
|
||||
|
||||
/**
|
||||
* Uninstall the component.
|
||||
* Removes all the resources created in the install step.
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
|
||||
|
||||
Author : $Author: maroy $
|
||||
Version : $Revision: 1.6 $
|
||||
Version : $Revision: 1.7 $
|
||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/PostgresqlPlayLog.cxx,v $
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
|
@ -125,19 +125,68 @@ PostgresqlPlayLog :: configure(const xmlpp::Element & element)
|
|||
*----------------------------------------------------------------------------*/
|
||||
void
|
||||
PostgresqlPlayLog :: install(void) throw (std::exception)
|
||||
{
|
||||
if (!isInstalled()) {
|
||||
Ptr<Connection>::Ref conn;
|
||||
try {
|
||||
conn = cm->getConnection();
|
||||
Ptr<Statement>::Ref stmt(conn->createStatement());
|
||||
stmt->execute(createStmt);
|
||||
cm->returnConnection(conn);
|
||||
} catch (std::exception &e) {
|
||||
if (conn) {
|
||||
cm->returnConnection(conn);
|
||||
}
|
||||
throw std::logic_error(e.what());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Check to see if the PostgresqlPlayLog has already been installed.
|
||||
*----------------------------------------------------------------------------*/
|
||||
bool
|
||||
PostgresqlPlayLog :: isInstalled(void) throw (std::exception)
|
||||
{
|
||||
Ptr<Connection>::Ref conn;
|
||||
try {
|
||||
Ptr<Statement>::Ref stmt;
|
||||
ResultSet * res;
|
||||
|
||||
conn = cm->getConnection();
|
||||
Ptr<Statement>::Ref stmt(conn->createStatement());
|
||||
stmt->execute(createStmt);
|
||||
|
||||
// see if we can connect at all
|
||||
stmt.reset(conn->createStatement());
|
||||
stmt->execute("SELECT 1");
|
||||
res = stmt->getResultSet();
|
||||
if (!res->next() || (res->getInt(1) != 1)) {
|
||||
throw std::runtime_error("Can't connect to database");
|
||||
}
|
||||
|
||||
// see if the schedule table exists
|
||||
try {
|
||||
stmt.reset(conn->createStatement());
|
||||
stmt->execute("SELECT COUNT(*) FROM playLog");
|
||||
res = stmt->getResultSet();
|
||||
if (!res->next() || (res->getInt(1) < 0)) {
|
||||
cm->returnConnection(conn);
|
||||
return false;
|
||||
}
|
||||
} catch (std::exception &e) {
|
||||
cm->returnConnection(conn);
|
||||
return false;
|
||||
}
|
||||
|
||||
cm->returnConnection(conn);
|
||||
} catch (std::exception &e) {
|
||||
if (conn) {
|
||||
cm->returnConnection(conn);
|
||||
}
|
||||
throw std::logic_error(e.what());
|
||||
throw;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -21,8 +21,8 @@
|
|||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
|
||||
Author : $Author: fgerlits $
|
||||
Version : $Revision: 1.3 $
|
||||
Author : $Author: maroy $
|
||||
Version : $Revision: 1.4 $
|
||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/PostgresqlPlayLog.h,v $
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
|
@ -80,8 +80,8 @@ using namespace LiveSupport::Core;
|
|||
* <!ELEMENT postgresqlPlayLog EMPTY >
|
||||
* </code></pre>
|
||||
*
|
||||
* @author $Author: fgerlits $
|
||||
* @version $Revision: 1.3 $
|
||||
* @author $Author: maroy $
|
||||
* @version $Revision: 1.4 $
|
||||
*/
|
||||
class PostgresqlPlayLog : public Configurable,
|
||||
public PlayLogInterface
|
||||
|
@ -186,6 +186,16 @@ class PostgresqlPlayLog : public Configurable,
|
|||
virtual void
|
||||
install(void) throw (std::exception);
|
||||
|
||||
/**
|
||||
* Check to see if the component has already been installed.
|
||||
*
|
||||
* @return true if the component is properly installed,
|
||||
* false otherwise
|
||||
* @exception std::exception on generic problems
|
||||
*/
|
||||
virtual bool
|
||||
isInstalled(void) throw (std::exception);
|
||||
|
||||
/**
|
||||
* Uninstall the component.
|
||||
* Removes all the resources created in the install step.
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
|
||||
|
||||
Author : $Author: maroy $
|
||||
Version : $Revision: 1.11 $
|
||||
Version : $Revision: 1.12 $
|
||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/PostgresqlSchedule.cxx,v $
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
|
@ -177,12 +177,59 @@ PostgresqlSchedule :: configure(const xmlpp::Element & element)
|
|||
*----------------------------------------------------------------------------*/
|
||||
void
|
||||
PostgresqlSchedule :: install(void) throw (std::exception)
|
||||
{
|
||||
if (!isInstalled()) {
|
||||
Ptr<Connection>::Ref conn;
|
||||
try {
|
||||
conn = cm->getConnection();
|
||||
Ptr<Statement>::Ref stmt(conn->createStatement());
|
||||
stmt->execute(createStmt);
|
||||
cm->returnConnection(conn);
|
||||
} catch (std::exception &e) {
|
||||
if (conn) {
|
||||
cm->returnConnection(conn);
|
||||
}
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Check to see if the PostgresqlSchedule has already been installed.
|
||||
*----------------------------------------------------------------------------*/
|
||||
bool
|
||||
PostgresqlSchedule :: isInstalled(void) throw (std::exception)
|
||||
{
|
||||
Ptr<Connection>::Ref conn;
|
||||
try {
|
||||
Ptr<Statement>::Ref stmt;
|
||||
ResultSet * res;
|
||||
|
||||
conn = cm->getConnection();
|
||||
Ptr<Statement>::Ref stmt(conn->createStatement());
|
||||
stmt->execute(createStmt);
|
||||
|
||||
// see if we can connect at all
|
||||
stmt.reset(conn->createStatement());
|
||||
stmt->execute("SELECT 1");
|
||||
res = stmt->getResultSet();
|
||||
if (!res->next() || (res->getInt(1) != 1)) {
|
||||
throw std::runtime_error("Can't connect to database");
|
||||
}
|
||||
|
||||
// see if the schedule table exists
|
||||
try {
|
||||
stmt.reset(conn->createStatement());
|
||||
stmt->execute("SELECT COUNT(*) FROM schedule");
|
||||
res = stmt->getResultSet();
|
||||
if (!res->next() || (res->getInt(1) < 0)) {
|
||||
return false;
|
||||
cm->returnConnection(conn);
|
||||
}
|
||||
} catch (std::exception &e) {
|
||||
cm->returnConnection(conn);
|
||||
return false;
|
||||
}
|
||||
|
||||
cm->returnConnection(conn);
|
||||
} catch (std::exception &e) {
|
||||
if (conn) {
|
||||
|
@ -190,6 +237,8 @@ PostgresqlSchedule :: install(void) throw (std::exception)
|
|||
}
|
||||
throw;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -21,8 +21,8 @@
|
|||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
|
||||
Author : $Author: fgerlits $
|
||||
Version : $Revision: 1.7 $
|
||||
Author : $Author: maroy $
|
||||
Version : $Revision: 1.8 $
|
||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/PostgresqlSchedule.h,v $
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
|
@ -80,8 +80,8 @@ using namespace LiveSupport::Core;
|
|||
* <!ELEMENT postgresqlSchedule EMPTY >
|
||||
* </code></pre>
|
||||
*
|
||||
* @author $Author: fgerlits $
|
||||
* @version $Revision: 1.7 $
|
||||
* @author $Author: maroy $
|
||||
* @version $Revision: 1.8 $
|
||||
*/
|
||||
class PostgresqlSchedule : public Configurable,
|
||||
public ScheduleInterface
|
||||
|
@ -217,6 +217,16 @@ class PostgresqlSchedule : public Configurable,
|
|||
virtual void
|
||||
install(void) throw (std::exception);
|
||||
|
||||
/**
|
||||
* Check to see if the component has already been installed.
|
||||
*
|
||||
* @return true if the component is properly installed,
|
||||
* false otherwise
|
||||
* @exception std::exception on generic problems
|
||||
*/
|
||||
virtual bool
|
||||
isInstalled(void) throw (std::exception);
|
||||
|
||||
/**
|
||||
* Uninstall the component.
|
||||
* Removes all the resources created in the install step.
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
|
||||
|
||||
Author : $Author: maroy $
|
||||
Version : $Revision: 1.2 $
|
||||
Version : $Revision: 1.3 $
|
||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/ScheduleFactory.cxx,v $
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
|
@ -129,6 +129,20 @@ ScheduleFactory :: install(void) throw (std::exception)
|
|||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Check to see if the schedule factory has already been installed.
|
||||
*----------------------------------------------------------------------------*/
|
||||
bool
|
||||
ScheduleFactory :: isInstalled(void) throw (std::exception)
|
||||
{
|
||||
if (!schedule) {
|
||||
throw std::logic_error("ScheduleFactory not yet configured");
|
||||
}
|
||||
|
||||
return schedule->isInstalled();
|
||||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Install the schedule factory.
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
|
||||
|
||||
Author : $Author: maroy $
|
||||
Version : $Revision: 1.2 $
|
||||
Version : $Revision: 1.3 $
|
||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/ScheduleFactory.h,v $
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
|
@ -86,7 +86,7 @@ using namespace LiveSupport::Core;
|
|||
* PostgresqlSchedule documentation.
|
||||
*
|
||||
* @author $Author: maroy $
|
||||
* @version $Revision: 1.2 $
|
||||
* @version $Revision: 1.3 $
|
||||
* @see PostgresqlSchedule
|
||||
*/
|
||||
class ScheduleFactory : virtual public Configurable,
|
||||
|
@ -171,6 +171,16 @@ class ScheduleFactory : virtual public Configurable,
|
|||
virtual void
|
||||
install(void) throw (std::exception);
|
||||
|
||||
/**
|
||||
* Check to see if the component has already been installed.
|
||||
*
|
||||
* @return true if the component is properly installed,
|
||||
* false otherwise
|
||||
* @exception std::exception on generic problems
|
||||
*/
|
||||
virtual bool
|
||||
isInstalled(void) throw (std::exception);
|
||||
|
||||
/**
|
||||
* Uninstall the component.
|
||||
* Removes all the resources created in the install step.
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
|
||||
|
||||
Author : $Author: maroy $
|
||||
Version : $Revision: 1.24 $
|
||||
Version : $Revision: 1.25 $
|
||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/SchedulerDaemon.cxx,v $
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
|
@ -343,6 +343,20 @@ SchedulerDaemon :: install(void) throw (std::exception)
|
|||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Check to see if the scheduler has been installed.
|
||||
*----------------------------------------------------------------------------*/
|
||||
bool
|
||||
SchedulerDaemon :: isInstalled(void) throw (std::exception)
|
||||
{
|
||||
// TODO: check if we have already been configured
|
||||
Ptr<ScheduleFactory>::Ref sf = ScheduleFactory::getInstance();
|
||||
Ptr<PlayLogFactory>::Ref plf = PlayLogFactory::getInstance();
|
||||
|
||||
return sf->isInstalled() && plf->isInstalled();
|
||||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Install the scheduler daemon.
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
@ -368,6 +382,10 @@ SchedulerDaemon :: uninstall(void) throw (std::exception)
|
|||
void
|
||||
SchedulerDaemon :: startup (void) throw ()
|
||||
{
|
||||
if (!isInstalled()) {
|
||||
install();
|
||||
}
|
||||
|
||||
try {
|
||||
sessionId = authentication->login(login, password);
|
||||
} catch (XmlRpcException &e) {
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
|
||||
|
||||
Author : $Author: maroy $
|
||||
Version : $Revision: 1.18 $
|
||||
Version : $Revision: 1.19 $
|
||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/SchedulerDaemon.h,v $
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
|
@ -162,7 +162,7 @@ using namespace LiveSupport::PlaylistExecutor;
|
|||
* </code></pre>
|
||||
*
|
||||
* @author $Author: maroy $
|
||||
* @version $Revision: 1.18 $
|
||||
* @version $Revision: 1.19 $
|
||||
* @see ConnectionManagerFactory
|
||||
* @see AuthenticationClientFactory
|
||||
* @see StorageClientFactory
|
||||
|
@ -400,6 +400,16 @@ class SchedulerDaemon : public Installable,
|
|||
virtual void
|
||||
install(void) throw (std::exception);
|
||||
|
||||
/**
|
||||
* Check to see if the component has already been installed.
|
||||
*
|
||||
* @return true if the component is properly installed,
|
||||
* false otherwise
|
||||
* @exception std::exception on generic problems
|
||||
*/
|
||||
virtual bool
|
||||
isInstalled(void) throw (std::exception);
|
||||
|
||||
/**
|
||||
* Uninstall the component.
|
||||
* Removes all the resources created in the install step.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue