InfiniSQL  v0.1.2-alpha
Massive Scale Transaction Processing
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Mboxes Class Reference

collection of producers More...

#include <Mbox.h>

Collaboration diagram for Mboxes:

Classes

struct  location_s
 address and MboxProducer for an actor More...
 

Public Member Functions

 Mboxes ()
 
 Mboxes (int64_t nodeidarg)
 collection of producers More...
 
virtual ~Mboxes ()
 
void update (class Topology &top)
 update Topology of producers More...
 
void update (class Topology &top, int64_t myActorid)
 update Topology of producers More...
 
void toActor (const Topology::addressStruct &source, const Topology::addressStruct &dest, class Message &msg)
 produce Message for specific actor More...
 
void toUserSchemaMgr (const Topology::addressStruct &source, class Message &msg)
 produce Message for replica's UserSchemaMgr More...
 
void toDeadlockMgr (const Topology::addressStruct &source, class Message &msg)
 produce Message for replica's DeadlockMgr More...
 
void toPartition (const Topology::addressStruct &source, int64_t partitionid, class Message &msg)
 produce Message for Engine associated with specific partition More...
 
int64_t toAllOfType (actortypes_e type, const Topology::addressStruct &source, class Message &msg)
 
int64_t toAllOfTypeThisReplica (actortypes_e type, const Topology::addressStruct &source, class Message &msg)
 produce Message destined to all actors of type on current replica More...
 
void sendObBatch ()
 send batched Message objects destined to remote nodes More...
 

Public Attributes

int64_t nodeid
 
class MboxProducer topologyMgr
 
class MboxProducer userSchemaMgr
 
class MboxProducer deadlockMgr
 
class MboxProducer listener
 
class MboxProducer obGateway
 
class MboxProducer ibGateway
 
std::vector< class MboxProducertransactionAgents
 
std::vector< class MboxProducerengines
 
std::vector< class MboxProducer * > actoridToProducers
 
std::vector< class MboxProducer * > transactionAgentPtrs
 
std::vector< class MboxProducer * > enginePtrs
 
class MboxProducertopologyMgrPtr
 
location_s userSchemaMgrLocation
 
location_s deadlockMgrLocation
 
class MboxProducerlistenerPtr
 
class MboxProducerobGatewayPtr
 
std::vector< location_spartitionToProducers
 
std::vector< vector< int > > allActors
 
boost::unordered_map< int16_t,
std::vector< int > > 
allActorsThisReplica
 

Detailed Description

collection of producers

This class lets each actor keep track of destinations in a consistent way

Definition at line 139 of file Mbox.h.

Constructor & Destructor Documentation

Mboxes::Mboxes ( )

Definition at line 193 of file Mbox.cc.

193  : Mboxes(0)
194 {
195 }
Mboxes::Mboxes ( int64_t  nodeidarg)

collection of producers

Parameters
nodeidargnodeid

Definition at line 197 of file Mbox.cc.

References deadlockMgr, ibGateway, listener, MboxProducer::mbox, obGateway, topologyMgr, and userSchemaMgr.

197  : nodeid(nodeidarg),
198  topologyMgrPtr(NULL),
201  listenerPtr(NULL),
202  obGatewayPtr (NULL)
203 {
204  topologyMgr.mbox = NULL;
205  userSchemaMgr.mbox = NULL;
206  deadlockMgr.mbox = NULL;
207  listener.mbox = NULL;
208  ibGateway.mbox = NULL;
209  obGateway.mbox = NULL;
210 }
Mboxes::~Mboxes ( )
virtual

Definition at line 212 of file Mbox.cc.

213 {
214 }

Member Function Documentation

void Mboxes::sendObBatch ( )

send batched Message objects destined to remote nodes

Definition at line 551 of file Mbox.cc.

References MboxProducer::obBatchMsg, obGatewayPtr, and MboxProducer::sendMsg().

Referenced by DeadlockMgr::DeadlockMgr(), Engine::Engine(), MboxProducer::sendMsg(), TransactionAgent::TransactionAgent(), and UserSchemaMgr::UserSchemaMgr().

552 {
553  if (obGatewayPtr != NULL)
554  {
555  if (obGatewayPtr->obBatchMsg != NULL)
556  {
558  obGatewayPtr->obBatchMsg=NULL;
559  }
560  }
561 }

Here is the call graph for this function:

Here is the caller graph for this function:

void Mboxes::toActor ( const Topology::addressStruct source,
const Topology::addressStruct dest,
class Message msg 
)

