GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | ||||||||||||||||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | ||||||||||||||||||||||||||||||||||
GeezerVison is showing university.voltdb.com — @SnapshotRestore Using VoltDB@SnapshotRestore@SnapshotRestore — Restores a database from disk using a native format snapshot. Synopsis@SnapshotRestore String directory-path, String unique-ID @SnapshotRestore String json-encoded-options DescriptionThe @SnapshotRestore system procedure restores a previously saved database from disk to memory. The snapshot must be in native format. (You cannot restore a CSV format snapshot using @SnapshotRestore.) The restore request is propagated to all nodes of the cluster, so a single call to @SnapshotRestore will restore the entire database cluster. If the database is empty — that is, there is no data or schema defined in the database — the restore operation restores the schema and the requested data. If a schema is already defined, the restore operation restores data only for those tables defined in the current schema. There are two forms of the @SnapshotRestroe procedure, as described below. See Chapter 14, Saving & Restoring a VoltDB Database for more information about saving and restoring VoltDB databases. Individual ArgumentsWhen you specify the arguments as individual parameters, you must specify two arguments:
JSON-Encoded ArgumentsWhen you specify the arguments as a JSON-encoded string, you can specify not only what snapshot to use, but what data to restore from that snapshot. Table G.1, “@SnapshotRestoreOptions” describes the possible options when restoring a snapshot using JSON-encoded arguments. Table G.1. @SnapshotRestoreOptions
For example, the JSON-encoded arguments to restore the tables Employee and Company from the "mydb" snapshot in the /tmp directory is the following: {path:"/tmp",nonce:"mydb",tables:["employee","company"]}Return ValuesReturns one VoltTable with a row for every table restored at each execution site.
ExamplesThe following example uses @SnapshotRestore to restore previously saved database content from the path
$ sqlcmd 1> exec @SnapshotRestore '/tmp/voltdb/backup/', 'flight'; Alternately, you can use the voltadmin restore command to perform the same function: $ voltadmin restore /tmp/voltdb/backup/ flight Since there are a number of situations that impact what data is restored, it is a good idea to review the return values to see what tables and partitions were affected. In the following program example, the contents of the VoltTable array is written to standard output so the operator can confirm that the restore completed as expected. VoltTable[] results = null;
try {
results = client.callProcedureSync("@SnapshotRestore",
"/tmp/voltdb/backup/",
"flight").getResults();
}
catch (Exception e) {
e.printStackTrace();
}
for (int t=0; t<results.length; t++) {
VoltTable table = results[t];
for (int r=0;r<table.getRowCount();r++) {
VoltTableRow row = table.fetchRow(r);
System.out.printf("Node %d Site %d restoring " +
"table %s partition %d.\n",
row.getLong("HOST_ID"), row.getLong("SITE_ID"),
row.getString("TABLE"),row.getLong("PARTITION"));
}
}
| ||||||||||||||||||||||||||||||||||
| You are visitor 01402775 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |