KMIP Multiple Operation Batching
The KMIP protocol allows for multiple operations to be sent in a single client-to-server request payload. CADP for Java KMIP Multiple Operation Batching methods enable you to accumulate multiple KMIP operations and sends them to the server in a single request. Using this CADP for Java feature, a KMIP client can achieve more efficiency on the client and minimize network round-trips.
You also have the option of saving batches of multiple KMIP operations so that you can re-run them without repeating set-up API calls.
Each KMIP operation and the server-managed objects, parameters and attributes needed to fulfill the operation are processed as a unit of work known as a Batch Item. For example, in a single request, the first Batch Item might find a key by name using the KMIPLocate Operation, and this Batch Item could be followed in the same request by a KMIP Get Operation Batch Item to export the key. This batching avoids a second roundtrip and having to handle the Unique Identifier on the client.
Note
If the current Batch Item doesn't contain a Unique Identifier attribute, the server has an “ID Placeholder” variable that is used instead. The ID Placeholder on the server caches the Unique Identifier attribute of the single managed object that was affected or located by the previous Batch Item.
You can take advantage of KMIP operation batching using either of two basic approaches:
Accumulate multiple batch items into a single request
By placing the KMIP session into batch mode with the
startBatching()
method, you cause all CADP for Java and methods invoked by the client in thatKMIPSession
to be deferred for server execution until theflushBatch()
method is called on that session. Related methods that assist with this approach to batching are also available. You also have the option to save the accumulated KMIP operations to a file so that you can re-run a set of batch items without repeating all the setup work. (Be aware that not all combinations of operations are suitable for batching. It doesn't make sense to batch those that rely on independent steps, or that contain transient names or attribute values.)Use an existing KMIP Session multi-operation batch method
Use an existing KMIP Session multi-operation batch method. CADP for Java provides KMIPSession methods that operate on multiple managed objects in a single KMIP request. These methods take implicit advantage of KMIP batch items. For example, you can effectively perform a “Get key by name” request by using the
KMIPSession.getKey("keyname")
method to perform locate and get operations in a single request. Other currently available methods are described below.Note
KMIPSession.getKey() takes advantage of the Unique Identifier (UID) that is retained on the server side in the ID Placeholder variable, enabling CADP for Java to perform more than one KMIP operation in a single request. The server remembers the last UID located.
Accumulate multiple batch items into a single request
In a KMIPSession, in batching mode, you effectively accumulate operations until a flushBatch()
operation is performed. The following operations are also available:
void KMIPSession.startBatching()
KMIPBatchResults KMIPSession.flushBatch()
void KMIPSession.abortBatch()
boolean KMIPSession.isBatching()
A KMIP session can save and execute KMIP batch items from a client-side operating system file:
void KMIPSession.saveBatch(File f)
void KMIPSession.saveBatch(String filespec)
KMIPBatchResults KMIPSession.executeBatchFile(File file)
KMIPBatchResults KMIPSession.executeBatchFile(String file)
The order of operations is maintained, and the Batch continues if an error occurs on the server for an individual operation.
The following KMIP methods can be used in KMIP multiple operation batching:
Add Attribute
Create
Certify/Recertify
Delete Attribute
Destroy
Get
Get Attribute List
Get Key by Name
Locate
Modify Attribute
Query (server attributes)
Register
Get Attributes
Results
KMIPBatchResults
- an iterable hashmap, one per KMIP operation in the batch. The map key is the batchid of the individual KMIP operation. KMIPBatchItemResult - for each KMIP operation requested as a batch item, the following attributes are returned in a KMIPBatchItemResult object:
Operation performed
Status
Message - if not status "Success"
UIDs - set of UIDs of managed objects affected, if any
KMIPAttributes - if any
For more information and guidance, refer to the KMIPBatchSample.java.
KMIP session multiple operation batch methods
As of version 6.2.0, CADP for Java supports the KMIPSession operations on attributes that are listed below, which can be included in these batches. These are in addition to export and delete by name, which take advantage of multiple KMIP Batch Items and which have always been supported.
addAllAttributes()
modifyAllAttributes()
deleteAllAttributes()
deleteAll()