public abstract class AbstractStoreBasedTagProvider extends java.lang.Object implements TagProvider, TypeManagerProvider, ScanclassListener, TagSubscriptionChangeListener, RedundancyStateListener, TagStoreListener, ExecutableTagCollection
Modifier and Type | Class and Description |
---|---|
protected class |
AbstractStoreBasedTagProvider.AddTagsTask
Used to run inside of the tag lock, adjusts names or deletes previous, and adds the new tags.
|
protected class |
AbstractStoreBasedTagProvider.LeasedTagMaintenanceManager |
protected static class |
AbstractStoreBasedTagProvider.SmartTagLicenseTracker |
protected static class |
AbstractStoreBasedTagProvider.TagAddNameResolver
This is a tricky little hack for handling tag name modification when adding many tags.
|
protected class |
AbstractStoreBasedTagProvider.TemporaryConfigProvider
Provides the tag so that we don't have to look anything up during register, then we'll switch it to the tag
provider
|
Modifier and Type | Field and Description |
---|---|
protected java.util.List<NotLicensedTag> |
notLicensedTags |
protected java.util.Map<java.lang.String,java.util.List<ExecutableTag>> |
orphanedHistoricalTags |
protected TagExecutor |
orphanedTagExecutor |
protected java.util.Map<java.lang.String,java.util.List<ExecutableTag>> |
orphanedTags |
protected java.util.Map<EntityId,ExecutableScanClass> |
scIdMap |
protected java.util.Map<java.lang.String,ExecutableScanClass> |
scNameMap |
protected java.util.Map<EntityId,ExecutableTag> |
tagIdMap |
protected TagTree |
tagTree |
protected ComplexTypeManager |
typeManager |
protected java.util.Map<EntityId,java.util.Set<EntityId>> |
udtMemberMap |
NO_IMP_SENTINAL_LISTSTR, NO_IMP_SENTINAL_PROPSET
Modifier | Constructor and Description |
---|---|
protected |
AbstractStoreBasedTagProvider(GatewayContext context,
TagProviderMeta meta) |
protected |
AbstractStoreBasedTagProvider(GatewayContext context,
TagProviderMeta meta,
java.lang.String dataSource) |
Modifier and Type | Method and Description |
---|---|
void |
addScanClasses(java.util.List<ScanClass> scanClasses)
****************************** START - Configuration Code.
|
void |
addTags(TagPath parentFolder,
java.util.List<TagNode> tags,
TagManagerBase.CollisionPolicy policy)
Tag configuration code
These functions operate by passing the op down into the tag store.
|
protected <T extends Tag> |
breakupTagsBySC(java.util.Collection<T> tags,
boolean historical) |
java.util.List<Tag> |
browse(TagPath path)
Provides the tags located beneath the specified path.
|
abstract java.util.List<BrowseElement> |
browseOPC(java.lang.String driver,
BrowseElement root)
****************************** START - Browsing *******************************
|
protected TagPermissionsModel.PermissionResult |
checkCustomPermissions(TagPath path,
Tag tag,
boolean isWrite,
AuthenticatedUser user) |
protected void |
checkNameChange(java.util.Collection<ExecutableTag> tagsToChange,
java.lang.String name)
Verifies that the name change won't collide, throws exception otherwise.
|
protected abstract TagStore |
createAndConfigureTagStore()
Abstract functions
|
protected abstract ExecutableFactory |
createExecutableFactory() |
protected void |
deregisterOrphanedTags(java.lang.String scanclass,
java.util.Collection<ExecutableTag> tags,
boolean historical) |
void |
editTags(java.util.List<TagPath> paths,
TagDiff edit)
Applies the given TagDiff edit to the paths indicated
|
protected abstract void |
evaluateScanClassLeases(java.util.Set<java.lang.String> subscribedScanClasses)
Called when it's necessary to look at what scan classes are leased, and take the appropriate action, such as
setting the scan classes expiration, or writing to the database.
|
void |
executeScanclass(java.lang.String scname) |
protected TagPath |
findClosestExistingFolder(TagPath path)
Returns the path of the closest folder currently present in the tag tree.
|
protected GatewayContext |
getContext()
************************************* From TagDriver **************************************
|
java.lang.String |
getDatasourceName() |
protected ExecutableFactory |
getExecutableFactory() |
ExecutionManager |
getExecutionManager() |
protected abstract SQLTagsExecutor |
getExecutor()
Gets the 'scanclassexecutor', which is the owner of the scanclass.
|
protected GatewayFolderTag |
getFolderTag(TagPath path)
Returns a folder tag, creating it if necessary.
|
protected java.util.List<EntityId> |
getIds(java.util.Collection<ExecutableTag> tags) |
TagProviderMeta |
getInformation()
Provides meta information that describes the tag provider.
|
protected java.lang.Exception |
getLastError() |
protected AbstractStoreBasedTagProvider.SmartTagLicenseTracker |
getLicenseTracker() |
protected LoggerEx |
getLogger() |
java.lang.String |
getName()
*********************************** Core functions, TagDriver interface.
|
QualifiedPath |
getObjectPath() |
GatewayTag |
getRunningTag(TagPath path) |
protected ExecutableScanClass |
getScanClass(EntityId id) |
java.util.List<ScanClass> |
getScanClasses()
Returns the scan classes defined for the provider, if the provider supports them.
|
protected java.util.List<ExecutableScanClass> |
getScanClassesForNames(java.util.Collection<java.lang.String> names)
Returns the scan classes for the given names, with NULL value for names that weren't found.
|
protected ExecutableScanClass |
getScanClassForName(java.lang.String name) |
org.apache.log4j.Logger |
getSQLTErrorLogger() |
ProfileStatus |
getStatus() |
TagProviderInformation |
getStatusInformation()
Returns execution information that describes the current state of the provider.
|
protected ExecutableTag |
getTag(EntityId id) |
Tag |
getTag(TagPath path)
Returns the tag located at a specific path.
|
TagDiagnostics |
getTagDiagnostics(TagPath path)
Gets information about the state of an executing tag.
|
protected ProviderSubscriptionManager |
getTagReferenceManager() |
protected java.util.Set<ExecutableTag> |
getTagsForPaths(java.util.Collection<TagPath> paths,
boolean deep) |
protected java.util.Set<ExecutableTag> |
getTagsForPaths(java.util.Collection<TagPath> paths,
boolean deep,
boolean includeTopLevel,
com.google.common.base.Predicate<ExecutableTag> filterPredicate)
Will return the tags for the given paths, recursing deeply if specified.
|
protected TagStore |
getTagStore() |
TypeManager |
getTypeManager() |
protected void |
handleDeletedScanclasses(java.util.Collection<EntityId> ids) |
protected void |
handleDeletedTags(java.util.Collection<EntityId> ids) |
protected void |
handleModifiedScanClasses(java.util.Collection<TagStoreObject<ScanClass>> scanClasses) |
protected void |
handleModifiedTags(java.util.Collection<TagStoreObject<TagConfig>> tags) |
protected void |
internalStartup(TagSubscriptionModel model) |
protected java.util.List<Quality> |
internalWriteToFolders(java.util.List<WriteRequest<TagPath>> requests) |
protected java.util.List<Quality> |
internalWriteValue(java.util.List<WriteRequest<TagPath>> requests)
Initiates a value write.
|
protected boolean |
isErrored() |
protected boolean |
isFolderTag(TagPath path)
Returns true if the given path exists, and is a Folder.
|
boolean |
isPublic()
Returns whether this driving is public/browsable.
|
protected boolean |
isRunning() |
protected boolean |
isTagLicensable(ExecutableTag tag)
Returns whether the tag is affected by a tag limit license.
|
protected void |
manageSubscriptions(java.util.Collection<TagSubscription> subs,
boolean add) |
void |
modifyScanClass(java.lang.String scName,
ScanClass newDefinition) |
protected void |
notifyTagsChanged(java.util.Collection<EntityId> ids) |
protected void |
processOPCWrites(java.util.List<TagOPCWriteRequest> writeValues) |
java.util.List<QualifiedValue> |
read(java.util.List<TagPath> paths,
AuthenticatedUser user,
boolean isSystem)
Reads the values of the given tag paths.
|
void |
redundancyConnStatusChanged(ClusterPeerConnectionStatus status)
Called when the connection state between this node and the other changes- on connect and disconnect.
|
void |
redundancyStateChanged(RedundancyState newState)
Called when the node's "redundancy state" changes - ie, its activity level.
|
protected void |
registerOrphanedTags(java.lang.String scanclass,
java.util.Collection<ExecutableTag> tags,
boolean historical) |
protected void |
registerTags(java.util.Collection<ExecutableTag> tags)
The process of registering tags consists of the following stages: 1) Find the existing tags we're replacing,
remove them from their current scan classes.
|
protected void |
reloadTags(java.util.Set<EntityId> ids)
Asks the tag store to reload the selected tags.
|
protected void |
removeImplicitFolders(java.util.List<TagPath> paths)
These handles the removal of folders that were created implicitly, and therefore don't have an entity id.
|
void |
removeScanClasses(java.util.List<java.lang.String> scanclassNames)
Removes scan classes with the given names.
|
void |
removeTags(java.util.List<TagPath> tagPaths)
Removes the tags at the given tag paths.
|
protected void |
renameFolder(ExecutableTag tag,
java.lang.String newName) |
protected void |
reregisterOrphanedTags(ExecutableScanClass sce,
boolean historical) |
protected void |
reregisterUnlicensedTags()
When events occur that could possibly free up tags in the license, this function is called to try to re-register
the ones we previously excluded.
|
protected void |
retireHistoricalTags(java.util.Collection<ExecutableTag> tags) |
protected void |
runInConfigLock(java.lang.Runnable r)
Allows subclasses to perform any action they want inside the config lock, which protects tags and scan classes.
|
void |
scanclassRateChanged(ScanclassEvent e) |
void |
scanclassStatisticsChanged(ScanclassEvent e) |
void |
setDatasourceName(java.lang.String value) |
protected void |
setLastError(java.lang.Exception lastError) |
protected void |
setRunning(boolean running) |
void |
shutdown() |
protected void |
startScanclasses() |
void |
startup(TagSubscriptionModel model) |
protected void |
stopScanclasses() |
void |
subscriptionChanged(TagSubscriptionChangeEvent event) |
protected void |
tagLimitChanged() |
void |
tagstoreItemsAdded(java.util.Collection<TagStoreObject<TagConfig>> tags,
java.util.Collection<TagStoreObject<ScanClass>> scanClasses)
Item management and execution functions.
|
void |
tagstoreItemsRemoved(java.util.Collection<EntityId> tagIds,
java.util.Collection<EntityId> scanclassIds) |
void |
tagstorePropertiesChanged(java.util.Collection<TagPropertyValue> values)
Indicates that properties have changed, originating from the tag store.
|
void |
tagValuesChanged(java.util.List<TagPropertyValue> values)
This is the function that is called when a sc completes execution.
|
protected void |
updateStatMetrics(java.util.Map<java.lang.String,NamedValue<StatMetric>> statMetrics)
Gives sub classes the opportunity to add their own stat metrics onto the map that will be returned to
getStatusInformation.
|
protected void |
updateStatusProperties(java.util.Map<java.lang.String,NamedValue> properties) |
protected void |
verifyOrCreateScanClasses(java.util.Collection<java.lang.String> scNames,
boolean historical)
We currently make sure there's a scan class instantiated for any name that a tag has.
|
protected java.util.List<Tag> |
wrapTagsToDef(java.util.List<Tag> tags) |
java.util.List<Quality> |
write(java.util.List<WriteRequest<TagPath>> requests,
AuthenticatedUser user,
boolean isSystem)
Performs the given write requests against the tags, checking the authenticated user/isSystem permissions.
|
protected java.util.List<Quality> |
writeToLocalTags(java.util.List<WriteRequest<TagPath>> requests)
Writes directly to tags in this driver.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getDrivers, getExtendedTagResources, getHistoricalProviders
protected final java.util.Map<java.lang.String,ExecutableScanClass> scNameMap
protected final java.util.Map<EntityId,ExecutableScanClass> scIdMap
protected TagTree tagTree
protected final java.util.Map<EntityId,ExecutableTag> tagIdMap
protected final java.util.Map<java.lang.String,java.util.List<ExecutableTag>> orphanedTags
protected final java.util.Map<java.lang.String,java.util.List<ExecutableTag>> orphanedHistoricalTags
protected final java.util.List<NotLicensedTag> notLicensedTags
protected TagExecutor orphanedTagExecutor
protected ComplexTypeManager typeManager
protected AbstractStoreBasedTagProvider(GatewayContext context, TagProviderMeta meta)
protected AbstractStoreBasedTagProvider(GatewayContext context, TagProviderMeta meta, java.lang.String dataSource)
public ExecutionManager getExecutionManager()
public TypeManager getTypeManager()
getTypeManager
in interface TypeManagerProvider
protected AbstractStoreBasedTagProvider.SmartTagLicenseTracker getLicenseTracker()
protected TagStore getTagStore()
public QualifiedPath getObjectPath()
public org.apache.log4j.Logger getSQLTErrorLogger()
public java.lang.String getDatasourceName()
public void setDatasourceName(java.lang.String value)
protected abstract TagStore createAndConfigureTagStore()
protected ExecutableTag getTag(EntityId id)
protected boolean isFolderTag(TagPath path)
path
- protected void internalStartup(TagSubscriptionModel model) throws java.lang.Exception
java.lang.Exception
public void shutdown()
shutdown
in interface TagProvider
protected java.util.List<EntityId> getIds(java.util.Collection<ExecutableTag> tags)
public void tagstoreItemsAdded(java.util.Collection<TagStoreObject<TagConfig>> tags, java.util.Collection<TagStoreObject<ScanClass>> scanClasses)
tagstoreItemsAdded
in interface TagStoreListener
public void tagstoreItemsRemoved(java.util.Collection<EntityId> tagIds, java.util.Collection<EntityId> scanclassIds)
tagstoreItemsRemoved
in interface TagStoreListener
public void tagstorePropertiesChanged(java.util.Collection<TagPropertyValue> values)
TagStoreListener
tagstorePropertiesChanged
in interface TagStoreListener
protected void handleModifiedScanClasses(java.util.Collection<TagStoreObject<ScanClass>> scanClasses)
protected void handleDeletedScanclasses(java.util.Collection<EntityId> ids)
protected void handleModifiedTags(java.util.Collection<TagStoreObject<TagConfig>> tags)
protected void handleDeletedTags(java.util.Collection<EntityId> ids)
protected void removeImplicitFolders(java.util.List<TagPath> paths)
paths
- protected void reloadTags(java.util.Set<EntityId> ids)
ids
- protected void notifyTagsChanged(java.util.Collection<EntityId> ids)
public void addTags(TagPath parentFolder, java.util.List<TagNode> tags, TagManagerBase.CollisionPolicy policy) throws java.lang.Exception
addTags
in interface TagProvider
java.lang.Exception
public void editTags(java.util.List<TagPath> paths, TagDiff edit) throws java.lang.Exception
TagProvider
editTags
in interface TagProvider
java.lang.Exception
protected void checkNameChange(java.util.Collection<ExecutableTag> tagsToChange, java.lang.String name) throws java.lang.Exception
pathsToChange
- name
- java.lang.Exception
public void removeTags(java.util.List<TagPath> tagPaths) throws java.lang.Exception
TagProvider
removeTags
in interface TagProvider
java.lang.Exception
protected void renameFolder(ExecutableTag tag, java.lang.String newName) throws java.lang.Exception
java.lang.Exception
protected void verifyOrCreateScanClasses(java.util.Collection<java.lang.String> scNames, boolean historical) throws java.lang.Exception
java.lang.Exception
public void addScanClasses(java.util.List<ScanClass> scanClasses) throws java.lang.Exception
addScanClasses
in interface TagProvider
java.lang.Exception
public void modifyScanClass(java.lang.String scName, ScanClass newDefinition) throws java.lang.Exception
modifyScanClass
in interface TagProvider
java.lang.Exception
public void removeScanClasses(java.util.List<java.lang.String> scanclassNames)
TagProvider
removeScanClasses
in interface TagProvider
public abstract java.util.List<BrowseElement> browseOPC(java.lang.String driver, BrowseElement root) throws java.lang.Exception
browseOPC
in interface TagProvider
java.lang.Exception
protected GatewayContext getContext()
protected LoggerEx getLogger()
protected abstract ExecutableFactory createExecutableFactory()
public ProfileStatus getStatus()
public TagProviderInformation getStatusInformation()
TagProvider
getStatusInformation
in interface TagProvider
protected void setRunning(boolean running)
protected boolean isRunning()
protected boolean isErrored()
protected void setLastError(java.lang.Exception lastError)
protected java.lang.Exception getLastError()
protected void startScanclasses()
protected void stopScanclasses()
protected void updateStatusProperties(java.util.Map<java.lang.String,NamedValue> properties)
protected void updateStatMetrics(java.util.Map<java.lang.String,NamedValue<StatMetric>> statMetrics)
statMetrics
- public java.lang.String getName()
public TagProviderMeta getInformation()
TagProvider
getInformation
in interface TagProvider
public boolean isPublic()
isPublic
in interface TagProvider
protected ProviderSubscriptionManager getTagReferenceManager()
public final void startup(TagSubscriptionModel model)
startup
in interface TagProvider
public java.util.List<Tag> browse(TagPath path)
TagCollection
browse
in interface TagCollection
public Tag getTag(TagPath path)
TagCollection
getTag
in interface TagCollection
public GatewayTag getRunningTag(TagPath path)
getRunningTag
in interface ExecutableTagCollection
protected GatewayFolderTag getFolderTag(TagPath path)
path
- public TagDiagnostics getTagDiagnostics(TagPath path)
TagProvider
getTagDiagnostics
in interface TagProvider
public java.util.List<ScanClass> getScanClasses()
TagProvider
getScanClasses
in interface TagProvider
protected final ExecutableFactory getExecutableFactory()
protected java.util.Set<ExecutableTag> getTagsForPaths(java.util.Collection<TagPath> paths, boolean deep, boolean includeTopLevel, com.google.common.base.Predicate<ExecutableTag> filterPredicate)
paths
- protected java.util.Set<ExecutableTag> getTagsForPaths(java.util.Collection<TagPath> paths, boolean deep)
protected java.util.List<ExecutableScanClass> getScanClassesForNames(java.util.Collection<java.lang.String> names)
names
- @Nullable protected ExecutableScanClass getScanClassForName(java.lang.String name)
protected ExecutableScanClass getScanClass(EntityId id)
protected void runInConfigLock(java.lang.Runnable r) throws java.lang.Exception
r
- java.lang.Exception
public void executeScanclass(java.lang.String scname)
executeScanclass
in interface TagProvider
protected TagPermissionsModel.PermissionResult checkCustomPermissions(TagPath path, Tag tag, boolean isWrite, AuthenticatedUser user)
public java.util.List<QualifiedValue> read(java.util.List<TagPath> paths, AuthenticatedUser user, boolean isSystem)
TagProvider
read
in interface TagProvider
paths
- of tags to read.user
- against which to check security permissions.isSystem
- if true, will bypass most security checks.public final java.util.List<Quality> write(java.util.List<WriteRequest<TagPath>> requests, AuthenticatedUser user, boolean isSystem)
TagProvider
write
in interface TagProvider
requests
- provide the target path and value to write.user
- against which to check security permissions.isSystem
- if true, will bypass most security checks.protected java.util.List<Quality> internalWriteValue(java.util.List<WriteRequest<TagPath>> requests)
requests
- tags
- protected java.util.List<Quality> internalWriteToFolders(java.util.List<WriteRequest<TagPath>> requests)
protected java.util.List<Quality> writeToLocalTags(java.util.List<WriteRequest<TagPath>> requests)
requests
- protected abstract SQLTagsExecutor getExecutor()
protected abstract void evaluateScanClassLeases(java.util.Set<java.lang.String> subscribedScanClasses)
protected void registerTags(java.util.Collection<ExecutableTag> tags)
tags
- protected TagPath findClosestExistingFolder(TagPath path)
protected <T extends Tag> java.util.Map<java.lang.String,java.util.List<T>> breakupTagsBySC(java.util.Collection<T> tags, boolean historical)
protected void retireHistoricalTags(java.util.Collection<ExecutableTag> tags)
protected void registerOrphanedTags(java.lang.String scanclass, java.util.Collection<ExecutableTag> tags, boolean historical)
protected void reregisterOrphanedTags(ExecutableScanClass sce, boolean historical)
protected void deregisterOrphanedTags(java.lang.String scanclass, java.util.Collection<ExecutableTag> tags, boolean historical)
public void tagValuesChanged(java.util.List<TagPropertyValue> values)
tagValuesChanged
in interface TagValueListener
e
- public void scanclassStatisticsChanged(ScanclassEvent e)
scanclassStatisticsChanged
in interface ScanclassListener
public void scanclassRateChanged(ScanclassEvent e)
scanclassRateChanged
in interface ScanclassListener
protected void processOPCWrites(java.util.List<TagOPCWriteRequest> writeValues)
public void subscriptionChanged(TagSubscriptionChangeEvent event)
subscriptionChanged
in interface TagSubscriptionChangeListener
protected void manageSubscriptions(java.util.Collection<TagSubscription> subs, boolean add)
public void redundancyStateChanged(RedundancyState newState)
RedundancyStateListener
redundancyStateChanged
in interface RedundancyStateListener
public void redundancyConnStatusChanged(ClusterPeerConnectionStatus status)
RedundancyStateListener
redundancyConnStatusChanged
in interface RedundancyStateListener
protected boolean isTagLicensable(ExecutableTag tag)
tag
- protected void reregisterUnlicensedTags()
protected void tagLimitChanged()