produce Message for specific actor

Parameters
sourcesource address
destdestination address
msgMessage

Sends message by global actor address

Definition at line 347 of file Mbox.cc.

References Topology::addressStruct::actorid, actoridToProducers, Topology::addressStruct::nodeid, nodeid, obGatewayPtr, MboxProducer::sendMsg(), and Message::setEnvelope().

Referenced by Engine::apply(), Transaction::commit(), DeadlockMgr::deadlock(), TransactionAgent::handledispatch(), IbGateway::inbufhandler(), TransactionAgent::newprocedure(), UserSchemaMgr::operationHandler(), SubTransaction::replyTransaction(), toAllOfType(), toAllOfTypeThisReplica(), toDeadlockMgr(), and toUserSchemaMgr().

349 {
350  msg.setEnvelope(source, dest, msg);
351 
352  if (nodeid==dest.nodeid)
353  {
354  actoridToProducers[dest.actorid]->sendMsg(msg);
355  }
356  else
357  {
358  obGatewayPtr->sendMsg(msg);
359  }
360 }

Here is the call graph for this function:

Here is the caller graph for this function:

int64_t Mboxes::toAllOfType ( actortypes_e  type,
const Topology::addressStruct source,
class Message msg 
)

produce Message destined to all actors of type

Parameters
typedestination actor type
sourcesource address
msgMessage
Returns

Definition at line 389 of file Mbox.cc.

References allActors, Message::messageStruct, PAYLOADCOMMITROLLBACK, PAYLOADDEADLOCK, PAYLOADMESSAGE, PAYLOADSOCKET, PAYLOADSUBTRANSACTION, Message::message_s::payloadtype, PAYLOADUSERSCHEMA, and toActor().

Referenced by TransactionAgent::addcolumn(), TransactionAgent::compile(), TransactionAgent::createtable(), and TransactionAgent::schemaBoilerplate().

392 {
393  int64_t tally = 0;
394 
395  for (int16_t n=1; n < (int16_t)allActors.size(); n++)
396  {
397  for (int16_t m=FIRSTACTORID; m < (int16_t)allActors[n].size(); m++)
398  {
399  if (allActors[n][m] == (int)type)
400  {
401  switch (msg.messageStruct.payloadtype)
402  {
403  case PAYLOADMESSAGE:
404  {
405  class Message *nmsg = new class Message;
406  *nmsg = *((class Message *)&msg);
407  toActor(source, {n, m}, *nmsg);
408  }
409  break;
410 
411  case PAYLOADSOCKET:
412  {
413  class MessageSocket *nmsg = new class MessageSocket;
414  *nmsg = *((class MessageSocket *)&msg);
415  toActor(source, {n, m}, *nmsg);
416  }
417  break;
418 
419  case PAYLOADUSERSCHEMA:
420  {
421  class MessageUserSchema *nmsg = new class MessageUserSchema;
422  *nmsg = *((class MessageUserSchema *)&msg);
423  toActor(source, {n, m}, *nmsg);
424  }
425  break;
426 
427  case PAYLOADDEADLOCK:
428  {
429  class MessageDeadlock *nmsg = new class MessageDeadlock;
430  *nmsg = *((class MessageDeadlock *)&msg);
431  toActor(source, {n, m}, *nmsg);
432  }
433  break;
434 
436  {
437  class MessageSubtransactionCmd *nmsg =
438  new class MessageSubtransactionCmd;
439  *nmsg = *((class MessageSubtransactionCmd *)&msg);
440  toActor(source, {n, m}, *nmsg);
441  }
442  break;
443 
445  {
446  class MessageCommitRollback *nmsg =
447  new class MessageCommitRollback;
448  *nmsg = *((class MessageCommitRollback *)&msg);
449  toActor(source, {n, m}, *nmsg);
450  }
451  break;
452 
453  default:
454  printf("%s %i anomaly %i\n", __FILE__, __LINE__,
455  msg.messageStruct.payloadtype);
456  }
457 
458  tally++;
459  }
460  }
461  }
462 
463  return tally;
464 }

Here is the call graph for this function:

Here is the caller graph for this function:

int64_t Mboxes::toAllOfTypeThisReplica ( actortypes_e  type,
const Topology::addressStruct source,
class Message msg 
)

produce Message destined to all actors of type on current replica

Parameters
typedestination actor type
sourcesource address
msgMesage
Returns

Definition at line 466 of file Mbox.cc.

