InfiniSQL  v0.1.2-alpha
Massive Scale Transaction Processing
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Topology.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2013 Mark Travis <mtravis15432+src@gmail.com>
3  * All rights reserved. No warranty, explicit or implicit, provided.
4  *
5  * This file is part of InfiniSQL(tm).
6 
7  * InfiniSQL is free software: you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License version 3
9  * as published by the Free Software Foundation.
10  *
11  * InfiniSQL is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with InfiniSQL. If not, see <http://www.gnu.org/licenses/>.
18  */
19 
30 #ifndef INFINISQLTOPOLOGY_H
31 #define INFINISQLTOPOLOGY_H
32 
33 #include <cstdlib>
34 #include <vector>
35 #include <stdint.h>
36 #include <pthread.h>
37 #include <string>
38 #include <stdio.h>
39 #include <boost/unordered_map.hpp>
40 #include "cfgenum.h"
41 #include <map>
42 
43 using std::string;
44 using std::map;
45 
46 extern pthread_mutex_t nodeTopologyMutex;
47 extern FILE *logfile;
48 using std::vector;
49 
50 class Mbox;
51 
54 class Topology
55 {
56 public:
61  struct __attribute__ ((__packed__)) addressStruct
62  {
63  int16_t nodeid;
64  int16_t actorid;
65  };
66 
71  {
73  int64_t instance;
74  class Mbox *mbox;
75  actortypes_e type;
76  int epollfd;
77  std::string argstring;
78  std::string node;
79  std::string service;
80  std::vector<std::string> nodes;
81  std::vector<std::string> services;
82  };
83 
88  struct actor_s
89  {
90  actortypes_e type;
91  int64_t instance;
92  class Mbox *mbox;
93  };
94 
95  Topology();
96  Topology(const Topology &orig);
97  virtual ~Topology();
98 
116  partitionAddress *newActor(actortypes_e type, class Mbox *mbox, int epollfd,
117  const string &argstring, int64_t actorid,
118  const vector<string> &nodes,
119  const vector<string> &services);
120 
121  int16_t nodeid;
125 
126  //local
128  size_t numengines;
130 
131  vector<actor_s> actorList;
132 
133  //global
134  int16_t numpartitions;
139  // partitionList[replicaid][partition] = {nodeid, actorid}
140  std::vector< vector<partitionAddress> > partitionList;
141  std::vector<partitionAddress> partitionListThisReplica;
142  std::map< int64_t, vector<std::string> > ibGateways;
143  // allActors[nodeid][actorid] = type
144  std::vector< vector<int> > allActors;
145  boost::unordered_map< int16_t, std::vector<int> > allActorsThisReplica;
146  // replicaMembers[replica][member] = nodeid
147  std::vector< vector<int16_t> > replicaMembers;
148  // tas[nodeid][tainstance] = actorid
149  std::vector< vector<int16_t> > tas;
150 };
151 
152 #endif /* INFINISQLTOPOLOGY_H */