1 /* 2 Copyright (c) 2007, 2014, Oracle and/or its affiliates. All rights reserved. 3 4 This program is free software; you can redistribute it and/or modify 5 it under the terms of the GNU General Public License, version 2.0, 6 as published by the Free Software Foundation. 7 8 This program is also distributed with certain software (including 9 but not limited to OpenSSL) that is licensed under separate terms, 10 as designated in a particular file or component or in included license 11 documentation. The authors of MySQL hereby grant you an additional 12 permission to link the program and your derivative works with the 13 separately licensed software that they have included with MySQL. 14 15 This program is distributed in the hope that it will be useful, 16 but WITHOUT ANY WARRANTY; without even the implied warranty of 17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 GNU General Public License, version 2.0, for more details. 19 20 You should have received a copy of the GNU General Public License 21 along with this program; if not, write to the Free Software 22 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 23 */ 24 25 #ifndef NDBT_MIX_RESTARTER_HPP 26 #define NDBT_MIX_RESTARTER_HPP 27 28 #include <ndb_global.h> 29 #include <mgmapi.h> 30 #include <Vector.hpp> 31 #include <BaseString.hpp> 32 #include "NdbRestarter.hpp" 33 #include "NDBT_Test.hpp" 34 35 #define NMR_SR "SR" 36 #define NMR_SR_THREADS_ACTIVE "SR_ThreadsActiveCount" 37 #define NMR_SR_VALIDATE_THREADS "SR_ValidateThreadCount" 38 #define NMR_SR_VALIDATE_THREADS_ACTIVE "SR_ValidateThreadsActiveCount" 39 40 class NdbMixRestarter : public NdbRestarter 41 { 42 public: 43 enum RestartTypeMask 44 { 45 RTM_RestartCluster = 0x01, 46 RTM_RestartNode = 0x02, 47 RTM_RestartNodeInitial = 0x04, 48 RTM_StopNode = 0x08, 49 RTM_StopNodeInitial = 0x10, 50 RTM_StartNode = 0x20, 51 52 RTM_COUNT = 6, 53 54 RTM_ALL = 0xFF, 55 RTM_SR = RTM_RestartCluster, 56 RTM_NR = 0x2 | 0x4 | 0x8 | 0x10 | 0x20 57 }; 58 59 enum SR_State { 60 SR_RUNNING = 0, 61 SR_STOPPING = 1, 62 SR_STOPPED = 2, 63 SR_VALIDATING = 3 64 }; 65 66 NdbMixRestarter(unsigned * seed = 0, const char* _addr = 0); 67 ~NdbMixRestarter(); 68 69 void setRestartTypeMask(Uint32 mask); 70 int runUntilStopped(NDBT_Context* ctx, NDBT_Step* step, Uint32 freq); 71 int runPeriod(NDBT_Context* ctx, NDBT_Step* step, Uint32 time, Uint32 freq); 72 73 int init(NDBT_Context* ctx, NDBT_Step* step); 74 int dostep(NDBT_Context* ctx, NDBT_Step* step); 75 int finish(NDBT_Context* ctx, NDBT_Step* step); 76 77 private: 78 unsigned * seed; 79 unsigned ownseed; 80 Uint32 m_mask; 81 Vector<ndb_mgm_node_state> m_nodes; 82 int restart_cluster(NDBT_Context* ctx, NDBT_Step* step, bool abort = false); 83 }; 84 85 #endif 86