前の項で作成した順序を実行するには、TableAPI.execute()
メソッドを使用します。
package kvstore.basicExample; try { tableH.execute(opList, null); } 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 (IllegalArgumentException iae) { // An operation in the list was null or empty. // Or at least one operation operates on a row // with a shard key that is different // than the others. // Or more than one operation uses the same key. } catch (DurabilityException de) { // The durability guarantee could not be met. } catch (RequestTimeoutException rte) { // The operation was not completed inside of the // default request timeout limit. } catch (FaultException fe) { // A generic error occurred }
前述の例外のいずれかがスローされると、順序全体が中止され、データは、順序を実行しなかった場合の状態になることに注意してください。
TableAPI.execute()
はオプションでWriteOptions
クラス・インスタンスを取得できます。このクラス・インスタンスでは、次のものを指定できます。
この順序に使用する永続性保証。デフォルトの永続性保証を使用する場合、このパラメータにnull
を渡します。
順序全体の処理に許される時間の上限を示すタイムアウト値。このパラメータに0
を指定すると、デフォルトのリクエスト・タイムアウト値が使用されます。
タイムアウト値で使用される単位を表すTimeUnit
。たとえば、TimeUnit.MILLISECONDS
です。
WriteOptions
の使用の例は、「永続性保証」を参照してください。