[hydra-commits] hydra/servicediscovery.git branch "master" updated.
Commits to the Hydra project code repositories
hydra-commits at lists.digium.com
Wed Jul 21 07:50:34 CDT 2010
branch "master" has been updated
via 9ec08565f9196f3153c6e29cd9006d5ef4c07df4 (commit)
via c71ec8ee4107ec285d59fa9f1a66a9bdb3bcee86 (commit)
via 7fb7a276e9d9896306e1e08aae2ab5e0587518de (commit)
via 03a6fff5a6efa2ca763208e7eae6f0a8884bf828 (commit)
via 1b2f322f3383b1b98441c5d5ffa2e43e180020c4 (commit)
via 841dee6cfe38551aba23b6dbc8c67047aeb318d8 (commit)
from 157981e3086b2a457a65c4303a18e8b0f70cd163 (commit)
Summary of changes:
CMakeLists.txt | 2 +-
slice/CMakeLists.txt | 5 ++++-
slice/service_discovery.ice | 2 +-
slice/service_discovery_events.ice | 25 +++++++++++++++++++++++++
src/CMakeLists.txt | 4 +++-
src/ServiceDiscoveryManagement.cpp | 10 ++++++++--
src/ServiceDiscoveryManagement.h | 6 ++++--
src/ServiceLocator.cpp | 34 +++++++++++++++++++++++++++++++++-
src/ServiceManagement.cpp | 25 +++++++++++++++++++++++--
src/ServiceManagement.h | 8 +++++---
10 files changed, 107 insertions(+), 14 deletions(-)
create mode 100644 slice/service_discovery_events.ice
- Log -----------------------------------------------------------------
commit 9ec08565f9196f3153c6e29cd9006d5ef4c07df4
Author: Joshua Colp <jcolp at digium.com>
Date: Wed Jul 21 09:51:36 2010 -0300
Add remaining service specific events.
diff --git a/src/ServiceManagement.cpp b/src/ServiceManagement.cpp
index 127f9e0..249a12c 100644
--- a/src/ServiceManagement.cpp
+++ b/src/ServiceManagement.cpp
@@ -15,6 +15,8 @@ ServiceManagementImpl::ServiceManagementImpl(ServiceDiscoveryManagementImpl* man
: _management(management), _service(service), _adapter(adapter), _service_discovery_topic(service_discovery_topic), _guid(guid)
{
managementprx = ServiceManagementPrx::uncheckedCast(adapter->addWithUUID(this));
+
+ _service_discovery_topic->ServiceRegistered(_guid);
}
/* This is the isSupported implementation for the service itself */
@@ -58,11 +60,27 @@ void ServiceManagementImpl::addDiscoveryParams(const ServiceDiscoveryParamsPtr&
supported_discovery_params.push_back(spec);
}
+void ServiceManagementImpl::suspend(const Ice::Current&)
+{
+ suspended = true;
+
+ _service_discovery_topic->ServiceSuspended(_guid);
+}
+
+void ServiceManagementImpl::unsuspend(const Ice::Current&)
+{
+ suspended = false;
+
+ _service_discovery_topic->ServiceUnsuspended(_guid);
+}
+
void ServiceManagementImpl::unregister(const Ice::Current&)
{
_adapter->remove(managementprx->ice_getIdentity());
_management->removeService(this);
+
+ _service_discovery_topic->ServiceUnregistered(_guid);
}
diff --git a/src/ServiceManagement.h b/src/ServiceManagement.h
index f881717..edcf1dc 100644
--- a/src/ServiceManagement.h
+++ b/src/ServiceManagement.h
@@ -14,8 +14,8 @@ class ServiceManagementImpl : public ServiceManagement
public:
ServiceManagementImpl(ServiceDiscoveryManagementImpl*, Ice::ObjectPrx, Ice::ObjectAdapterPtr, EventsPrx, const string&);
void addDiscoveryParams(const ServiceDiscoveryParamsPtr&, const std::string&, const Ice::Current&);
- void suspend(const Ice::Current&) { suspended = true; };
- void unsuspend(const Ice::Current&) { suspended = false; };
+ void suspend(const Ice::Current&);
+ void unsuspend(const Ice::Current&);
void unregister(const Ice::Current&);
Ice::ObjectPrx GetService(void) { return _service; };
ServiceManagementPrx GetServiceManagementPrx(void) { return managementprx; };
commit c71ec8ee4107ec285d59fa9f1a66a9bdb3bcee86
Author: Joshua Colp <jcolp at digium.com>
Date: Wed Jul 21 09:48:04 2010 -0300
Add a unique identifier to the addService method and store it internally for logging/events.
diff --git a/slice/service_discovery.ice b/slice/service_discovery.ice
index e216dd3..31e70c5 100644
--- a/slice/service_discovery.ice
+++ b/slice/service_discovery.ice
@@ -51,7 +51,7 @@ module Hydra {
/* Interface to do service discovery management (adding of services and compare components) */
interface ServiceDiscoveryManagement {
/* API call which adds a service to service discovery, still requires parameters to be added though */
- ServiceManagement *addService(Object *service);
+ ServiceManagement *addService(Object *service, string guid);
/* API call which adds a comparison service to service discovery */
void addCompare(string compareguid, ServiceDiscoveryParamsCompare *compare) throws DuplicateCompare;
/* API call which removes a comparison service from service discovery */
diff --git a/src/ServiceDiscoveryManagement.cpp b/src/ServiceDiscoveryManagement.cpp
index 0c0f056..932c32f 100644
--- a/src/ServiceDiscoveryManagement.cpp
+++ b/src/ServiceDiscoveryManagement.cpp
@@ -41,9 +41,9 @@ Ice::ObjectProxySeq ServiceDiscoveryManagementImpl::locateAll(const ServiceDisco
}
}
-ServiceManagementPrx ServiceDiscoveryManagementImpl::addService(const Ice::ObjectPrx& service, const Ice::Current&)
+ServiceManagementPrx ServiceDiscoveryManagementImpl::addService(const Ice::ObjectPrx& service, const string& guid, const Ice::Current&)
{
- ServiceManagementImpl* new_service = new ServiceManagementImpl(this, service, _adapter, _service_discovery_topic);
+ ServiceManagementImpl* new_service = new ServiceManagementImpl(this, service, _adapter, _service_discovery_topic, guid);
return new_service->GetServiceManagementPrx();
}
diff --git a/src/ServiceDiscoveryManagement.h b/src/ServiceDiscoveryManagement.h
index cb764ea..1a0fcda 100644
--- a/src/ServiceDiscoveryManagement.h
+++ b/src/ServiceDiscoveryManagement.h
@@ -18,7 +18,7 @@ public:
: _adapter(adapter), _service_discovery_topic(service_discovery_topic) { };
Ice::ObjectPrx locate(const ServiceDiscoveryParamsPtr&);
Ice::ObjectProxySeq locateAll(const ServiceDiscoveryParamsPtr&);
- ServiceManagementPrx addService(const Ice::ObjectPrx&, const Ice::Current&);
+ ServiceManagementPrx addService(const Ice::ObjectPrx&, const string&, const Ice::Current&);
void addCompare(const string&, const ServiceDiscoveryParamsComparePrx&, const Ice::Current&);
void removeCompare(const string&, const Ice::Current&);
bool isSupported(const string&, const ServiceDiscoveryParamsPtr&);
diff --git a/src/ServiceManagement.cpp b/src/ServiceManagement.cpp
index 7cac31d..127f9e0 100644
--- a/src/ServiceManagement.cpp
+++ b/src/ServiceManagement.cpp
@@ -10,8 +10,9 @@ using namespace Hydra::Discovery;
#include "ServiceDiscoveryManagement.h"
#include "ServiceManagement.h"
-ServiceManagementImpl::ServiceManagementImpl(ServiceDiscoveryManagementImpl* management, Ice::ObjectPrx service, Ice::ObjectAdapterPtr adapter, EventsPrx service_discovery_topic)
- : _management(management), _service(service), _adapter(adapter), _service_discovery_topic(service_discovery_topic)
+ServiceManagementImpl::ServiceManagementImpl(ServiceDiscoveryManagementImpl* management, Ice::ObjectPrx service, Ice::ObjectAdapterPtr adapter,
+ EventsPrx service_discovery_topic, const string& guid)
+ : _management(management), _service(service), _adapter(adapter), _service_discovery_topic(service_discovery_topic), _guid(guid)
{
managementprx = ServiceManagementPrx::uncheckedCast(adapter->addWithUUID(this));
}
diff --git a/src/ServiceManagement.h b/src/ServiceManagement.h
index f487f10..f881717 100644
--- a/src/ServiceManagement.h
+++ b/src/ServiceManagement.h
@@ -12,7 +12,7 @@ private:
class ServiceManagementImpl : public ServiceManagement
{
public:
- ServiceManagementImpl(ServiceDiscoveryManagementImpl*, Ice::ObjectPrx, Ice::ObjectAdapterPtr, EventsPrx);
+ ServiceManagementImpl(ServiceDiscoveryManagementImpl*, Ice::ObjectPrx, Ice::ObjectAdapterPtr, EventsPrx, const string&);
void addDiscoveryParams(const ServiceDiscoveryParamsPtr&, const std::string&, const Ice::Current&);
void suspend(const Ice::Current&) { suspended = true; };
void unsuspend(const Ice::Current&) { suspended = false; };
@@ -28,4 +28,5 @@ private:
ServiceManagementPrx managementprx;
vector<ServiceDiscoveryParamsSpec> supported_discovery_params;
EventsPrx _service_discovery_topic;
+ string _guid;
};
commit 7fb7a276e9d9896306e1e08aae2ab5e0587518de
Author: Joshua Colp <jcolp at digium.com>
Date: Wed Jul 21 09:43:48 2010 -0300
Create the service discovery topic if it does not exist and pass around a proxy to it so we can publish events. Right now only the Comparison* events get generated due to the service not having a name or unique identifier. I am working on adding that in and then will add those events as well.
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index d7298d4..d9092e8 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -1,6 +1,7 @@
# Create the actual standalone service locator component
hydra_component_init(service_locator CXX)
hydra_component_add_slice(service_locator service_discovery)
+hydra_component_add_slice(service_locator service_discovery_events)
hydra_component_add_file(service_locator ServiceLocator.cpp)
hydra_component_add_file(service_locator ServiceDiscoveryManagement.cpp)
hydra_component_add_file(service_locator ServiceManagement.cpp)
diff --git a/src/ServiceDiscoveryManagement.cpp b/src/ServiceDiscoveryManagement.cpp
index 7b08c29..0c0f056 100644
--- a/src/ServiceDiscoveryManagement.cpp
+++ b/src/ServiceDiscoveryManagement.cpp
@@ -43,7 +43,7 @@ Ice::ObjectProxySeq ServiceDiscoveryManagementImpl::locateAll(const ServiceDisco
ServiceManagementPrx ServiceDiscoveryManagementImpl::addService(const Ice::ObjectPrx& service, const Ice::Current&)
{
- ServiceManagementImpl* new_service = new ServiceManagementImpl(this, service, _adapter);
+ ServiceManagementImpl* new_service = new ServiceManagementImpl(this, service, _adapter, _service_discovery_topic);
return new_service->GetServiceManagementPrx();
}
@@ -58,6 +58,8 @@ void ServiceDiscoveryManagementImpl::addCompare(const string& guid, const Servic
ServiceDiscoveryComparator new_comparator(service);
compares[guid] = new_comparator;
+
+ _service_discovery_topic->ComparisonRegistered(guid);
};
void ServiceDiscoveryManagementImpl::removeCompare(const string& guid, const Ice::Current&)
@@ -69,6 +71,8 @@ void ServiceDiscoveryManagementImpl::removeCompare(const string& guid, const Ice
}
compares.erase(guid);
+
+ _service_discovery_topic->ComparisonUnregistered(guid);
};
bool ServiceDiscoveryManagementImpl::isSupported(const string& compare_guid, const ServiceDiscoveryParamsPtr& params)
diff --git a/src/ServiceDiscoveryManagement.h b/src/ServiceDiscoveryManagement.h
index 98d1dc6..cb764ea 100644
--- a/src/ServiceDiscoveryManagement.h
+++ b/src/ServiceDiscoveryManagement.h
@@ -14,7 +14,8 @@ private:
class ServiceDiscoveryManagementImpl : public ServiceDiscoveryManagement
{
public:
- ServiceDiscoveryManagementImpl(Ice::ObjectAdapterPtr adapter) : _adapter(adapter) { };
+ ServiceDiscoveryManagementImpl(Ice::ObjectAdapterPtr adapter, EventsPrx service_discovery_topic)
+ : _adapter(adapter), _service_discovery_topic(service_discovery_topic) { };
Ice::ObjectPrx locate(const ServiceDiscoveryParamsPtr&);
Ice::ObjectProxySeq locateAll(const ServiceDiscoveryParamsPtr&);
ServiceManagementPrx addService(const Ice::ObjectPrx&, const Ice::Current&);
@@ -26,4 +27,5 @@ private:
Ice::ObjectAdapterPtr _adapter;
map<string, ServiceDiscoveryComparator> compares;
vector<ServiceManagementImpl*> services;
+ EventsPrx _service_discovery_topic;
};
diff --git a/src/ServiceLocator.cpp b/src/ServiceLocator.cpp
index 001cb18..f9fd657 100644
--- a/src/ServiceLocator.cpp
+++ b/src/ServiceLocator.cpp
@@ -56,10 +56,40 @@ Ice::ObjectProxySeq ServiceDiscoveryImpl::locateAll(const ServiceDiscoveryParams
*/
int ServiceLocatorApp::run(int argc, char* argv[])
{
+ IceStorm::TopicManagerPrx topicManager = IceStorm::TopicManagerPrx::checkedCast(communicator()->propertyToProxy("TopicManager.Proxy"));
+
+ if (!topicManager) {
+ cerr << "Failed to get a proxy to the topic manager, pout ;(" << endl;
+ return 0;
+ }
+
+ Ice::PropertiesPtr props = communicator()->getProperties();
+ string topicName = props->getProperty("ServiceDiscovery.TopicName");
+
+ if (topicName.empty()) {
+ topicName = "::hydra::service::discovery";
+ }
+
+ IceStorm::TopicPrx topic;
+ try {
+ topic = topicManager->retrieve(topicName);
+ }
+ catch(const IceStorm::NoSuchTopic&) {
+ try {
+ topic = topicManager->create(topicName);
+ }
+ catch(const IceStorm::TopicExists&) {
+ cerr << "Oh snap! Race condition creating topic, aborting" << endl;
+ return 0;
+ }
+ }
+
+ EventsPrx service_discovery_topic = EventsPrx::uncheckedCast(topic->getPublisher());
+
/* TODO: Place these on separate adapters for security reasons */
Ice::ObjectAdapterPtr adapter = communicator()->createObjectAdapter("ServiceLocatorAdapter");
- ServiceDiscoveryManagementImpl* DiscoveryServiceManagement = new ServiceDiscoveryManagementImpl(adapter);
+ ServiceDiscoveryManagementImpl* DiscoveryServiceManagement = new ServiceDiscoveryManagementImpl(adapter, service_discovery_topic);
adapter->add(DiscoveryServiceManagement, communicator()->stringToIdentity("DiscoveryServiceManagement"));
diff --git a/src/ServiceManagement.cpp b/src/ServiceManagement.cpp
index d657029..7cac31d 100644
--- a/src/ServiceManagement.cpp
+++ b/src/ServiceManagement.cpp
@@ -10,8 +10,8 @@ using namespace Hydra::Discovery;
#include "ServiceDiscoveryManagement.h"
#include "ServiceManagement.h"
-ServiceManagementImpl::ServiceManagementImpl(ServiceDiscoveryManagementImpl* management, Ice::ObjectPrx service, Ice::ObjectAdapterPtr adapter)
- : _management(management), _service(service), _adapter(adapter)
+ServiceManagementImpl::ServiceManagementImpl(ServiceDiscoveryManagementImpl* management, Ice::ObjectPrx service, Ice::ObjectAdapterPtr adapter, EventsPrx service_discovery_topic)
+ : _management(management), _service(service), _adapter(adapter), _service_discovery_topic(service_discovery_topic)
{
managementprx = ServiceManagementPrx::uncheckedCast(adapter->addWithUUID(this));
}
diff --git a/src/ServiceManagement.h b/src/ServiceManagement.h
index a2faf0b..f487f10 100644
--- a/src/ServiceManagement.h
+++ b/src/ServiceManagement.h
@@ -12,7 +12,7 @@ private:
class ServiceManagementImpl : public ServiceManagement
{
public:
- ServiceManagementImpl(ServiceDiscoveryManagementImpl* management, Ice::ObjectPrx service, Ice::ObjectAdapterPtr adapter);
+ ServiceManagementImpl(ServiceDiscoveryManagementImpl*, Ice::ObjectPrx, Ice::ObjectAdapterPtr, EventsPrx);
void addDiscoveryParams(const ServiceDiscoveryParamsPtr&, const std::string&, const Ice::Current&);
void suspend(const Ice::Current&) { suspended = true; };
void unsuspend(const Ice::Current&) { suspended = false; };
@@ -27,4 +27,5 @@ private:
Ice::ObjectAdapterPtr _adapter;
ServiceManagementPrx managementprx;
vector<ServiceDiscoveryParamsSpec> supported_discovery_params;
+ EventsPrx _service_discovery_topic;
};
commit 03a6fff5a6efa2ca763208e7eae6f0a8884bf828
Author: Joshua Colp <jcolp at digium.com>
Date: Wed Jul 21 09:25:35 2010 -0300
Update to use v4 of the cmake build infrastructure.
diff --git a/CMakeLists.txt b/CMakeLists.txt
index b3ed5e5..94936f5 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -4,7 +4,7 @@
cmake_minimum_required(VERSION 2.6)
# Include common Hydra build infrastructure
-include(cmake/Hydra_v3.cmake)
+include(cmake/Hydra_v4.cmake)
# This project is C++ based and requires a minimum of 3.4
hydra_project(service_locator 3.4 CXX)
diff --git a/slice/CMakeLists.txt b/slice/CMakeLists.txt
index 39ea5fd..4eddc05 100644
--- a/slice/CMakeLists.txt
+++ b/slice/CMakeLists.txt
@@ -1,5 +1,5 @@
# Compile our service discovery slice definition so we can then use it
-hydra_compile_slice(service_discovery.ice)
+hydra_compile_slice(service_discovery.ice lib "Slice Defined API" Core)
# Can't forget about events
-hydra_compile_slice(service_discovery_events.ice)
+hydra_compile_slice(service_discovery_events.ice lib "Slice Defined API" Core)
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index f58781b..d7298d4 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -6,4 +6,4 @@ hydra_component_add_file(service_locator ServiceDiscoveryManagement.cpp)
hydra_component_add_file(service_locator ServiceManagement.cpp)
hydra_component_add_ice_libraries(service_locator IceStorm)
hydra_component_build_standalone(service_locator)
-hydra_component_install(service_locator)
+hydra_component_install(service_locator RUNTIME bin "Service Locator." Core)
commit 1b2f322f3383b1b98441c5d5ffa2e43e180020c4
Author: Joshua Colp <jcolp at digium.com>
Date: Wed Jul 21 09:22:45 2010 -0300
Include the stuff required to use IceStorm.
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 3b4a6d5..f58781b 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -4,5 +4,6 @@ hydra_component_add_slice(service_locator service_discovery)
hydra_component_add_file(service_locator ServiceLocator.cpp)
hydra_component_add_file(service_locator ServiceDiscoveryManagement.cpp)
hydra_component_add_file(service_locator ServiceManagement.cpp)
+hydra_component_add_ice_libraries(service_locator IceStorm)
hydra_component_build_standalone(service_locator)
hydra_component_install(service_locator)
diff --git a/src/ServiceDiscoveryManagement.cpp b/src/ServiceDiscoveryManagement.cpp
index 34e952a..7b08c29 100644
--- a/src/ServiceDiscoveryManagement.cpp
+++ b/src/ServiceDiscoveryManagement.cpp
@@ -1,6 +1,8 @@
#include <Ice/Ice.h>
+#include <IceStorm/IceStorm.h>
#include "service_discovery.h"
+#include "service_discovery_events.h"
using namespace std;
using namespace Hydra::Discovery;
diff --git a/src/ServiceLocator.cpp b/src/ServiceLocator.cpp
index d23d6ea..001cb18 100644
--- a/src/ServiceLocator.cpp
+++ b/src/ServiceLocator.cpp
@@ -1,6 +1,8 @@
#include <Ice/Ice.h>
+#include <IceStorm/IceStorm.h>
#include "service_discovery.h"
+#include "service_discovery_events.h"
using namespace std;
using namespace Hydra::Discovery;
diff --git a/src/ServiceManagement.cpp b/src/ServiceManagement.cpp
index 7729b71..d657029 100644
--- a/src/ServiceManagement.cpp
+++ b/src/ServiceManagement.cpp
@@ -1,6 +1,8 @@
#include <Ice/Ice.h>
+#include <IceStorm/IceStorm.h>
#include "service_discovery.h"
+#include "service_discovery_events.h"
using namespace std;
using namespace Hydra::Discovery;
commit 841dee6cfe38551aba23b6dbc8c67047aeb318d8
Author: Joshua Colp <jcolp at digium.com>
Date: Wed Jul 21 09:16:01 2010 -0300
Add service discovery events slice definition.
diff --git a/slice/CMakeLists.txt b/slice/CMakeLists.txt
index d8a4479..39ea5fd 100644
--- a/slice/CMakeLists.txt
+++ b/slice/CMakeLists.txt
@@ -1,2 +1,5 @@
# Compile our service discovery slice definition so we can then use it
hydra_compile_slice(service_discovery.ice)
+
+# Can't forget about events
+hydra_compile_slice(service_discovery_events.ice)
diff --git a/slice/service_discovery_events.ice b/slice/service_discovery_events.ice
new file mode 100644
index 0000000..e3c6249
--- /dev/null
+++ b/slice/service_discovery_events.ice
@@ -0,0 +1,25 @@
+module Hydra {
+
+ module Discovery {
+
+ /* Topic used for service discovery events */
+ const string TOPIC="::hydra::service::discovery";
+
+ interface Events {
+ /* Event that is fired when a comparison service is registered */
+ void ComparisonRegistered(string guid);
+ /* Event that is fired when a comparison service is unregistered */
+ void ComparisonUnregistered(string guid);
+ /* Event that is fired when a service is registered */
+ void ServiceRegistered(string guid);
+ /* Event that is fired when a service is unregistered */
+ void ServiceUnregistered(string guid);
+ /* Event that is fired when a service is suspended */
+ void ServiceSuspended(string guid);
+ /* Event that is fired when a service is unsuspended */
+ void ServiceUnsuspended(string guid);
+ };
+
+ };
+
+};
-----------------------------------------------------------------------
--
hydra/servicediscovery.git
More information about the asterisk-scf-commits
mailing list