nodeadminmutator

package
v0.0.0-...-4334ecd Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 18, 2020 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var AddNode = &graphql.Field{
	Type:        graphql.Boolean,
	Description: "Add new node to the cluster",
	Args: graphql.FieldConfigArgument{
		"nodeID": &graphql.ArgumentConfig{
			Description: "Node ID",
			Type:        graphql.NewNonNull(kind.GQLUInt64Type),
		},

		"address": &graphql.ArgumentConfig{
			Description: "Raft address of the node",
			Type:        graphql.NewNonNull(graphql.String),
		},

		"configChangeIndex": &graphql.ArgumentConfig{
			Description: "Config change index",
			Type:        graphql.NewNonNull(kind.GQLUInt64Type),
		},
	},
	Resolve: func(p graphql.ResolveParams) (interface{}, error) {
		nodeID := p.Args["nodeID"].(*kind.UInt64)
		address := p.Args["address"].(string)
		configChangeIndex := p.Args["configChangeIndex"].(*kind.UInt64)

		nodeAdmin, ok := p.Source.(*flamed.NodeAdmin)
		if !ok {
			return nil, nil
		}
		err := nodeAdmin.AddNode(nodeID.Value(), address, configChangeIndex.Value())
		if err != nil {
			return nil, gqlerrors.NewFormattedError(err.Error())
		}

		return true, nil
	},
}
View Source
var AddObserver = &graphql.Field{
	Type:        graphql.Boolean,
	Description: "Add new node to the cluster",
	Args: graphql.FieldConfigArgument{
		"nodeID": &graphql.ArgumentConfig{
			Description: "Node ID",
			Type:        graphql.NewNonNull(kind.GQLUInt64Type),
		},

		"address": &graphql.ArgumentConfig{
			Description: "Raft address of the node",
			Type:        graphql.NewNonNull(graphql.String),
		},

		"configChangeIndex": &graphql.ArgumentConfig{
			Description: "Config change index",
			Type:        graphql.NewNonNull(kind.GQLUInt64Type),
		},
	},
	Resolve: func(p graphql.ResolveParams) (interface{}, error) {
		nodeID := p.Args["nodeID"].(*kind.UInt64)
		address := p.Args["address"].(string)
		configChangeIndex := p.Args["configChangeIndex"].(*kind.UInt64)

		nodeAdmin, ok := p.Source.(*flamed.NodeAdmin)
		if !ok {
			return nil, nil
		}
		err := nodeAdmin.AddObserver(nodeID.Value(), address, configChangeIndex.Value())
		if err != nil {
			return nil, gqlerrors.NewFormattedError(err.Error())
		}

		return true, nil
	},
}
View Source
var AddWitness = &graphql.Field{
	Type:        graphql.Boolean,
	Description: "Add new node to the cluster",
	Args: graphql.FieldConfigArgument{
		"nodeID": &graphql.ArgumentConfig{
			Description: "Node ID",
			Type:        graphql.NewNonNull(kind.GQLUInt64Type),
		},

		"address": &graphql.ArgumentConfig{
			Description: "Raft address of the node",
			Type:        graphql.NewNonNull(graphql.String),
		},

		"configChangeIndex": &graphql.ArgumentConfig{
			Description: "Config change index",
			Type:        graphql.NewNonNull(kind.GQLUInt64Type),
		},
	},
	Resolve: func(p graphql.ResolveParams) (interface{}, error) {
		nodeID := p.Args["nodeID"].(*kind.UInt64)
		address := p.Args["address"].(string)
		configChangeIndex := p.Args["configChangeIndex"].(*kind.UInt64)

		nodeAdmin, ok := p.Source.(*flamed.NodeAdmin)
		if !ok {
			return nil, nil
		}
		err := nodeAdmin.AddWitness(nodeID.Value(), address, configChangeIndex.Value())
		if err != nil {
			return nil, gqlerrors.NewFormattedError(err.Error())
		}

		return true, nil
	},
}
View Source
var BuildIndex = &graphql.Field{
	Type:        graphql.Boolean,
	Description: "Build or rebuild full state database index",
	Resolve: func(p graphql.ResolveParams) (interface{}, error) {
		nodeAdmin, ok := p.Source.(*flamed.NodeAdmin)
		if !ok {
			return false, nil
		}
		nodeAdmin.BuildIndex()
		return true, nil
	},
}
View Source
var BuildIndexByNamespace = &graphql.Field{
	Type:        graphql.Boolean,
	Description: "Build or rebuild state database index by namespace",
	Args: graphql.FieldConfigArgument{
		"namespace": &graphql.ArgumentConfig{
			Description: "Namespace",
			Type:        graphql.NewNonNull(graphql.String),
		},
	},
	Resolve: func(p graphql.ResolveParams) (interface{}, error) {
		namespace := p.Args["namespace"].(string)
		namespaceBytes := []byte(namespace)
		if !utility.IsNamespaceValid(namespaceBytes) {
			return nil, gqlerrors.NewFormattedError(x.ErrInvalidNamespace.Error())
		}

		nodeAdmin, ok := p.Source.(*flamed.NodeAdmin)
		if !ok {
			return false, nil
		}

		nodeAdmin.BuildIndexByNamespace(namespaceBytes)
		return true, nil
	},
}
View Source
var DeleteNode = &graphql.Field{
	Type:        graphql.Boolean,
	Description: "Add new node to the cluster",
	Args: graphql.FieldConfigArgument{
		"nodeID": &graphql.ArgumentConfig{
			Description: "Node ID",
			Type:        graphql.NewNonNull(kind.GQLUInt64Type),
		},
		"configChangeIndex": &graphql.ArgumentConfig{
			Description: "Config change index",
			Type:        graphql.NewNonNull(kind.GQLUInt64Type),
		},
	},
	Resolve: func(p graphql.ResolveParams) (interface{}, error) {
		nodeID := p.Args["nodeID"].(*kind.UInt64)
		configChangeIndex := p.Args["configChangeIndex"].(*kind.UInt64)

		nodeAdmin, ok := p.Source.(*flamed.NodeAdmin)
		if !ok {
			return nil, nil
		}
		err := nodeAdmin.DeleteNode(nodeID.Value(), configChangeIndex.Value())
		if err != nil {
			return nil, gqlerrors.NewFormattedError(err.Error())
		}

		return true, nil
	},
}
View Source
var GQLNodeAdminMutatorType = graphql.NewObject(graphql.ObjectConfig{
	Name:        "NodeAdminMutator",
	Description: "`NodeAdminMutator` gives the ability to perform administrative tasks of the cluster",
	Fields: graphql.Fields{

		"addNode": AddNode,

		"addObserver": AddObserver,

		"addWitness": AddWitness,

		"deleteNode": DeleteNode,

		"runStorageGC": RunStorageGC,

		"buildIndex": BuildIndex,

		"buildIndexByNamespace": BuildIndexByNamespace,

		"requestSnapshot": RequestSnapshot,
	},
})
View Source
var RequestSnapshot = &graphql.Field{
	Type:        kind.GQLUInt64Type,
	Description: "Add new node to the cluster",
	Args: graphql.FieldConfigArgument{
		"compactionOverhead": &graphql.ArgumentConfig{
			Description: "Compaction overhead",
			Type:        graphql.NewNonNull(kind.GQLUInt64Type),
		},
		"exported": &graphql.ArgumentConfig{
			Description: "Will the snapshot be exported?",
			Type:        graphql.NewNonNull(graphql.Boolean),
		},
		"overrideCompactionOverhead": &graphql.ArgumentConfig{
			Description: "Compaction overhead override flag",
			Type:        graphql.NewNonNull(graphql.Boolean),
		},
	},
	Resolve: func(p graphql.ResolveParams) (interface{}, error) {
		compactionOverhead := p.Args["compactionOverhead"].(*kind.UInt64)
		exported := p.Args["exported"].(bool)
		overrideCompactionOverhead := p.Args["overrideCompactionOverhead"].(bool)
		exportPath := viper.GetString(constant.StoragePath) + "/snapshot"
		utility.MkPath(exportPath)
		nodeAdmin, ok := p.Source.(*flamed.NodeAdmin)
		if !ok {
			return nil, nil
		}
		n, err := nodeAdmin.RequestSnapshot(compactionOverhead.Value(),
			exportPath,
			exported,
			overrideCompactionOverhead)

		if err != nil {
			return nil, gqlerrors.NewFormattedError(err.Error())
		}

		return kind.NewUInt64FromUInt64(n), nil
	},
}
View Source
var RunStorageGC = &graphql.Field{
	Type:        graphql.Boolean,
	Description: "Run storage garbage collector",
	Resolve: func(p graphql.ResolveParams) (interface{}, error) {
		nodeAdmin, ok := p.Source.(*flamed.NodeAdmin)
		if !ok {
			return false, nil
		}
		nodeAdmin.RunStorageGC()
		return true, nil
	},
}

Functions

This section is empty.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL