~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/plugin/scheduler.cc

  • Committer: Lee Bieber
  • Date: 2010-11-07 19:34:48 UTC
  • mfrom: (1910.1.2 build)
  • Revision ID: kalebral@gmail.com-20101107193448-64kdu912qej354sh
Merge Stewart - including adapting and expanding the "differences from mysql" page from the wiki.
Merge Stewart - fix bug 668143: drizzleslap with --commit runs second iteration data load in a transaction

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2
2
 *  vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
3
3
 *
4
 
 *  Copyright (C) 2008 Sun Microsystems, Inc.
 
4
 *  Copyright (C) 2008 Sun Microsystems
5
5
 *
6
6
 *  This program is free software; you can redistribute it and/or modify
7
7
 *  it under the terms of the GNU General Public License as published by
26
26
#include "drizzled/gettext.h"
27
27
#include "drizzled/errmsg_print.h"
28
28
 
 
29
using namespace std;
 
30
 
29
31
namespace drizzled
30
32
{
31
33
 
32
34
extern size_t my_thread_stack_size;
33
35
 
34
 
std::vector<plugin::Scheduler *> all_schedulers;
 
36
vector<plugin::Scheduler *> all_schedulers;
35
37
 
36
38
/* Globals (TBK) */
37
39
static plugin::Scheduler *scheduler= NULL;
38
40
 
39
41
 
40
 
class FindSchedulerByName : public std::unary_function<plugin::Scheduler *, bool>
 
42
class FindSchedulerByName : public unary_function<plugin::Scheduler *, bool>
41
43
{
42
 
  const std::string *name;
 
44
  const string *name;
43
45
public:
44
 
  FindSchedulerByName(const std::string *name_arg)
 
46
  FindSchedulerByName(const string *name_arg)
45
47
    : name(name_arg) {}
46
48
  result_type operator() (argument_type sched)
47
49
  {
52
54
 
53
55
bool plugin::Scheduler::addPlugin(plugin::Scheduler *sched)
54
56
{
55
 
  std::vector<plugin::Scheduler *>::iterator iter=
56
 
    std::find_if(all_schedulers.begin(), all_schedulers.end(), 
 
57
  vector<plugin::Scheduler *>::iterator iter=
 
58
    find_if(all_schedulers.begin(), all_schedulers.end(), 
57
59
            FindSchedulerByName(&sched->getName()));
58
60
 
59
61
  if (iter != all_schedulers.end())
60
62
  {
61
 
    errmsg_printf(error::ERROR,
 
63
    errmsg_printf(ERRMSG_LVL_ERROR,
62
64
                  _("Attempted to register a scheduler %s, but a scheduler "
63
65
                    "has already been registered with that name.\n"),
64
66
                    sched->getName().c_str());
74
76
 
75
77
void plugin::Scheduler::removePlugin(plugin::Scheduler *sched)
76
78
{
77
 
  all_schedulers.erase(std::find(all_schedulers.begin(),
 
79
  all_schedulers.erase(find(all_schedulers.begin(),
78
80
                            all_schedulers.end(),
79
81
                            sched));
80
82
}
81
83
 
82
84
 
83
 
bool plugin::Scheduler::setPlugin(const std::string& name)
 
85
bool plugin::Scheduler::setPlugin(const string& name)
84
86
{
85
 
  std::vector<plugin::Scheduler *>::iterator iter=
86
 
    std::find_if(all_schedulers.begin(), all_schedulers.end(), 
 
87
  vector<plugin::Scheduler *>::iterator iter=
 
88
    find_if(all_schedulers.begin(), all_schedulers.end(), 
87
89
            FindSchedulerByName(&name));
88
90
 
89
91
  if (iter != all_schedulers.end())
95
97
    return false;
96
98
  }
97
99
 
98
 
  errmsg_printf(error::WARN,
 
100
  errmsg_printf(ERRMSG_LVL_WARN,
99
101
                _("Attempted to configure %s as the scheduler, which did "
100
102
                  "not exist.\n"), name.c_str());
101
103
  return true;