Specifying Server Operation Name, Transaction Type, and Formal Parameters

For each class you derive from ostc_ServerOperation, the constructor must do the following:

Example

txfer_operation::txfer_operation() : 
      ostc_ServerOperation("transfer", ostc::isolated_update)
{
      addArgument("from_acct_name", ostc::ostc_string);
      addArgument("to_acct_name", ostc::ostc_string);
      addArgument("amount", ostc::ostc_float);

      addReturnSetAttribute("val", ostc::ostc_float);
      addReturnSetAttribute("name", ostc::ostc_string);
}

Operation Name

"transfer" is the name of the operation. It must be passed to the base type constructor.

Transaction Type

ostc::isolated_update is the type of transaction to use to execute the operation. As with the operation name, it must be passed to the base type constructor. Use this type of transaction for operations that update persistent data. The possible transaction types are

With read_only, mvccRead, and shared_update, requests from different thin clients are batched into the same ObjectStore transaction. This increases throughput by reducing commit overhead.

Important note

Use shared_update only with extreme care. Using shared_update inappropriately can cause incorrect results and database corruption.

With any, the router chooses a Server running any type of transaction. The operation must be read-only if there are read or mvccRead Servers running. The operation must be safe for batch transactions if there are shared_update Servers running.

An operations that uses the transaction type none must access no persistent data.

Formal Parameters

Each call to addArgument() specifies an argument name and type. These are the same names and types that the thin client must use when setting the actual arguments.

addReturnSetAttribute() specifies the attribute name and value type for an attribute of the returned objects. Call this function onece for each attribute you want the returned objects to have.

Click here for the example in context.

Type Enumerators

The types are specified with enumerators defined in the scope of the class ostc. The following table shows what type each enumerator signifies:

ostc_int32 32-bit integer
ostc_int64 64-bit integer
ostc_string char*
ostc_float float
ostc_double double
ostc_oid ostc_OID* (object identifier set by user)
ostc_binary void* (for bit streams)



[previous] [next]