MySQL Lists are EOL. Please join:

List:Commits« Previous MessageNext Message »
From:jonas Date:March 9 2006 10:13am
Subject:bk commit into 5.1 tree (jonas:1.2155)
View as plain text  
Below is the list of changes that have just been committed into a local
5.1 repository of jonas. When jonas does a push these changes will
be propagated to the main repository and, within 24 hours after the
push, to the public repository.
For information on how to access the public repository
see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html

ChangeSet
  1.2155 06/03/09 11:13:13 jonas@stripped +1 -0
  Merge perch.ndb.mysql.com:/home/jonas/src/mysql-5.0
  into  perch.ndb.mysql.com:/home/jonas/src/mysql-5.1-new

  storage/ndb/src/kernel/blocks/suma/Suma.hpp
    1.14 06/03/09 11:13:10 jonas@stripped +0 -2
    merge

  storage/ndb/src/kernel/blocks/suma/Suma.hpp
    1.3.2.2 06/03/09 11:12:22 jonas@stripped +0 -0
    Merge rename: ndb/src/kernel/blocks/suma/Suma.hpp -> storage/ndb/src/kernel/blocks/suma/Suma.hpp

# This is a BitKeeper patch.  What follows are the unified diffs for the
# set of deltas contained in the patch.  The rest of the patch, the part
# that BitKeeper cares about, is below these diffs.
# User:	jonas
# Host:	perch.ndb.mysql.com
# Root:	/home/jonas/src/mysql-5.1-new/RESYNC

--- 1.3.2.1/ndb/src/kernel/blocks/suma/Suma.hpp	2006-03-09 11:11:04 +01:00
+++ 1.14/storage/ndb/src/kernel/blocks/suma/Suma.hpp	2006-03-09 11:13:10 +01:00
@@ -24,6 +24,7 @@
 
 #include <SLList.hpp>
 #include <DLList.hpp>
+#include <DLFifoList.hpp>
 #include <KeyTable.hpp>
 #include <DataBuffer.hpp>
 #include <SignalCounter.hpp>
@@ -32,14 +33,14 @@
 
 #include <signaldata/UtilSequence.hpp>
 #include <signaldata/SumaImpl.hpp>
