public final class QueryScope extends java.lang.Object
This class allows applications to define queries that are done on a subset of nodes in the cluster.
When a query is executed using a user defined query scope, the current
audit mode is used to verify the scope. If the default QueryScope.AuditMode.AUDIT_NODE_LIST
audit mode
is enabled, distributed queries are skipped if distribution is not
active when the query is executed. If distribution is active, only
those nodes that are active in the node list are used in the query,
all other nodes are ignored. Otherwise, the auditing documented in the
QueryScope.AuditMode
enumeration is
performed, and a ResourceUnavailableException exception is thrown
if the audit fails.
When setAuditMode(AuditMode)
is called, no audits
are done at that time. Only when a query is executed is auditing done.
This insures that auditing is performed before each execution of the query.
To support cluster wide queries, the QUERY_CLUSTER
predefined instance of QueryScope can be used.
To disable node or cluster scoped queries, the QUERY_LOCAL
predefined instance of QueryScope can be used.
Modifier and Type | Class and Description |
---|---|
static class |
QueryScope.AuditMode
Possible audits that can be applied to the query.
|
Modifier and Type | Field and Description |
---|---|
static QueryScope |
QUERY_CLUSTER
The query will be done on all active nodes in the cluster.
|
static QueryScope |
QUERY_LOCAL
The query will be done only on the local node.
|
Constructor and Description |
---|
QueryScope()
Create a QueryScope instance with no nodes.
|
QueryScope(java.lang.String[] remoteNodes)
Create a QueryScope instance
|
Modifier and Type | Method and Description |
---|---|
void |
addNode(java.lang.String nodeName)
Adds the specified node if not already present.
|
QueryScope.AuditMode |
getAuditMode()
Return the current audit mode.
|
java.lang.String[] |
getNodes()
Get the nodes defined for this query scope.
|
void |
removeNode(java.lang.String nodeName)
Removed the specified node.
|
void |
setAuditMode(QueryScope.AuditMode auditMode)
Set audit mode when queries are executed.
|
public static final QueryScope QUERY_LOCAL
public static final QueryScope QUERY_CLUSTER
public QueryScope()
public QueryScope(java.lang.String[] remoteNodes)
remoteNodes
- Array of remote nodes.public void addNode(java.lang.String nodeName) throws java.lang.UnsupportedOperationException
nodeName
- Node to add.java.lang.UnsupportedOperationException
- The operation was called on QUERY_LOCAL or QUERY_CLUSTER.public void removeNode(java.lang.String nodeName) throws java.lang.UnsupportedOperationException
nodeName
- Node to remove.java.lang.UnsupportedOperationException
- The operation was called on QUERY_LOCAL or QUERY_CLUSTER.public java.lang.String[] getNodes()
If this method is called on QUERY_LOCAL or QUERY_CLUSTER instances, a zero length array is returned.
public void setAuditMode(QueryScope.AuditMode auditMode) throws java.lang.UnsupportedOperationException
auditMode
- Audit mode to use.java.lang.UnsupportedOperationException
- The operation was called on QUERY_LOCAL or QUERY_CLUSTER.public QueryScope.AuditMode getAuditMode() throws java.lang.UnsupportedOperationException
java.lang.UnsupportedOperationException
- The operation was called on QUERY_LOCAL or QUERY_CLUSTER.