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


Chapter 5 Using the Example Code : ASOperations

ASOperations
The first example program you should examine is the ASOperations example. ASOperations defines and joins (as a leech) a space called myspace that has a very basic definition consisting of three fields.
You should launch more than one instance of ASOperations at the same time to see the different instances interacting with each other over the same space (for example, you can try the lock or compare and put operations).
Overview
ASOperations is a basic example that demonstrates how to connect to a metaspace, define and join a space, and invoke the basic methods of the API for performing operations on the space, such as put and get. ASOperations is the first example that you should examine and run to get familiar with ActiveSpaces. ASOperations is also sometimes run with other examples, so it is a good idea to become familiar with it first.
The following are some of the features of ActiveSpaces that ASOperations exercises:
Metaspace Connect, close, begin transaction, commit transaction, rollback transaction.
Space Define, close, get, put, putAll, take, compare the previous tuple value and if still the same do a put, get the number of entries in a space, display the entries in the space, lock, unlock.
Starting ASOperations
The following examples show how to invoke ASOperations for each of the API sets:
Java Invocation
java ASOperations -metaspace examplems -member_name op
C Invocation
ASOperations -metaspace examplems -member_name op
.NET Invocation
AS_HOME\examples\dotnet\ASOperations.exe -metaspace examplems -member_name op
ASOperations by default joins a space (myspace) as a leech. If you try to run ASOperations 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 ASOperations and specify -role seeder as a command line option.
Starting ASOperations With Security
The following is an example of the command line options that you can use when starting ASOperations to have it join the security domain exdomain and to use a space with an additional encrypted field:
-discovery tcp://127.0.0.1:50000 -member_name op -security_token exdomain_token.txt -encrypt_field
These command line options start ASOperations 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 ASOperations to put data into the space, you will see the following additional prompt:
Put: Enter the value to be encrypted (string):
The value you enter at this prompt is stored into a field named secure_value that is defined as a string. Any string value that you enter in response to this prompt will be 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 ASOperations
After ASOperations initializes, the following options are displayed, which allow you to perform actions on the space or metaspace:
b - begin transaction
c - commit transaction
r - rollback transaction
s - Displays the number of entries in the space.
br - Displays the entries in the space. If no filter is specified, all entries in the space will be displayed.
p - put a tuple into a space
pm - put a list of tuples into a space
cp - do a compare and put of a tuple into a space
g - get a tuple from a space
t - take a tuple from a space
l - lock a tuple in a space
u - unlock a tuple in a space
q - exit the example
Some options prompt you for a key. The key is an integer value.
You might also be prompted for a value. A value is a string. When prompted for a value, if you press Return instead of entering a string, the value is considered null. For example, the following key/value pairs are valid:
1, ant
2, bat
3,
4, dog
5, eel
Using ASOperations with Shared-Nothing Persistence
See Shared-Nothing Persistence for detailed information on how to run ASOperations using the built-in shared-nothing persistence feature.

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