@StopNode

Documentation

VoltDB Home » Documentation » Using VoltDB

@StopNode

@StopNode — Stops a VoltDB server process, removing the node from the cluster.

Synopsis

@StopNode Integer host-ID

Description

The @StopNode system procedure lets you stop a specific server in a K-safe cluster. You specify which node to stop using the host ID, which is the unique identifier for the node assigned by VoltDB when the server joins the cluster.

Note that by calling the @StopNode procedure on a node other than the node being stopped, you will receive a return status indicating the success or failure of the call. If you call the procedure on the node that you are requesting to stop, the return status can only indicate that the call was interrupted (by the VoltDB process on the node stopping), not whether it was successfully completed or not.

If you call @StopNode on a node or cluster that is not K-safe — either because it was started with a K-safety value of zero or one or more nodes have failed so any further failure could crash the database — the @StopNode procedure will not be executed. You can only stop nodes on a cluster that will remain viable after the node stops. To stop the entire cluster, please use the voltadmin shutdown command.

Return Values

Returns one VoltTable with one row.

NameDatatypeDescription
STATUSBIGINTAlways returns the value zero (0) indicating success.

Examples

The following program example uses grep, sqlcmd, and the @SystemInformation stored procedure to identify the host ID for a specific node (doodah) of the cluster. The example then uses that host ID (2) to call @StopNode and stop the desired node.

$ echo "exec @SystemInformation overview;" | sqlcmd | grep "doodah"
       2 HOSTNAME                doodah
$ sqlcmd
1> exec @StopNode 2;

The next example uses the voltadmin stop command to perform the same action. Note that voltadmin stop performs the translation from a network name to a host ID for you.

$ voltadmin stop doodah

The following Java code fragment performs the same function programmatically.

try {
     results = client.callProcedure("@SystemInformation",
                                    "overview").getResults();
}
catch (Exception e) { e.printStackTrace(); }

VoltTable table = results[0];
table.resetRowPosition();
int targetHostID = -1;

while (table.advanceRow() && targetHostId < 0) { 
    if ( (table.getString("KEY") == "HOSTNAME") && 
            (table.getString("VALUE") == targetHostName) ) {
         targetHostId = (int) table.getLong("HOST_ID");
    }
} 

try {
      client.callProcedure("@SStopNode", 
                           targetHostId).getResults();
   }
  catch (Exception e) { e.printStackTrace(); }