順序の実行

前の項で作成した順序を実行するには、KVStore.execute()メソッドを使用します。

package kvstore.basicExample;

...

import oracle.kv.DurabilityException;
import oracle.kv.FaultException;
import oracle.kv.OperationExecutionException;
import oracle.kv.RequestTimeoutException;

...
            
try {
    kvstore.execute(opList);
} catch (OperationExecutionException oee) {
    // Some error occurred that prevented the sequence
    // from executing successfully. Use
    // oee.getFailedOperationIndex() to determine which
    // operation failed. Use oee.getFailedOperationResult()
    // to obtain an OperationResult object, which you can
    // use to troubleshoot the cause of the execution
    // exception.
} catch (DurabilityException de) {
    // The durability guarantee could not be met.
} catch (IllegalArgumentException iae) {
    // An operation in the list was null or empty.

    // Or at least one operation operates on a key
    // with a major path component that is different
    // than the others.

    // Or more than one operation uses the same key.
} catch (RequestTimeoutException rte) {
    // The operation was not completed inside of the
    // default request timeout limit.
} catch (FaultException fe) {
    // A generic error occurred
} 

前述の例外のいずれかがスローされると、順序全体が中止され、データは、順序を実行しなかった場合の状態になることに注意してください。

より詳細に指定できるKVStore.execute()も使用できます。次のものを指定できます。

  • 操作のリスト。

  • この順序に使用する永続性保証。デフォルトの永続性保証を使用する場合、このパラメータにnullを渡します。

  • 順序全体の処理に許される時間の上限を示すタイムアウト値。0を指定すると、デフォルトのリクエスト・タイムアウト値が使用されます。

  • タイムアウト値で使用される単位を表すTimeUnit。たとえば、TimeUnit.MILLISECONDSです。

WriteOptionsの使用例については、「永続性保証」を参照してください。