+#include <ndbapi/NdbDictionary.hpp>
+
+class Suma : public SimulatedBlock {
+  BLOCK_DEFINES(Suma);
+public:
+  Suma(Block_context& ctx);
+  virtual ~Suma();
 
-class SumaParticipant : public SimulatedBlock {
-protected:
-  SumaParticipant(const Configuration & conf);
-  virtual ~SumaParticipant();
-  BLOCK_DEFINES(SumaParticipant);
-  
-protected:
   /**
    * Private interface
    */
@@ -58,14 +59,19 @@
  /**
    * Dict interface
    */
+#if 0
   void execLIST_TABLES_REF(Signal* signal);
   void execLIST_TABLES_CONF(Signal* signal);
+#endif
   void execGET_TABINFOREF(Signal* signal);
   void execGET_TABINFO_CONF(Signal* signal);
-#if 0
+
   void execGET_TABLEID_CONF(Signal* signal);
   void execGET_TABLEID_REF(Signal* signal);
-#endif
+
+  void execDROP_TAB_CONF(Signal* signal);
+  void execALTER_TAB_REQ(Signal* signal);
+  void execCREATE_TAB_CONF(Signal* signal);
   /**
    * Scan interface
    */
@@ -82,7 +88,6 @@
   void execTRIG_ATTRINFO(Signal* signal);
   void execFIRE_TRIG_ORD(Signal* signal);
   void execSUB_GCP_COMPLETE_REP(Signal* signal);
-  void runSUB_GCP_COMPLETE_ACC(Signal* signal);
   
   /**
    * DIH signals
@@ -106,6 +111,9 @@
   void execCONTINUEB(Signal* signal);
 
 public:
+
+  void suma_ndbrequire(bool v);
+
   typedef DataBuffer<15> TableList;
   
   union FragmentDescriptor { 
@@ -127,47 +135,70 @@
     Uint32 m_dummy;
   };
 
-  struct Table {
-    Table() { m_tableId = ~0; }
-    void release(SumaParticipant&);
+  struct Subscriber {
+    Uint32 m_senderRef;
+    Uint32 m_senderData;
+    Uint32 m_subPtrI; //reference to subscription
+    Uint32 nextList;
+
+    union { Uint32 nextPool; Uint32 prevList; };
+  };
+  typedef Ptr<Subscriber> SubscriberPtr;
+
+  /**
+   * Subscriptions
+   */
+
+  struct Subscription {
+    Uint32 m_senderRef;
+    Uint32 m_senderData;
+    Uint32 m_subscriptionId;
+    Uint32 m_subscriptionKey;
+    Uint32 m_subscriptionType;
+    Uint16 m_options;
+
+    enum Options {
+      REPORT_ALL       = 0x1,
+      REPORT_SUBSCRIBE = 0x2
+    };
+
+    enum State {
+      UNDEFINED,
+      LOCKED,
+      DEFINED,
+      DROPPED
+    };
+    State m_state;
+    Uint32 n_subscribers;
 
-    union { Uint32 m_tableId; Uint32 key; };
-    Uint32 m_schemaVersion;
-    Uint32 m_hasTriggerDefined[3]; // Insert/Update/Delete
-    Uint32 m_triggerIds[3]; // Insert/Update/Delete
-    
-    /**
-     * Default order in which to ask for attributes during scan
-     *   1) Fixed, not nullable
-     *   2) Rest
-     */
-    DataBuffer<15>::Head m_attributes; // Attribute id's
-    
-    /**
-     * Fragments
-     */
-    DataBuffer<15>::Head m_fragments;  // Fragment descriptors
-    
-    /**
-     * Hash table stuff
-     */
     Uint32 nextHash;
     union { Uint32 prevHash; Uint32 nextPool; };
+
     Uint32 hashValue() const {
-      return m_tableId;
+      return m_subscriptionId + m_subscriptionKey;
     }
-    bool equal(const Table& rec) const {
-      return m_tableId == rec.m_tableId;
+
+    bool equal(const Subscription & s) const {
+      return 
+	m_subscriptionId == s.m_subscriptionId && 
+	m_subscriptionKey == s.m_subscriptionKey;
     }
+    /**
+     * The following holds the tables included 
+     * in the subscription.
+     */
+    Uint32 m_tableId;
+    Uint32 m_table_ptrI;
   };
+  typedef Ptr<Subscription> SubscriptionPtr;
+
+  class Table;
+  friend class Table;
   typedef Ptr<Table> TablePtr;
 
-  /**
-   * Subscriptions
-   */
   struct SyncRecord {
-    SyncRecord(SumaParticipant& s, DataBuffer<15>::DataBufferPool & p)
-      : m_locked(false), m_tableList(p), suma(s)
+    SyncRecord(Suma& s, DataBuffer<15>::DataBufferPool & p)
+      : m_tableList(p), suma(s)
 #ifdef ERROR_INSERT
 	, cerrorInsert(s.cerrorInsert)
 #endif
@@ -175,52 +206,31 @@
     
     void release();
 
+    Uint32 m_senderRef;
+    Uint32 m_senderData;
+
     Uint32 m_subscriptionPtrI;
-    bool   m_locked;
-    bool   m_doSendSyncData;
-    bool   m_error;
-    TableList m_tableList;    // Tables to sync (snapshoted at beginning)
+    Uint32 m_error;
+    Uint32 m_currentTable;
+    TableList m_tableList;    // Tables to sync
     TableList::DataBufferIterator m_tableList_it;
 
     /**
-     * Sync meta
-     */
-    void startMeta(Signal*);
-    void nextMeta(Signal*);
-    void completeMeta(Signal*);
-    
-    /**
-     * Create triggers
-     */
-    Uint32 m_latestTriggerId;
-    void startTrigger(Signal* signal);
-    void nextTrigger(Signal* signal);
-    void completeTrigger(Signal* signal);
-    void createAttributeMask(AttributeMask&, Table*);
-    
-    /**
-     * Drop triggers
-     */
-    void startDropTrigger(Signal* signal);
-    void nextDropTrigger(Signal* signal);
-    void completeDropTrigger(Signal* signal);
-
-    /**
      * Sync data
      */
-    Uint32 m_currentTable;          // Index in m_tableList
     Uint32 m_currentFragment;       // Index in tabPtr.p->m_fragments
     DataBuffer<15>::Head m_attributeList; // Attribute if other than default
     DataBuffer<15>::Head m_tabList; // tables if other than default
     
     Uint32 m_currentTableId;        // Current table
     Uint32 m_currentNoOfAttributes; // No of attributes for current table
+
     void startScan(Signal*);
     void nextScan(Signal*);
     bool getNextFragment(TablePtr * tab, FragmentDescriptor * fd);
-    void completeScan(Signal*);
+    void completeScan(Signal*, int error= 0);
 
-    SumaParticipant & suma;
+    Suma & suma;
 #ifdef ERROR_INSERT
     UintR &cerrorInsert;
 #endif
@@ -229,95 +239,101 @@
       suma.progError(line, cause, extra); 
     }
     
-    void runLIST_TABLES_CONF(Signal* signal);
-    void runGET_TABINFO_CONF(Signal* signal);    
-    void runGET_TABINFOREF(Signal* signal);
-    
-    void runDI_FCOUNTCONF(Signal* signal);
-    void runDIGETPRIMCONF(Signal* signal);
-
-    void runCREATE_TRIG_CONF(Signal* signal);
-    void runDROP_TRIG_CONF(Signal* signal);
-    void runDROP_TRIG_REF(Signal* signal);
-    void runDropTrig(Signal* signal, Uint32 triggerId, Uint32 tableId);
-
-    Uint32 ptrI;
+    Uint32 prevList; Uint32 ptrI;
     union { Uint32 nextPool; Uint32 nextList; };
   };
   friend struct SyncRecord;
-  
-  struct Subscription {
-    Uint32 m_subscriberRef;
-    Uint32 m_subscriberData;
-    Uint32 m_senderRef;
-    Uint32 m_senderData;
-    Uint32 m_subscriptionId;
-    Uint32 m_subscriptionKey;
-    Uint32 m_subscriptionType;
-    Uint32 m_coordinatorRef;
-    Uint32 m_syncPtrI;  // Active sync operation
-    Uint32 m_nSubscribers;
-    bool m_markRemove;
 
-    Uint32 nextHash;
-    union { Uint32 prevHash; Uint32 nextPool; };
+  int initTable(Signal *signal,Uint32 tableId, TablePtr &tabPtr,
+		Ptr<SyncRecord> syncPtr);
+  int initTable(Signal *signal,Uint32 tableId, TablePtr &tabPtr,
+		SubscriberPtr subbPtr);
+  int initTable(Signal *signal,Uint32 tableId, TablePtr &tabPtr);
+  
+  void completeOneSubscriber(Signal* signal, TablePtr tabPtr, SubscriberPtr subbPtr);
+  void completeAllSubscribers(Signal* signal, TablePtr tabPtr);
+  void completeInitTable(Signal* signal, TablePtr tabPtr);
 
-    Uint32 hashValue() const {
-      return m_subscriptionId + m_subscriptionKey;
-    }
+  struct Table {
+    Table() { m_tableId = ~0; n_subscribers = 0; }
+    void release(Suma&);
+    void checkRelease(Suma &suma);
+
+    DLList<Subscriber>::Head c_subscribers;
+    DLList<SyncRecord>::Head c_syncRecords;
+
+    enum State {
+      UNDEFINED,
+      DEFINING,
+      DEFINED,
+      DROPPED,
+      ALTERED
+    };
+    State m_state;
 
-    bool equal(const Subscription & s) const {
-      return 
-	m_subscriptionId == s.m_subscriptionId && 
-	m_subscriptionKey == s.m_subscriptionKey;
-    }
+    Uint32 m_ptrI;
+    SubscriberPtr m_drop_subbPtr;
+
+    Uint32 n_subscribers;
+    bool m_reportAll;
+
+    bool parseTable(SegmentedSectionPtr ptr, Suma &suma);
     /**
-     * The following holds the table names of tables included 
-     * in the subscription.
+     * Create triggers
+     */
+    int setupTrigger(Signal* signal, Suma &suma);
+    void completeTrigger(Signal* signal);
+    void createAttributeMask(AttributeMask&, Suma &suma);
+    
+    /**
+     * Drop triggers
      */
-    // TODO we've got to fix this, this is to inefficient. Tomas
-    char m_tables[MAX_TABLES];
+    void dropTrigger(Signal* signal,Suma&);
+    void runDropTrigger(Signal* signal, Uint32 triggerId,Suma&);
+
+    /**
+     * Sync meta
+     */    
 #if 0
-    char m_tableNames[MAX_TABLES][MAX_TAB_NAME_SIZE];
+    void runLIST_TABLES_CONF(Signal* signal);
 #endif
+    
+    union { Uint32 m_tableId; Uint32 key; };
+    Uint32 m_schemaVersion;
+    Uint32 m_hasTriggerDefined[3]; // Insert/Update/Delete
+    Uint32 m_triggerIds[3]; // Insert/Update/Delete
+
+    Uint32 m_error;
     /**
-     * "Iterator" used to iterate through m_tableNames
+     * Default order in which to ask for attributes during scan
+     *   1) Fixed, not nullable
+     *   2) Rest
      */
-    Uint32 m_maxTables;
-    Uint32 m_currentTable;
-  };
-  typedef Ptr<Subscription> SubscriptionPtr;
-  
-  struct Subscriber {
-    Uint32 m_senderRef;
-    Uint32 m_senderData;
-    Uint32 m_subscriberRef;
-    Uint32 m_subscriberData;
-    Uint32 m_subPtrI; //reference to subscription
-    Uint32 m_firstGCI; // first GCI to send
-    Uint32 m_lastGCI; // last acnowledged GCI
-    Uint32 nextList;
-    union { Uint32 nextPool; Uint32 prevList; };
-  };
-  typedef Ptr<Subscriber> SubscriberPtr;
-
-  struct Bucket {
-    bool active;
-    bool handover;
-    bool handover_started;
-    Uint32 handoverGCI;
+    DataBuffer<15>::Head m_attributes; // Attribute id's
+    
+    /**
+     * Fragments
+     */
+    Uint32 m_fragCount;
+    DataBuffer<15>::Head m_fragments;  // Fragment descriptors
+    
+    /**
+     * Hash table stuff
+     */
+    Uint32 nextHash;
+    union { Uint32 prevHash; Uint32 nextPool; };
+    Uint32 hashValue() const {
+      return m_tableId;
+    }
+    bool equal(const Table& rec) const {
+      return m_tableId == rec.m_tableId;
+    }
   };
-#define NO_OF_BUCKETS 24
-  struct Bucket c_buckets[NO_OF_BUCKETS];
-  bool c_handoverToDo;
-  Uint32 c_lastCompleteGCI;
 
   /**
    * 
    */
   DLList<Subscriber> c_metaSubscribers;
-  DLList<Subscriber> c_dataSubscribers;
-  DLList<Subscriber> c_prepDataSubscribers;
   DLList<Subscriber> c_removeDataSubscribers;
 
   /**
@@ -330,24 +346,11 @@
    * Pools
    */
   ArrayPool<Subscriber> c_subscriberPool;
-  ArrayPool<Table> c_tablePool_;
+  ArrayPool<Table> c_tablePool;
   ArrayPool<Subscription> c_subscriptionPool;
   ArrayPool<SyncRecord> c_syncPool;
   DataBuffer<15>::DataBufferPool c_dataBufferPool;
 
-  /**
-   * for restarting Suma not to start sending data too early
-   */
-  bool c_restartLock;
-
-  /**
-   * for flagging that a GCI containg inconsistent data
-   * typically due to node failiure
-   */
-
-  Uint32 c_lastInconsistentGCI;
-  Uint32 c_nodeFailGCI;
-
   NodeBitmask c_failedApiNodes;
   
   /**
@@ -355,76 +358,38 @@
    */
   bool removeSubscribersOnNode(Signal *signal, Uint32 nodeId);
 
-  bool parseTable(Signal* signal, class GetTabInfoConf* conf, Uint32 tableId,
-		  SyncRecord* syncPtr_p);
   bool checkTableTriggers(SegmentedSectionPtr ptr);
 
   void addTableId(Uint32 TableId,
 		  SubscriptionPtr subPtr, SyncRecord *psyncRec);
 
-  void sendSubIdRef(Signal* signal, Uint32 errorCode);
-  void sendSubCreateConf(Signal* signal, Uint32 sender, SubscriptionPtr subPtr);  
-  void sendSubCreateRef(Signal* signal, const SubCreateReq& req, Uint32 errorCode);  
-  void sendSubStartRef(SubscriptionPtr subPtr, Signal* signal,
-		       Uint32 errorCode, bool temporary = false);
-  void sendSubStartRef(Signal* signal,
-		       Uint32 errorCode, bool temporary = false);
-  void sendSubStopRef(Signal* signal,
-		      Uint32 errorCode, bool temporary = false);
+  void sendSubIdRef(Signal* signal,Uint32 senderRef,Uint32 senderData,Uint32 errorCode);
+  void sendSubCreateRef(Signal* signal, Uint32 errorCode);
+  void sendSubStartRef(Signal*, SubscriberPtr, Uint32 errorCode, SubscriptionData::Part);
+  void sendSubStartRef(Signal* signal, Uint32 errorCode);
+  void sendSubStopRef(Signal* signal, Uint32 errorCode);
   void sendSubSyncRef(Signal* signal, Uint32 errorCode);  
   void sendSubRemoveRef(Signal* signal, const SubRemoveReq& ref,
-			Uint32 errorCode, bool temporary = false);
+			Uint32 errorCode);
   void sendSubStartComplete(Signal*, SubscriberPtr, Uint32, 
 			    SubscriptionData::Part);
   void sendSubStopComplete(Signal*, SubscriberPtr);
   void sendSubStopReq(Signal* signal, bool unlock= false);
 
-  void completeSubRemoveReq(Signal* signal, SubscriptionPtr subPtr);
+  void completeSubRemove(SubscriptionPtr subPtr);
 
-  Uint32 getFirstGCI(Signal* signal);
-  Uint32 decideWhoToSend(Uint32 nBucket, Uint32 gci);
+  void reportAllSubscribers(Signal *signal,
+                            NdbDictionary::Event::_TableEvent table_event,
+                            SubscriptionPtr subPtr,
+                            SubscriberPtr subbPtr);
 
-  virtual Uint32 getStoreBucket(Uint32 v) = 0;
-  virtual Uint32 getResponsibleSumaNodeId(Uint32 D) = 0;
-  virtual Uint32 RtoI(Uint32 sumaRef, bool dieOnNotFound = true) = 0;
-
-  struct FailoverBuffer {
-    //    FailoverBuffer(DataBuffer<15>::DataBufferPool & p);
-    FailoverBuffer();
-
-    bool subTableData(Uint32 gci, Uint32 *src, int sz);
-    bool subGcpCompleteRep(Uint32 gci);
-    bool nodeFailRep();
-
-    //    typedef DataBuffer<15> GCIDataBuffer;
-    //    GCIDataBuffer                      m_GCIDataBuffer;
-    //    GCIDataBuffer::DataBufferIterator  m_GCIDataBuffer_it;
-
-    Uint32 *c_gcis;
-    int c_sz;
-
-    //    Uint32 *c_buf;
-    //    int c_buf_sz;
-
-    int c_first;
-    int c_next;
-    bool c_full;
-  } c_failoverBuffer;
+  Uint32 getFirstGCI(Signal* signal);
 
   /**
    * Table admin
    */
   void convertNameToId( SubscriptionPtr subPtr, Signal * signal);
 
-
-};
-
-class Suma : public SumaParticipant {
-  BLOCK_DEFINES(Suma);
-public:
-  Suma(const Configuration & conf);
-  virtual ~Suma();
-private:
   /**
    * Public interface
    */
@@ -452,11 +417,11 @@
   void execREAD_NODESCONF(Signal* signal);
   void execNODE_FAILREP(Signal* signal);
   void execINCL_NODEREQ(Signal* signal);
-  void execCONTINUEB(Signal* signal);
   void execSIGNAL_DROPPED_REP(Signal* signal);
+  void execAPI_START_REP(Signal* signal);
   void execAPI_FAILREQ(Signal* signal) ;
 
-  void execSUB_GCP_COMPLETE_ACC(Signal* signal);
+  void execSUB_GCP_COMPLETE_ACK(Signal* signal);
 
   /**
    * Controller interface
@@ -470,17 +435,14 @@
   void execSUB_START_REF(Signal* signal);
   void execSUB_START_CONF(Signal* signal);
 
-  void execSUB_STOP_REF(Signal* signal);
-  void execSUB_STOP_CONF(Signal* signal);
-
-  void execSUB_SYNC_REF(Signal* signal);
-  void execSUB_SYNC_CONF(Signal* signal);
-  
   void execSUB_ABORT_SYNC_REF(Signal* signal);
   void execSUB_ABORT_SYNC_CONF(Signal* signal);
 
-  void execSUMA_START_ME(Signal* signal);
+  void execSUMA_START_ME_REQ(Signal* signal);
+  void execSUMA_START_ME_REF(Signal* signal);
+  void execSUMA_START_ME_CONF(Signal* signal);
   void execSUMA_HANDOVER_REQ(Signal* signal);
+  void execSUMA_HANDOVER_REF(Signal* signal);
   void execSUMA_HANDOVER_CONF(Signal* signal);
 
   /**
@@ -494,9 +456,6 @@
   void execUTIL_SEQUENCE_REF(Signal* signal);
   void execCREATE_SUBID_REQ(Signal* signal);
   
-  Uint32 getStoreBucket(Uint32 v);
-  Uint32 getResponsibleSumaNodeId(Uint32 D);
-
   /**
    * for Suma that is restarting another
    */
@@ -505,99 +464,169 @@
     Restart(Suma& s);
 
     Suma & suma;
+    Uint32 nodeId;
 
-    bool c_okToStart[MAX_REPLICAS];
-    bool c_waitingToStart[MAX_REPLICAS];
-
-    DLHashTable<SumaParticipant::Subscription>::Iterator c_subPtr; // TODO  [MAX_REPLICAS] 
-    SubscriberPtr c_subbPtr; // TODO [MAX_REPLICAS] 
+    DLHashTable<Subscription>::Iterator c_subIt;
+    KeyTable<Table>::Iterator c_tabIt;
 
     void progError(int line, int cause, const char * extra) { 
       suma.progError(line, cause, extra); 
     }
 
     void resetNode(Uint32 sumaRef);
-    void runSUMA_START_ME(Signal*, Uint32 sumaRef);
+    void runSUMA_START_ME_REQ(Signal*, Uint32 sumaRef);
     void startNode(Signal*, Uint32 sumaRef);
 
     void createSubscription(Signal* signal, Uint32 sumaRef);
     void nextSubscription(Signal* signal, Uint32 sumaRef);
+    void runSUB_CREATE_CONF(Signal* signal);
     void completeSubscription(Signal* signal, Uint32 sumaRef);
 
-    void startSync(Signal* signal, Uint32 sumaRef);
-    void nextSync(Signal* signal, Uint32 sumaRef);
-    void completeSync(Signal* signal, Uint32 sumaRef);
-
+    void startSubscriber(Signal* signal, Uint32 sumaRef);
+    void nextSubscriber(Signal* signal, Uint32 sumaRef, SubscriberPtr subbPtr);
     void sendSubStartReq(SubscriptionPtr subPtr, SubscriberPtr subbPtr,
 			 Signal* signal, Uint32 sumaRef);
-    void startSubscriber(Signal* signal, Uint32 sumaRef);
-    void nextSubscriber(Signal* signal, Uint32 sumaRef);
+    void runSUB_START_CONF(Signal* signal);
     void completeSubscriber(Signal* signal, Uint32 sumaRef);
 
     void completeRestartingNode(Signal* signal, Uint32 sumaRef);
+    void resetRestart(Signal* signal);
   } Restart;
 
 private:
   friend class Restart;
-  struct SubCoordinator {
-    Uint32 m_subscriberRef;
-    Uint32 m_subscriberData;
-    
-    Uint32 m_subscriptionId;
-    Uint32 m_subscriptionKey;
-    
-    NdbNodeBitmask m_participants;
-    
-    Uint32 m_outstandingGsn;
-    SignalCounter m_outstandingRequests;
-    
-    Uint32 nextList;
-    union { Uint32 prevList; Uint32 nextPool; };
-  };
-  Ptr<SubCoordinator> SubCoordinatorPtr;
-  
-  struct Node {
-    Uint32 nodeId;
-    Uint32 alive;
-    Uint32 nextList;
-    union { Uint32 prevList; Uint32 nextPool; };
-  };
-  typedef Ptr<Node> NodePtr;
-
   /**
    * Variables
    */
   NodeId c_masterNodeId;
-  SLList<Node> c_nodes;
-  NdbNodeBitmask c_aliveNodes;
-  NdbNodeBitmask c_preparingNodes;
-
-  Uint32 RtoI(Uint32 sumaRef, bool dieOnNotFound = true);
+  NdbNodeBitmask c_alive_nodes;
+  
+  /**
+   * for restarting Suma not to start sending data too early
+   */
+  struct Startup
+  {
+    bool m_wait_handover;
+    Uint32 m_restart_server_node_id;
+    NdbNodeBitmask m_handover_nodes;
+  } c_startup;
+  
+  NodeBitmask c_connected_nodes;  // (NODE/API) START REP / (API/NODE) FAIL REQ
+  NodeBitmask c_subscriber_nodes; // 
 
   /**
    * for all Suma's to keep track of other Suma's in Node group
    */
   Uint32 c_nodeGroup;
   Uint32 c_noNodesInGroup;
-  Uint32 c_idInNodeGroup;
-  NodeId c_nodesInGroup[MAX_REPLICAS];
+  Uint32 c_nodesInGroup[MAX_REPLICAS];
+  NdbNodeBitmask c_nodes_in_nodegroup_mask;  // NodeId's of nodes in nodegroup
 
-  /**
-   * don't seem to be used
-   */
-  ArrayPool<Node> c_nodePool;
-  ArrayPool<SubCoordinator> c_subCoordinatorPool;
-  DLList<SubCoordinator> c_runningSubscriptions;
-};
+  void send_start_me_req(Signal* signal);
+  void check_start_handover(Signal* signal);
+  void send_handover_req(Signal* signal);
+
+  Uint32 get_responsible_node(Uint32 B) const;
+  Uint32 get_responsible_node(Uint32 B, const NdbNodeBitmask& mask) const;
+  bool check_switchover(Uint32 bucket, Uint32 gci);
+
+public:  
+  struct Page_pos
+  {
+    Uint32 m_page_id;
+    Uint32 m_page_pos;  
+    Uint32 m_max_gci;   // max gci on page
+    Uint32 m_last_gci;  // last gci on page
+  };
+private:
+  
+  struct Bucket 
+  {
+    enum {
+      BUCKET_STARTING = 0x1  // On starting node
+      ,BUCKET_HANDOVER = 0x2 // On running node
+      ,BUCKET_TAKEOVER = 0x4 // On takeing over node
+      ,BUCKET_RESEND   = 0x8 // On takeing over node
+    };
+    Uint16 m_state;
+    Uint16 m_switchover_node;
+    Uint16 m_nodes[MAX_REPLICAS]; 
+    Uint32 m_switchover_gci;
+    Uint32 m_max_acked_gci;
+    Uint32 m_buffer_tail;   // Page
+    Page_pos m_buffer_head;
+  };
+  
+  struct Buffer_page 
+  {
+    STATIC_CONST( DATA_WORDS = 8192 - 9);
+    Uint32 _tupdata1;
+    Uint32 _tupdata2;
+    Uint32 _tupdata3;
+    Uint32 _tupdata4;
+    Uint32 m_page_state;     // Used by TUP buddy algorithm
+    Uint32 m_page_chunk_ptr_i;
+    Uint32 m_next_page;      
+    Uint32 m_words_used;     // 
+    Uint32 m_max_gci;        //
+    Uint32 m_data[DATA_WORDS];
+  };
+  
+  STATIC_CONST( NO_OF_BUCKETS = 24 ); // 24 = 4*3*2*1! 
+  Uint32 c_no_of_buckets;
+  struct Bucket c_buckets[NO_OF_BUCKETS];
+  
+  STATIC_CONST( BUCKET_MASK_SIZE = (((NO_OF_BUCKETS+31)>> 5)) );
+  typedef Bitmask<BUCKET_MASK_SIZE> Bucket_mask;
+  Bucket_mask m_active_buckets;
+  Bucket_mask m_switchover_buckets;  
+  
+  class Dbtup* m_tup;
+  void init_buffers();
+  Uint32* get_buffer_ptr(Signal*, Uint32 buck, Uint32 gci, Uint32 sz);
+  Uint32 seize_page();
+  void free_page(Uint32 page_id, Buffer_page* page);
+  void out_of_buffer(Signal*);
+  void out_of_buffer_release(Signal* signal, Uint32 buck);
+
+  void start_resend(Signal*, Uint32 bucket);
+  void resend_bucket(Signal*, Uint32 bucket, Uint32 gci, 
+		     Uint32 page_pos, Uint32 last_gci);
+  void release_gci(Signal*, Uint32 bucket, Uint32 gci);
+
+  Uint32 m_max_seen_gci;      // FIRE_TRIG_ORD
+  Uint32 m_max_sent_gci;      // FIRE_TRIG_ORD -> send
+  Uint32 m_last_complete_gci; // SUB_GCP_COMPLETE_REP
+  Uint32 m_out_of_buffer_gci;
+  Uint32 m_gcp_complete_rep_count;
+
+  struct Gcp_record 
+  {
+    Uint32 m_gci;
+    NodeBitmask m_subscribers;
+    union {
+      Uint32 nextPool;
+      Uint32 nextList;
+    };
+    Uint32 prevList;
+  };
+  ArrayPool<Gcp_record> c_gcp_pool;
+  DLFifoList<Gcp_record> c_gcp_list;
 
-inline Uint32
-Suma::RtoI(Uint32 sumaRef, bool dieOnNotFound) {
-  for (Uint32 i = 0; i < c_noNodesInGroup; i++) {
-    if (sumaRef == calcSumaBlockRef(c_nodesInGroup[i]))
-      return i;
-  }
-  ndbrequire(!dieOnNotFound);
-  return RNIL;
-}
+  struct Page_chunk
+  {
+    Uint32 m_page_id;
+    Uint32 m_size;
+    Uint32 m_free;
+    union {
+      Uint32 nextPool;
+      Uint32 nextList;
+    };
+    Uint32 prevList;
+  };
+
+  Uint32 m_first_free_page;
+  ArrayPool<Page_chunk> c_page_chunk_pool;
+};
 
 #endif
Thread
bk commit into 5.1 tree (jonas:1.2155)jonas9 Mar