References allActors, allActorsThisReplica, Message::messageStruct, PAYLOADCOMMITROLLBACK, PAYLOADDEADLOCK, PAYLOADMESSAGE, PAYLOADSOCKET, PAYLOADSUBTRANSACTION, Message::message_s::payloadtype, PAYLOADUSERSCHEMA, and toActor().

469 {
470  int64_t tally = 0;
471 
472  boost::unordered_map< int16_t, vector<int> >::iterator it;
473 
474  for (it = allActorsThisReplica.begin(); it != allActorsThisReplica.end();
475  ++it)
476  {
477  for (int16_t m=FIRSTACTORID; m <
478  (int16_t)allActorsThisReplica[it->first].size(); m++)
479  {
480  if (allActorsThisReplica[it->first][m] == (int)type)
481  {
482  printf("%s %i n m %i %i allActors %i allActorsThisReplica %i\n",
483  __FILE__, __LINE__, it->first, m, allActors[it->first][m],
484  allActorsThisReplica[it->first][m]);
485 
486  switch (msg.messageStruct.payloadtype)
487  {
488  case PAYLOADMESSAGE:
489  {
490  class Message *nmsg = new class Message;
491  *nmsg = *((class Message *)&msg);
492  toActor(source, {it->first, m}, *nmsg);
493  }
494  break;
495 
496  case PAYLOADSOCKET:
497  {
498  class MessageSocket *nmsg = new class MessageSocket;
499  *nmsg = *((class MessageSocket *)&msg);
500  toActor(source, {it->first, m}, *nmsg);
501  }
502  break;
503 
504  case PAYLOADUSERSCHEMA:
505  {
506  class MessageUserSchema *nmsg = new class MessageUserSchema;
507  *nmsg = *((class MessageUserSchema *)&msg);
508  toActor(source, {it->first, m}, *nmsg);
509  }
510  break;
511 
512  case PAYLOADDEADLOCK:
513  {
514  class MessageDeadlock *nmsg = new class MessageDeadlock;
515  *nmsg = *((class MessageDeadlock *)&msg);
516  toActor(source, {it->first, m}, *nmsg);
517  }
518  break;
519 
521  {
522  class MessageSubtransactionCmd *nmsg =
523  new class MessageSubtransactionCmd;
524  *nmsg = *((class MessageSubtransactionCmd *)&msg);
525  toActor(source, {it->first, m}, *nmsg);
526  }
527  break;
528 
530  {
531  class MessageCommitRollback *nmsg =
532  new class MessageCommitRollback;
533  *nmsg = *((class MessageCommitRollback *)&msg);
534  toActor(source, {it->first, m}, *nmsg);
535  }
536  break;
537 
538  default:
539  printf("%s %i anomaly %i\n", __FILE__, __LINE__,
540  msg.messageStruct.payloadtype);
541  }
542 
543  tally++;
544  }
545  }
546  }
547 
548  return tally;
549 }

Here is the call graph for this function:

void Mboxes::toDeadlockMgr ( const Topology::addressStruct source,
class Message msg 
)

produce Message for replica's DeadlockMgr

Parameters
sourcesource address
msgMessage

Definition at line 368 of file Mbox.cc.

References Mboxes::location_s::address, deadlockMgrLocation, and toActor().

Referenced by Transaction::abortCmd(), Transaction::checkLock(), and Transaction::checkSqlLock().

370 {
371  toActor(source, deadlockMgrLocation.address, msg);
372 }

Here is the call graph for this function:

Here is the caller graph for this function:

void Mboxes::toPartition ( const Topology::addressStruct source,
int64_t  partitionid,
class Message msg 
)

produce Message for Engine associated with specific partition

Parameters
sourcesource address
partitioniddestination partition
msgMessage

Definition at line 374 of file Mbox.cc.

References Mboxes::location_s::address, Mboxes::location_s::destmbox, partitionToProducers, MboxProducer::sendMsg(), and Message::setEnvelope().

Referenced by Transaction::continueCommitTransaction(), TransactionAgent::handledispatch(), Transaction::rollback(), and Transaction::sendTransaction().

376 {
377  if (partitionid < 0 || (size_t)partitionid > partitionToProducers.size()-1)
378  {
379  printf("%s %i anomaly %li %lu\n", __FILE__, __LINE__, partitionid,
380  (unsigned long)partitionToProducers.size());
381  return;
382  }
383 
384  location_s &destLocation = partitionToProducers[partitionid];
385  msg.setEnvelope(source, destLocation.address, msg);
386  destLocation.destmbox->sendMsg(msg);
387 }

