2015-05-30 20:00:46 +00:00
|
|
|
package influxdb
|
|
|
|
|
|
|
|
import (
|
|
|
|
"errors"
|
|
|
|
"fmt"
|
2015-06-10 18:18:16 +00:00
|
|
|
"strings"
|
2015-05-30 20:00:46 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
var (
|
|
|
|
// ErrFieldsRequired is returned when a point does not any fields.
|
|
|
|
ErrFieldsRequired = errors.New("fields required")
|
|
|
|
|
|
|
|
// ErrFieldTypeConflict is returned when a new field already exists with a different type.
|
|
|
|
ErrFieldTypeConflict = errors.New("field type conflict")
|
2016-02-24 13:34:19 +00:00
|
|
|
|
|
|
|
// ErrUpgradeEngine will be returned when it's determined that
|
|
|
|
// the server has encountered shards that are not in the `tsm1`
|
|
|
|
// format.
|
|
|
|
ErrUpgradeEngine = errors.New("\n\n" + upgradeMessage + "\n\n")
|
2015-05-30 20:00:46 +00:00
|
|
|
)
|
|
|
|
|
2015-10-07 13:38:30 +00:00
|
|
|
// ErrDatabaseNotFound indicates that a database operation failed on the
|
|
|
|
// specified database because the specified database does not exist.
|
2015-06-03 15:32:50 +00:00
|
|
|
func ErrDatabaseNotFound(name string) error { return fmt.Errorf("database not found: %s", name) }
|
2015-05-30 20:00:46 +00:00
|
|
|
|
2015-10-07 13:38:30 +00:00
|
|
|
// ErrRetentionPolicyNotFound indicates that the named retention policy could
|
|
|
|
// not be found in the database.
|
2015-09-17 01:31:03 +00:00
|
|
|
func ErrRetentionPolicyNotFound(name string) error {
|
|
|
|
return fmt.Errorf("retention policy not found: %s", name)
|
|
|
|
}
|
|
|
|
|
2015-05-30 20:00:46 +00:00
|
|
|
// IsClientError indicates whether an error is a known client error.
|
|
|
|
func IsClientError(err error) bool {
|
2015-06-10 18:18:16 +00:00
|
|
|
if err == nil {
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
2015-05-30 20:00:46 +00:00
|
|
|
if err == ErrFieldsRequired {
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
if err == ErrFieldTypeConflict {
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
|
2015-06-10 18:18:16 +00:00
|
|
|
if strings.Contains(err.Error(), ErrFieldTypeConflict.Error()) {
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
|
2015-05-30 20:00:46 +00:00
|
|
|
return false
|
|
|
|
}
|
2016-02-24 13:34:19 +00:00
|
|
|
|
|
|
|
const upgradeMessage = `*******************************************************************
|
|
|
|
UNSUPPORTED SHARD FORMAT DETECTED
|
|
|
|
|
|
|
|
As of version 0.11, only tsm shards are supported. Please use the
|
|
|
|
influx_tsm tool to convert non-tsm shards.
|
|
|
|
|
|
|
|
More information can be found at the documentation site:
|
|
|
|
https://docs.influxdata.com/influxdb/v0.10/administration/upgrading
|
|
|
|
*******************************************************************`
|