Equalizer  1.6.1
include/eq/fabric/node.h
1 
2 /* Copyright (c) 2010-2013, Stefan Eilemann <eile@eyescale.ch>
3  * 2010, Cedric Stalder<cedric.stalder@gmail.com>
4  *
5  * This library is free software; you can redistribute it and/or modify it under
6  * the terms of the GNU Lesser General Public License version 2.1 as published
7  * by the Free Software Foundation.
8  *
9  * This library is distributed in the hope that it will be useful, but WITHOUT
10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11  * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
12  * details.
13  *
14  * You should have received a copy of the GNU Lesser General Public License
15  * along with this library; if not, write to the Free Software Foundation, Inc.,
16  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
17  */
18 
19 #ifndef EQFABRIC_NODE_H
20 #define EQFABRIC_NODE_H
21 
22 #include <eq/fabric/object.h> // base class
23 #include <eq/fabric/types.h>
24 
25 namespace eq
26 {
27 namespace fabric
28 {
30  template< class C, class N, class P, class V > class Node : public Object
31  {
32  public:
34  typedef std::vector< P* > Pipes;
35 
39  C* getConfig() { return _config; }
40 
42  const C* getConfig() const { return _config; }
43 
45  const Pipes& getPipes() const { return _pipes; }
46 
52  bool isApplicationNode() const { return _isAppNode; }
53 
55  EQFABRIC_INL void setApplicationNode( const bool isAppNode );
56 
58  EQFABRIC_INL NodePath getPath() const;
59  P* findPipe( const UUID& id );
60 
68  EQFABRIC_INL VisitorResult accept( V& visitor );
69 
71  EQFABRIC_INL VisitorResult accept( V& visitor ) const;
73 
76  // Note: also update string array initialization in node.ipp
79  {
83  IATTR_HINT_AFFINITY,
84  IATTR_LAST,
85  IATTR_ALL = IATTR_LAST + 5
86  };
87 
89  EQFABRIC_INL void setIAttribute( const IAttribute attr,
90  const int32_t value );
91 
93  EQFABRIC_INL int32_t getIAttribute( const IAttribute attr ) const;
94 
96  static const std::string& getIAttributeString( const IAttribute attr );
98 
101  EQFABRIC_INL virtual void backup();
102  EQFABRIC_INL virtual void restore();
103  void create( P** pipe );
104  void release( P* pipe );
105  virtual void output( std::ostream& ) const {}
106  EQFABRIC_INL virtual uint128_t commit( const uint32_t incarnation =
107  CO_COMMIT_NEXT );
109 
110  protected:
112  Node( C* parent );
114  EQFABRIC_INL virtual ~Node();
115 
117  EQFABRIC_INL virtual void serialize( co::DataOStream& os,
118  const uint64_t dirtyBits );
120  EQFABRIC_INL virtual void deserialize( co::DataIStream& is,
121  const uint64_t dirtyBits );
122 
123  EQFABRIC_INL virtual void notifyDetach();
124 
126  EQFABRIC_INL virtual void setDirty( const uint64_t bits );
127 
129  virtual ChangeType getChangeType() const { return UNBUFFERED; }
130 
131  enum DirtyBits
132  {
133  DIRTY_ATTRIBUTES = Object::DIRTY_CUSTOM << 0,
134  DIRTY_PIPES = Object::DIRTY_CUSTOM << 1,
135  DIRTY_MEMBER = Object::DIRTY_CUSTOM << 2,
136  DIRTY_NODE_BITS =
137  DIRTY_ATTRIBUTES | DIRTY_PIPES | DIRTY_MEMBER |
138  DIRTY_OBJECT_BITS
139  };
140 
142  virtual uint64_t getRedistributableBits() const
143  { return DIRTY_NODE_BITS; }
144 
145  private:
147  Pipes _pipes;
148 
150  C* const _config;
151 
152  struct BackupData
153  {
154  BackupData();
156  int32_t iAttributes[IATTR_ALL];
157  }
158  _data, _backup;
159 
160  bool _isAppNode;
161 
162  struct Private;
163  Private* _private; // placeholder for binary-compatible changes
164 
165  template< class, class, class, class > friend class Pipe;
166  void _addPipe( P* pipe );
167  bool _removePipe( P* pipe );
168 
170  bool _mapNodeObjects() { return _config->mapNodeObjects(); }
171  };
172 
173  template< class C, class N, class P, class V > EQFABRIC_INL
174  std::ostream& operator << ( std::ostream&, const Node< C, N, P, V >& );
175 }
176 }
177 
178 #endif // EQFABRIC_NODE_H
Internal base class for all distributed, inheritable Equalizer objects.
Definition: object.h:39
IAttribute
Possible values for integer attributes.
Definition: iAttribute.h:30
const Pipes & getPipes() const
const C * getConfig() const
A Node represents a single computer in the cluster.
std::vector< P * > Pipes
A vector of pointers to pipes.
EQFABRIC_INL VisitorResult accept(V &visitor)
Perform a depth-first traversal of this node.
EQFABRIC_INL int32_t getIAttribute(const IAttribute attr) const
virtual EQFABRIC_INL void setDirty(const uint64_t bits)
Base data transport class for nodes.
Timeout when auto-launching the node.