Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

vmware broker second algo

  • Loading branch information...
commit c8d6bea02cbed4be539eaafa53032984d34ba40a 1 parent 660891d
root authored
View
71 cluster/handlers-state.c
@@ -203,11 +203,16 @@ int doStartService(ncMetadata *ccMeta) {
sem_mywait(CONFIG);
if (config->ccState == SHUTDOWNCC) {
logprintfl(EUCAWARN, "StartService(): attempt to start a shutdown CC, skipping.\n");
- sem_mypost(CONFIG);
- return(ret);
+ ret++;
+ } else if (ccCheckState()) {
+ logprintfl(EUCAWARN, "StartService(): ccCheckState() returned failures, skipping.\n");
+ ret++;
+ } else {
+ logprintfl(EUCADEBUG, "StartService(): starting service\n");
+ ret=0;
+ config->kick_enabled = 0;
+ ccChangeState(DISABLED);
}
- config->kick_enabled = 0;
- ccChangeState(DISABLED);
sem_mypost(CONFIG);
logprintfl(EUCAINFO, "StartService(): done\n");
@@ -229,11 +234,16 @@ int doStopService(ncMetadata *ccMeta) {
sem_mywait(CONFIG);
if (config->ccState == SHUTDOWNCC) {
logprintfl(EUCAWARN, "StopService(): attempt to stop a shutdown CC, skipping.\n");
- sem_mypost(CONFIG);
- return(ret);
+ ret++;
+ } else if (ccCheckState()) {
+ logprintfl(EUCAWARN, "StopService(): ccCheckState() returned failures, skipping.\n");
+ ret++;
+ } else {
+ logprintfl(EUCADEBUG, "StopService(): stopping service\n");
+ ret=0;
+ config->kick_enabled = 0;
+ ccChangeState(STOPPED);
}
- config->kick_enabled = 0;
- ccChangeState(STOPPED);
sem_mypost(CONFIG);
logprintfl(EUCAINFO, "StopService(): done\n");
@@ -255,9 +265,13 @@ int doEnableService(ncMetadata *ccMeta) {
sem_mywait(CONFIG);
if (config->ccState == SHUTDOWNCC) {
logprintfl(EUCAWARN, "EnableService(): attempt to enable a shutdown CC, skipping.\n");
- sem_mypost(CONFIG);
- return(ret);
+ ret++;
+ } else if (ccCheckState()) {
+ logprintfl(EUCAWARN, "EnableService(): ccCheckState() returned failures, skipping.\n");
+ ret++;
} else if (config->ccState != ENABLED) {
+ logprintfl(EUCADEBUG, "EnableService(): enabling service\n");
+ ret=0;
// tell monitor thread to (re)enable
config->kick_monitor_running = 0;
config->kick_network = 1;
@@ -267,17 +281,19 @@ int doEnableService(ncMetadata *ccMeta) {
}
sem_mypost(CONFIG);
- // wait for a minute to make sure CC is running again
- done=0;
- for (i=0; i<60 && !done; i++) {
- sem_mywait(CONFIG);
- if (config->kick_monitor_running) {
- done++;
- }
- sem_mypost(CONFIG);
- if (!done) {
- logprintfl(EUCADEBUG, "EnableService(): waiting for monitor to re-initialize (%d/60)\n", i);
- sleep(1);
+ if (config->ccState == ENABLED) {
+ // wait for a minute to make sure CC is running again
+ done=0;
+ for (i=0; i<60 && !done; i++) {
+ sem_mywait(CONFIG);
+ if (config->kick_monitor_running) {
+ done++;
+ }
+ sem_mypost(CONFIG);
+ if (!done) {
+ logprintfl(EUCADEBUG, "EnableService(): waiting for monitor to re-initialize (%d/60)\n", i);
+ sleep(1);
+ }
}
}
@@ -300,11 +316,16 @@ int doDisableService(ncMetadata *ccMeta) {
sem_mywait(CONFIG);
if (config->ccState == SHUTDOWNCC) {
logprintfl(EUCAWARN, "DisableService(): attempt to disable a shutdown CC, skipping.\n");
- sem_mypost(CONFIG);
- return(ret);
+ ret++;
+ } else if (ccCheckState()) {
+ logprintfl(EUCAWARN, "DisableService(): ccCheckState() returned failures, skipping.\n");
+ ret++;
+ } else {
+ logprintfl(EUCADEBUG, "DisableService(): disabling service\n");
+ ret=0;
+ config->kick_enabled = 0;
+ ccChangeState(DISABLED);
}
- config->kick_enabled = 0;
- ccChangeState(DISABLED);
sem_mypost(CONFIG);
logprintfl(EUCAINFO, "DisableService(): done\n");
View
1  cluster/handlers-state.h
@@ -72,6 +72,7 @@ int doStartService(ncMetadata *ccMeta);
int doStopService(ncMetadata *ccMeta);
int doEnableService(ncMetadata *ccMeta);
int doDisableService(ncMetadata *ccMeta);
+int doShutdownService(ncMetadata *ccMeta);
int validCmp(ccInstance *inst, void *in);
int instNetParamsSet(ccInstance *inst, void *in);
View
13 cluster/handlers.c
@@ -2876,7 +2876,7 @@ int ccCheckState() {
bzero(chost, sizeof(char) * MAX_PATH);
rc = tokenize_uri(curi, uriType, chost, &port, path);
if (!strcmp(curi, buri)) {
- logprintfl(EUCAWARN, "ccCheckState(): detected local broker in not ready state\n");
+ logprintfl(EUCAWARN, "ccCheckState(): detected local broker (%s) matching local CC (%s) in NOTREADY state\n", config->notreadyServices[i].uris[j], config->ccStatus.serviceId.uris[0]);
}
}
}
@@ -2885,9 +2885,8 @@ int ccCheckState() {
}
snprintf(localDetails, 1023, "ERRORS=%d", ret);
- sem_mywait(CONFIG);
snprintf(config->ccStatus.details, 1023, "%s", localDetails);
- sem_mypost(CONFIG);
+
return(ret);
}
@@ -3036,18 +3035,16 @@ void *monitor_thread(void *in) {
}
}
+ // do state checks under CONFIG lock
+ sem_mywait(CONFIG);
if (ccCheckState()) {
logprintfl(EUCAERROR, "monitor_thread(): ccCheckState() returned failures\n");
- sem_mywait(CONFIG);
config->kick_enabled = 0;
ccChangeState(NOTREADY);
- sem_mypost(CONFIG);
} else if (config->ccState == NOTREADY) {
- sem_mywait(CONFIG);
ccChangeState(DISABLED);
- sem_mypost(CONFIG);
}
-
+ sem_mypost(CONFIG);
shawn();
logprintfl(EUCADEBUG, "monitor_thread(localState=%s): done\n", config->ccStatus.localState);
View
1  cluster/handlers.h
@@ -323,6 +323,7 @@ int changeState(ccResource *in, int newstate);
int ccIsEnabled(void);
int ccIsDisabled(void);
int ccChangeState(int newstate);
+int ccCheckState();
int ccGetStateString(char *outstr, int n);
int readConfigFile(char configFiles[][MAX_PATH], int numFiles);
Please sign in to comment.
Something went wrong with that request. Please try again.