|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.hd.d.pg2k.svrCore.datasource.ExhibitDataTunnelSource
public abstract class ExhibitDataTunnelSource
Exhibit pipeline stage that fetches its data across a master/slave tunnel. Some of the visible types and values are used by the implementations of both ends of the tunnel (eg the tunnel servlet) to help implement the shared protocol.
This takes data from the server's own DataSourceBean by default.
| Nested Class Summary | |
|---|---|
static class |
ExhibitDataTunnelSource.HIRPCCache
Cache/lock to improve performance of inbound RPC. |
static class |
ExhibitDataTunnelSource.PacketProtector
The immutable adjunct for a RawPacket that includes the HMAC and other anti-attack data. |
static class |
ExhibitDataTunnelSource.RawPacket
Immutable raw packet to send in either direction over a byte stream connection. |
| Nested classes/interfaces inherited from interface org.hd.d.pg2k.svrCore.datasource.SimpleExhibitPipelineIF |
|---|
SimpleExhibitPipelineIF.PropsKey |
| Field Summary | |
|---|---|
private java.lang.Object |
_nR_lock
Private lock for _noteResult. |
protected static boolean |
_protocolDebug
If true, extra instrumentation for protocol debug; definitely not for release code. |
private int |
_REPAIR_RETRY_LEAD_MS
How soon ahead of other callers we try to silently repair a broken connection, ms; non-negative. |
private static boolean |
BLOCK_RAW_FILE_CACHEING
If true then never pass through a request to cache content locally. |
private java.lang.Long |
doNotTryMasterUntil
Time before which we should not again try to contact the master; null if master is fine. |
static byte[] |
EMPTY_PAYLOAD
Convenience value; (immutable) zero-length byte array for use as an empty packet payload. |
static int |
FAIL_RETRY_WAIT_MAX_MS
Maximum wait after failed tunnel call before retry (ms). |
static int |
FAIL_RETRY_WAIT_MIN_MS
Minimum wait after failed tunnel call before retry (ms); strictly positive. |
private static boolean |
FORCE_GC_AND_FINALISERS_AFTER_POLL_FAIL
If true, try GC and running finalizers after some connection failures. |
protected static boolean |
KEEP_SERVER_CONNECTION_ALIVE
If true, allow connection/resource sharing between calls if possible. |
private long |
lastSuccessfulConnectionTime
Time when last successful connection was made, or 0 if no connection.. |
protected SimpleLoggerIF |
logger
Our logger which falls back to System.out if servlet log not available; never null. |
static CompressionLevel |
MAX_AEP_DIFF_COMP_LEVEL
Maximum level of compression in AEP "diff" RPC supported in this implementation, client or server side. |
static int |
MIN_AEP_RETENTION_MS
Minimum time (ms) for which we will hold latest newly-created AEP response; strictly positive. |
private static EventVariableValue[] |
NO_EVENT_VALUES
Immutable empty result indicating no event values available. |
private StatsLogger.StatsConfig |
statsIDTS
The stats set to which we log general tunnel source stats. |
private int |
successiveFailureCount
Successive failure count; reset to zero upon success. |
static java.lang.String |
TSNAME_RPCIOEX
General stats event name: RPC failure due to an IOException. |
static java.lang.String |
TSNAME_RPCREQUEST
General stats event name: RPC request. |
static java.lang.String |
TSNAME_SHORTREAD
General stats event name: "short" raw data read, less than bulk-transfer block size.. |
static java.lang.String |
TSNAMEPR_RPCTYPE
General stats event name prefix: RPC request packet type. |
SimpleVariableValue |
uniqueClientID
Our unique client-side end-point identifier. |
| Fields inherited from interface org.hd.d.pg2k.svrCore.datasource.SimpleExhibitPipelineIF |
|---|
MAX_USER_READ_SIZE |
| Constructor Summary | |
|---|---|
ExhibitDataTunnelSource(SimpleLoggerIF logger)
Create an instance, passing in a (non-null) logger to use. |
|
| Method Summary | |
|---|---|
protected java.lang.String |
_getStratumUpstreamName()
Return short unique name of upstream peer/server suitable for Stratum; never null but can be "" for 'unknown'. |
private void |
_noteResult(boolean success)
Routine to note success or failure of RPC call and adjust control variables. |
private SimpleVariableValue |
adjustGlobalMapForSet(SimpleVariableValue svv)
Adjust globalMap for outgoing (upstream) set operation. |
void |
destroy()
May attempt to free up outbound connections and/or prevent new ones. |
void |
doNOOP(boolean unguarded)
Does a NO-OP on the server. |
protected ExhibitDataTunnelSource.RawPacket |
doRPC(ExhibitDataTunnelSource.RawPacket packetOut)
Make an RPC call over HTTP[S] with the given outgoing packet. |
protected abstract ExhibitDataTunnelSource.RawPacket |
doRPCRaw(ExhibitDataTunnelSource.RawPacket packetOut)
Make an RPC call over the underlying medium with the given outgoing packet; never null. |
protected Tuple.Pair<java.lang.Integer,java.io.InputStream> |
doRPCRawWithStreamResponse(ExhibitDataTunnelSource.RawPacket packetOut,
boolean allowBigReadTimeout)
Optimised RPC call with the given outgoing packet and returning packet body as an InputStream; never null nor with a null stream. |
protected ExhibitDataTunnelSource.RawPacket |
doRPCUnguarded(ExhibitDataTunnelSource.RawPacket packetOut)
Just like doRPC() but does not back off in face of previous failures; never null. |
AllExhibitImmutableData |
getAllExhibitImmutableData(long oldStamp)
Gets all static exhibit data if its timestamp is not that specified. |
AllExhibitProperties |
getAllExhibitProperties(AllExhibitProperties oldAEP,
boolean allowAutoRecovery)
Gets set of all exhibit properties if not that specified, attempting minimise data transferred across the tunnel. |
AllExhibitProperties |
getAllExhibitProperties(long oldHash)
Gets set of all exhibit properties if its hash is not that specified. |
EventVariableValue |
getEventValue(SimpleVariableDefinition def,
EventPeriod intervalSelector,
boolean current)
Get the current partial, or previous full, event set at the specified interval; never null. |
EventVariableValue[] |
getEventValues(SimpleVariableDefinition def,
EventPeriod intervalSelector,
long intervalNumber,
java.util.BitSet whichValues)
Get the specified global event sets for the specified intervals; never null. |
GenProps |
getGenProps(long oldStamp)
Gets the general properties as a GenProps object if its timestamp is not that specified. |
java.util.Properties |
getGenSecProps(long oldStamp)
Gets the security properties as a Properties object if its timestamp is not that specified. |
long |
getLastSuccessfulConnectionTime()
Get time of last successful connection, or 0 if none. |
java.util.Properties |
getProperties(SimpleExhibitPipelineIF.PropsKey key,
long versionID)
Get requested Properties selected by key and versionID. |
void |
getRawFile(java.nio.ByteBuffer buf,
Name.ExhibitFull exhibitName,
int position,
boolean dontCache)
Get a chunk of the raw exhibit binary. |
ExhibitStaticAttr |
getStaticAttr(Name.ExhibitFull name)
Get the static attributes for a given exhibit. |
Stratum |
getStratum()
Returns the (incremented) upstream stratum adjusted to include transit time; never null. |
ExhibitThumbnails |
getThumbnails(Name.ExhibitFull name,
boolean create)
Gets the thumbnails for an exhibit. |
SimpleVariableValue |
getVariable(SimpleVariableDefinition var)
Get variable, or returns null if no such non-local variable. |
SimpleVariableValue[] |
getVariables(long changedSince)
Fetch variable values from the master. |
private static ExhibitDataTunnelSource.RawPacket |
handleGetAllExhibitImmutableData(SimpleExhibitPipelineIF source,
ExhibitDataTunnelSource.RawPacket reqPacket,
ExhibitDataTunnelSource.HIRPCCache cache,
SimpleLoggerIF logger)
Handle an incoming GetAllExhibitImmutableData request; never null. |
private static ExhibitDataTunnelSource.RawPacket |
handleGetAllExhibitProperties(SimpleExhibitPipelineIF source,
ExhibitDataTunnelSource.RawPacket reqPacket,
java.lang.String clientAddr,
ExhibitDataTunnelSource.HIRPCCache cache,
SimpleLoggerIF logger)
Handle an incoming GetAllExhibitProperties request; never null. |
private static ExhibitDataTunnelSource.RawPacket |
handleGetAllExhibitPropertiesDiff(SimpleExhibitPipelineIF source,
ExhibitDataTunnelSource.RawPacket reqPacket,
java.lang.String clientAddr,
ExhibitDataTunnelSource.HIRPCCache cache,
SimpleLoggerIF logger)
Handle an incoming GetAllExhibitPropertiesDiff request; never null. |
private static ExhibitDataTunnelSource.RawPacket |
handleGetEventValues(SimpleExhibitPipelineIF source,
ExhibitDataTunnelSource.RawPacket reqPacket)
Handle an incoming GetEventValues request; never null. |
private static ExhibitDataTunnelSource.RawPacket |
handleGetGenProps(SimpleExhibitPipelineIF source,
ExhibitDataTunnelSource.RawPacket reqPacket)
Handle an incoming GetGenProps request; never null. |
private static ExhibitDataTunnelSource.RawPacket |
handleGetGenSecProps(SimpleExhibitPipelineIF source,
ExhibitDataTunnelSource.RawPacket reqPacket)
Handle an incoming GetGenSecProps request; never null. |
private static ExhibitDataTunnelSource.RawPacket |
handleGetRawFile(SimpleExhibitPipelineIF source,
ExhibitDataTunnelSource.RawPacket reqPacket)
Handle an incoming GetRawFile request; never null. |
private static ExhibitDataTunnelSource.RawPacket |
handleGetStaticAttr(SimpleExhibitPipelineIF source,
ExhibitDataTunnelSource.RawPacket reqPacket)
Handle an incoming GetStaticAttr request; never null. |
private static ExhibitDataTunnelSource.RawPacket |
handleGetStratum(SimpleExhibitPipelineIF source,
ExhibitDataTunnelSource.RawPacket reqPacket)
Handle an incoming GetStratum request; never null. |
private static ExhibitDataTunnelSource.RawPacket |
handleGetThumbnails(SimpleExhibitPipelineIF source,
ExhibitDataTunnelSource.RawPacket reqPacket)
Handle an incoming GetThumbnails request; never null. |
private static ExhibitDataTunnelSource.RawPacket |
handleGetVariable(SimpleExhibitPipelineIF source,
ExhibitDataTunnelSource.RawPacket reqPacket)
Handle an incoming GetVariable request; never null. |
private static ExhibitDataTunnelSource.RawPacket |
handleGetVariables(SimpleExhibitPipelineIF source,
ExhibitDataTunnelSource.RawPacket reqPacket)
Handle an incoming GetVariables request; never null. |
static ExhibitDataTunnelSource.RawPacket |
handleInboundRPC(SimpleExhibitPipelineIF source,
ExhibitDataTunnelSource.RawPacket reqPacket,
java.lang.String clientAddr,
ExhibitDataTunnelSource.HIRPCCache cache,
SimpleLoggerIF logger)
Handles input request packet from slave across a tunnel. |
private static ExhibitDataTunnelSource.RawPacket |
handleSetVariables(SimpleExhibitPipelineIF source,
ExhibitDataTunnelSource.RawPacket reqPacket,
java.lang.String clientAddr,
SimpleLoggerIF logger)
Handle an incoming SetVariables request; never null. |
private static ExhibitDataTunnelSource.RawPacket |
handleSyncVariables(SimpleExhibitPipelineIF source,
ExhibitDataTunnelSource.RawPacket reqPacket)
Handle an incoming SyncVariables request; never null. |
static byte[] |
intSer(int value)
Helper method to serialise a single free-standing int value. |
boolean |
isBroken()
Returns true if we currently cannot talk to the master, false otherwise. |
static byte[] |
longSer(long value)
Helper method to serialise a single free-standing long value. |
void |
poll(GenProps gp)
Poll periodically. |
void |
setVariable(SimpleVariableValue newValue)
Set variable. |
int |
setVariables(SimpleVariableValue[] newValues)
Set variables; must not be null or contain nulls. |
void |
syncVariables(boolean force)
Synchronise variables with upstream values. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
private static final boolean FORCE_GC_AND_FINALISERS_AFTER_POLL_FAIL
public static final int FAIL_RETRY_WAIT_MIN_MS
public static final int FAIL_RETRY_WAIT_MAX_MS
Most requests during the wait will be vetoed cleanly and quickly allowing timely service to the slave's clients.
We vary this limit slightly between slaves/instances to help avoid them colliding with one another especially if hitting this upper bound.
protected static final boolean KEEP_SERVER_CONNECTION_ALIVE
An open connection would probably improve TCP efficiency and reduce latency for an underlying HTTP[S] connection, for example. (We might allow HTTP/1.1 streaming and connection sharing to be done for us by the JDK runtime if this is true.)
protected static final boolean _protocolDebug
public final SimpleVariableValue uniqueClientID
This is unique to each tunnel client end-point instance and is created afresh on each run, so a rebooted client gets a new ID.
Uses secure/good generator to try to ensure global uniqueness. (This may be expensive to compute; we might be able to defer this until first needed.)
protected final SimpleLoggerIF logger
private final StatsLogger.StatsConfig statsIDTS
public static final java.lang.String TSNAME_RPCREQUEST
public static final java.lang.String TSNAME_RPCIOEX
public static final java.lang.String TSNAMEPR_RPCTYPE
public static final java.lang.String TSNAME_SHORTREAD
public static final byte[] EMPTY_PAYLOAD
private volatile long lastSuccessfulConnectionTime
Set by _noteResult() after a good exchange with the master; never cleared and never null.
private volatile java.lang.Long doNotTryMasterUntil
Cleared to null by _noteResult() after a good exchange with the master; the wait to another attempt is approximately doubled after a failed exchange.
private int successiveFailureCount
Cleared to zero on a successful packet exchange; incremented after each failure.
private final java.lang.Object _nR_lock
private static final EventVariableValue[] NO_EVENT_VALUES
public static final CompressionLevel MAX_AEP_DIFF_COMP_LEVEL
private final int _REPAIR_RETRY_LEAD_MS
public static final int MIN_AEP_RETENTION_MS
Note that in dire straits this lower limit may be ignored.
Should typically be of the order of many minutes.
private static final boolean BLOCK_RAW_FILE_CACHEING
| Constructor Detail |
|---|
public ExhibitDataTunnelSource(SimpleLoggerIF logger)
| Method Detail |
|---|
public long getLastSuccessfulConnectionTime()
public boolean isBroken()
private void _noteResult(boolean success)
success - call with this true immediately after successful RPC exchange with master;
call with false otherwise
public void doNOOP(boolean unguarded)
throws java.io.IOException
unguarded - if true, this ignores any recent connection problems
and immediately tries to contact the master,
else it behaves like other operations and is quickly vetoed
while the master is failing
java.io.IOException - in case of trouble communicating with master.
public ExhibitStaticAttr getStaticAttr(Name.ExhibitFull name)
throws java.io.IOException
Sends name as a UTF string and allows compression. (We use UTF since we know that the length is limited and the all-ASCII nature of valid names should yield one-byte-per-char encoding before compression.)
This will fail with a null name argument.
(Big secret: if this class is used behind, for example, ExhibitDataSimpleCache, this method will never be called because all such calls are answered direct from the cache.)
getStaticAttr in interface SimpleExhibitPipelineIFjava.io.IOException - if the operation cannot be completed due to I/O
restrictions or failure
public void getRawFile(java.nio.ByteBuffer buf,
Name.ExhibitFull exhibitName,
int position,
boolean dontCache)
throws java.io.IOException
Sends name as a UTF string and allows compression of the request. (We use UTF since we know that the length is limited and the all-ASCII nature of valid names should yield one-byte-per-char encoding before compression.)
We send the start and (computed) afterEnd arguments as int values.
We return the data as-is.
getRawFile in interface SimpleExhibitPipelineIFbuf - the buffer into which to read the data;
must be non-null, in put()able state,
and with remaining capacity of at least the requested number of bytesexhibitName - the full name of the exhibit to read from;
never null and must be syntactically validposition - position/index of first byte in exhibitFile to read;
non-negativedontCache - if true, this is a hint not to attempt to cache this
or displace anything from extant caches for this data
as it may for example be precaching or random activity;
by default callers should leave this false to allow cacheing
java.lang.IllegalArgumentException - for blatantly invalid name,
or non-positive length
java.io.IOException - for requests that cannot be fulfilled because of
I/O restrictions or problems, such as link failure or
an upper bound on the length of a request
public AllExhibitImmutableData getAllExhibitImmutableData(long oldStamp)
throws java.io.IOException
If no exhibits are currently installed a default set with a zero timestamp is returned.
If the caller's copy appears to be up-to-date (eg the oldStamp matches that that we would have been returned) null is returned.
getAllExhibitImmutableData in interface SimpleExhibitPipelineIFjava.io.IOException - if the operation cannot be completed due to I/O
restrictions or failure
public AllExhibitProperties getAllExhibitProperties(long oldHash)
throws java.io.IOException
If no exhibits are currently installed then a default set with a zero timestamp is returned.
If the caller's copy appears to be up-to-date (eg the oldHash matches that that would have been returned) then null is returned.
Because the AEP drives the entire Gallery, we always let the request go over the tunnel even if recent calls have failed. For example, we don't want mirrors to remain out of sync for too long.
This also typically takes a lot of bandwidth and CPU/wallclock time, so is optimised and stripped down to a minimum, and relies on the AEP deserialisation for serious error checking.
It is hoped that using the streamed form will overlap I/O and CPU work and thus get the new AEP into the client quicker and smoother.
We attempt to be good citizens and note most RPC successes/failures to help maintain the tunnel's view of the master's status.
(Because satisfying these calls may take a long time, the upstream server may veto concurrent queries that return anything other than null.)
As a further attempt to minimise time and bandwidth, we may try the "diff" version of this call, falling back to the normal version if this fails.
getAllExhibitProperties in interface SimpleExhibitPipelineIFjava.io.IOException - if the operation cannot be completed due to I/O
restrictions or failure
public AllExhibitProperties getAllExhibitProperties(AllExhibitProperties oldAEP,
boolean allowAutoRecovery)
throws java.io.IOException
If the AEP specified is null then the remote AEP will be fetched and returned unconditionally.
If no exhibits are currently installed then a default set with a zero timestamp is returned.
If the caller's copy appears to be up-to-date (eg the oldHash matches that that would have been returned) then null is returned.
This is an attempted optimisation of the getAllExhibitProperties(long oldHash), returning a diff or extra-highly-compressed AEP representation.
This may not be supported at all by the remote end of the connection, or may fail for lack of resources, etc, so we can automatically fall back to the usual call in case of difficulty.
(We do not record failures as connection/tunnel problems, though we do note successful calls in favour of the connection status.)
oldAEP - current latest AEP held by the callerallowAutoRecovery - if true then allow fallback to generic AEP fetch method
java.io.IOExceptionpublic static byte[] longSer(long value)
public static byte[] intSer(int value)
public GenProps getGenProps(long oldStamp)
throws java.io.IOException
If no props are currently installed/available a default set with a zero timestamp is returned.
If the caller's copy appears to be up-to-date (eg the oldStamp matches that that we would have been returned) null is returned.
On the wire this is (outbound) a 8-byte timestamp and by return should be an empty payload (corresponding to null) or a serialised GenProps object (uncompressed for now).
Because GenProps are so important to the functioning of the entire Gallery, we always let the request go over the tunnel even if recent calls have failed.
getGenProps in interface SimpleExhibitPipelineIFjava.io.IOException - if the operation cannot be completed due to I/O
restrictions or failure
public java.util.Properties getGenSecProps(long oldStamp)
throws java.io.IOException
If no props are currently installed/available a default set with a zero timestamp is returned.
If the caller's copy appears to be up-to-date (eg the oldStamp matches that that would have been returned) null is returned.
getGenSecProps in interface SimpleExhibitPipelineIFjava.io.IOException - if the operation cannot be completed due to I/O
restrictions or failure
public ExhibitThumbnails getThumbnails(Name.ExhibitFull name,
boolean create)
throws java.io.IOException
Because it is important for a new mirror to gather thumbnails ASAP to show to a user, we make this call immune to being blocked when the tunnel connection appears poor.
getThumbnails in interface SimpleExhibitPipelineIFcreate - if true, and no thumbnail yet exists, try to
create one if possible, else only return an existing one
java.io.IOException - if the operation cannot be completed due to I/O
restrictions or failure
public void setVariable(SimpleVariableValue newValue)
throws java.io.IOException,
java.lang.UnsupportedOperationException
setVariable in interface BasicVarMgrInterfacejava.io.IOException - in case of I/O problems
java.lang.UnsupportedOperationException - when attempting to set localsprivate SimpleVariableValue adjustGlobalMapForSet(SimpleVariableValue svv)
If the argument is in the correct form, it is returned unchanged.
If the argument is illegal, ie not suitable to send upstream, then an exception is thrown to veto the send.
java.lang.IllegalArgumentException - if an invalid argument is passed,
eg unable to be converted to be sent upstream because it has
an invalid globalMap
public int setVariables(SimpleVariableValue[] newValues)
throws java.io.IOException,
java.lang.UnsupportedOperationException
Variables not defined in SystemVariables are rejected.
Duplicates may be discarded or rejected, or sent as is in which case it is undefined in which order they are applied.
We try to set all values that we can for
Format on the wire:
setVariables in interface BasicVarMgrInterfacejava.io.IOException - in case of I/O problems
java.lang.UnsupportedOperationException
public SimpleVariableValue getVariable(SimpleVariableDefinition var)
throws java.io.IOException,
java.lang.UnsupportedOperationException
When asked for the the system ID, we always answer the question locally.
Note that the local system ID can be retrieved whether or not the master server is responding.
Format on the wire is:
getVariable in interface BasicVarMgrInterfacevar - definition of variable to fetch; never null
java.io.IOException - in case of I/O error
java.lang.UnsupportedOperationException - if a local variable
other than the system ID is requested
public SimpleVariableValue[] getVariables(long changedSince)
throws java.io.IOException
Note that the local system ID can be retrieved whether or not the master server is responding providing the stamp is -1, though in that case it might be the only value returned. The caller should periodically use -1 to ensure that they have a full set of global variables, eg in case the server rebooted.
Format on the wire:
getVariables in interface BasicVarMgrInterfacejava.io.IOException
public EventVariableValue getEventValue(SimpleVariableDefinition def,
EventPeriod intervalSelector,
boolean current)
The current set is the most timely, but may not contain enough data to be meaningful if the new interval has just started.
The previous set is complete and thus most likely to have enough samples to be useful, but is not completely current.
Implemented in terms of the more general call in the hope that batched calls for several values will be more common and more efficient. This also reduces the number of distinct RPC calls that we have to implement.
getEventValue in interface BasicVarMgrInterfacedef - event definition (must be for an event); never nullintervalSelector - one of EVENT_INTERVAL_SELECTOR_xxx valuescurrent - if true the current event set is returned,
else the previous complete set is returned
public EventVariableValue[] getEventValues(SimpleVariableDefinition def,
EventPeriod intervalSelector,
long intervalNumber,
java.util.BitSet whichValues)
Requests for more than SystemVariables.EVENT_SAMPLES_RETAINED in the past (or for the future!) cannot be satisfied and data will not be returned for them.
Usually not more than SystemVariables.EVENT_SAMPLES_RETAINED samples will be returned in response to any one request as a safety measure.
We do various small optimisations to reduce fruitless traffic over what may be a slow and/or expensive connection:
The responses from the server may be large and slow, so we allow streaming to give better incremental CPU/resource consumption and better throughput.
Returns an empty result if asked for a 'local' value.
Returns an empty result if the tunnel is currently broken or in case of other non-permanent error.
TODO: Optimise RPC call by allowing for sparse requests with different request/response format.
getEventValues in interface BasicVarMgrInterfacedef - event definition (must be for an event); never nullintervalSelector - one of EVENT_INTERVAL_SELECTOR_xxx valuesintervalNumber - a time (as from System.currentTimeMillis())
which identifies the first interval for which data is potentially
required; if too far in the past or future then possibly no data
will be available,
zero is used to access the "all" bucketwhichValues - each true bit represents a slot for which data is
required, bit 0 indicating data from the slot within which
firstIntervalTime is located, bit 1 the previous slot, etc;
null is treated as the common case equivalent to just bit 0 set
public void syncVariables(boolean force)
throws java.io.IOException
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 returns immediately and the operation is not propagated across the tunnel.
In any case, it is rarely the right thing for a casual user to vall this as it may be very expensive.
syncVariables in interface SimpleVariablePipelineIFforce - 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, do nothing
java.io.IOException - if one is received from upstream
public java.util.Properties getProperties(SimpleExhibitPipelineIF.PropsKey key,
long versionID)
throws java.io.IOException
getProperties in interface SimpleExhibitPipelineIFkey - selector (with possible embedded sub-key)
for desired properties set; never nullversionID - if -1 then map is always returned if available,
else must be non-negative and null is returned if the versionID
presented matches that of the current version
(ie if the caller has presumably got the up-to-date version);
may be a timestamp or a hash or other value,
and by convention is zero only for an empty properties set
java.io.IOException
public Stratum getStratum()
throws java.io.IOException
getStratum in interface SimpleExhibitPipelineIFjava.io.IOExceptionprotected java.lang.String _getStratumUpstreamName()
public void poll(GenProps gp)
However, our general policy is not to force traffic if we need not.
This can be overridden by a derived class, though it is suggested that this be called with super.poll(gp) if so.
poll in interface SimpleExhibitPipelineIFpublic void destroy()
destroy in interface SimpleExhibitPipelineIF
protected abstract ExhibitDataTunnelSource.RawPacket doRPCRaw(ExhibitDataTunnelSource.RawPacket packetOut)
throws java.io.IOException
This can be locked on the instance lock to serialise RPCs, if the tunnel can only usefully handle one call at once.
Must be implemented by the deriving class to suit its transmission medium.
packetOut - request packet; never null
java.io.IOException - in case of I/O difficulties
protected Tuple.Pair<java.lang.Integer,java.io.InputStream> doRPCRawWithStreamResponse(ExhibitDataTunnelSource.RawPacket packetOut,
boolean allowBigReadTimeout)
throws java.io.IOException
This streams the content of the response packet and will object if it sees any IOException or if the packets come back with the wrong op code.
A terminating trailer byte may or may not be visible on the returned stream thus allowing the implementation to be as efficient as possible.
This may return after all the input data has been collected, or while some or all is still to come, and thus the returned stream may fail and throw an exception.
The first element of the result is the length of the response data (not including any non-data trailer bytes from the packet even if present) but may be null if this length is not known when the packet header is seen, eg because the packet body was compressed.
This may be implemented/overridden by the deriving class to suit its transmission medium, and as an optimisation to reduce copying and allow streaming, ie starting to process the input before it is all received.
The data stream is always of uncompressed data, regardless of whether the data was sent compressed on the wire, ie this routine will correctly decompress data on the fly as/when needed.
The caller must close the stream promptly to release resources such as file handles and non-Java memory.
packetOut - request packet; never nullallowBigReadTimeout - TODO
java.io.IOException - in case of I/O difficulties
protected ExhibitDataTunnelSource.RawPacket doRPC(ExhibitDataTunnelSource.RawPacket packetOut)
throws java.io.IOException
Called by all the public data-pipeline methods to transport information over the tunnel.
packetOut - request packet; never null
java.io.IOException - in case of I/O difficulties
protected ExhibitDataTunnelSource.RawPacket doRPCUnguarded(ExhibitDataTunnelSource.RawPacket packetOut)
throws java.io.IOException
Most callers should use the normal doRPC().
packetOut - never null
java.io.IOException
public static ExhibitDataTunnelSource.RawPacket handleInboundRPC(SimpleExhibitPipelineIF source,
ExhibitDataTunnelSource.RawPacket reqPacket,
java.lang.String clientAddr,
ExhibitDataTunnelSource.HIRPCCache cache,
SimpleLoggerIF logger)
throws java.io.IOException,
PGMasterNotInServiceException
reqPacket - the request packet; never nullclientAddr - the tunnel client's address as seen by us;
may be null if not applicable or availablecache - if not null, then selected routines with
slow/expensive responses will not be serviced concurrently
but concurrent calls will be vetoed quickly instead
and expensive-to-compute values may be (partially) cachedlogger - logging area for warnings, etc; never null.
java.io.IOException - in case of difficulty upstream
PGMasterNotInServiceException - if the upstream data source
is down/unavailable
private static ExhibitDataTunnelSource.RawPacket handleGetGenSecProps(SimpleExhibitPipelineIF source,
ExhibitDataTunnelSource.RawPacket reqPacket)
throws java.io.IOException
java.io.IOException
private static ExhibitDataTunnelSource.RawPacket handleSyncVariables(SimpleExhibitPipelineIF source,
ExhibitDataTunnelSource.RawPacket reqPacket)
throws java.io.IOException
java.io.IOException
private static ExhibitDataTunnelSource.RawPacket handleGetAllExhibitPropertiesDiff(SimpleExhibitPipelineIF source,
ExhibitDataTunnelSource.RawPacket reqPacket,
java.lang.String clientAddr,
ExhibitDataTunnelSource.HIRPCCache cache,
SimpleLoggerIF logger)
throws java.io.IOException,
java.io.InterruptedIOException
java.io.IOException
java.io.InterruptedIOException
private static ExhibitDataTunnelSource.RawPacket handleGetAllExhibitProperties(SimpleExhibitPipelineIF source,
ExhibitDataTunnelSource.RawPacket reqPacket,
java.lang.String clientAddr,
ExhibitDataTunnelSource.HIRPCCache cache,
SimpleLoggerIF logger)
throws java.io.IOException
java.io.IOException
private static ExhibitDataTunnelSource.RawPacket handleGetGenProps(SimpleExhibitPipelineIF source,
ExhibitDataTunnelSource.RawPacket reqPacket)
throws java.io.IOException
java.io.IOException
private static ExhibitDataTunnelSource.RawPacket handleGetStaticAttr(SimpleExhibitPipelineIF source,
ExhibitDataTunnelSource.RawPacket reqPacket)
throws java.io.IOException
java.io.IOException
private static ExhibitDataTunnelSource.RawPacket handleGetEventValues(SimpleExhibitPipelineIF source,
ExhibitDataTunnelSource.RawPacket reqPacket)
throws java.io.IOException
Result is:
java.io.IOException
private static ExhibitDataTunnelSource.RawPacket handleGetVariables(SimpleExhibitPipelineIF source,
ExhibitDataTunnelSource.RawPacket reqPacket)
throws java.io.IOException
java.io.IOException
private static ExhibitDataTunnelSource.RawPacket handleSetVariables(SimpleExhibitPipelineIF source,
ExhibitDataTunnelSource.RawPacket reqPacket,
java.lang.String clientAddr,
SimpleLoggerIF logger)
throws java.io.IOException
We'll validate the entire set of values, and reject the whole lot if any are dubious.
java.io.IOException
private static ExhibitDataTunnelSource.RawPacket handleGetVariable(SimpleExhibitPipelineIF source,
ExhibitDataTunnelSource.RawPacket reqPacket)
throws java.io.IOException
java.io.IOException
private static ExhibitDataTunnelSource.RawPacket handleGetRawFile(SimpleExhibitPipelineIF source,
ExhibitDataTunnelSource.RawPacket reqPacket)
throws java.io.IOException
FIXME: decide whether to honour a false dontCache flag or not
java.io.IOException
private static ExhibitDataTunnelSource.RawPacket handleGetThumbnails(SimpleExhibitPipelineIF source,
ExhibitDataTunnelSource.RawPacket reqPacket)
throws java.io.IOException
java.io.IOException
private static ExhibitDataTunnelSource.RawPacket handleGetAllExhibitImmutableData(SimpleExhibitPipelineIF source,
ExhibitDataTunnelSource.RawPacket reqPacket,
ExhibitDataTunnelSource.HIRPCCache cache,
SimpleLoggerIF logger)
throws java.io.IOException
java.io.IOException
private static ExhibitDataTunnelSource.RawPacket handleGetStratum(SimpleExhibitPipelineIF source,
ExhibitDataTunnelSource.RawPacket reqPacket)
throws java.io.IOException
java.io.IOException
|
DHD Multimedia Gallery V1.57.21 | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||