31#include <ArmarXCore/interface/core/ArmarXManagerInterface.h>
32#include <ArmarXCore/interface/core/BasicTypes.h>
33#include <ArmarXCore/interface/core/MiceManagerInsightProvider.h>
36#include <condition_variable>
43#include <Ice/BuiltinSequences.h>
44#include <Ice/CommunicatorF.h>
45#include <Ice/Current.h>
46#include <Ice/Metrics.h>
47#include <Ice/ObjectAdapterF.h>
48#include <Ice/Properties.h>
49#include <IceUtil/Handle.h>
99 virtual public ArmarXManagerInterface,
105 enum ArmarXManagerState
127 std::string host =
"localhost",
128 std::string locatorName =
"IceGrid/Locator",
129 Ice::StringSeq args = Ice::StringSeq());
183 bool addWithOwnAdapter =
true,
184 const std::string& objectName =
"",
185 bool useOwnScheduleThread =
true)
override;
187 const std::string& objectName,
188 bool addWithOwnAdapter =
true,
189 bool useOwnScheduleThread =
true);
193 const std::string& objectName =
"",
194 bool useOwnScheduleThread =
true);
197 const std::string& objectName,
198 bool addWithOwnAdapter =
true,
199 bool useOwnScheduleThread =
true);
279 ManagedIceObjectState
getObjectState(
const std::string& objectName,
280 const Ice::Current&
c = Ice::emptyCurrent)
override;
290 ManagedIceObjectConnectivity
292 const Ice::Current&
c = Ice::emptyCurrent)
override;
302 mice::MiceObjectConnectivity
304 const Ice::Current&
c = Ice::emptyCurrent)
override;
310 ::armarx::StringStringDictionary
312 const ::Ice::Current& = Ice::emptyCurrent)
override;
314 const ::Ice::Current&)
override;
318 Ice::PropertiesAdminPrx
321 IceMX::MetricsAdminPrx
getMetricsAdmin(
const Ice::Current& = Ice::emptyCurrent)
override;
347 Ice::StringSeq
getObjectNames(
const Ice::Current&
c = Ice::emptyCurrent)
override;
357 std::string
getHostname(
const Ice::Current&
c = Ice::emptyCurrent)
override;
395 template <
class Function,
class Data>
399 const std::string&
id =
"",
400 IceUtil::Time deletionDelay = IceUtil::Time::seconds(3),
401 IceUtil::Time orphantDeletionDelay = IceUtil::Time::seconds(6),
402 long heartBeatMs = 1000)
407 std::forward<
decltype(f)>(f),
408 std::forward<
decltype(d)>(d),
410 orphantDeletionDelay,
412 remoteReferenceCountControlBlockManager->add(ptr);
416 template <
class Function>
419 const std::string&
id =
"",
420 IceUtil::Time deletionDelay = IceUtil::Time::seconds(3),
421 IceUtil::Time orphantDeletionDelay = IceUtil::Time::seconds(6),
422 long heartBeatMs = 1000)
427 std::forward<
decltype(f)>(f),
429 orphantDeletionDelay,
431 remoteReferenceCountControlBlockManager->add(ptr);
435 template <
class Function,
class Data>
439 const std::string&
id =
"",
440 IceUtil::Time deletionDelay = IceUtil::Time::seconds(3))
446 std::forward<
decltype(f)>(f),
447 std::forward<
decltype(d)>(d),
449 remoteReferenceCountControlBlockManager->add(ptr);
453 template <
class Function>
456 const std::string&
id =
"",
457 IceUtil::Time deletionDelay = IceUtil::Time::seconds(3))
461 this,
id, std::forward<
decltype(f)>(f), deletionDelay);
462 remoteReferenceCountControlBlockManager->add(ptr);
473 using ObjectSchedulerMap = std::map<std::string, ArmarXObjectSchedulerPtr>;
474 using ObjectSchedulerList = std::vector<ArmarXObjectSchedulerPtr>;
480 void cleanupSchedulers();
486 void disconnectDependees(
const std::string&
object);
487 void disconnectAllObjects();
488 std::vector<std::string> getDependendees(
const std::string& removedObject);
495 void wakeupWaitingSchedulers();
498 void removeAllObjects(
bool blocking);
505 void checkDependencies();
522 void installProcessFacet();
525 std::string applicationName;
528 ArmarXManagerState managerState;
529 std::mutex managerStateMutex;
537 ObjectSchedulerMap managedObjects;
538 ObjectSchedulerList terminatingObjects;
539 mutable std::recursive_mutex managedObjectsMutex;
540 std::mutex terminatingObjectsMutex;
542 std::mutex schedulerListMutex;
543 std::vector<ArmarXMultipleObjectsSchedulerPtr> singleThreadedSchedulers;
546 std::mutex shutdownMutex;
547 std::condition_variable shutdownCondition;
556 std::shared_ptr<SharedRemoteHandleState> sharedRemoteHandleState;
557 std::shared_ptr<RemoteReferenceCountControlBlockManager>
558 remoteReferenceCountControlBlockManager;
Main class of an ArmarX process.
const Ice::ObjectAdapterPtr & getAdapter() const
SimpleRemoteReferenceCountControlBlockPtr< Function, Data > createSimpleRemoteReferenceCount(Function f, Data d, const std::string &id="", IceUtil::Time deletionDelay=IceUtil::Time::seconds(3))
RemoteReferenceCountControlBlockPtr< Function, Data > createRemoteReferenceCount(Function f, Data d, const std::string &id="", IceUtil::Time deletionDelay=IceUtil::Time::seconds(3), IceUtil::Time orphantDeletionDelay=IceUtil::Time::seconds(6), long heartBeatMs=1000)
SimpleRemoteReferenceCountControlBlockPtr< Function > createSimpleRemoteReferenceCount(Function f, const std::string &id="", IceUtil::Time deletionDelay=IceUtil::Time::seconds(3))
Ice::StringSeq getObjectNames(const Ice::Current &c=Ice::emptyCurrent) override
Retrieve the names of all ManagedIceObject.
void setGlobalMinimumLoggingLevel(MessageTypeT minimumLoggingLevel)
Set minimum logging level to output in log stream.
void enableProfiling(bool enable)
Enable or disable profiling of CPU Usage.
mice::MiceObjectConnectivity getMiceObjectConnectivity(const std::string &objectName, const Ice::Current &c=Ice::emptyCurrent) override
Retrieve connectivity of a ManagedIceObject.
const std::shared_ptr< SharedRemoteHandleState > & getSharedRemoteHandleState() const
ArmarXManager(std::string applicationName, int port=4061, std::string host="localhost", std::string locatorName="IceGrid/Locator", Ice::StringSeq args=Ice::StringSeq())
ArmarXManager constructor.
Ice::PropertiesAdminPrx getPropertiesAdmin(const Ice::Current &=Ice::emptyCurrent) override
void updateComponentIceProperties(const Ice::PropertyDict &properties)
const IceManagerPtr & getIceManager() const
Retrieve the instance of the icemanager.
ManagedIceObjectConnectivity getObjectConnectivity(const std::string &objectName, const Ice::Current &c=Ice::emptyCurrent) override
Retrieve connectivity of a ManagedIceObject.
IceMX::MetricsAdminPrx getMetricsAdmin(const Ice::Current &=Ice::emptyCurrent) override
void waitForShutdown()
Wait for shutdown.
virtual void addObjectAsync(const ManagedIceObjectPtr &object, const std::string &objectName, bool addWithOwnAdapter=true, bool useOwnScheduleThread=true)
void addObject(const ManagedIceObjectPtr &object, bool addWithOwnAdapter=true, const std::string &objectName="", bool useOwnScheduleThread=true) override
Add a ManagedIceObject to the manager.
::armarx::StringStringDictionary getObjectProperties(const ::std::string &objectName, const ::Ice::Current &=Ice::emptyCurrent) override
getObjectProperties is used to retrieve the properties of an object
const Ice::CommunicatorPtr & getCommunicator() const
static bool CheckIceConnection(const Ice::CommunicatorPtr &communicator, bool printHint)
void shutdown()
Shuts down the ArmarXManager.
void increaseSchedulers(int increaseBy)
increased the number of single threaded schedulers.
std::string getHostname(const Ice::Current &c=Ice::emptyCurrent) override
Gets the hostname of the host running the manager.
static void RegisterKnownObjectFactoriesWithIce(const Ice::CommunicatorPtr &ic)
Registers all object factories that are known with Ice.
void removeObjectBlocking(const ManagedIceObjectPtr &object) override
Removes an object from the manager.
void setDataPaths(std::string dataPaths)
Set data paths used to search for datafiles.
void asyncShutdown(std::size_t timeoutMs=0)
Calls shutdown() after a timeout.
StringVariantBaseMap getMetaInfo(const std::string &, const Ice::Current &) override
std::vector< ManagedIceObjectPtr > getManagedObjects() override
Retrieve pointers to all ManagedIceObject.
bool checkIceConnection(bool printHint=true) const
bool isShutdown()
Whether ArmarXManager shutdown has been finished.
void enableLogging(bool enable)
Enable or disable logging.
Ice::StringSeq getManagedObjectNames(const Ice::Current &c=Ice::emptyCurrent) override
Retrieve the names of all ManagedIceObject.
ManagedIceObjectState getObjectState(const std::string &objectName, const Ice::Current &c=Ice::emptyCurrent) override
Retrieve state of a ManagedIceObject.
RemoteReferenceCountControlBlockPtr< Function > createRemoteReferenceCount(Function f, const std::string &id="", IceUtil::Time deletionDelay=IceUtil::Time::seconds(3), IceUtil::Time orphantDeletionDelay=IceUtil::Time::seconds(6), long heartBeatMs=1000)
ObjectPropertyInfos getObjectPropertyInfos(const ::std::string &objectName, const ::Ice::Current &) override
void removeObjectNonBlocking(const ManagedIceObjectPtr &object) override
Removes an object from the manager.
~ArmarXManager() override
ObjectPropertyInfos getApplicationPropertyInfos(const ::Ice::Current &) override
void registerKnownObjectFactoriesWithIce()
non static convenience version of ArmarXManager::RegisterKnownObjectFactoriesWithIce()
void setComponentIceProperties(const Ice::PropertiesPtr &properties)
Calls Component::setIceProperties() on all components assigend to this ArmarXManager Instance.
friend class ArmarXObjectObserver
Takes care of the lifecycle management of ManagedIceObjects.
The IceManager class provides simplified access to commonly used Ice features.
MessageTypeT minimumLoggingLevel
The registery interface is implemented by ArmarXManagers.
The periodic task executes one thread method repeatedly using the time period specified in the constr...
std::shared_ptr< ScopedRecursiveLock > ScopedRecursiveLockPtr
::IceInternal::Handle<::Ice::Properties > PropertiesPtr
::IceInternal::Handle<::Ice::Communicator > CommunicatorPtr
::IceInternal::Handle<::Ice::ObjectAdapter > ObjectAdapterPtr
This file offers overloads of toIce() and fromIce() functions for STL container types.
IceUtil::Handle< ArmarXManager > ArmarXManagerPtr
std::map< std::string, VariantBasePtr > StringVariantBaseMap
IceUtil::Handle< RemoteReferenceCountControlBlock< FunctionType, DataType > > RemoteReferenceCountControlBlockPtr
IceUtil::Handle< ArmarXObjectScheduler > ArmarXObjectSchedulerPtr
IceUtil::Handle< SimpleRemoteReferenceCountControlBlock< FunctionType, DataType > > SimpleRemoteReferenceCountControlBlockPtr
IceUtil::Handle< ArmarXMultipleObjectsScheduler > ArmarXMultipleObjectsSchedulerPtr
IceInternal::Handle< ArmarXObjectObserver > ArmarXObjectObserverPtr
IceUtil::Handle< IceManager > IceManagerPtr
IceManager smart pointer.
IceInternal::Handle< ManagedIceObject > ManagedIceObjectPtr
This holds the shared state of all RemoteHandleControlBlocks for one armarx manager.