CM支持start/stop -I
This commit is contained in:
parent
e9ff888085
commit
076eddece0
@ -92,24 +92,24 @@ ResStatus GetResInstStatus(uint32 instId)
|
||||
return result;
|
||||
}
|
||||
|
||||
status_t CheckResInstInfo(uint32 nodeId, uint32 instId)
|
||||
status_t CheckResInstInfo(uint32 *nodeId, uint32 instId)
|
||||
{
|
||||
for (uint32 i = 0; i < CusResCount(); ++i) {
|
||||
(void)pthread_rwlock_rdlock(&g_resStatus[i].rwlock);
|
||||
for (uint32 j = 0; j < g_resStatus[i].status.instanceCount; ++j) {
|
||||
if (g_resStatus[i].status.resStat[j].cmInstanceId != instId) {
|
||||
continue;
|
||||
}
|
||||
if (g_resStatus[i].status.resStat[j].nodeId != nodeId) {
|
||||
if (*nodeId == 0) {
|
||||
*nodeId = g_resStatus[i].status.resStat[j].nodeId;
|
||||
return CM_SUCCESS;
|
||||
}
|
||||
if (g_resStatus[i].status.resStat[j].nodeId != *nodeId) {
|
||||
write_runlog(FATAL, "resource(%s) instance(%u) is in node(%u) not in node(%u).\n",
|
||||
g_resStatus[i].status.resName, instId, g_resStatus[i].status.resStat[j].nodeId, nodeId);
|
||||
(void)pthread_rwlock_unlock(&g_resStatus[i].rwlock);
|
||||
g_resStatus[i].status.resName, instId, g_resStatus[i].status.resStat[j].nodeId, *nodeId);
|
||||
return CM_ERROR;
|
||||
}
|
||||
(void)pthread_rwlock_unlock(&g_resStatus[i].rwlock);
|
||||
return CM_SUCCESS;
|
||||
}
|
||||
(void)pthread_rwlock_unlock(&g_resStatus[i].rwlock);
|
||||
}
|
||||
write_runlog(FATAL, "instanceId(%u) is not a resource instanceId.\n", instId);
|
||||
return CM_ERROR;
|
||||
|
@ -31,7 +31,7 @@ static void StartUsage(const char *projectName)
|
||||
projectName);
|
||||
#else
|
||||
(void)printf(_(" %s start [-z AVAILABILITY_ZONE [--cm_arbitration_mode=ARBITRATION_MODE]] | "
|
||||
"[-n NODEID [-D DATADIR | -I RESOURCE_INSTANCE_ID]] [-t SECS] \n"),
|
||||
"[-n NODEID [-D DATADIR]] | [-I RESOURCE_INSTANCE_ID [-n NODEID]] [-t SECS] \n"),
|
||||
projectName);
|
||||
#endif
|
||||
}
|
||||
@ -67,7 +67,7 @@ static void UsageHelp(const char *projectName)
|
||||
(void)printf(_(" %s view [-v | -N | -n NODEID | -c] [-l FILENAME]\n"), projectName);
|
||||
(void)printf(_(" %s disable -n NODEID -D DATADIR [-t SECS]\n"), projectName);
|
||||
#else
|
||||
(void)printf(_(" %s stop [[-z AVAILABILITY_ZONE] | [-n NODEID [-D DATADIR | -I RESOURCE_INSTANCE_ID]]] [-t SECS] "
|
||||
(void)printf(_(" %s stop [[-z AVAILABILITY_ZONE] | [-n NODEID [-D DATADIR]] | [-I RESOURCE_INSTANCE_ID [-n NODEID]]] [-t SECS] "
|
||||
"[-m SHUTDOWN-MODE]\n"), projectName);
|
||||
(void)printf(_(" %s query [-z ALL] [-l FILENAME] [-v [-C [-s] [-S] [-d] [-i] [-F] [-x] [-p]] | [-r]] [-t SECS] "
|
||||
"[--minorityAz=AZ_NAME]\n"), projectName);
|
||||
|
@ -247,7 +247,7 @@ status_t do_start(void)
|
||||
|
||||
(void)clock_gettime(CLOCK_MONOTONIC, &g_startTime);
|
||||
/* start the whole cluster */
|
||||
if (g_command_operation_azName == NULL && g_commandOperationNodeId == 0) {
|
||||
if (g_commandOperationInstanceId == 0 && g_command_operation_azName == NULL && g_commandOperationNodeId == 0) {
|
||||
#ifdef ENABLE_MULTIPLE_NODES
|
||||
if (cn_resumes_restart) {
|
||||
write_stderr(_("%s: enable resuming the fault CN.\n"), g_progname);
|
||||
@ -322,8 +322,8 @@ status_t do_start(void)
|
||||
/* start a az with availability zone name */
|
||||
write_runlog(LOG, "start the availability zone: %s. \n", g_command_operation_azName);
|
||||
start_az(g_command_operation_azName);
|
||||
} else if (g_commandOperationNodeId > 0 && g_commandOperationInstanceId > 0) {
|
||||
if (CheckResInstInfo(g_commandOperationNodeId, g_commandOperationInstanceId) != CM_SUCCESS) {
|
||||
} else if (g_commandOperationInstanceId > 0) {
|
||||
if (CheckResInstInfo(&g_commandOperationNodeId, g_commandOperationInstanceId) != CM_SUCCESS) {
|
||||
write_runlog(ERROR, "can't do start resource instance, instId:%u.\n", g_commandOperationInstanceId);
|
||||
return CM_ERROR;
|
||||
}
|
||||
|
@ -147,15 +147,14 @@ int DoStop(void)
|
||||
}
|
||||
#endif
|
||||
|
||||
if (g_command_operation_azName == NULL && g_commandOperationNodeId == 0) {
|
||||
if (g_commandOperationInstanceId == 0 && g_command_operation_azName == NULL && g_commandOperationNodeId == 0) {
|
||||
write_runlog(LOG, "stop cluster. \n");
|
||||
stop_cluster();
|
||||
} else if (g_command_operation_azName != NULL) {
|
||||
write_runlog(LOG, "stop the availability zone: %s. \n", g_command_operation_azName);
|
||||
|
||||
stop_az(g_command_operation_azName);
|
||||
} else if ((g_commandOperationNodeId > 0) && (g_commandOperationInstanceId > 0)) {
|
||||
if (CheckResInstInfo(g_commandOperationNodeId, g_commandOperationInstanceId) != CM_SUCCESS) {
|
||||
} else if (g_commandOperationInstanceId > 0) {
|
||||
if (CheckResInstInfo(&g_commandOperationNodeId, g_commandOperationInstanceId) != CM_SUCCESS) {
|
||||
write_runlog(ERROR, "can't do stop resource instance, instId:%u.\n", g_commandOperationInstanceId);
|
||||
return 1;
|
||||
}
|
||||
|
@ -28,6 +28,6 @@
|
||||
#include "cm_defs.h"
|
||||
|
||||
ResStatus GetResInstStatus(uint32 instId);
|
||||
status_t CheckResInstInfo(uint32 nodeId, uint32 instId);
|
||||
status_t CheckResInstInfo(uint32 *nodeId, uint32 instId);
|
||||
|
||||
#endif // CM_CTL_COMMON_RES_H
|
||||
|
Loading…
x
Reference in New Issue
Block a user