24#include "ArmarXCore/interface/core/RemoteObjectNode.h"
32#include <Ice/Object.h>
33#include <Ice/ObjectAdapter.h>
34#include <Ice/PropertiesAdmin.h>
35#include <IceUtil/Handle.h>
41#include "ArmarXCore/interface/core/UserException.h"
42#include "ArmarXCore/interface/core/util/distributed/RemoteHandle/RemoteHandleControlBlock.h"
53 static const unsigned CORE_COUNT_STD = std::thread::hardware_concurrency();
57 static const unsigned CORE_COUNT_MIN = 1;
61 static const unsigned CORE_COUNT_DEFAULT = std::max(CORE_COUNT_STD, CORE_COUNT_MIN);
66 return CORE_COUNT_DEFAULT;
73 ARMARX_DEBUG_S <<
"processor core count according to (std/requested from user) : "
74 << CORE_COUNT_STD <<
"/" << newCount;
88 std::lock_guard<std::mutex> lock{
dataMutex};
96 std::lock_guard<std::mutex> lock{
dataMutex};
103 std::lock_guard<std::mutex> lock{
dataMutex};
115 const std::string& registrationName,
116 const ComponentParameter& params,
121 throw ServerShuttingDown{};
127 ClientSideRemoteHandleControlBlockBasePtr
129 const std::string& registrationName,
130 const ComponentParameter& params,
135 throw ServerShuttingDown{};
143 const Ice::ObjectPtr& registree,
148 throw ServerShuttingDown{};
150 auto mioPtr = ManagedIceObjectPtr::dynamicCast(registree);
160 ClientSideRemoteHandleControlBlockBasePtr
162 const Ice::ObjectPtr& registree,
167 throw ServerShuttingDown{};
169 auto mioPtr = ManagedIceObjectPtr::dynamicCast(registree);
181 const Ice::ObjectPtr& registree,
186 throw ServerShuttingDown{};
188 auto mioPtr = ManagedIceObjectPtr::dynamicCast(registree);
196 ident.name = registrationName;
200 ClientSideRemoteHandleControlBlockBasePtr
202 const Ice::ObjectPtr& registree,
207 throw ServerShuttingDown{};
209 auto mioPtr = ManagedIceObjectPtr::dynamicCast(registree);
217 ident.name = registrationName;
223 std::string registrationName)
227 auto mioPrx = mioPtr->getProxy(-1);
228 return {std::move(mioPtr), std::move(mioPrx)};
233 const std::string& registrationName,
234 const ComponentParameter& params)
238 throw NoSuchComponentFactory{
"There is no component factory for the name " +
239 componentFactoryName};
242 params.prop, params.configName, params.configDomain),
250 return {std::move(ident), std::move(ioPrx)};
253 ClientSideRemoteHandleControlBlockBasePtr
257 auto mioPtr = std::move(mio.
ptr);
266 [axManager, mioPtr, ron,
id]
268 axManager->removeObjectNonBlocking(mioPtr);
269 ron->removeRemoteHandledObject(id);
272 std::lock_guard<std::mutex> lock(
dataMutex);
275 mioRH.directHandle->forceDeletion();
276 throw ServerShuttingDown{};
280 return mioRH.clientSideRemoteHandleControlBlock;
283 ClientSideRemoteHandleControlBlockBasePtr
287 auto ioIdent = std::move(io.
ident);
295 [objAdapter, ioIdent, ron,
id]
297 objAdapter->remove(ioIdent);
298 ron->removeRemoteHandledObject(id);
301 std::lock_guard<std::mutex> lock(
dataMutex);
304 ioRH.directHandle->forceDeletion();
305 throw ServerShuttingDown{};
309 return ioRH.clientSideRemoteHandleControlBlock;
317 std::lock_guard<std::mutex> lock(
dataMutex);
321 throw ServerShuttingDown{};
333 std::lock_guard<std::mutex> lock(
dataMutex);
337 throw ServerShuttingDown{};
347 std::lock_guard<std::mutex> lock(
dataMutex);
355 it->second->forceDeletion();
363 std::lock_guard<std::mutex> lock(
dataMutex);
366 elem.second->forceDeletion();
372 axManager->removeObjectBlocking(obj);
376 auto adapter = axManager->getAdapter();
379 adapter->remove(ident);
std::string getName() const
Retrieve name of object.
ArmarXManagerPtr getArmarXManager() const
Returns the ArmarX manager used to add and remove components.
static bool has(const std::string &key)
static const ComponentCreatorObject & get(const std::string &key)
static std::vector< std::string > getKeys()
static ManagementData create(ArmarXManagerPtr manager, Ice::ObjectPrx managedObjectPrx, Deleter deleter)
Creates a new RemoteHandleControlBlock.
void shutdownAndCleanup()
Ice::ObjectPrx registerPersistentObjectWithIdentity(const Ice::Identity &ident, const Ice::ObjectPtr ®istree, const Ice::Current &=Ice::emptyCurrent) override
ClientSideRemoteHandleControlBlockBasePtr createRemoteHandledComponent(const std::string &componentFactoryName, const std::string ®istrationName, const ComponentParameter ¶ms, const Ice::Current &=Ice::emptyCurrent) override
Ice::ObjectPrx doRegisterPersistentManagedIceObjectAtRON(ManagedIceObjectPtrAndPrx mio)
IceObjectIdentityAndPrx setupIceObject(const Ice::ObjectPtr &ptr, Ice::Identity ident)
Ice::ObjectPrx doRegisterPersistentIceObjectAtRON(IceObjectIdentityAndPrx io)
std::vector< ManagedIceObjectPtr > persistentManagedIceObjects
The persistent managed ice objects.
Ice::Long getNumberOfRemoteHandledObjects(const Ice::Current &=Ice::emptyCurrent) const override
Ice::Long getNumberOfObjects(const Ice::Current &=Ice::emptyCurrent) const override
Ice::ObjectPrx registerPersistentObject(const std::string ®istrationName, const Ice::ObjectPtr ®istree, const Ice::Current &=Ice::emptyCurrent) override
ClientSideRemoteHandleControlBlockBasePtr doRegisterRemoteHandledIceObjectAtRON(IceObjectIdentityAndPrx io)
ClientSideRemoteHandleControlBlockBasePtr doRegisterRemoteHandledManagedIceObjectAtRON(ManagedIceObjectPtrAndPrx mio)
ClientSideRemoteHandleControlBlockBasePtr registerRemoteHandledObjectWithIdentity(const Ice::Identity &ident, const Ice::ObjectPtr ®istree, const Ice::Current &=Ice::emptyCurrent) override
std::atomic_bool shuttingDown
static unsigned getDefaultCoreCount()
std::atomic< Ice::Long > nextRemoteHandledObjectId
Ice::IdentitySeq persistentIceObjectIdentities
The identities of persistent ice objects.
std::size_t coreCountUsed
The nuber of cores returned, when querried for it.
Ice::Long getNumberOfPersistentObjects(const Ice::Current &=Ice::emptyCurrent) const override
virtual void setCoreCount(int newCount)
Ice::StringSeq getKnownComponentFactories(const Ice::Current &=Ice::emptyCurrent) const override
ManagedIceObjectPtrAndPrx setupComponent(const std::string &componentFactoryName, const std::string ®istrationName, const ComponentParameter ¶ms)
ClientSideRemoteHandleControlBlockBasePtr registerRemoteHandledObject(const std::string ®istrationName, const Ice::ObjectPtr ®istree, const Ice::Current &=Ice::emptyCurrent) override
std::mutex dataMutex
mutex to protect the map
void removeRemoteHandledObject(Ice::Long id)
void onExitComponent() override
Removes all remote objects.
std::unordered_map< Ice::Long, RemoteHandleControlBlockPtr > remoteHandledObjects
the map of running objects
ManagedIceObjectPtrAndPrx setupManagedIceObject(ManagedIceObjectPtr mioPtr, std::string registrationName)
Ice::ObjectPrx createPersistentComponent(const std::string &componentFactoryName, const std::string ®istrationName, const ComponentParameter ¶ms, const Ice::Current &=Ice::emptyCurrent) override
#define ARMARX_DEBUG_S
The logging level for output that is only interesting while debugging.
#define ARMARX_ERROR_S
The logging level for unexpected behaviour, that must be fixed.
This file offers overloads of toIce() and fromIce() functions for STL container types.
IceInternal::Handle< ManagedIceObject > ManagedIceObjectPtr
IceInternal::Handle< RemoteObjectNode > RemoteObjectNodePtr
An ice handle for a RemoteObjectNodeComponent.