Library Version 12.1.6.0

DbEnv::rep_set_view()
Prev | Chapter 11. Replication Methods | Next

## DbEnv::rep_set_view()

    #include <db_cxx.h>

    int
    DbEnv::rep_set_view(int (*partial_func)(DB_ENV *dbenv,
        const char *name, int *result, u_int32_t flags));

The `DbEnv::rep_set_view()` method specifies that this environment is a replication view. A replication view is a special type of client that can contain a full or partial copy of the replicated data. A partial view uses a callback to determine the subset of database files to replicate. A replication view does not vote in elections, cannot become master, and cannot contribute to transactional durability.

The `DbEnv::rep_set_view()` method configures operations performed using the specified DbEnv handle, not all operations performed on the underlying database environment.

The `DbEnv::rep_set_view()` method must be called prior to opening the environment. Also the method must be called every time the environment is used after that point. Once an environment is configured as a view, it stays that way for the lifetime of the environment.

The `DbEnv::rep_set_view()` method either returns a non-zero error value or throws an exception that encapsulates a non-zero error value on failure, and returns 0 on success.

### Note

Berkeley DB is not re-entrant. The callback function for this method should not attempt to make library calls (for example, to release locks or close open handles). Re-entering Berkeley DB is not guaranteed to work correctly, and the results are undefined.

### Parameters

#### partial_func

The partial_func callback function determines whether a particular database file should be replicated to the local site. If a NULL callback is specified, all database files will be replicated. The parameters to partial_func are as follows:

- `dbenv`

  The dbenv parameter is the enclosing database environment handle.

- `name`

  The name parameter is the physical on-disk file name of the database. In-memory databases are always replicated and do not invoke this callback.

- `result`

  The result parameter is an output parameter indicating whether the file should be replicated. Set it to 0 to reject this file or to a non-zero value to accept this file.

- `flags`

  The flags parameter is currently unused.

The partial function must return 0 on success and non-zero on failure. If the partial function fails, the environment will panic.

### Errors

The `DbEnv::rep_set_view()` method may fail and throw a DbException exception, encapsulating one of the following non-zero errors, or return one of the following non-zero errors:

#### EINVAL

The method was called after the environment was opened.

### Class

DbEnv

### See Also

Replication and Related Methods

Prev | Up | Next
DbEnv::rep_set_transport() | Home | DbEnv::rep_start()