Class StatementMetricArray
java.lang.Object
com.espertech.esper.common.internal.metrics.stmtmetrics.StatementMetricArray
Holder for statement group's statement metrics.
Changes to StatementMetric instances must be done in a read-lock:
getRwLock.readLock.lock() metric = getAddMetric(index) metric.accountFor(cpu, wall, etc) getRwLock.readLock.unlock()
All other changes are done under write lock for this class.
This is a collection backed by an array that grows by 50% each time expanded, maintains a free/busy list of statement names, maintains an element number of last used element.
The flush operaton copies the complete array, thereby keeping array size. Statement names are only removed on the next flush.
-
Constructor Summary
ConstructorDescriptionStatementMetricArray
(String runtimeURI, String name, int initialSize, boolean isReportInactive) Ctor. -
Method Summary
Modifier and TypeMethodDescriptionint
addStatementGetIndex
(DeploymentIdNamePair statement) Adds a statement and returns the index added at.Flushes the existing metrics via array copy and swap.getAddMetric
(int index) Returns an existing or creates a new statement metric for the index.getName()
Returns the read-write lock, for read-lock when modifications are made.boolean
void
iterate
(Consumer<EPMetricsStatement> consumer) void
removeStatement
(DeploymentIdNamePair statement) Remove a statement.int
Returns maximum collection size (last used element), which may not truely reflect the number of actual statements held as some slots may empty up when statements are removed.
-
Constructor Details
-
StatementMetricArray
public StatementMetricArray(String runtimeURI, String name, int initialSize, boolean isReportInactive) Ctor.- Parameters:
runtimeURI
- runtime URIname
- name of statement groupinitialSize
- initial size of arrayisReportInactive
- true to indicate to report on inactive statements
-
-
Method Details
-
removeStatement
Remove a statement.Next flush actually frees the slot that this statement occupied.
- Parameters:
statement
- to remove
-
addStatementGetIndex
Adds a statement and returns the index added at.May reuse an empty slot, grow the underlying array, or append to the end.
- Parameters:
statement
- deployment-id and name pair- Returns:
- index added to
-
flushMetrics
Flushes the existing metrics via array copy and swap.May report all statements (empty and non-empty slots) and thereby null values.
Returns null to indicate no reports to do.
- Returns:
- metrics
-
getRwLock
Returns the read-write lock, for read-lock when modifications are made.- Returns:
- lock
-
getAddMetric
Returns an existing or creates a new statement metric for the index.- Parameters:
index
- of statement- Returns:
- metric to modify under read lock
-
sizeLastElement
public int sizeLastElement()Returns maximum collection size (last used element), which may not truely reflect the number of actual statements held as some slots may empty up when statements are removed.- Returns:
- known maximum size
-
getName
-
iterate
-
isReportInactive
public boolean isReportInactive()
-