net.xqhs.graphs.context
Class CCMImplementation

java.lang.Object
  extended by net.xqhs.util.config.Config
      extended by net.xqhs.util.logging.Unit
          extended by net.xqhs.graphs.context.CCMImplementation
All Implemented Interfaces:
ContinuousContextMatchingPlatform, ContinuousMatchingProcess, net.xqhs.util.config.Configurable

public class CCMImplementation
extends net.xqhs.util.logging.Unit
implements ContinuousContextMatchingPlatform


Nested Class Summary
(package private)  class CCMImplementation.MatchNotificationTarget
           
 
Nested classes/interfaces inherited from class net.xqhs.util.config.Config
net.xqhs.util.config.Config.ConfigLockedException
 
Nested classes/interfaces inherited from interface net.xqhs.graphs.context.ContinuousMatchingProcess
ContinuousMatchingProcess.MatchNotificationReceiver
 
Field Summary
(package private)  boolean continuousMatching
           
(package private)  GraphMatchingPlatform matchingPlatform
           
(package private)  java.util.Map<ContextPattern,java.util.Set<CCMImplementation.MatchNotificationTarget>> notificationTargets
           
(package private)  Instant.TimeKeeper theTime
           
 
Fields inherited from class net.xqhs.util.logging.Unit
DEFAULT_LEVEL, DEFAULT_UNIT_NAME
 
