org.hd.d.pg2k.test.dev
Class SystemVariablesTest.TestVarCacheStage

java.lang.Object
  extended by org.hd.d.pg2k.svrCore.datasource.SimpleExhibitPipelineFilter
      extended by org.hd.d.pg2k.test.dev.SystemVariablesTest.TestVarCacheStage
All Implemented Interfaces:
SimpleExhibitPipelineIF, BasicVarMgrInterface, SimpleVariablePipelineIF
Enclosing class:
SystemVariablesTest

static final class SystemVariablesTest.TestVarCacheStage
extends SimpleExhibitPipelineFilter

Simple pipeline stage that caches variable values. This can be optionally write-through.

Note that all data operations return null; this class is for var testing purposes only (thus is not public).


Nested Class Summary
 
Nested classes/interfaces inherited from interface org.hd.d.pg2k.svrCore.datasource.SimpleExhibitPipelineIF
SimpleExhibitPipelineIF.PropsKey
 
Field Summary
private  PipelineVarMgr vars
          Variable manager.
 
Fields inherited from class org.hd.d.pg2k.svrCore.datasource.SimpleExhibitPipelineFilter
source
 
Fields inherited from interface org.hd.d.pg2k.svrCore.datasource.SimpleExhibitPipelineIF
MAX_USER_READ_SIZE
 
Constructor Summary
SystemVariablesTest.TestVarCacheStage(SimpleExhibitPipelineIF upstream, boolean writeThrough)
          Construct test variable-caching stage.
 
Method Summary
 SimpleVariableValue getVariable(SimpleVariableDefinition var)
          Get a single variable value; returns null if no such value or wrong type.
 SimpleVariableValue[] getVariables(long changedSince)
          Get set of variable values altered on or after specified time, or get all values with -1; never null.
 void poll(GenProps gp)
          Poll periodically (of the order of seconds) to do bg work.
 void setVariable(SimpleVariableValue newValue)
          Set variable to the given value (the variable name and definition are implicit).
 int setVariables(SimpleVariableValue[] newValues)
          Update a number of variables at once for efficiency; returns the number of variables set.
 void syncVariables(boolean force)
          Synchronise variables with upstream values.
 
Methods inherited from class org.hd.d.pg2k.svrCore.datasource.SimpleExhibitPipelineFilter
destroy, getAllExhibitImmutableData, getAllExhibitProperties, getEventValue, getEventValues, getGenProps, getGenSecProps, getProperties, getRawFile, getStaticAttr, getThumbnails
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

vars

private final PipelineVarMgr vars
Variable manager.

Constructor Detail

SystemVariablesTest.TestVarCacheStage

SystemVariablesTest.TestVarCacheStage(SimpleExhibitPipelineIF upstream,
                                      boolean writeThrough)
Construct test variable-caching stage.

Parameters:
upstream - upstream stage of pipeline; non-null
writeThrough - if true, all set operations "write-through" this cahce stage immediately...
Method Detail

setVariable

public void setVariable(SimpleVariableValue newValue)
                 throws java.io.IOException,
                        java.lang.UnsupportedOperationException
Description copied from class: SimpleExhibitPipelineFilter
Set variable to the given value (the variable name and definition are implicit). The value set should be immediately readable with getVariable() as the "main" value of the variable even for global variables.

Specified by:
setVariable in interface BasicVarMgrInterface
Overrides:
setVariable in class SimpleExhibitPipelineFilter
Throws:
java.io.IOException - in case of I/O difficulty
java.lang.UnsupportedOperationException - if a variable is set that we could never handle, eg a non-System-ID local variable at the client end of a tunnel

setVariables

public int setVariables(SimpleVariableValue[] newValues)
                 throws java.io.IOException
Description copied from class: SimpleExhibitPipelineFilter
Update a number of variables at once for efficiency; returns the number of variables set. Is passed a set of SimpleVariableValues and behaves as if it operates on all of them by calling setVariable() for each item in the set.

An implementation may "fail fast" on the first error/exception, or may attempt to continue and do as much as possible.

An implementation may throw an IllegalArgumentException on attempt to: set a variable with value of wrong type or incompatible definition, set a non-existent or read-only variable (or these may be ignored)

Specified by:
setVariables in interface BasicVarMgrInterface
Overrides:
setVariables in class SimpleExhibitPipelineFilter
Returns:
the number of variable values set; never negative, never more than the number passed in
Throws:
java.io.IOException

getVariable

public SimpleVariableValue getVariable(SimpleVariableDefinition var)
Description copied from class: SimpleExhibitPipelineFilter
Get a single variable value; returns null if no such value or wrong type. Implementations should, where possible, trim from the globalMap of returned values any apparently-stale data, so as to return only reasonably-live data to the caller.

Specified by:
getVariable in interface BasicVarMgrInterface
Overrides:
getVariable in class SimpleExhibitPipelineFilter
Parameters:
var - definition of variable to fetch; never null

getVariables

public SimpleVariableValue[] getVariables(long changedSince)
Description copied from class: SimpleExhibitPipelineFilter
Get set of variable values altered on or after specified time, or get all values with -1; never null. This may be slow if there are many live variables.

Specified by:
getVariables in interface BasicVarMgrInterface
Overrides:
getVariables in class SimpleExhibitPipelineFilter

syncVariables

public void syncVariables(boolean force)
                   throws java.io.IOException
Description copied from class: SimpleExhibitPipelineFilter
Synchronise variables with upstream values. Pushes updated values upstream to the source, calls sync on the source if called with the "force" argument true, and then retrieves changed values from upstream.

When called with force==true, this acts like a full "memory barrier", flushing all write-cached items downstream immediately and afterwards getting the value of all upstream values with getVariables(-1), but may be expensive in terms of CPU or bandwidth, so use sparingly.

When called with force=false, this incrementally flushes outstanding writes and will then fetch all, or only new, values from upstream, so is potentally much less resource-intensive. In particular, this does not propagate the sync() upstream.

In any case, it is rarely the right thing for a casual user to vall this as it may be very expensive.

Specified by:
syncVariables in interface SimpleVariablePipelineIF
Overrides:
syncVariables in class SimpleExhibitPipelineFilter
Parameters:
force - if true, this will force a full write flush, a full sync upstream, then full read with getVariables(-1), to get the effect of a full "barrier"; otherwise, in general, a more incremental and non-propagating mode is used which still does a write flush but may chose to do a partial read of "new" upstream values
Throws:
java.io.IOException - if one is received from upstream

poll

public void poll(GenProps gp)
          throws java.io.IOException
Description copied from class: SimpleExhibitPipelineFilter
Poll periodically (of the order of seconds) to do bg work. The current generic system properties are passed in...

Specified by:
poll in interface SimpleExhibitPipelineIF
Overrides:
poll in class SimpleExhibitPipelineFilter
Throws:
java.io.IOException - in case of difficulty, but even if a sub-ordinate call throws IOException the poll() call should make some effort to do as much of its work as reasonably possible

DHD Multimedia Gallery V1.53.0

Copyright (c) 1996-2009, Damon Hart-Davis. All rights reserved.