Пример #1
0
int main(int argc, char *argv[])
{
	int rc = ts_init();
	if (rc == -1)
		return 1;

	/* parse arguments */
	switch (ts_options_process(&tss.opts, argc, argv)) {
	case TS_MODE_USAGE:
		ts_options_free(&tss.opts);
		return ts_options_usage();
	case TS_MODE_VERSION:
		ts_options_free(&tss.opts);
		return 0;
	case TS_MODE_CREATE:
		break;
	}

	/* load configuration file */
	rc = ts_config_load(&tss.opts);
	if (rc == -1)
		goto done;

	/* create spaces */
	rc = ts_space_init(&tss.s);
	if (rc == -1)
		goto done;
	rc = ts_space_fill(&tss.s, &tss.opts);
	if (rc == -1)
		goto done;

	printf("work_dir: %s\n", tss.opts.cfg.work_dir);
	printf("snap_dir: %s\n", tss.opts.cfg.snap_dir);
	printf("wal_dir:  %s\n", tss.opts.cfg.wal_dir);
	printf("spaces:   %d\n", mh_size(tss.s.t));

	/* indexate snapshot and xlog data */
	rc = ts_indexate();
	if (rc == -1)
		goto done;
	/* write snapshot */
	rc = ts_snapshot_create();
	if (rc == -1)
		goto done;
	printf("complete.\n");

done:
	ts_free();
	return (rc == -1 ? 1 : 0);
}
Пример #2
0
int tc_verify(struct tc_options *opts)
{
	printf(">>> Signature file verification\n");

	/* 1. create spaces according to a configuration file */
	struct tc_spaces ss;
	int rc = tc_space_init(&ss);
	if (rc == -1)
		return -1;
	rc = tc_space_fill(&ss, opts);
	if (rc == -1)
		goto error;

	/* 2. load signature file */
	uint64_t last_xlog_lsn = 0;
	uint64_t last_snap_lsn = 0;
	rc = tc_file_load(&ss, (char*)opts->file, &last_xlog_lsn,
			  &last_snap_lsn);
	if (rc == -1)
		goto error;

	printf("(signature) loading %s\n", opts->file);

	printf("configured spaces: %"PRIu32"\n", mh_size(ss.t));
	printf("last xlog lsn: %"PRIu64"\n", last_xlog_lsn);
	printf("last snapshot lsn: %"PRIu64"\n", last_snap_lsn);
	
	/* 3. start verification process */
	rc = tc_verify_match(&ss, last_xlog_lsn, last_snap_lsn,
			     opts->cfg.snap_dir);

	printf("%s\n", (rc == 0) ? "OK": "FAILED");

	tc_space_free(&ss);
	return rc;
error:	
	tc_space_free(&ss);
	return -1;
}