summaryrefslogtreecommitdiff
path: root/cpp/src
diff options
context:
space:
mode:
authorBenoit Foucher <benoit@zeroc.com>2002-09-25 22:38:26 +0000
committerBenoit Foucher <benoit@zeroc.com>2002-09-25 22:38:26 +0000
commitf953fd71ec8e0d1ae425428dcfd9721dea40a608 (patch)
tree94e36c55732771d5d5f9bc9dea60794902704194 /cpp/src
parentAdded server activation settings. (diff)
downloadice-f953fd71ec8e0d1ae425428dcfd9721dea40a608.tar.bz2
ice-f953fd71ec8e0d1ae425428dcfd9721dea40a608.tar.xz
ice-f953fd71ec8e0d1ae425428dcfd9721dea40a608.zip
Added server activation settings to icepackadmin.
Diffstat (limited to 'cpp/src')
-rw-r--r--cpp/src/IcePack/AdminI.cpp36
-rw-r--r--cpp/src/IcePack/AdminI.h2
-rw-r--r--cpp/src/IcePack/Grammar.y5
-rw-r--r--cpp/src/IcePack/Internal.ice21
-rw-r--r--cpp/src/IcePack/Parser.cpp41
-rw-r--r--cpp/src/IcePack/Parser.h1
-rw-r--r--cpp/src/IcePack/Scanner.l4
-rw-r--r--cpp/src/IcePack/ServerBuilder.cpp23
-rw-r--r--cpp/src/IcePack/ServerBuilder.h1
-rw-r--r--cpp/src/IcePack/ServerFactory.cpp5
-rw-r--r--cpp/src/IcePack/ServerI.cpp18
-rw-r--r--cpp/src/IcePack/ServerI.h3
12 files changed, 133 insertions, 27 deletions
diff --git a/cpp/src/IcePack/AdminI.cpp b/cpp/src/IcePack/AdminI.cpp
index f09b89c5f96..8b592d22bb7 100644
--- a/cpp/src/IcePack/AdminI.cpp
+++ b/cpp/src/IcePack/AdminI.cpp
@@ -168,6 +168,42 @@ IcePack::AdminI::getAllServerNames(const Current&) const
return _serverRegistry->getAll();
}
+ServerActivation
+IcePack::AdminI::getServerActivation(const ::std::string& name, const Ice::Current&) const
+{
+ ServerPrx server = _serverRegistry->findByName(name);
+ try
+ {
+ return server->getActivationMode();
+ }
+ catch(const Ice::ObjectNotExistException&)
+ {
+ throw ServerNotExistException();
+ }
+ catch(const Ice::LocalException&)
+ {
+ throw NodeUnreachableException();
+ }
+}
+
+void
+IcePack::AdminI::setServerActivation(const ::std::string& name, ServerActivation mode, const Ice::Current&)
+{
+ ServerPrx server = _serverRegistry->findByName(name);
+ try
+ {
+ return server->setActivationMode(mode);
+ }
+ catch(const Ice::ObjectNotExistException&)
+ {
+ throw ServerNotExistException();
+ }
+ catch(const Ice::LocalException&)
+ {
+ throw NodeUnreachableException();
+ }
+}
+
string
IcePack::AdminI::getAdapterEndpoints(const string& name, const Current&) const
{
diff --git a/cpp/src/IcePack/AdminI.h b/cpp/src/IcePack/AdminI.h
index c6d1db877ec..9b8c2bd8196 100644
--- a/cpp/src/IcePack/AdminI.h
+++ b/cpp/src/IcePack/AdminI.h
@@ -36,6 +36,8 @@ public:
virtual bool startServer(const ::std::string&, const Ice::Current&);
virtual void stopServer(const ::std::string&, const Ice::Current&);
virtual Ice::StringSeq getAllServerNames(const Ice::Current&) const;
+ virtual ServerActivation getServerActivation(const ::std::string&, const Ice::Current&) const;
+ virtual void setServerActivation(const ::std::string&, ServerActivation, const Ice::Current&);
virtual ::std::string getAdapterEndpoints(const ::std::string&, const ::Ice::Current&) const;
virtual Ice::StringSeq getAllAdapterNames(const ::Ice::Current&) const;
diff --git a/cpp/src/IcePack/Grammar.y b/cpp/src/IcePack/Grammar.y
index 0b4f6e5a6ad..c7f987e8969 100644
--- a/cpp/src/IcePack/Grammar.y
+++ b/cpp/src/IcePack/Grammar.y
@@ -51,6 +51,7 @@ yyerror(const char* s)
%token ICE_PACK_STATE
%token ICE_PACK_PID
%token ICE_PACK_ENDPOINTS
+%token ICE_PACK_ACTIVATION
%%
@@ -131,6 +132,10 @@ command
{
parser->pidServer($3);
}
+| ICE_PACK_SERVER ICE_PACK_ACTIVATION strings ';'
+{
+ parser->activationServer($3);
+}
| ICE_PACK_SERVER ICE_PACK_REMOVE strings ';'
{
parser->removeServer($3);
diff --git a/cpp/src/IcePack/Internal.ice b/cpp/src/IcePack/Internal.ice
index 7f45ccaa799..f3f123c89d6 100644
--- a/cpp/src/IcePack/Internal.ice
+++ b/cpp/src/IcePack/Internal.ice
@@ -244,6 +244,20 @@ class Server
int getPid();
/**
+ *
+ * Set the server activation mode.
+ *
+ **/
+ void setActivationMode(ServerActivation mode);
+
+ /**
+ *
+ * Get the server activation mode.
+ *
+ **/
+ ServerActivation getActivationMode();
+
+ /**
*
* The description of this server.
*
@@ -258,6 +272,13 @@ class Server
*
**/
ServerAdapters adapters;
+
+ /**
+ *
+ * The server activation mode.
+ *
+ **/
+ ServerActivation activation;
};
/**
diff --git a/cpp/src/IcePack/Parser.cpp b/cpp/src/IcePack/Parser.cpp
index 4831be1a1f0..f1e1ae5efc5 100644
--- a/cpp/src/IcePack/Parser.cpp
+++ b/cpp/src/IcePack/Parser.cpp
@@ -60,6 +60,8 @@ IcePack::Parser::usage()
"server describe NAME Get server NAME description.\n"
"server state NAME Get server NAME state.\n"
"server pid NAME Get server NAME pid.\n"
+ "server activation NAME [on-demand | manual] Set the server activation mode to\n"
+ " on-demand or manual activation"
"server start NAME Starts server NAME.\n"
"server stop NAME Stop server NAME.\n"
"server remove NAME Remove server NAME.\n"
@@ -335,12 +337,13 @@ IcePack::Parser::describeServer(const list<string>& args)
try
{
ServerDescription desc = _admin->getServerDescription(args.front());
+ ServerActivation activation = _admin->getServerActivation(args.front());
cout << "name = " << desc.name << endl;
cout << "node = " << desc.node << endl;
cout << "path = " << desc.path << endl;
cout << "pwd = " << desc.pwd << endl;
- cout << "activation = " << (desc.activation == OnDemand ? "on-demand" : "manual") << endl;
+ cout << "activation = " << (activation == OnDemand ? "on-demand" : "manual") << endl;
cout << "args = ";
copy(desc.theArgs.begin(), desc.theArgs.end(), ostream_iterator<string>(cout," "));
cout << endl;
@@ -428,6 +431,42 @@ IcePack::Parser::pidServer(const list<string>& args)
}
void
+IcePack::Parser::activationServer(const list<string>& args)
+{
+ if(args.size() != 2)
+ {
+ error("`server activation' requires exactly two arguments\n(`help' for more info)");
+ return;
+ }
+
+ try
+ {
+ list<string>::const_iterator p = args.begin();
+ string name = *p++;
+ string mode = *p++;
+
+ if(mode == "on-demand")
+ {
+ _admin->setServerActivation(name, OnDemand);
+ }
+ else if(mode == "manual")
+ {
+ _admin->setServerActivation(name, Manual);
+ }
+ else
+ {
+ error("Unknown mode: " + mode);
+ }
+ }
+ catch(const Exception& ex)
+ {
+ ostringstream s;
+ s << ex;
+ error(s.str());
+ }
+}
+
+void
IcePack::Parser::listAllServers()
{
try
diff --git a/cpp/src/IcePack/Parser.h b/cpp/src/IcePack/Parser.h
index d1ce46e4158..c5adb5ed52f 100644
--- a/cpp/src/IcePack/Parser.h
+++ b/cpp/src/IcePack/Parser.h
@@ -79,6 +79,7 @@ public:
void stopServer(const std::list<std::string>&);
void describeServer(const std::list<std::string>&);
void stateServer(const std::list<std::string>&);
+ void activationServer(const std::list<std::string>&);
void pidServer(const std::list<std::string>&);
void removeServer(const std::list<std::string>&);
void listAllServers();
diff --git a/cpp/src/IcePack/Scanner.l b/cpp/src/IcePack/Scanner.l
index ee00147b0c6..f124584aa05 100644
--- a/cpp/src/IcePack/Scanner.l
+++ b/cpp/src/IcePack/Scanner.l
@@ -156,6 +156,10 @@ NL [\n]
return ICE_PACK_PING;
}
+"activation" {
+ return ICE_PACK_ACTIVATION;
+}
+
{WS}*(\\{WS}*{NL})? {
int len = strlen(yytext);
for(int i = 0; i < len; ++i)
diff --git a/cpp/src/IcePack/ServerBuilder.cpp b/cpp/src/IcePack/ServerBuilder.cpp
index 159c4b20014..b4e4a14b1fe 100644
--- a/cpp/src/IcePack/ServerBuilder.cpp
+++ b/cpp/src/IcePack/ServerBuilder.cpp
@@ -290,22 +290,6 @@ IcePack::ServerHandler::startElement(const XMLCh *const name, AttributeList &att
string name = getAttributeValue(attrs, "name");
_builder.registerAdapter(name, getAttributeValue(attrs, "endpoints"), _currentAdapterId);
}
- else if(str == "activation")
- {
- string mode = getAttributeValue(attrs, "mode");
- if(mode == "manual")
- {
- _builder.setActivationMode(Manual);
- }
- else if(mode == "on-demand")
- {
- _builder.setActivationMode(OnDemand);
- }
- else
- {
- throw DeploySAXParseException("unkown value for attribute mode", _locator);
- }
- }
}
void
@@ -354,7 +338,6 @@ IcePack::ServerBuilder::ServerBuilder(const NodeInfoPtr& nodeInfo,
_libraryPath = _variables["libpath"];
_description.node = nodeInfo->getNode()->getName();
_description.theTargets = targets;
- _description.activation = OnDemand;
}
void
@@ -675,12 +658,6 @@ IcePack::ServerBuilder::setKind(ServerBuilder::ServerKind kind)
_kind = kind;
}
-void
-IcePack::ServerBuilder::setActivationMode(ServerActivation activation)
-{
- _description.activation = activation;
-}
-
ServerPrx
IcePack::ServerBuilder::getServer() const
{
diff --git a/cpp/src/IcePack/ServerBuilder.h b/cpp/src/IcePack/ServerBuilder.h
index c9df3eba349..52f12e617e8 100644
--- a/cpp/src/IcePack/ServerBuilder.h
+++ b/cpp/src/IcePack/ServerBuilder.h
@@ -47,7 +47,6 @@ public:
void addOption(const std::string&);
void addJavaOption(const std::string&);
void setKind(ServerKind);
- void setActivationMode(ServerActivation);
ServerPrx getServer() const;
ServerAdapterPrx getServerAdapter(const std::string& name) const;
diff --git a/cpp/src/IcePack/ServerFactory.cpp b/cpp/src/IcePack/ServerFactory.cpp
index 33b91e046f6..21b283afc90 100644
--- a/cpp/src/IcePack/ServerFactory.cpp
+++ b/cpp/src/IcePack/ServerFactory.cpp
@@ -158,6 +158,11 @@ IcePack::ServerFactory::createServerAndAdapters(const ServerDescription& descrip
serverI->adapters.push_back(adapterProxy);
}
+ //
+ // By default server is always activated on demand.
+ //
+ serverI->activation = OnDemand;
+
_adapter->add(serverI, id);
_serverEvictor->createObject(id, serverI);
diff --git a/cpp/src/IcePack/ServerI.cpp b/cpp/src/IcePack/ServerI.cpp
index f572e47ab0a..e8dcdc66a2e 100644
--- a/cpp/src/IcePack/ServerI.cpp
+++ b/cpp/src/IcePack/ServerI.cpp
@@ -43,9 +43,9 @@ IcePack::ServerI::getServerDescription(const Ice::Current&)
}
bool
-IcePack::ServerI::start(ServerActivation activation, const Ice::Current& current)
+IcePack::ServerI::start(ServerActivation act, const Ice::Current& current)
{
- if(activation < description.activation)
+ if(act < activation)
{
return false;
}
@@ -316,6 +316,20 @@ IcePack::ServerI::getPid(const Ice::Current& current)
return _activator->getServerPid(this);
}
+void
+IcePack::ServerI::setActivationMode(ServerActivation mode, const ::Ice::Current&)
+{
+ IceUtil::Monitor< ::IceUtil::Mutex>::Lock sync(*this);
+ activation = mode;
+}
+
+ServerActivation
+IcePack::ServerI::getActivationMode(const ::Ice::Current&)
+{
+ IceUtil::Monitor< ::IceUtil::Mutex>::Lock sync(*this);
+ return activation;
+}
+
void
IcePack::ServerI::stopInternal()
{
diff --git a/cpp/src/IcePack/ServerI.h b/cpp/src/IcePack/ServerI.h
index f4178bc4b4b..345d53b1678 100644
--- a/cpp/src/IcePack/ServerI.h
+++ b/cpp/src/IcePack/ServerI.h
@@ -43,6 +43,9 @@ public:
virtual ServerState getState(const ::Ice::Current&);
virtual Ice::Int getPid(const ::Ice::Current&);
+ virtual void setActivationMode(ServerActivation, const ::Ice::Current&);
+ virtual ServerActivation getActivationMode(const ::Ice::Current&);
+
private:
void stopInternal();