Copyright © TIBCO Software Inc. All Rights Reserved
Copyright © TIBCO Software Inc. All Rights Reserved


Chapter 5 Using the Example Code : ASBatchOperations

ASBatchOperations
ASBatchOperations demonstrates how to perform batch operations on spaces.
Overview
ASBatchOperations is similar to ASOperations, except that instead of getting or putting one data item at a time, you can get or put a list of data items at one time.
The following are some of the features of ActiveSpaces that ASBatchOperations exercises:
Metaspace connect, close
Space define, getAll, putAll, putAll and lockAll, compareAndPutAll, takeAll, lockAll, unlockAll
Starting ASBatchOperations
The following examples show how to invoke ASBatchOperations for each of the API sets:
Java Invocation
java ASBatchOperations -metaspace examplems -member_name batchop
C Invocation
ASBatchOperations -metaspace examplems -member_name batchop
.NET Invocation
AS_HOME\examples\dotnet\ASBatchOperations.exe -metaspace examplems -member_name batchop
ASBatchOperations by default joins a space (myspace) as a leech. If you try to run ASBatchOperations using the default settings, you will get the following message asking you to start a seeder:
waiting for the space to be ready...
please start 1 seeder nodes (ex. as-agent)
You have two options:
Run ASBatchOperations and specify -role seeder as a command line option.
Starting ASBatchOperations With Security
The following example shows the command line options that you can use when starting ASBatchOperations to have it join the security domain exdomain and use a space with an additional encrypted field:
-discovery tcp://127.0.0.1:50000 -member_name batchop -security_token exdomain_token.txt -encrypt_field
These command line options start ASBatchOperations using the default metaspace named ms and allow it to connect to a security domain controller that has been started using the example security policy file example_policy.txt.
When you use ASBatchOperations to put data into the space, you see the following additional prompt:
Put All: Enter the value to be encrypted (string):
The value you enter at this prompt is stored into a field named secure_value, which is defined as a string. Any string value that you enter in response to this prompt is encrypted when it is stored in the space or when it is persisted.
See the section Data Encryption in Chapter 4., “Implementing ActiveSpaces Security” for information on encrypting data fields.
Using ASBatchOperations
After ASBatchOperations initializes, the following options are displayed from the main loop of the program and allow you to perform actions on the space or metaspace:
p - put all, allows you to enter a sequence of data to be put into the space
pl - put all and lock the space entries, same as p option except the space entries are locked.
Locking means the entries cannot be modified but they can still be read. An entry remains locked until it is specifically unlocked.
g - get all, allows the user to enter a list of keys for entries to be retrieved from the space, retrieves the entries, then displays the entries.
t - take all, allows the user to enter a list of keys for entries to be removed from the space, removes the entries, then displays the removed entries.
l - lock all, allows the user to enter a list of keys for entries to be locked in a space, locks the entries, then displays the locked entries.
q - exit the program
After each of the above options is performed, a list of suboptions is displayed to continue to allow you to work with your list of entries. Suboptions are provided for all of the main options, except t (take all), because the list of entries that were originally taken from the space no longer exists in the space.
The following suboptions are available to be invoked on the list of space entries generated while invoking the main options:
r - remove all entries in your list from the space
l - lock all entries in your list in the space
u - unlock all entries in your list in the space
p - put new values for your existing entries by doing a compareAndPutAll()
s - Exit the suboptions menu

Copyright © TIBCO Software Inc. All Rights Reserved
Copyright © TIBCO Software Inc. All Rights Reserved