Constructor Summary
CCMImplementation(Instant.TimeKeeper time, MonitorPack monitorLink)
           
 
Method Summary
 CCMImplementation addContextPattern(ContextPattern pattern)
          Adds a context pattern to the set of context patterns, if not already existing.
 CCMImplementation addMatchNotificationTarget(ContextPattern pattern, ContinuousMatchingProcess.MatchNotificationReceiver receiver)
          Adds a notification target for matches of the specified pattern.
 CCMImplementation addMatchNotificationTarget(int thresholdK, ContinuousMatchingProcess.MatchNotificationReceiver receiver)
          Registers a ContinuousMatchingProcess.MatchNotificationReceiver as target for notifications for new matches below or with a specified k (see Match.
protected  void getMatching()
           
 boolean isContinuouslyMatching()
           
protected  void notifyContextChange()
           
 CCMImplementation removeContextPattern(ContextPattern pattern)
          Removes a pattern from the platform.
 ContinuousMatchingProcess removeMatchNotificationTarget(ContinuousMatchingProcess.MatchNotificationReceiver receiver)
          Removes all registrations of the specified ContinuousMatchingProcess.MatchNotificationReceiver.
 CCMImplementation setContextGraph(ContextGraph graph)
          Assigns a new context graph to this implementation.
 CCMImplementation startContinuousMatching()
          Instructs the process to start or to resume (from the state in which it was stopped).
 ContinuousMatchingProcess startMatchingAgainstAllPatterns(Graph graph, int thresholdK, ContinuousMatchingProcess.MatchNotificationReceiver receiver)
          Creates a new ContinuousMatchingProcess, unrelated to the platform except for the set of patterns, to match all patterns against the specified Graph instance.
 ContinuousMatchingProcess startMatchingAgainstGraph(Graph pattern, int thresholdK, ContinuousMatchingProcess.MatchNotificationReceiver receiver)
          Creates a new ContinuousMatchingProcess, unrelated to the platform except for the current sequence of the Context Graph (not the matching sequence), that matches the context graph against the specified pattern.
 CCMImplementation stopContinuousMatching()
          Instructs the process to stop.
 
Methods inherited from class net.xqhs.util.logging.Unit
compose, dbg, doExit, getDefaultUnitName, getUnitName, l, le, lf, li, lock, lockedR, lr, lr, lw, setLink, setLink, setLogDisplay, setLogEnsureNew, setLoggerClass, setLoggerType, setLoggerTypeClass, setLogLevel, setLogReporter, setUnitName, setUnitName
 
Methods inherited from class net.xqhs.util.config.Config
build, ensureLocked, locked, lockedEx, makeDefaults
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

theTime

Instant.TimeKeeper theTime

matchingPlatform

GraphMatchingPlatform matchingPlatform

continuousMatching

boolean continuousMatching

notificationTargets

java.util.Map<ContextPattern,java.util.Set<CCMImplementation.MatchNotificationTarget>> notificationTargets
Constructor Detail

CCMImplementation

public CCMImplementation(Instant.TimeKeeper time,
                         MonitorPack monitorLink)
Method Detail

setContextGraph

public CCMImplementation setContextGraph(ContextGraph graph)
Description copied from interface: ContinuousContextMatchingPlatform
Assigns a new context graph to this implementation. It will also set the time keeper of the graph to the time keeper of the platform.

The platform will begin matching the current set of patterns to the new graph immediately.

Specified by:
setContextGraph in interface ContinuousContextMatchingPlatform
Parameters:
graph - - the ContextGraph.
Returns:
the platform itself.

addContextPattern

public CCMImplementation addContextPattern(ContextPattern pattern)
Description copied from interface: ContinuousContextMatchingPlatform
Adds a context pattern to the set of context patterns, if not already existing.

The pattern will not allow modifications after this method is called (it will be Config.locked().

Matching against the pattern will begin immediately.

Specified by:
addContextPattern in interface ContinuousContextMatchingPlatform
Parameters:
pattern - - the GraphPattern to add.
Returns:
the platform itself.

removeContextPattern

public CCMImplementation removeContextPattern(ContextPattern pattern)
Description copied from interface: ContinuousContextMatchingPlatform
Removes a pattern from the platform.

Specified by:
removeContextPattern in interface ContinuousContextMatchingPlatform
Parameters:
pattern - - the ContextPattern to remove.
Returns:
the platform itself.

addMatchNotificationTarget

public CCMImplementation addMatchNotificationTarget(int thresholdK,
                                                    ContinuousMatchingProcess.MatchNotificationReceiver receiver)
Description copied from interface: ContinuousMatchingProcess
Registers a ContinuousMatchingProcess.MatchNotificationReceiver as target for notifications for new matches below or with a specified k (see Match.

Specified by:
addMatchNotificationTarget in interface ContinuousMatchingProcess
Parameters:
thresholdK - - the threshold k.
receiver - - the receiver for the notifications.
Returns:
the process itself.

addMatchNotificationTarget

public CCMImplementation addMatchNotificationTarget(ContextPattern pattern,
                                                    ContinuousMatchingProcess.MatchNotificationReceiver receiver)
Description copied from interface: ContinuousContextMatchingPlatform
Adds a notification target for matches of the specified pattern.

Specified by:
addMatchNotificationTarget in interface ContinuousContextMatchingPlatform
Parameters:
pattern - - the GraphPattern whose new matches will be notified to the receiver.
receiver - - the receiver of notifications.
Returns:
the platform itself.

removeMatchNotificationTarget

public ContinuousMatchingProcess removeMatchNotificationTarget(ContinuousMatchingProcess.MatchNotificationReceiver receiver)
Description copied from interface: ContinuousMatchingProcess
Removes all registrations of the specified ContinuousMatchingProcess.MatchNotificationReceiver.

Specified by:
removeMatchNotificationTarget in interface ContinuousMatchingProcess
Parameters:
receiver - - the specified notification receiver.
Returns:
the process itself.

startMatchingAgainstAllPatterns

public ContinuousMatchingProcess startMatchingAgainstAllPatterns(Graph graph,
                                                                 int thresholdK,
                                                                 ContinuousMatchingProcess.MatchNotificationReceiver receiver)
Description copied from interface: ContinuousContextMatchingPlatform
Creates a new ContinuousMatchingProcess, unrelated to the platform except for the set of patterns, to match all patterns against the specified Graph instance.

The matching process is started immediately

When matches of any k below or equal to the specified threshold are detected, the notification receiver is invoked.

Specified by:
startMatchingAgainstAllPatterns in interface ContinuousContextMatchingPlatform
Parameters:
graph - - the graph to match the patterns against.
thresholdK - - the threshold k (see Match).
receiver - - the receiver for match notifications.
Returns:
the newly created and started ContinuousMatchingProcess instance.

startMatchingAgainstGraph

public ContinuousMatchingProcess startMatchingAgainstGraph(Graph pattern,
                                                           int thresholdK,
                                                           ContinuousMatchingProcess.MatchNotificationReceiver receiver)
Description copied from interface: ContinuousContextMatchingPlatform
Creates a new ContinuousMatchingProcess, unrelated to the platform except for the current sequence of the Context Graph (not the matching sequence), that matches the context graph against the specified pattern.

Matching is done against a shadow of the context graph. Any subsequent changes to the context graph will not be visible in the matching process.

Except for the snapshot of the context graph, this method uses no resources of the platform.

The matching process is started immediately.

When matches of any k below or equal to the specified threshold are detected, the notification receiver is invoked.

Specified by:
startMatchingAgainstGraph in interface ContinuousContextMatchingPlatform
Parameters:
pattern - - the pattern to match (can be a normal Graph).
thresholdK - - the threshold k (see Match).
receiver - - the receiver for match notifications.
Returns:
the newly created and started ContinuousMatchingProcess instance.

startContinuousMatching

public CCMImplementation startContinuousMatching()
Description copied from interface: ContinuousMatchingProcess
Instructs the process to start or to resume (from the state in which it was stopped). It may already be ongoing.

Specified by:
startContinuousMatching in interface ContinuousMatchingProcess
Returns:
the process itself.

stopContinuousMatching

public CCMImplementation stopContinuousMatching()
Description copied from interface: ContinuousMatchingProcess
Instructs the process to stop. State will be kept until the process is resumed. It may already be stopped.

Specified by:
stopContinuousMatching in interface ContinuousMatchingProcess
Returns:
the process itself.

isContinuouslyMatching

public boolean isContinuouslyMatching()
Specified by:
isContinuouslyMatching in interface ContinuousMatchingProcess
Returns:
true if the process is currently ongoing (in a separate thread). false otherwise.

getMatching

protected void getMatching()

notifyContextChange

protected void notifyContextChange()