Example #1
0
func (c ChangeIndexOptions) ValidateOrPanic() {
	if c.NumShards == 0 {
		base.LogPanic("The number of shards must be greater than 0")
	}

	// make sure num_shards is a power of two, or panic
	isPowerOfTwo := base.IsPowerOfTwo(c.NumShards)
	if !isPowerOfTwo {
		errMsg := "Invalid value for num_shards in feed_params: %v Must be a power of 2 so that all shards have the same number of vbuckets"
		base.LogPanic(errMsg, c.NumShards)
	}

}
Example #2
0
func ValidateConfigOrPanic(runMode SyncGatewayRunMode) {

	// if the user passes -skipRunModeValidation on the command line, then skip validation
	if config.SkipRunmodeValidation == true {
		base.Logf("Skipping runmode (accel vs normal) config validation")
		return
	}

	switch runMode {
	case SyncGatewayRunModeNormal:
		// if index writer == true for any databases, panic
		if config.HasAnyIndexWriterConfiguredDatabases() {
			base.LogPanic("SG is running in normal mode but there are databases configured as index writers")
		}
	case SyncGatewayRunModeAccel:
		// if index writer != true for any databases, panic
		if config.HasAnyIndexReaderConfiguredDatabases() {
			base.LogPanic("SG is running in sg-accelerator mode but there are databases configured as index readers")
		}
	}

}