Class Resetter
public final class Resetter extends Object
When receiving a reset request, the Spiderwiz framework creates a Resetter
object and calls
Main.onObjectReset()
to give a chance to the application to fulfill the
request programmatically. The method returns true
when done this way.
If onObjectReset()
returns false
then the framework does automatic reset by fulfilling the request from the
governed data object tree.
That parameter to onObjectReset()
is an object of type Resetter
that is documented here.
It contains information about the requested object type. It also serves as a
carrier to deliver objects back to the requester. As such, it facilitates efficient
delivery by directing the reset items to the channel over which they were requested, as well as providing a mechanism for
buffering the data and moderate its delivery to avoid network congestion in case of bulk delivery of a large amount of items.
The class has few methods that can be used to control the delivery process.
Note that even if onObjectReset()
returns false
, the framework uses the same Resetter
object that
was provided to it for automatic object reset, therefore giving the method a chance to fine tune the Resetter
object
used for automatic reset.
-
Method Summary
Modifier and Type Method Description void
endOfData()
Marks end of data.String
getObjectCode()
Returns theObject Code
of the data objects requested by this resetter.int
getResetCount()
Returns the number of items that were delivered by this resetter since it restarted.ZDate
getStartReset()
Returns the time reset was restarted.boolean
isAborted()
Returns true if the current Resetter object is aborted by an overriding reset request.boolean
resetObject(DataObject object)
Resets one item.void
setLossless(boolean lossless)
Sets lossless mode.void
setMaxCapacity(int capacity)
Sets the maximum capacity of the resetter buffer.void
setResetRate(int rate)
Sets the reset rate in elements per minute.
-
Method Details
-
getObjectCode
Returns theObject Code
of the data objects requested by this resetter.- Returns:
- the Object Code of the data objects requested by this resetter.
-
resetObject
Resets one item.Your reset procedure shall call this method for each item you want to reset. The method accepts as a parameter one data object that shall be of the same
Object Code
as the resetter object and buffers it for delivery to the reset requester.The method returns
true
if the operation is successful. It returnsfalse
in the following cases:- Parameters:
object
- the item to reset.- Returns:
- true if and only if the reset object has been buffered for delivery successfully.
-
endOfData
public void endOfData()Marks end of data.Call this method to mark the end of reset data. When the reset buffer is fully flushed for delivery
Main.onResetCompleted()
is called. -
setMaxCapacity
public void setMaxCapacity(int capacity)Sets the maximum capacity of the resetter buffer.The resetter mechanism uses a buffer to moderate delivery rate. When the buffer gets full, if the resetter is set to
lossless
then further calls toresetObject()
block until buffer space is freed, otherwise excess data is discarded and data is lost.Call this method to set the resetter buffer capacity. The default is 200K items.
- Parameters:
capacity
- Resetter buffer capacity in number of reset items.
-
setLossless
public void setLossless(boolean lossless)Sets lossless mode.The resetter mechanism uses a buffer to moderate delivery rate. When the buffer gets full, if the resetter is set to
lossless
then further calls toresetObject()
block until buffer space is freed, otherwise excess data is discarded and data is lost.By default resetters are lossy. Call this method with
lossless
value set totrue
to make it lossless.- Parameters:
lossless
- true to set a lossless resetter, false to set a lossy resetter.
-
setResetRate
public void setResetRate(int rate)Sets the reset rate in elements per minute.Calls this method to set reset rate to the given amount of elements per minute. A zero value eliminates the moderation effect, causing every element to be sent as soon as possible. A negative value (the default) tells the resetter to take the value from
[stream rate]
property of the application's configuration file. The default value, if that property does not exist, is 30,000 elements per minute.- Parameters:
rate
- reset rate in elements per minute, zero to eliminate moderation and negative value to use the configured value.
-
getResetCount
public final int getResetCount()Returns the number of items that were delivered by this resetter since it restarted.- Returns:
- the number of items that were delivered by this resetter since it restarted.
-
getStartReset
Returns the time reset was restarted.- Returns:
- the time reset was restarted.
-
isAborted
public boolean isAborted()Returns true if the current Resetter object is aborted by an overriding reset request.This happens when a new object reset request arrives from the same channel that previously requested a reset for the same object type and processing of that request has not finished yet. In this case the current object stops processing further
resetObject()
requests, but your implementation ofonObjectReset()
would not know it. You can call this method to check if resetting has been aborted and do something accordingly.- Returns:
- true if and only if the current Resetter object is aborted by an overriding reset request.
-