This chapter provides a complete listing and reference for the methods in the OpenScript SharedDataService Class of SharedData Module Application Programming Interface (API).
The following section provides an alphabetical listing of the methods in the OpenScript SharedDataService API.
The following table lists the SharedDataService API methods in alphabetical order.
Table 21-1 List of SharedDataService Methods
Method | Description |
---|---|
Removes all mappings from a hash map. |
|
Removes all of the elements from a queue. |
|
Creates a hash map with the name and the life time. |
|
Creates a queue with the specified name and life time. |
|
Removes all mappings and their data listeners from a hash map. |
|
Removes all of the elements and their data listeners from a queue. |
|
Returns the value to which the specified key is mapped in a hash map, or blocked until the default timeout if the map contains no mapping for this key. |
|
Returns all of the keys contained in a hash map. |
|
Get the length of the queue. |
|
Inserts the specified element at the front of the specified queue. |
|
Inserts the specified element at the end of the specified queue. |
|
Retrieves but does not remove the first element of the specified queue, or blocked until the default timeout if the queue is empty. |
|
Retrieves but does not remove last element of the specified queue, or blocked until the default timeout if the queue is empty. |
|
Retrieves and removes the first element of the specified queue, or blocked until the default timeout if the queue is empty. |
|
Retrieves and removes the last element of the specific queue, or blocked until the default timeout if the queue is empty. |
|
Associates the specified value with the specified key in a session hash map. |
|
Removes the mapping for this key from a map if present. |
|
Sets the connection parameters for the shared data service. |
|
Waits for the specific value to be added to the queue until the default timeout. |
The following sections provide detailed reference information for each method and enum in the SharedDataService Class of SharedData Module Application Programming Interface.
Removes all mappings from a hash map.
The sharedData.clearMap method has the following command format(s):
sharedData.clearMap(name);
represents an exception that may be thrown during the execution of a script where the exception should be reported to an end user through the controller.
Removes all of the elements from a queue.
The sharedData.clearQueue method has the following command format(s):
sharedData.clearQueue(name);
represents an exception that may be thrown during the execution of a script where the exception should be reported to an end user through the controller.
Creates a hash map with the name and the life time.
If the hash map already exists, update its life time with the new life time value.
The sharedData.createMap method has the following command format(s):
sharedData.createMap(name, lifeTime);
a String specifying the name of the hash map to be created.
the life time the hash map will live. Its unit is minutes.
represents an exception that may be thrown during the execution of a script where the exception should be reported to an end user through the controller.
Creates a queue with the specified name and life time.
If the queue already exists, update its life time with the new life time value.
The sharedData.createQueue method has the following command format(s):
sharedData.createQueue(name, lifeTime);
a String specifying the name of the queue to be created.
the life time the queue will live. Its unit is minutes.
represents an exception that may be thrown during the execution of a script where the exception should be reported to an end user through the controller.
Removes all mappings and their data listeners from a hash map.
The sharedData.destroyMap method has the following command format(s):
sharedData.destroyMap(name);
represents an exception that may be thrown during the execution of a script where the exception should be reported to an end user through the controller.
Removes all of the elements and their data listeners from a queue.
The sharedData.destroyQueue method has the following command format(s):
sharedData.destroyQueue(name);
represents an exception that may be thrown during the execution of a script where the exception should be reported to an end user through the controller.
Returns the value to which the specified key is mapped in a hash map, or blocked until the default timeout if the map contains no mapping for this key.
The default "timeout" is set in the playback settings which has a default value of 20 seconds.
The sharedData.getFromMap method has the following command format(s):
sharedData.getFromMap(name, key);
sharedData.getFromMap(name, key, timeout);
a String specifying the name of the hash map
a String specifying the key with which the specified value is to be associated.
a Long specifying the maximum time of getting blocked. The unit is milliseconds.
represents an exception that may be thrown during the execution of a script where the exception should be reported to an end user through the controller.
the value to which the specified key is mapped, or null if the map contains no mapping for this key.
Returns all of the keys contained in a hash map.
The sharedData.getKeysOfMap method has the following command format(s):
sharedData.getKeysOfMap(name);
represents an exception that may be thrown during the execution of a script where the exception should be reported to an end user through the controller.
Get the length of the queue.
The "timeout" is set in the playback settings whose default value is 20 seconds.
The sharedData.getLengthOfQueue method has the following command format(s):
sharedData.getLengthOfQueue(name);
sharedData.getLengthOfQueue(name, timeout);
a String specifying the name of the queue.
a long specifying the maximum time of getting blocked. The unit is milliseconds.
represents an exception that may be thrown during the execution of a script where the exception should be reported to an end user through the controller.
Inserts the specified element at the front of the specified queue.
If the queue does not exist, a new one with the name will be created with a default life time of 20 minutes.
The sharedData.offerFirst method has the following command format(s):
sharedData.offerFirst(name, value);
a String specifying the name of the queue that the value will be put into.
a Serializable value to be put into a queue.
represents an exception that may be thrown during the execution of a script where the exception should be reported to an end user through the controller.
Inserts the different data type elements at the front of "queueA".
info("parameter type - String"); sharedData.offerFirst("queueA", "value"); info("parameter type - list of Strings"); ArrayList<String> listOfStr = new ArrayList<String>(); listOfStr.add(0, "val1"); listOfStr.add(1, "val2"); sharedData.offerFirst("queueA", listOfStr); info("parameter type - boolean"); sharedData.offerFirst("queueA", true); info("parameter type - int"); sharedData.offerFirst("queueA", 10); info("parameter type - double"); sharedData.offerFirst("queueA", 10.5); info("parameter type - long"); sharedData.offerFirst("queueA", 100);
Inserts the specified element at the end of the specified queue.
If the queue does not exist, a new one with the name will be created with a default life time of 20 minutes.
The sharedData.offerLast method has the following command format(s):
sharedData.offerLast(name, value);
a String specifying the name of the queue that the value will be put into.
a Serializable value to be put into the queue.
represents an exception that may be thrown during the execution of a script where the exception should be reported to an end user through the controller.
Inserts the different data type elements at the end of "queueA".
info("parameter type - String"); sharedData.offerLast("queueA", "value"); info("parameter type - list of Strings"); ArrayList<String> listOfStr = new ArrayList<String>(); listOfStr.add(0, "val1"); listOfStr.add(1, "val2"); sharedData.offerLast("queueA", listOfStr); info("parameter type - boolean"); sharedData.offerLast("queueA", true); info("parameter type - int"); sharedData.offerLast("queueA", 10); info("parameter type - double"); sharedData.offerLast("queueA", 10.5); info("parameter type - long"); sharedData.offerLast("queueA", 100);
Retrieves but does not remove the first element of the specified queue, or blocked until the default timeout if the queue is empty.
The "timeout" is set in the playback settings which has a default value of 20 seconds.
The sharedData.peekFirst method has the following command format(s):
sharedData.peekFirst(name);
sharedData.peekFirst(name, timeout);
a String specifying the name of the queue.
a Long specifying the maximum time of getting blocked. The unit is milliseconds.
represents an exception that may be thrown during the execution of a script where the exception should be reported to an end user through the controller.
Retrieves but does not remove last element of the specified queue, or blocked until the default timeout if the queue is empty.
The "timeout" is set in the playback settings which has a default value of 20 seconds.
The sharedData.peekLast method has the following command format(s):
sharedData.peekLast(name);
sharedData.peekLast(name, timeout);
a String specifying the name of the queue.
a Long specifying the maximum time of getting blocked. The unit is milliseconds.
represents an exception that may be thrown during the execution of a script where the exception should be reported to an end user through the controller.
Retrieves and removes the first element of the specified queue, or blocked until the default timeout if the queue is empty.
The "timeout" is set in the playback settings which has a default value of 20 seconds.
The sharedData.pollFirst method has the following command format(s):
sharedData.pollFirst(name);
sharedData.pollFirst(name, timeout);
a String specifying the name of the queue.
a Long specifying the maximum time of getting blocked. The unit is milliseconds.
represents an exception that may be thrown during the execution of a script where the exception should be reported to an end user through the controller.
Retrieves and removes the last element of the specific queue, or blocked until the default timeout if the queue is empty.
The "timeout" is set in the playback settings which has a default value of 20 seconds.
The sharedData.pollLast method has the following command format(s):
sharedData.pollLast(name);
sharedData.pollLast(name, timeout);
a String specifying the name of the queue.
a Long specifying the maximum time of getting blocked. The unit is milliseconds.
represents an exception that may be thrown during the execution of a script where the exception should be reported to an end user through the controller.
Associates the specified value with the specified key in a session hash map.
If the map previously contained a mapping for this key, the old value is replaced. If the hash map does not exist, a new one with the name will be created with a default life time of 20 minutes.
The sharedData.putToMap method has the following command format(s):
sharedData.putToMap(name, key, value);
a String specifying the name of the map
a String specifying the key with which the specified value is to be associated.
a Serializable value to be associated with the specified key.
represents an exception that may be thrown during the execution of a script where the exception should be reported to an end user through the controller.
Associates the value with the key in a session hash map.
info("parameter type - String"); sharedData.putToMap("mapA", "key", "value"); info("parameter type - list of Strings"); ArrayList<String> listOfStr = new ArrayList<String>(); listOfStr.add(0, "val1"); listOfStr.add(1, "val2"); sharedData.putToMap("mapA", "key", listOfStr); info("parameter type - boolean"); sharedData.putToMap("mapA", "key", true); info("parameter type - int"); sharedData.putToMap("mapA", "key", 10); info("parameter type - double"); sharedData.putToMap("mapA", "key", 10.5); info("parameter type - long"); sharedData.putToMap("mapA", "key", 100);
Removes the mapping for this key from a map if present.
The sharedData.removeFromMap method has the following command format(s):
sharedData.removeFromMap(name, key);
sharedData.removeFromMap(name, key, timeout);
a String specifying the name of the hash map.
a String specifying the key with which the specified value is to be associated.
a Long specifying the maximum time of getting blocked. The unit is milliseconds.
represents an exception that may be thrown during the execution of a script where the exception should be reported to an end user through the controller.
Sets the connection parameters for the shared data service.
The connection parameters can be specified using the Add option on the Script menu.
The sharedData.setConnectionParameters method has the following command format(s):
sharedData.setConnectionParameters(address, userName, password);
a String specifying the address of the Oracle Load Testing server to use for the Shared Data Service.
a String specifying the username to use for authentication.
a String specifying the password to use for authentication.
represents an exception that may be thrown during the execution of a script where the exception should be reported to an end user through the controller.
Waits for the specific value to be added to the queue until the default timeout.
The "timeout" is set in the playback settings which has a default value of 20 seconds.
The sharedData.waitFor method has the following command format(s):
sharedData.waitFor(queueName, desiredValue);
sharedData.waitFor(queueName, desiredValue, timeout);
a String specifying the name of the queue.
a Serializable value that is expected to be added to the queue.
a Long specifying the maximum time of waiting. The unit is milliseconds.
represents an exception that may be thrown during the execution of a script where the exception should be reported to an end user through the controller.
Waits for the specific value to be added to the queue. Timeout after 5 seconds.
info("parameter type - String"); Boolean isFound1 = sharedData.waitFor("queueA", "key1", 5000); if (!isFound1) warn("Can not find item 'Key1' in queueA"); else info("Found item 'key1' in queueA"); info("parameter type - list of Strings"); ArrayList<String> listOfStr = new ArrayList<String>(); listOfStr.add(0, "val1"); listOfStr.add(1, "val2"); Boolean isFound2 = sharedData.waitFor("queueA", listOfStr, 5000); if (!isFound2) warn("Can not find item 'listOfStr' in queueA"); else info("Found item of queue item 'listOfStr' in queueA"); info("parameter type - boolean"); Boolean isFound3 = sharedData.waitFor("queueA", true, 5000); if (!isFound3) warn("Can not find item 'true' in queueA"); else info("Found item 'true' in queueA"); info("parameter type - int"); Boolean isFound4 = sharedData.waitFor("queueA", 10, 5000); if (!isFound4) warn("Can not find item '10' in queueA"); else info("Found item '10' in queueA"); info("parameter type - double"); Boolean isFound5 = sharedData.waitFor("queueA", 10.5, 5000); if (!isFound5) warn("Can not find item '10.5' in queueA"); else info("Found item '10.5' in queueA"); info("parameter type - long"); Boolean isFound6 = sharedData.waitFor("queueA", 100, 5000); if (!isFound6) warn("Can not find item '100' in queueA"); else info("Found item '100' in queueA");