本文整理汇总了Golang中github.com/outbrain/golib/log.Errore函数的典型用法代码示例。如果您正苦于以下问题:Golang Errore函数的具体用法?Golang Errore怎么用?Golang Errore使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Errore函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: ResetSlave
// ResetSlave resets a slave, breaking the replication
func ResetSlave(instanceKey *InstanceKey) (*Instance, error) {
instance, err := ReadTopologyInstance(instanceKey)
if err != nil {
return instance, log.Errore(err)
}
if instance.SlaveRunning() {
return instance, fmt.Errorf("Cannot reset slave on: %+v because slave is running", instanceKey)
}
if *config.RuntimeCLIFlags.Noop {
return instance, fmt.Errorf("noop: aborting reset-slave operation on %+v; signalling error but nothing went wrong.", *instanceKey)
}
// MySQL's RESET SLAVE is done correctly; however SHOW SLAVE STATUS still returns old hostnames etc
// and only resets till after next restart. This leads to orchestrator still thinking the instance replicates
// from old host. We therefore forcibly modify the hostname.
// RESET SLAVE ALL command solves this, but only as of 5.6.3
_, err = ExecInstanceNoPrepare(instanceKey, `change master to master_host='_'`)
if err != nil {
return instance, log.Errore(err)
}
_, err = ExecInstanceNoPrepare(instanceKey, `reset slave /*!50603 all */`)
if err != nil {
return instance, log.Errore(err)
}
log.Infof("Reset slave %+v", instanceKey)
instance, err = ReadTopologyInstance(instanceKey)
return instance, err
}
开发者ID:BrianIp,项目名称:orchestrator,代码行数:32,代码来源:instance_topology_dao.go
示例2: submitSeedStateEntry
// submitSeedStateEntry submits a seed state: a single step in the overall seed process
func submitSeedStateEntry(seedId int64, action string, errorMessage string) (int64, error) {
db, err := db.OpenOrchestrator()
if err != nil {
return 0, log.Errore(err)
}
res, err := sqlutils.Exec(db, `
insert
into agent_seed_state (
agent_seed_id, state_timestamp, state_action, error_message
) VALUES (
?, NOW(), ?, ?
)
`,
seedId,
action,
errorMessage,
)
if err != nil {
return 0, log.Errore(err)
}
id, err := res.LastInsertId()
return id, err
}
开发者ID:openark,项目名称:orchestrator,代码行数:26,代码来源:agent_dao.go
示例3: ExpireBlockedRecoveries
// ExpireBlockedRecoveries clears listing of blocked recoveries that are no longer actually blocked.
func ExpireBlockedRecoveries() error {
// Older recovery is acknowledged by now, hence blocked recovery should be released.
// Do NOTE that the data in blocked_topology_recovery is only used for auditing: it is NOT the data
// based on which we make automated decisions.
_, err := db.ExecOrchestrator(`
delete
from blocked_topology_recovery
using
blocked_topology_recovery
left join topology_recovery on (blocking_recovery_id = topology_recovery.recovery_id and acknowledged = 0)
where
acknowledged is null
`,
)
if err != nil {
return log.Errore(err)
}
// Some oversampling, if a problem has not been noticed for some time (e.g. the server came up alive
// before action was taken), expire it.
// Recall that RegisterBlockedRecoveries continuously updated the last_blocked_timestamp column.
_, err = db.ExecOrchestrator(`
delete
from blocked_topology_recovery
where
last_blocked_timestamp < NOW() - interval ? second
`, (config.Config.RecoveryPollSeconds * 5),
)
if err != nil {
return log.Errore(err)
}
return nil
}
开发者ID:dveeden,项目名称:orchestrator,代码行数:33,代码来源:topology_recovery_dao.go
示例4: StopSlave
// StopSlave stops replication on a given instance
func StopSlave(instanceKey *InstanceKey) (*Instance, error) {
instance, err := ReadTopologyInstance(instanceKey)
if err != nil {
return instance, log.Errore(err)
}
if !instance.IsSlave() {
return instance, fmt.Errorf("instance is not a slave: %+v", instanceKey)
}
_, err = ExecInstanceNoPrepare(instanceKey, `stop slave`)
if err != nil {
// Patch; current MaxScale behavior for STOP SLAVE is to throw an error if slave already stopped.
if instance.isMaxScale() && err.Error() == "Error 1199: Slave connection is not running" {
err = nil
}
}
if err != nil {
return instance, log.Errore(err)
}
instance, err = ReadTopologyInstance(instanceKey)
log.Infof("Stopped slave on %+v, Self:%+v, Exec:%+v", *instanceKey, instance.SelfBinlogCoordinates, instance.ExecBinlogCoordinates)
return instance, err
}
开发者ID:BrianIp,项目名称:orchestrator,代码行数:26,代码来源:instance_topology_dao.go
示例5: UpdateAgentInfo
// UpdateAgentInfo updates some agent state in backend table
func UpdateAgentInfo(hostname string, agent Agent) error {
db, err := db.OpenOrchestrator()
if err != nil {
return log.Errore(err)
}
_, err = sqlutils.Exec(db, `
update
host_agent
set
last_seen = NOW(),
mysql_port = ?,
count_mysql_snapshots = ?
where
hostname = ?`,
agent.MySQLPort,
len(agent.LogicalVolumes),
hostname,
)
if err != nil {
return log.Errore(err)
}
return nil
}
开发者ID:openark,项目名称:orchestrator,代码行数:26,代码来源:agent_dao.go
示例6: DetachSlave
// DetachSlave detaches a slave from replication; forcibly corrupting the binlog coordinates (though in such way
// that is reversible)
func DetachSlave(instanceKey *InstanceKey) (*Instance, error) {
instance, err := ReadTopologyInstance(instanceKey)
if err != nil {
return instance, log.Errore(err)
}
if instance.SlaveRunning() {
return instance, fmt.Errorf("Cannot detach slave on: %+v because slave is running", instanceKey)
}
isDetached, _, _ := instance.ExecBinlogCoordinates.DetachedCoordinates()
if isDetached {
return instance, fmt.Errorf("Cannot (need not) detach slave on: %+v because slave is already detached", instanceKey)
}
if *config.RuntimeCLIFlags.Noop {
return instance, fmt.Errorf("noop: aborting detach-slave operation on %+v; signalling error but nothing went wrong.", *instanceKey)
}
detachedCoordinates := BinlogCoordinates{LogFile: fmt.Sprintf("//%s:%d", instance.ExecBinlogCoordinates.LogFile, instance.ExecBinlogCoordinates.LogPos), LogPos: instance.ExecBinlogCoordinates.LogPos}
// Encode the current coordinates within the log file name, in such way that replication is broken, but info can still be resurrected
_, err = ExecInstanceNoPrepare(instanceKey, fmt.Sprintf(`change master to master_log_file='%s', master_log_pos=%d`, detachedCoordinates.LogFile, detachedCoordinates.LogPos))
if err != nil {
return instance, log.Errore(err)
}
log.Infof("Detach slave %+v", instanceKey)
instance, err = ReadTopologyInstance(instanceKey)
return instance, err
}
开发者ID:BrianIp,项目名称:orchestrator,代码行数:34,代码来源:instance_topology_dao.go
示例7: EndMaintenance
// EndMaintenance will terminate an active maintenance via maintenanceToken
func EndMaintenance(maintenanceToken int64) error {
db, err := db.OpenOrchestrator()
if err != nil {
return log.Errore(err)
}
res, err := sqlutils.Exec(db, `
update
database_instance_maintenance
set
maintenance_active = NULL,
end_timestamp = NOW()
where
database_instance_maintenance_id = ?
`,
maintenanceToken,
)
if err != nil {
return log.Errore(err)
}
if affected, _ := res.RowsAffected(); affected == 0 {
err = fmt.Errorf("Instance is not in maintenance mode; token = %+v", maintenanceToken)
} else {
// success
instanceKey, _ := ReadMaintenanceInstanceKey(maintenanceToken)
AuditOperation("end-maintenance", instanceKey, fmt.Sprintf("maintenanceToken: %d", maintenanceToken))
}
return err
}
开发者ID:shuhaowu,项目名称:orchestrator,代码行数:30,代码来源:maintenance_dao.go
示例8: ReattachSlave
// ReattachSlave restores a detached slave back into replication
func ReattachSlave(instanceKey *InstanceKey) (*Instance, error) {
instance, err := ReadTopologyInstance(instanceKey)
if err != nil {
return instance, log.Errore(err)
}
if instance.SlaveRunning() {
return instance, fmt.Errorf("Cannot (need not) reattach slave on: %+v because slave is running", instanceKey)
}
isDetached, detachedLogFile, detachedLogPos := instance.ExecBinlogCoordinates.DetachedCoordinates()
if !isDetached {
return instance, fmt.Errorf("Cannot reattach slave on: %+v because slave is not detached", instanceKey)
}
if *config.RuntimeCLIFlags.Noop {
return instance, fmt.Errorf("noop: aborting reattach-slave operation on %+v; signalling error but nothing went wrong.", *instanceKey)
}
_, err = ExecInstanceNoPrepare(instanceKey, fmt.Sprintf(`change master to master_log_file='%s', master_log_pos=%s`, detachedLogFile, detachedLogPos))
if err != nil {
return instance, log.Errore(err)
}
log.Infof("Reattach slave %+v", instanceKey)
instance, err = ReadTopologyInstance(instanceKey)
return instance, err
}
开发者ID:BrianIp,项目名称:orchestrator,代码行数:31,代码来源:instance_topology_dao.go
示例9: AttemptElection
// AttemptElection tries to grab leadership (become active node)
func AttemptElection() (bool, error) {
db, err := db.OpenOrchestrator()
if err != nil {
return false, log.Errore(err)
}
sqlResult, err := sqlutils.Exec(db, `
update active_node set
hostname = ?,
token = ?,
last_seen_active = now()
where
anchor = 1
and (
last_seen_active < now() - interval ? second
or hostname = ''
or (hostname = ? and token = ?)
)
`,
ThisHostname, ProcessToken.Hash, config.Config.ActiveNodeExpireSeconds, ThisHostname, ProcessToken.Hash,
)
if err != nil {
return false, log.Errore(err)
}
rows, err := sqlResult.RowsAffected()
return (rows > 0), err
}
开发者ID:shuhaowu,项目名称:orchestrator,代码行数:29,代码来源:election_dao.go
示例10: WriteClusterDomainName
// WriteClusterDomainName will write (and override) the domain name of a cluster
func WriteClusterDomainName(clusterName string, domainName string) error {
writeFunc := func() error {
db, err := db.OpenOrchestrator()
if err != nil {
return log.Errore(err)
}
_, err = sqlutils.Exec(db, `
insert into
cluster_domain_name (cluster_name, domain_name, last_registered)
values
(?, ?, NOW())
on duplicate key update
domain_name=values(domain_name),
last_registered=values(last_registered)
`,
clusterName,
domainName)
if err != nil {
return log.Errore(err)
}
return nil
}
return ExecDBWriteFunc(writeFunc)
}
开发者ID:ruo91,项目名称:orchestrator,代码行数:27,代码来源:cluster_domain_dao.go
示例11: EndDowntime
// EndDowntime will remove downtime flag from an instance
func EndDowntime(instanceKey *InstanceKey) error {
db, err := db.OpenOrchestrator()
if err != nil {
return log.Errore(err)
}
res, err := sqlutils.Exec(db, `
update
database_instance_downtime
set
downtime_active = NULL,
end_timestamp = NOW()
where
hostname = ?
and port = ?
and downtime_active = 1
`,
instanceKey.Hostname,
instanceKey.Port,
)
if err != nil {
return log.Errore(err)
}
if affected, _ := res.RowsAffected(); affected == 0 {
err = fmt.Errorf("Instance is not in downtime mode: %+v", instanceKey)
} else {
// success
AuditOperation("end-downtime", instanceKey, "")
}
return err
}
开发者ID:shuhaowu,项目名称:orchestrator,代码行数:33,代码来源:downtime_dao.go
示例12: queryResultData
// queryResultData returns a raw array of rows for a given query, optionally reading and returning column names
func queryResultData(db *sql.DB, query string, retrieveColumns bool, args ...interface{}) (ResultData, []string, error) {
var err error
defer func() {
if derr := recover(); derr != nil {
err = errors.New(fmt.Sprintf("QueryRowsMap unexpected error: %+v", derr))
}
}()
columns := []string{}
rows, err := db.Query(query, args...)
if err != nil && err != sql.ErrNoRows {
return EmptyResultData, columns, log.Errore(err)
}
defer rows.Close()
if retrieveColumns {
// Don't pay if you don't want to
columns, err = rows.Columns()
if err != nil {
return nil, nil, log.Errore(err)
}
}
resultData := ResultData{}
err = ScanRowsToArrays(rows, func(rowData []CellData) error {
resultData = append(resultData, rowData)
return nil
})
return resultData, columns, err
}
开发者ID:rbastic,项目名称:golib,代码行数:29,代码来源:sqlutils.go
示例13: ChangeMasterCredentials
// ChangeMasterCredentials issues a CHANGE MASTER TO... MASTER_USER=, MASTER_PASSWORD=...
func ChangeMasterCredentials(instanceKey *InstanceKey, masterUser string, masterPassword string) (*Instance, error) {
instance, err := ReadTopologyInstance(instanceKey)
if err != nil {
return instance, log.Errore(err)
}
if masterUser == "" {
return instance, log.Errorf("Empty user in ChangeMasterCredentials() for %+v", *instanceKey)
}
if instance.SlaveRunning() {
return instance, fmt.Errorf("ChangeMasterTo: Cannot change master on: %+v because slave is running", *instanceKey)
}
log.Debugf("ChangeMasterTo: will attempt changing master credentials on %+v", *instanceKey)
if *config.RuntimeCLIFlags.Noop {
return instance, fmt.Errorf("noop: aborting CHANGE MASTER TO operation on %+v; signalling error but nothing went wrong.", *instanceKey)
}
_, err = ExecInstanceNoPrepare(instanceKey, fmt.Sprintf("change master to master_user='%s', master_password='%s'",
masterUser, masterPassword))
if err != nil {
return instance, log.Errore(err)
}
log.Infof("ChangeMasterTo: Changed master credentials on %+v", *instanceKey)
instance, err = ReadTopologyInstance(instanceKey)
return instance, err
}
开发者ID:BrianIp,项目名称:orchestrator,代码行数:30,代码来源:instance_topology_dao.go
示例14: SkipQuery
// SkipQuery skip a single query in a failed replication instance
func SkipQuery(instanceKey *InstanceKey) (*Instance, error) {
instance, err := ReadTopologyInstance(instanceKey)
if err != nil {
return instance, log.Errore(err)
}
if !instance.IsSlave() {
return instance, fmt.Errorf("instance is not a slave: %+v", instanceKey)
}
if instance.Slave_SQL_Running {
return instance, fmt.Errorf("Slave SQL thread is running on %+v", instanceKey)
}
if instance.LastSQLError == "" {
return instance, fmt.Errorf("No SQL error on %+v", instanceKey)
}
if *config.RuntimeCLIFlags.Noop {
return instance, fmt.Errorf("noop: aborting skip-query operation on %+v; signalling error but nothing went wrong.", *instanceKey)
}
log.Debugf("Skipping one query on %+v", instanceKey)
if instance.UsingOracleGTID {
err = skipQueryOracleGtid(instance)
} else if instance.UsingMariaDBGTID {
return instance, log.Errorf("%+v is replicating with MariaDB GTID. To skip a query first disable GTID, then skip, then enable GTID again", *instanceKey)
} else {
err = skipQueryClassic(instance)
}
if err != nil {
return instance, log.Errore(err)
}
AuditOperation("skip-query", instanceKey, "Skipped one query")
return StartSlave(instanceKey)
}
开发者ID:BrianIp,项目名称:orchestrator,代码行数:35,代码来源:instance_topology_dao.go
示例15: UnresolveHostname
func UnresolveHostname(instanceKey *InstanceKey) (InstanceKey, bool, error) {
unresolvedHostname, err := readUnresolvedHostname(instanceKey.Hostname)
if err != nil {
return *instanceKey, false, log.Errore(err)
}
if unresolvedHostname == instanceKey.Hostname {
// unchanged. Nothing to do
return *instanceKey, false, nil
}
// We unresovled to a different hostname. We will now re-resolve to double-check!
unresolvedKey := &InstanceKey{Hostname: unresolvedHostname, Port: instanceKey.Port}
instance, err := ReadTopologyInstance(unresolvedKey)
if err != nil {
return *instanceKey, false, log.Errore(err)
}
if instance.Key.Hostname != instanceKey.Hostname {
// Resolve(Unresolve(hostname)) != hostname ==> Bad; reject
if *config.RuntimeCLIFlags.SkipUnresolveCheck {
return *instanceKey, false, nil
}
return *instanceKey, false, log.Errorf("Error unresolving; hostname=%s, unresolved=%s, re-resolved=%s; mismatch. Skip/ignore with --skip-unresolve-check", instanceKey.Hostname, unresolvedKey.Hostname, instance.Key.Hostname)
}
return *unresolvedKey, true, nil
}
开发者ID:shuhaowu,项目名称:orchestrator,代码行数:25,代码来源:resolve.go
示例16: acknowledgeRecoveries
// acknowledgeRecoveries sets acknowledged* details and clears the in_active_period flags from a set of entries
func acknowledgeRecoveries(owner string, comment string, markEndRecovery bool, whereClause string, args []interface{}) (countAcknowledgedEntries int64, err error) {
additionalSet := ``
if markEndRecovery {
additionalSet = `
end_recovery=IFNULL(end_recovery, NOW()),
`
}
query := fmt.Sprintf(`
update topology_recovery set
in_active_period = 0,
end_active_period_unixtime = IF(end_active_period_unixtime = 0, UNIX_TIMESTAMP(), end_active_period_unixtime),
%s
acknowledged = 1,
acknowledged_at = NOW(),
acknowledged_by = ?,
acknowledge_comment = ?
where
acknowledged = 0
and
%s
`, additionalSet, whereClause)
args = append(sqlutils.Args(owner, comment), args...)
sqlResult, err := db.ExecOrchestrator(query, args...)
if err != nil {
return 0, log.Errore(err)
}
rows, err := sqlResult.RowsAffected()
return rows, log.Errore(err)
}
开发者ID:BrianIp,项目名称:orchestrator,代码行数:30,代码来源:topology_recovery_dao.go
示例17: writePoolInstances
// writePoolInstances will write (and override) a single cluster name mapping
func writePoolInstances(pool string, instanceKeys [](*InstanceKey)) error {
writeFunc := func() error {
db, err := db.OpenOrchestrator()
if err != nil {
return log.Errore(err)
}
tx, err := db.Begin()
stmt, err := tx.Prepare(`delete from database_instance_pool where pool = ?`)
_, err = stmt.Exec(pool)
if err != nil {
tx.Rollback()
return log.Errore(err)
}
stmt, err = tx.Prepare(`insert into database_instance_pool (hostname, port, pool, registered_at) values (?, ?, ?, now())`)
for _, instanceKey := range instanceKeys {
_, err := stmt.Exec(instanceKey.Hostname, instanceKey.Port, pool)
if err != nil {
tx.Rollback()
return log.Errore(err)
}
}
if err != nil {
tx.Rollback()
return log.Errore(err)
}
tx.Commit()
return nil
}
return ExecDBWriteFunc(writeFunc)
}
开发者ID:enisoc,项目名称:orchestrator,代码行数:33,代码来源:pool_dao.go
示例18: HealthTest
// HealthTest attempts to write to the backend database and get a result
func HealthTest() (*HealthStatus, error) {
health := HealthStatus{Healthy: false, Hostname: ThisHostname, Token: ProcessToken.Hash}
sqlResult, err := RegisterNode("", "", false)
if err != nil {
health.Error = err
return &health, log.Errore(err)
}
rows, err := sqlResult.RowsAffected()
if err != nil {
health.Error = err
return &health, log.Errore(err)
}
health.Healthy = (rows > 0)
activeHostname, activeToken, isActive, err := ElectedNode()
if err != nil {
health.Error = err
return &health, log.Errore(err)
}
health.ActiveNode = fmt.Sprintf("%s;%s", activeHostname, activeToken)
health.IsActiveNode = isActive
health.AvailableNodes, err = ReadAvailableNodes(true)
return &health, nil
}
开发者ID:BrianIp,项目名称:orchestrator,代码行数:27,代码来源:health_dao.go
示例19: WriteLongRunningProcesses
// WriteLongRunningProcesses rewrites current state of long running processes for given instance
func WriteLongRunningProcesses(instanceKey *InstanceKey, processes []Process) error {
writeFunc := func() error {
db, err := db.OpenOrchestrator()
if err != nil {
return log.Errore(err)
}
_, err = sqlutils.Exec(db, `
delete from
database_instance_long_running_queries
where
hostname = ?
and port = ?
`,
instanceKey.Hostname,
instanceKey.Port)
if err != nil {
return log.Errore(err)
}
for _, process := range processes {
_, merr := sqlutils.Exec(db, `
insert into database_instance_long_running_queries (
hostname,
port,
process_id,
process_started_at,
process_user,
process_host,
process_db,
process_command,
process_time_seconds,
process_state,
process_info
) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`,
instanceKey.Hostname,
instanceKey.Port,
process.Id,
process.StartedAt,
process.User,
process.Host,
process.Db,
process.Command,
process.Time,
process.State,
process.Info,
)
if merr != nil {
err = merr
}
}
if err != nil {
return log.Errore(err)
}
return nil
}
return ExecDBWriteFunc(writeFunc)
}
开发者ID:shuhaowu,项目名称:orchestrator,代码行数:60,代码来源:process_dao.go
示例20: ExpireMaintenance
// ExpireMaintenance will remove the maintenance flag on old maintenances and on bounded maintenances
func ExpireMaintenance() error {
{
res, err := db.ExecOrchestrator(`
delete from
database_instance_maintenance
where
maintenance_active is null
and end_timestamp < NOW() - INTERVAL ? DAY
`,
config.Config.MaintenancePurgeDays,
)
if err != nil {
return log.Errore(err)
}
if rowsAffected, _ := res.RowsAffected(); rowsAffected > 0 {
AuditOperation("expire-maintenance", nil, fmt.Sprintf("Purged historical entries: %d", rowsAffected))
}
}
{
res, err := db.ExecOrchestrator(`
update
database_instance_maintenance
set
maintenance_active = NULL
where
maintenance_active = 1
and end_timestamp < NOW()
`,
)
if err != nil {
return log.Errore(err)
}
if rowsAffected, _ := res.RowsAffected(); rowsAffected > 0 {
AuditOperation("expire-maintenance", nil, fmt.Sprintf("Expired bounded: %d", rowsAffected))
}
}
{
res, err := db.ExecOrchestrator(`
update
database_instance_maintenance
left join node_health on (processing_node_hostname = node_health.hostname AND processing_node_token = node_health.token)
set
database_instance_maintenance.maintenance_active = NULL
where
node_health.last_seen_active IS NULL
and explicitly_bounded = 0
`,
)
if err != nil {
return log.Errore(err)
}
if rowsAffected, _ := res.RowsAffected(); rowsAffected > 0 {
AuditOperation("expire-maintenance", nil, fmt.Sprintf("Expired dead: %d", rowsAffected))
}
}
return nil
}
开发者ID:BrianIp,项目名称:orchestrator,代码行数:59,代码来源:maintenance_dao.go
注:本文中的github.com/outbrain/golib/log.Errore函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论