Interface ClusterNodeProvider
Note: Sometimes the documentation of methods in this class refers to the current node - that is either the current component or the node component to which the current wrapped is connected (if running remotely).
- Since:
- 4.0
-
Method Summary
Modifier and TypeMethodDescriptionbooleanAdds a new node on the current node and synchronizes the change into the cluster.Adds a new node on the current node and synchronizes the change into the cluster.consoleCommand(@NonNull String name) Get an information about a specific registered command on the current node.Get an information about a specific registered command on the current node.Get all commands which are registered on the current node.Get all commands which are registered on the current node.consoleTabCompleteResults(@NonNull String commandLine) Gets all tab complete results for the next argument in the provided command line.consoleTabCompleteResultsAsync(@NonNull String commandLine) Gets all tab complete results for the next argument in the provided command line.Get the network cluster node object association from the given node unique id registered on the current node.Get the network cluster node object association from the given node unique id registered on the current node.nodeInfoSnapshot(@NonNull String uniqueId) Get the network cluster node snapshot of the node with the given unique id.nodeInfoSnapshotAsync(@NonNull String uniqueId) Get the network cluster node snapshot of the node with the given unique id.Get the network cluster node snapshots of all nodes which are currently connected to the current node.Get the network cluster node snapshots of all nodes which are currently connected to the current node.nodes()Gets all nodes which are currently registered on the current node.Gets all nodes which are currently registered on the current node.booleanremoveNode(@NonNull String uniqueId) Removes the given node on the current node and synchronizes the change into the cluster.removeNodeAsync(@NonNull String uniqueId) Removes the given node on the current node and synchronizes the change into the cluster.sendCommandLine(@NonNull String commandLine) Sends the given command line to the current node and returns the output of the command from the execution.sendCommandLineAsync(@NonNull String commandLine) Sends the given command line to the current node and returns the output of the command from the execution.
-
Method Details
-
consoleCommands
Get all commands which are registered on the current node. Additions and removals to the returned collection are not possible and will not have any effect. There is no way to register a command from this provider because remote commands are not supported. You need to use the node command provider to register a command on the current node.- Returns:
- all registered commands.
-
consoleCommand
Get an information about a specific registered command on the current node. This method returns null if no command with the given name is present on the current node.- Parameters:
name- the name of the command to get the information of.- Returns:
- the command info of the command with the given name or null if no such command exists.
- Throws:
NullPointerException- if the given command name is null.
-
consoleTabCompleteResults
@NonNull @NonNull Collection<String> consoleTabCompleteResults(@NonNull @NonNull String commandLine) Gets all tab complete results for the next argument in the provided command line. An empty command line will list all root command names. This method resolves all tab completion results which are allowed to be executed via a console command source. This does not mean that the api is actually able to execute the command. For example, if the input istasksone suggestion might besetup(which will start the task console setup animation), the api is not allowed to execute that command but the result will be listed anyway.- Parameters:
commandLine- the current command line input to start the tab completion based on.- Returns:
- the suggestions for further input based on the current command line.
- Throws:
NullPointerException- if the given command line is null.
-
sendCommandLine
Sends the given command line to the current node and returns the output of the command from the execution. Only lines which were sent to the command sender are returned, lines send to the console directly are not caught by this method.- Parameters:
commandLine- the command line to execute.- Returns:
- all lines send to the command sender associated with this method call.
- Throws:
NullPointerException- if the given command line is null.
-
nodes
Gets all nodes which are currently registered on the current node. As per the CloudNet cluster contract, each node must know all other nodes in the cluster. Therefore, the returned collection is not synced with the cluster. Additions and removals to the returned collection are not possible and will not have a result, use the add/remove node methods for that purpose.- Returns:
- all nodes which are registered on the current node.
-
node
Get the network cluster node object association from the given node unique id registered on the current node. This method returns null if no node with the given unique is registered on the local node.- Parameters:
uniqueId- the unique id of the node to get the associated object of.- Returns:
- the cluster node object registered on the current node or null if no node with the given name is present.
- Throws:
NullPointerException- if the given unique id is null.
-
addNode
Adds a new node on the current node and synchronizes the change into the cluster. This method has no effect if a node with the same unique id is already present. This will also update the ip whitelist of all nodes and adds all network listeners of the given cluster node to it.After registering the node it can directly connect to the node the action was executed on. There is no guarantee that the method has an immediate effect on all nodes.
- Parameters:
node- the node to register.- Returns:
- true if the node was registered successfully, false otherwise.
- Throws:
NullPointerException- if the given node to register is null.
-
removeNode
Removes the given node on the current node and synchronizes the change into the cluster. This method has no effect if no node with the given unique id is registered on the current node. This will also update the ip whitelist of all nodes and removes all network listeners of the given cluster node from it.This method has an immediate effect. All nodes will disconnect the node and mark all services started on it as removed. The node has no chance after the method call to reconnect to the cluster until it was added again.
- Parameters:
uniqueId- the unique id of the node to remove.- Returns:
- true if the node was removed successfully, false otherwise.
- Throws:
NullPointerException- if the given node unique id is null.
-
nodeInfoSnapshots
Get the network cluster node snapshots of all nodes which are currently connected to the current node. A node might be registered and able to connect to the cluster, but will not appear in the list when it is not connected (or didn't send a snapshot after the connection yet).The returned snapshot collection is not modifiable as additions or removals from it will have no effect.
- Returns:
- the snapshot information of all nodes which are currently connected to the current node.
-
nodeInfoSnapshot
Get the network cluster node snapshot of the node with the given unique id. This method returns null either if no node with the given unique id exists or the node is currently not connected. If the existence of a node should get checked, usenode(String)instead.- Parameters:
uniqueId- the unique id of the node to get the snapshot of.- Returns:
- the snapshot of the node or null if no node with the given id is registered or the node is not connected.
- Throws:
NullPointerException- if the given node unique id is null.
-
consoleCommandsAsync
Get all commands which are registered on the current node. Additions and removals to the returned collection are not possible and will not have any effect. There is no way to register a command from this provider because remote commands are not supported. You need to use the node command provider to register a command on the current node.- Returns:
- a task completed with all registered commands.
-
consoleCommandAsync
Get an information about a specific registered command on the current node. This method returns null if no command with the given name is present on the current node.- Parameters:
name- the name of the command to get the information of.- Returns:
- a task completed with the info of the command with the given name or null if no such command exists.
- Throws:
NullPointerException- if the given command name is null.
-
consoleTabCompleteResultsAsync
@NonNull @NonNull CompletableFuture<Collection<String>> consoleTabCompleteResultsAsync(@NonNull @NonNull String commandLine) Gets all tab complete results for the next argument in the provided command line. An empty command line will list all root command names. This method resolves all tab completion results which are allowed to be executed via a console command source. This does not mean that the api is actually able to execute the command. For example, if the input istaskone suggestion might besetup(which will start the task console setup animation), the api is not allowed to execute that command but the result will be listed anyway.- Parameters:
commandLine- the current command line input to start the tab completion based on.- Returns:
- a task completed with the suggestions for further input based on the current command line.
- Throws:
NullPointerException- if the given command line is null.
-
sendCommandLineAsync
@NonNull @NonNull CompletableFuture<Collection<String>> sendCommandLineAsync(@NonNull @NonNull String commandLine) Sends the given command line to the current node and returns the output of the command from the execution. Only lines which were sent to the command sender are returned, lines send to the console directly are not caught by this method.- Parameters:
commandLine- the command line to execute.- Returns:
- a task completed with all lines send to the command sender associated with this method call.
- Throws:
NullPointerException- if the given command line is null.
-
nodesAsync
Gets all nodes which are currently registered on the current node. As per the CloudNet cluster contract, each node must know all other nodes in the cluster. Therefore, the returned collection is not synced with the cluster. Additions and removals to the returned collection are not possible will not have a result, use the add/remove node methods for that purpose.- Returns:
- a task completed with all nodes which are registered on the current node.
-
nodeAsync
@NonNull @NonNull CompletableFuture<NetworkClusterNode> nodeAsync(@NonNull @NonNull String uniqueId) Get the network cluster node object association from the given node unique id registered on the current node. This method returns null if no node with the given unique is registered on the local node.- Parameters:
uniqueId- the unique id of the node to get the associated object of.- Returns:
- a task completed with the cluster node object associated with the given unique id or null if unknown.
- Throws:
NullPointerException- if the given unique id is null.
-
addNodeAsync
@NonNull @NonNull CompletableFuture<Boolean> addNodeAsync(@NonNull @NonNull NetworkClusterNode node) Adds a new node on the current node and synchronizes the change into the cluster. This method has no effect if a node with the same unique id is already present. This will also update the ip whitelist of all nodes and adds all network listeners of the given cluster node to it.After registering the node it can directly connect to the node the action was executed on. There is no guarantee that the method has an immediate effect on all nodes.
- Parameters:
node- the node to register.- Returns:
- a task completed with true if the node was registered successfully, false otherwise.
- Throws:
NullPointerException- if the given node to register is null.
-
removeNodeAsync
Removes the given node on the current node and synchronizes the change into the cluster. This method has no effect if no node with the given unique id is registered on the current node. This will also update the ip whitelist of all nodes and removes all network listeners of the given cluster node from it.This method has an immediate effect. All nodes will disconnect the node and mark all services started on it as removed. The node has no chance after the method call to reconnect to the cluster until it was added again.
- Parameters:
uniqueId- the unique id of the node to remove.- Returns:
- a task completed with true if the node was removed successfully, false otherwise.
- Throws:
NullPointerException- if the given node unique id is null.
-
nodeInfoSnapshotsAsync
Get the network cluster node snapshots of all nodes which are currently connected to the current node. A node might be registered and able to connect to the cluster, but will not appear in the list when it is not connected (or didn't send a snapshot after the connection yet).The returned snapshot collection is not modifiable as additions or removals from it will have no effect.
- Returns:
- a task completed with the snapshot of all nodes which are currently connected to the current node.
-
nodeInfoSnapshotAsync
@NonNull @NonNull CompletableFuture<NodeInfoSnapshot> nodeInfoSnapshotAsync(@NonNull @NonNull String uniqueId) Get the network cluster node snapshot of the node with the given unique id. This method returns null either if no node with the given unique id exists or the node is currently not connected. If the existence of a node should get checked, usenode(String)instead.- Parameters:
uniqueId- the unique id of the node to get the snapshot of.- Returns:
- a task completed with the snapshot of the node or null if the node is not registered or connected.
- Throws:
NullPointerException- if the given node unique id is null.
-