Here is the call graph for this function:

Here is the caller graph for this function:

void Mboxes::toUserSchemaMgr ( const Topology::addressStruct source,
class Message msg 
)

produce Message for replica's UserSchemaMgr

Parameters
sourcesource address
msgMessage

Definition at line 362 of file Mbox.cc.

References Mboxes::location_s::address, toActor(), and userSchemaMgrLocation.

Referenced by TransactionAgent::changepassword(), TransactionAgent::createdomain(), TransactionAgent::createuser(), TransactionAgent::deletedomain(), TransactionAgent::deleteuser(), TransactionAgent::login(), and TransactionAgent::schemaBoilerplate().

364 {
365  toActor(source, userSchemaMgrLocation.address, msg);
366 }

Here is the call graph for this function:

Here is the caller graph for this function:

void Mboxes::update ( class Topology top)

update Topology of producers

Parameters
topnode's authoritative Topology

Updates the set of MboxProducers based on updated Topology. Should be called by an actor after it receives a message from TopologyMgr that a change in nodeTopology has happened. Should be passed a Topology local to the actor.

Definition at line 220 of file Mbox.cc.

Referenced by TopologyMgr::broadcastConfig(), DeadlockMgr::DeadlockMgr(), Engine::Engine(), IbGateway::IbGateway(), Listener::Listener(), ObGateway::ObGateway(), TransactionAgent::TransactionAgent(), and UserSchemaMgr::UserSchemaMgr().

221 {
222  update(top, 0);
223 }

Here is the caller graph for this function:

void Mboxes::update ( class Topology top,
int64_t  myActorid 
)

update Topology of producers

Parameters
topnode's authoritative Topology
myActoridactorid for owning actor

Definition at line 225 of file Mbox.cc.

References Topology::addressStruct::actorid, actoridToProducers, Topology::actorList, Mboxes::location_s::address, Topology::allActors, allActors, Topology::allActorsThisReplica, allActorsThisReplica, deadlockMgrLocation, Topology::deadlockMgrNode, Mboxes::location_s::destmbox, enginePtrs, listenerPtr, Topology::addressStruct::nodeid, Topology::nodeid, nodeTopology, nodeTopologyMutex, Topology::numengines, Topology::numobgateways, Topology::numpartitions, Topology::numtransactionagents, obGatewayPtr, Topology::partitionListThisReplica, partitionToProducers, topologyMgrPtr, transactionAgentPtrs, userSchemaMgrLocation, and Topology::userSchemaMgrNode.

226 {
227  class Topology *newTop = new class Topology();
228  std::swap(*newTop, top);
229  delete newTop;
230  pthread_mutex_lock(&nodeTopologyMutex);
231  top = nodeTopology;
232  pthread_mutex_unlock(&nodeTopologyMutex);
233 
234  // new, so delete the previous logic when switched over
235  // local
236  actoridToProducers.resize(top.actorList.size(), NULL);
237  transactionAgentPtrs.resize(top.numtransactionagents, NULL);
238  enginePtrs.resize(top.numengines, NULL);
239 
240  for (size_t n=0; n < top.actorList.size(); n++)
241  {
242  if (actoridToProducers[n]==NULL)
243  {
244  if (top.actorList[n].type != ACTOR_NONE)
245  {
246  actoridToProducers[n] =
247  new class MboxProducer(top.actorList[n].mbox,top.nodeid);
248  actoridToProducers[n]->mboxes=this;
249  }
250 
251  switch (top.actorList[n].type)
252  {
253  case ACTOR_TRANSACTIONAGENT:
254  transactionAgentPtrs[top.actorList[n].instance] =
256  break;
257 
258  case ACTOR_ENGINE:
259  enginePtrs[top.actorList[n].instance] = actoridToProducers[n];
260  break;
261 
262  case ACTOR_TOPOLOGYMGR:
264  break;
265 
266  case ACTOR_LISTENER:
268  break;
269 
270  case ACTOR_USERSCHEMAMGR:
271  {
272  userSchemaMgrLocation.address.nodeid = top.nodeid;
275  }
276  break;
277 
278  case ACTOR_DEADLOCKMGR:
279  {
280  deadlockMgrLocation.address.nodeid = top.nodeid;
283  }
284  break;
285 
286  case ACTOR_IBGATEWAY:
287  break;
288 
289  case ACTOR_OBGATEWAY:
290  if ((int64_t)(myActorid % top.numobgateways) ==
291  top.actorList[n].instance)
292  {
294  }
295  break;
296 
297  case ACTOR_NONE:
298  break;
299 
300  default:
301  printf("%s %i unhandled actor type: %i\n", __FILE__, __LINE__,
302  top.actorList[n].type);
303  }
304  }
305  }
306 
307  // global
308  location_s emptyLocation = {};
309  partitionToProducers.resize(top.numpartitions, emptyLocation);
310 
311  for (size_t n=0; n < top.partitionListThisReplica.size(); n++)
312  {
313  if (partitionToProducers[n].address.nodeid==0)
314  {
315  partitionToProducers[n].address =
316  top.partitionListThisReplica[n].address;
317 
318  if (top.nodeid==partitionToProducers[n].address.nodeid)
319  {
320  partitionToProducers[n].destmbox =
321  actoridToProducers[partitionToProducers[n].address.actorid];
322  }
323  else
324  {
325  partitionToProducers[n].destmbox = obGatewayPtr;
326  }
327  }
328  }
329 
330  vector< vector<int> > aa = top.allActors;
331  allActors.swap(aa);
332  boost::unordered_map< int16_t, vector<int> > aatr = top.allActorsThisReplica;
333  allActorsThisReplica.swap(aatr);
334 
335  if (top.userSchemaMgrNode && (top.userSchemaMgrNode != top.nodeid))
336  {
337  userSchemaMgrLocation.address = {top.userSchemaMgrNode, 3};
338  }
339 
340  if (top.deadlockMgrNode && (top.deadlockMgrNode != top.nodeid))
341  {
342  deadlockMgrLocation.address = {top.deadlockMgrNode, 2};
343  }
344 }

