Commit 791c6777 authored by hrchilds's avatar hrchilds

Update from March 10, 2005

git-svn-id: http://visit.ilight.com/svn/visit/trunk/src@429 18c085ea-50e0-402c-830e-de6fd14e8384
parent c5b5865d
......@@ -23,6 +23,15 @@
static void RemovePrependedDirs(const char *, char *);
static char executableName[256];
static char componentName[256];
static const char *const allComponentNames[] = {
"avtprep",
"cli",
"engine",
"gui",
"launcher",
"mdserver",
"viewer"
};
static ErrorFunction errorFunction = NULL;
static void *errorFunctionArgs = NULL;
......@@ -267,6 +276,41 @@ Init::GetComponentName(void)
return (const char *) componentName;
}
// ****************************************************************************
// Function: Init::ComponentNameToID
//
// Purpose: Return integer index of component name in list of all components
//
// ****************************************************************************
const int
Init::ComponentNameToID(const char *compName)
{
int n = sizeof(allComponentNames) / sizeof(allComponentNames[0]);
for (int i = 0; i < n; i++)
{
if (strcmp(compName, allComponentNames[i]) == 0)
return i;
}
return -1;
}
// ****************************************************************************
// Function: Init::ComponentNameToID
//
// Purpose: Return name of component with given index in list of all components
//
// ****************************************************************************
const char*
Init::ComponentIDToName(const int id)
{
int n = sizeof(allComponentNames) / sizeof(allComponentNames[0]);
if (id >= 0 && id < n)
return allComponentNames[id];
else
return "unknown";
}
// ****************************************************************************
// Function: Init::IsComponent
//
......
......@@ -27,6 +27,9 @@ typedef void (*ErrorFunction)(void *, const char *);
// Hank Childs, Tue Jun 1 11:47:36 PDT 2004
// Added Finalize (should I have renamed this namespace?).
//
// Mark C. Miller, Tue Mar 8 18:06:19 PST 2005
// Added ComponentNameToID and ComponentIDToName
//
// ****************************************************************************
namespace Init
......@@ -36,6 +39,8 @@ namespace Init
MISC_API void SetComponentName(const char *);
MISC_API const char * GetExecutableName();
MISC_API const char * GetComponentName();
MISC_API const int ComponentNameToID(const char *);
MISC_API const char * ComponentIDToName(const int);
MISC_API bool IsComponent(const char *);
MISC_API void ComponentIssueError(const char *);
MISC_API void ComponentRegisterErrorFunction(ErrorFunction, void *);
......
......@@ -303,6 +303,7 @@ SRC= AnimationAttributes.C \
Point.C \
PointAttributes.C \
PrinterAttributes.C \
ProcessAttributes.C \
QueryAttributes.C \
QueryList.C \
QueryOverTimeAttributes.C \
......
This diff is collapsed.
#ifndef PROCESSATTRIBUTES_H
#define PROCESSATTRIBUTES_H
#include <state_exports.h>
#include <string>
#include <AttributeSubject.h>
// ****************************************************************************
// Class: ProcessAttributes
//
// Purpose:
// attributes to describe a running process
//
// Notes: Autogenerated by xml2atts.
//
// Programmer: xml2atts
// Creation: Wed Mar 9 07:12:22 PDT 2005
//
// Modifications:
//
// ****************************************************************************
class STATE_API ProcessAttributes : public AttributeSubject
{
public:
ProcessAttributes();
ProcessAttributes(const ProcessAttributes &obj);
virtual ~ProcessAttributes();
virtual ProcessAttributes& operator = (const ProcessAttributes &obj);
virtual bool operator == (const ProcessAttributes &obj) const;
virtual bool operator != (const ProcessAttributes &obj) const;
virtual const std::string TypeName() const;
virtual bool CopyAttributes(const AttributeGroup *);
virtual AttributeSubject *CreateCompatible(const std::string &) const;
virtual AttributeSubject *NewInstance(bool) const;
// Property selection methods
virtual void SelectAll();
void SelectPids();
void SelectPpids();
void SelectHosts();
// Property setting methods
void SetPids(const doubleVector &pids_);
void SetPpids(const doubleVector &ppids_);
void SetHosts(const stringVector &hosts_);
void SetIsParallel(bool isParallel_);
// Property getting methods
const doubleVector &GetPids() const;
doubleVector &GetPids();
const doubleVector &GetPpids() const;
doubleVector &GetPpids();
const stringVector &GetHosts() const;
stringVector &GetHosts();
bool GetIsParallel() const;
// Keyframing methods
virtual std::string GetFieldName(int index) const;
virtual AttributeGroup::FieldType GetFieldType(int index) const;
virtual std::string GetFieldTypeName(int index) const;
virtual bool FieldsEqual(int index, const AttributeGroup *rhs) const;
private:
doubleVector pids;
doubleVector ppids;
stringVector hosts;
bool isParallel;
};
#endif
<?xml version="1.0"?>
<Attribute name="ProcessAttributes" purpose="attributes to describe a running process" persistent="false" exportAPI="STATE_API" exportInclude="state_exports.h">
<Field name="pids" label="pids" type="doubleVector"> </Field>
<Field name="ppids" label="pids" type="doubleVector"> </Field>
<Field name="hosts" label="hosts" type="stringVector"> </Field>
<Field name="isParallel" label="isParallel" type="bool"> false </Field>
</Attribute>
......@@ -3,6 +3,7 @@
#if !defined(_WIN32)
#include <strings.h>
#include <sys/types.h> // for getpid()
#include <unistd.h> // for alarm()
#endif
#include <new.h>
......@@ -71,6 +72,10 @@ const int INTERRUPT_MESSAGE_TAG = GetUniqueStaticMessageTag();
// Programmer: Jeremy Meredith
// Creation: July 10, 2003
//
// Modifications:
//
// Mark C. Miller, Tue Mar 8 17:59:40 PST 2005
// Added procAtts
// ****************************************************************************
Engine::Engine()
{
......@@ -79,6 +84,7 @@ Engine::Engine()
timeout = 0;
netmgr = NULL;
lb = NULL;
procAtts = NULL;
}
// ****************************************************************************
......@@ -247,6 +253,9 @@ Engine::Finalize(void)
// Hank Childs, Mon Feb 28 17:03:06 PST 2005
// Added StartQueryRPC.
//
// Mark C. Miller, Tue Mar 8 17:59:40 PST 2005
// Added procInfoRPC
//
// ****************************************************************************
void
......@@ -311,6 +320,7 @@ Engine::SetUpViewerInterface(int *argc, char **argv[])
renderRPC = new RenderRPC;
setWinAnnotAttsRPC = new SetWinAnnotAttsRPC;
cloneNetworkRPC = new CloneNetworkRPC;
procInfoRPC = new ProcInfoRPC;
xfer->Add(quitRPC);
xfer->Add(keepAliveRPC);
......@@ -331,6 +341,7 @@ Engine::SetUpViewerInterface(int *argc, char **argv[])
xfer->Add(renderRPC);
xfer->Add(setWinAnnotAttsRPC);
xfer->Add(cloneNetworkRPC);
xfer->Add(procInfoRPC);
// Create an object to implement the RPCs
rpcExecutors.push_back(new RPCExecutor<QuitRPC>(quitRPC));
......@@ -355,6 +366,7 @@ Engine::SetUpViewerInterface(int *argc, char **argv[])
rpcExecutors.push_back(new RPCExecutor<RenderRPC>(renderRPC));
rpcExecutors.push_back(new RPCExecutor<SetWinAnnotAttsRPC>(setWinAnnotAttsRPC));
rpcExecutors.push_back(new RPCExecutor<CloneNetworkRPC>(cloneNetworkRPC));
rpcExecutors.push_back(new RPCExecutor<ProcInfoRPC>(procInfoRPC));
// Hook up the expression list as an observed object.
Parser *p = new ExprParser(new avtExprNodeFactory());
......@@ -1778,3 +1790,93 @@ Engine::Disconnect()
delete instance;
instance = NULL;
}
// ****************************************************************************
// Method: Engine::GetProcessAttributes
//
// Purpose: Gets unix process attributes
//
// Programmer: Mark C. Miller
// Creation: March 8, 2005
//
// ****************************************************************************
ProcessAttributes *
Engine::GetProcessAttributes()
{
if (procAtts == NULL)
{
cerr << "Get Engine's Process Attributes" << endl;
procAtts = new ProcessAttributes;
doubleVector pids;
doubleVector ppids;
stringVector hosts;
int myPid = getpid();
int myPpid = getppid();
#ifdef PARALLEL
char myHost[2*MPI_MAX_PROCESSOR_NAME];
int strLen;
MPI_Get_processor_name(myHost, &strLen);
bool isParallel = true;
// collect pids and host names
int *allPids;
int *allPpids;
char *allHosts;
if (PAR_Rank() == 0)
{
allPids = new int[PAR_Size()];
allPpids = new int[PAR_Size()];
allHosts = new char[PAR_Size() * sizeof(myHost)];
}
MPI_Gather(&myPid, 1, MPI_INT,
allPids, 1, MPI_INT, 0, MPI_COMM_WORLD);
MPI_Gather(&myPpid, 1, MPI_INT,
allPpids, 1, MPI_INT, 0, MPI_COMM_WORLD);
MPI_Gather(&myHost, sizeof(myHost), MPI_CHAR,
allHosts, sizeof(myHost), MPI_CHAR, 0, MPI_COMM_WORLD);
if (PAR_Rank() == 0)
{
for (int i = 0; i < PAR_Size(); i++)
{
pids.push_back(allPids[i]);
ppids.push_back(allPpids[i]);
hosts.push_back(&allHosts[i*sizeof(myHost)]);
}
delete [] allPids;
delete [] allPpids;
delete [] allHosts;
}
#else
pids.push_back(myPid);
ppids.push_back(myPpid);
char myHost[256];
gethostname(myHost, sizeof(myHost));
hosts.push_back(myHost);
bool isParallel = false;
#endif
procAtts->SetPids(pids);
procAtts->SetPpids(ppids);
procAtts->SetHosts(hosts);
procAtts->SetIsParallel(isParallel);
}
return procAtts;
}
......@@ -23,6 +23,7 @@ class StartPickRPC;
class StartQueryRPC;
class UpdatePlotAttsRPC;
class UseNetworkRPC;
class ProcInfoRPC;
// Other classes
class avtDatabaseMetaData;
......@@ -33,6 +34,7 @@ class NetworkManager;
class NonBlockingRPC;
class Observer;
class Xfer;
class ProcessAttributes;
#include <vector>
#include <avtDataObjectWriter.h>
......@@ -86,6 +88,9 @@ class Xfer;
// Hank Childs, Mon Feb 28 17:03:06 PST 2005
// Added StartQueryRPC.
//
// Mark C. Miller, Tue Mar 8 18:06:19 PST 2005
// Added GetProcessAttributes
//
// ****************************************************************************
class Engine
......@@ -130,6 +135,9 @@ class Engine
// Tell the engine whether or not fatal exceptions have occurred
void SetNoFatalExceptions(bool nf) {noFatalExceptions = nf;}
// Method to get unix process information
ProcessAttributes *GetProcessAttributes();
// Various callbacks
static bool EngineAbortCallback(void *);
static bool EngineAbortCallbackParallel(void*, bool);
......@@ -206,12 +214,16 @@ class Engine
RenderRPC *renderRPC;
SetWinAnnotAttsRPC *setWinAnnotAttsRPC;
CloneNetworkRPC *cloneNetworkRPC;
ProcInfoRPC *procInfoRPC;
// The metadata, filename, format for a simulation
std::string filename;
std::string format;
avtDatabaseMetaData *metaData;
SILAttributes *silAtts;
// unix process attributes
ProcessAttributes *procAtts;
};
#endif
......@@ -32,6 +32,7 @@
#include <MakePlotRPC.h>
#include <OpenDatabaseRPC.h>
#include <PickRPC.h>
#include <ProcInfoRPC.h>
#include <QueryRPC.h>
#include <QuitRPC.h>
#include <ReadRPC.h>
......@@ -978,6 +979,34 @@ RPCExecutor<ClearCacheRPC>::Execute(ClearCacheRPC *rpc)
}
// ****************************************************************************
// Method: RPCExecutor<ProcInfoRPC>::Execute
//
// Purpose: Execute a request for process infor.
//
// Programmer: Mark C. Miller
// Creation: November 15, 2004
//
// ****************************************************************************
template<>
void
RPCExecutor<ProcInfoRPC>::Execute(ProcInfoRPC *rpc)
{
Engine *engine = Engine::Instance();
debug2 << "Executing ProcInfoRPC: " << endl;
TRY
{
rpc->SendReply(engine->GetProcessAttributes());
}
CATCH2(VisItException, e)
{
rpc->SendError(e.Message(), e.GetExceptionType());
}
ENDTRY
}
// ****************************************************************************
// Method: RPCExecutor<QueryRPC>::Execute
//
......
......@@ -140,6 +140,9 @@ EngineProxy::~EngineProxy()
// Hank Childs, Mon Feb 28 17:26:21 PST 2005
// Added StartQuery.
//
// Mark C. Miller, Tue Mar 8 17:59:40 PST 2005
// Added ProcInfoRPC
//
// ****************************************************************************
void
EngineProxy::SetupComponentRPCs()
......@@ -164,6 +167,7 @@ EngineProxy::SetupComponentRPCs()
xfer.Add(&renderRPC);
xfer.Add(&setWinAnnotAttsRPC);
xfer.Add(&cloneNetworkRPC);
xfer.Add(&procInfoRPC);
//
// Add other state objects to the transfer object
......@@ -1192,6 +1196,46 @@ EngineProxy::Query(const std::vector<int> &nid, const QueryAttributes *atts,
ClearStatus();
}
// ****************************************************************************
// Method: EngineProxy::GetProcInfo
//
// Purpose: Gets unix process information from the engine
//
// Programmer: Mark C. Miller
// Creation: November 15, 2004
//
// ****************************************************************************
void
EngineProxy::GetProcInfo(ProcessAttributes &retAtts)
{
procInfoRPC();
cerr << "In EngineProxy::GetProcInfo" << endl;
// Get the reply and update the progress bar
while (procInfoRPC.GetStatus() == VisItRPC::incomplete ||
procInfoRPC.GetStatus() == VisItRPC::warning)
{
procInfoRPC.RecvReply();
}
// Check for abort
if (procInfoRPC.GetStatus() == VisItRPC::abort)
{
ClearStatus();
EXCEPTION0(AbortException);
}
// Check for an error
if (procInfoRPC.GetStatus() == VisItRPC::error)
{
RECONSTITUTE_EXCEPTION(procInfoRPC.GetExceptionType(),
procInfoRPC.Message());
}
retAtts = procInfoRPC.GetReturnAtts();
}
// ****************************************************************************
// Method: EngineProxy::ReleaseData
......
......@@ -17,6 +17,7 @@
#include <MakePlotRPC.h>
#include <OpenDatabaseRPC.h>
#include <PickRPC.h>
#include <ProcInfoRPC.h>
#include <QueryRPC.h>
#include <ReleaseDataRPC.h>
#include <SetWinAnnotAttsRPC.h>
......@@ -224,6 +225,9 @@ class StatusAttributes;
// Kathleen Bonnell, Tue Mar 1 11:20:15 PST 2005
// Added UpdateExpressions.
//
// Mark C. Miller, Tue Mar 8 17:59:40 PST 2005
// Added GetProcInfo
//
// ****************************************************************************
class ENGINE_PROXY_API EngineProxy : public RemoteProxyBase
......@@ -311,6 +315,8 @@ public:
void CloneNetwork(const int, const QueryOverTimeAttributes *);
void UpdateExpressions(const ExpressionList &);
void GetProcInfo(ProcessAttributes &);
protected:
virtual void SetupComponentRPCs();
void ExtractEngineInformation();
......@@ -339,6 +345,7 @@ private:
SetWinAnnotAttsRPC setWinAnnotAttsRPC;
ExpressionList exprList;
CloneNetworkRPC cloneNetworkRPC;
ProcInfoRPC procInfoRPC;
// For indicating status.
StatusAttributes *statusAtts;
......
......@@ -137,6 +137,7 @@ SRC= \
MakePlotRPC.C \
OpenDatabaseRPC.C \
PickRPC.C \
ProcInfoRPC.C \
QueryRPC.C \
ReadRPC.C \
ReleaseDataRPC.C \
......
#include "ProcInfoRPC.h"
// ****************************************************************************
// Method: ProcInfoRPC
//
// Purpose:
// This is the RPC's constructor
//
// Programmer: Mark C. Miller
// Creation: November 15, 2004
//
// ****************************************************************************
ProcInfoRPC::ProcInfoRPC() : NonBlockingRPC("a", &returnAtts)
{
// nothing here;
}
#ifndef PROC_INFO_RPC_H
#define PROC_INFO_RPC_H
#include <engine_rpc_exports.h>
#include <VisItRPC.h>
#include <ProcessAttributes.h>
// ****************************************************************************
// Class: ProcInfoRPC
//
// Purpose:
// Implements an RPC to get process information
//
// Programmer: Mark C. Miller
// Creation: November 15, 2004
//
// ****************************************************************************
class ENGINE_RPC_API ProcInfoRPC : public NonBlockingRPC
{
public:
ProcInfoRPC();
virtual ~ProcInfoRPC() { };
// Invokation method
void operator()() { Execute(); };
void SelectAll() { };
// Property getting methods
ProcessAttributes GetReturnAtts() { return returnAtts; } ;
ProcessAttributes returnAtts;
};
#endif
......@@ -18,6 +18,7 @@
#include <CouldNotConnectException.h>
#include <AnnotationAttributes.h>
#include <PickAttributes.h>
#include <ProcessAttributes.h>
#include <QueryAttributes.h>
#include <StatusAttributes.h>
#include <ViewerFileServer.h>
......@@ -2775,6 +2776,24 @@ ViewerEngineManager::Query(const EngineKey &ek,
ENGINE_PROXY_RPC_END_NORESTART_RETHROW2;
}
// ****************************************************************************
// Method: ViewerEngineManager::GetProcInfo
//
// Purpose:
// Engine GetProcInfoRPC wrapped for safety.
//
// Programmer: Mark C. Miller
// Creation: November 15, 2004
//
// ****************************************************************************
bool
ViewerEngineManager::GetProcInfo(const EngineKey &ek, ProcessAttributes &retAtts)
{
ENGINE_PROXY_RPC_BEGIN("GetProcInfo");
engine->GetProcInfo(retAtts);
ENGINE_PROXY_RPC_END_NORESTART_RETHROW2;
}
// ****************************************************************************
// Method: ViewerEngineManager::ReleaseData
......
......@@ -20,6 +20,7 @@ class EngineList;
class EngineProxy;
class MaterialAttributes;
class PickAttributes;
class ProcessAttributes;
class QueryAttributes;
class QueryOverTimeAttributes;
class ViewerPlot;
......@@ -203,6 +204,9 @@ class avtDatabaseMetaData;
// Hank Childs, Wed Mar 2 11:52:32 PST 2005
// Added StartQuery.
//
// Mark C. Miller, Tue Mar 8 18:06:19 PST 2005
// Added GetProcInfo
//
// ****************************************************************************
class VIEWER_API ViewerEngineManager : public ViewerServerManager,
......@@ -293,6 +297,7 @@ class VIEWER_API ViewerEngineManager : public ViewerServerManager,
bool ClearCache(const EngineKey &ek, const char *dbName = 0);
bool Query(const EngineKey &ek, const std::vector<int> &networkIds,
const QueryAttributes *atts, QueryAttributes &retAtts);
bool GetProcInfo(const EngineKey &ek, ProcessAttributes &retAtts);
bool ReleaseData(const EngineKey &ek, int id);
bool CloneNetwork(const EngineKey &ek, int id,
const QueryOverTimeAttributes *qatts);
......
<
......@@ -33,6 +33,7 @@
#include <GlobalLineoutAttributes.h>
#include <HostProfile.h>
#include <HostProfileList.h>
#include <Init.h>
#include <InitVTK.h>
#include <InteractorAttributes.h>
#include <InvalidVariableException.h>
......@@ -44,6 +45,7 @@
#include <PlotList.h>
#include <PluginManagerAttributes.h>
#include <PrinterAttributes.h>
#include <ProcessAttributes.h>
#include <QueryAttributes.h>
#include <QueryList.h>
#include <RemoteProcess.h>
......@@ -136,6 +138,9 @@ using std::string;
// Jeremy Meredith, Wed Aug 25 10:32:18 PDT 2004
// Added metadata and SIL attributes (needed for simulations).