CUBRID Engine  latest
boot.h
Go to the documentation of this file.
1 /*
2  * Copyright 2008 Search Solution Corporation
3  * Copyright 2016 CUBRID Corporation
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  */
18 
19 /*
20  * boot.h - Boot management common header
21  */
22 
23 #ifndef _BOOT_H_
24 #define _BOOT_H_
25 
26 #include "client_credentials.hpp"
27 #include "es_common.h"
28 #include "porting.h"
29 #include "storage_common.h"
30 
31 #include <stdio.h>
32 
33 #define BOOT_NORMAL_CLIENT_TYPE(client_type) \
34  ((client_type) == DB_CLIENT_TYPE_DEFAULT \
35  || (client_type) == DB_CLIENT_TYPE_CSQL \
36  || (client_type) == DB_CLIENT_TYPE_READ_ONLY_CSQL \
37  || (client_type) == DB_CLIENT_TYPE_SKIP_VACUUM_CSQL \
38  || (client_type) == DB_CLIENT_TYPE_BROKER \
39  || (client_type) == DB_CLIENT_TYPE_READ_ONLY_BROKER \
40  || (client_type) == DB_CLIENT_TYPE_RW_BROKER_REPLICA_ONLY \
41  || (client_type) == DB_CLIENT_TYPE_RO_BROKER_REPLICA_ONLY)
42 
43 #define BOOT_READ_ONLY_CLIENT_TYPE(client_type) \
44  ((client_type) == DB_CLIENT_TYPE_READ_ONLY_CSQL \
45  || (client_type) == DB_CLIENT_TYPE_READ_ONLY_BROKER \
46  || (client_type) == DB_CLIENT_TYPE_SLAVE_ONLY_BROKER \
47  || (client_type) == DB_CLIENT_TYPE_RO_BROKER_REPLICA_ONLY \
48  || (client_type) == DB_CLIENT_TYPE_SO_BROKER_REPLICA_ONLY)
49 
50 #define BOOT_ADMIN_CLIENT_TYPE(client_type) \
51  ((client_type) == DB_CLIENT_TYPE_ADMIN_UTILITY \
52  || (client_type) == DB_CLIENT_TYPE_ADMIN_COMPACTDB_WOS \
53  || (client_type) == DB_CLIENT_TYPE_ADMIN_CSQL \
54  || (client_type) == DB_CLIENT_TYPE_ADMIN_CSQL_WOS \
55  || (client_type) == DB_CLIENT_TYPE_SKIP_VACUUM_ADMIN_CSQL)
56 
57 #define BOOT_LOG_REPLICATOR_TYPE(client_type) \
58  ((client_type) == DB_CLIENT_TYPE_LOG_COPIER \
59  || (client_type) == DB_CLIENT_TYPE_LOG_APPLIER)
60 
61 #define BOOT_CSQL_CLIENT_TYPE(client_type) \
62  ((client_type) == DB_CLIENT_TYPE_CSQL \
63  || (client_type) == DB_CLIENT_TYPE_READ_ONLY_CSQL \
64  || (client_type) == DB_CLIENT_TYPE_SKIP_VACUUM_CSQL \
65  || (client_type) == DB_CLIENT_TYPE_SKIP_VACUUM_ADMIN_CSQL \
66  || (client_type) == DB_CLIENT_TYPE_ADMIN_CSQL \
67  || (client_type) == DB_CLIENT_TYPE_ADMIN_CSQL_WOS)
68 
69 #define BOOT_BROKER_AND_DEFAULT_CLIENT_TYPE(client_type) \
70  ((client_type) == DB_CLIENT_TYPE_DEFAULT \
71  || (client_type) == DB_CLIENT_TYPE_BROKER \
72  || (client_type) == DB_CLIENT_TYPE_READ_ONLY_BROKER \
73  || (client_type) == DB_CLIENT_TYPE_SLAVE_ONLY_BROKER \
74  || BOOT_REPLICA_ONLY_BROKER_CLIENT_TYPE(client_type))
75 
76 #define BOOT_REPLICA_ONLY_BROKER_CLIENT_TYPE(client_type) \
77  ((client_type) == DB_CLIENT_TYPE_RW_BROKER_REPLICA_ONLY \
78  || (client_type) == DB_CLIENT_TYPE_RO_BROKER_REPLICA_ONLY \
79  || (client_type) == DB_CLIENT_TYPE_SO_BROKER_REPLICA_ONLY)
80 
81 #define BOOT_WRITE_ON_STANDY_CLIENT_TYPE(client_type) \
82  ((client_type) == DB_CLIENT_TYPE_LOG_APPLIER \
83  || (client_type) == DB_CLIENT_TYPE_RW_BROKER_REPLICA_ONLY \
84  || (client_type) == DB_CLIENT_TYPE_ADMIN_CSQL_WOS \
85  || (client_type) == DB_CLIENT_TYPE_ADMIN_COMPACTDB_WOS)
86 
87 /*
88  * BOOT_IS_ALLOWED_CLIENT_TYPE_IN_MT_MODE()
89  * ((broker_default type || (remote && csql or broker_default type)) ? 0 : 1)
90  */
91 #define BOOT_IS_ALLOWED_CLIENT_TYPE_IN_MT_MODE(host1, host2, client_type) \
92  ((BOOT_BROKER_AND_DEFAULT_CLIENT_TYPE(client_type) || \
93  ((host1 != NULL && strcmp (host1, host2)) && \
94  (BOOT_CSQL_CLIENT_TYPE(client_type) \
95  || BOOT_BROKER_AND_DEFAULT_CLIENT_TYPE(client_type)))) ? 0 : 1)
96 
97 #define BOOT_IS_PREFERRED_HOSTS_SET(credential) \
98  ((credential)->preferred_hosts != NULL \
99  && (credential)->preferred_hosts[0] != '\0')
100 
103 {
104  char *db_path;
105  char *vol_path;
106  char *log_path;
107  char *lob_path;
108  char *db_host;
109  char *db_comments;
110 };
111 
112 /*
113  * HA server state
114  */
116 {
117  HA_SERVER_STATE_NA = -1, /* N/A */
118  HA_SERVER_STATE_IDLE = 0, /* initial state */
123  HA_SERVER_STATE_MAINTENANCE = 5, /* maintenance mode */
124  HA_SERVER_STATE_DEAD = 6 /* server is dead - virtual state; not exists */
125 };
127 #define HA_SERVER_STATE_IDLE_STR "idle"
128 #define HA_SERVER_STATE_ACTIVE_STR "active"
129 #define HA_SERVER_STATE_TO_BE_ACTIVE_STR "to-be-active"
130 #define HA_SERVER_STATE_STANDBY_STR "standby"
131 #define HA_SERVER_STATE_TO_BE_STANDBY_STR "to-be-standby"
132 #define HA_SERVER_STATE_MAINTENANCE_STR "maintenance"
133 #define HA_SERVER_STATE_DEAD_STR "dead"
134 
137 {
138  char *db_full_name; /* PATH_MAX */
139  char *host_name; /* CUB_MAXHOSTNAMELEN */
140  char *lob_path; /* PATH_MAX + LOB_PATH_PREFIX_MAX */
147  HA_SERVER_STATE ha_server_state; /* HA_SERVER_STATE */
148  char server_session_key[SERVER_SESSION_KEY_SIZE];
150  char *db_lang;
151 };
152 
154 
155 #define LOB_PATH_PREFIX_MAX ES_URI_PREFIX_MAX
156 #define LOB_PATH_DEFAULT_PREFIX ES_POSIX_PATH_PREFIX
157 
158 /* Compose the full name of a database */
159 
160 inline void
161 COMPOSE_FULL_NAME (char *buf, size_t buf_size, const char *path, const char *name)
162 {
163  size_t len = strlen (path);
164  int ret;
165  if (len > 0 && path[len - 1] != PATH_SEPARATOR)
166  {
167  ret = snprintf (buf, buf_size - 1, "%s%c%s", path, PATH_SEPARATOR, name);
168  }
169  else
170  {
171  ret = snprintf (buf, buf_size - 1, "%s%s", path, name);
172  }
173  if (ret < 0)
174  {
175  abort ();
176  }
177 }
178 #endif /* _BOOT_H_ */
char * lob_path
Definition: boot.h:107
char * db_path
Definition: boot.h:104
float disk_compatibility
Definition: boot.h:146
char * db_comments
Definition: boot.h:109
char * db_host
Definition: boot.h:108
char boot_Host_name[CUB_MAXHOSTNAMELEN]
Definition: boot_cl.c:158
PGLENGTH log_page_size
Definition: boot.h:145
PGLENGTH page_size
Definition: boot.h:144
ha_server_state
Definition: boot.h:115
char * vol_path
Definition: boot.h:105
HA_SERVER_STATE ha_server_state
Definition: boot.h:147
void COMPOSE_FULL_NAME(char *buf, size_t buf_size, const char *path, const char *name)
Definition: boot.h:161
INT16 PGLENGTH
#define strlen(s1)
Definition: intl_support.c:43
#define SERVER_SESSION_KEY_SIZE
enum ha_server_state HA_SERVER_STATE
Definition: boot.h:126
#define CUB_MAXHOSTNAMELEN
Definition: porting.h:379
char * db_full_name
Definition: boot.h:138
#define PATH_SEPARATOR
Definition: porting.h:347
char * log_path
Definition: boot.h:106