Member Data Documentation

std::vector<class MboxProducer *> Mboxes::actoridToProducers

Definition at line 249 of file Mbox.h.

Referenced by TopologyMgr::broadcastConfig(), toActor(), and update().

std::vector< vector<int> > Mboxes::allActors

Definition at line 260 of file Mbox.h.

Referenced by toAllOfType(), toAllOfTypeThisReplica(), and update().

boost::unordered_map< int16_t, std::vector<int> > Mboxes::allActorsThisReplica

Definition at line 261 of file Mbox.h.

Referenced by toAllOfTypeThisReplica(), and update().

class MboxProducer Mboxes::deadlockMgr

Definition at line 241 of file Mbox.h.

Referenced by Mboxes().

location_s Mboxes::deadlockMgrLocation

Definition at line 254 of file Mbox.h.

Referenced by toDeadlockMgr(), and update().

std::vector<class MboxProducer *> Mboxes::enginePtrs

Definition at line 251 of file Mbox.h.

Referenced by update().

std::vector<class MboxProducer> Mboxes::engines

Definition at line 246 of file Mbox.h.

class MboxProducer Mboxes::ibGateway

Definition at line 244 of file Mbox.h.

Referenced by Mboxes().

class MboxProducer Mboxes::listener

Definition at line 242 of file Mbox.h.

Referenced by Mboxes().

class MboxProducer* Mboxes::listenerPtr

Definition at line 255 of file Mbox.h.

Referenced by update().

class MboxProducer Mboxes::obGateway

Definition at line 243 of file Mbox.h.

Referenced by Mboxes().

class MboxProducer* Mboxes::obGatewayPtr

Definition at line 256 of file Mbox.h.

Referenced by sendObBatch(), toActor(), and update().

std::vector<location_s> Mboxes::partitionToProducers

Definition at line 258 of file Mbox.h.

Referenced by toPartition(), and update().

class MboxProducer Mboxes::topologyMgr

Definition at line 239 of file Mbox.h.

Referenced by Mboxes().

class MboxProducer* Mboxes::topologyMgrPtr

Definition at line 252 of file Mbox.h.

Referenced by update().

std::vector<class MboxProducer *> Mboxes::transactionAgentPtrs

Definition at line 250 of file Mbox.h.

Referenced by Listener::Listener(), and update().

std::vector<class MboxProducer> Mboxes::transactionAgents

Definition at line 245 of file Mbox.h.

class MboxProducer Mboxes::userSchemaMgr

Definition at line 240 of file Mbox.h.

Referenced by Mboxes().

location_s Mboxes::userSchemaMgrLocation

Definition at line 253 of file Mbox.h.

Referenced by toUserSchemaMgr(), and update().


The documentation for this class was generated from the following files: