public abstract class FRAPI extends Object
This class defines the public interface to FusionReactor.
All API calls internally check whether FusionReactor is available before proceeding. Storing references to objects produced by this type any longer than strictly necessary (certainly not longer than the course of a single page request) is strongly discouraged, in order to reduce the scope for memory leaks. This object itself may be stored and reused if required.
This is a factory-type class; you must not instantiate it yourself, rather use the
getInstance()
method.
Modifier and Type | Field and Description |
---|---|
static int |
KILL_STATUS_ALREADY_DISPOSED
Indicates this request has already been disposed of -- already completed or killed.
|
static int |
KILL_STATUS_ALREADY_NOTIFIED
Indicates this request has already been notified of a kill action by some other mechanism.
|
static int |
KILL_STATUS_KILLED
Indicates this request was killed.
|
static int |
KILL_STATUS_NOT_KILLED
Indicates Guard attempted to kill this request but could not.
|
static int |
KILL_STATUS_UNABLE
Indicates this request could not be killed because the Intergral APM Guard OSGi Service is
not running, or the FusionReactor Guard Component is not available.
|
static String |
TRACE_CONTEXT_ID
Indicates the Transit context used to store FusionReactor Traces.
|
static String |
TRACE_CONTEXT_NAME
The name of the Transit property used to store traces.
|
Constructor and Description |
---|
FRAPI()
The default constructor should not be called publicly.
|
Modifier and Type | Method and Description |
---|---|
abstract com.intergral.apm.transit.txn.TrackedTransaction |
createTrackedTransaction(String flavor)
Creates a transaction in the APM Transit system.
|
abstract com.intergral.apm.transit.txn.BaseTransaction |
createTransaction(String flavor)
Creates a transaction in the APM Transit system.
|
abstract boolean |
deleteLog(String name)
Deletes a given logfile.
|
abstract void |
deregisterNotification(long id)
Deregister a previously-registered notification.
|
abstract void |
enableCloudMetric(String seriesId)
Enables a given metric for transfer to FusionReactor Cloud.
|
abstract String |
explainKillStatus(int killStatus)
Explain a given kill result value.
|
abstract com.intergral.apm.transit.txn.BaseTransaction |
getActiveMasterTransaction()
Get the master (root) transaction on this thread.
|
abstract com.intergral.apm.transit.txn.BaseTransaction |
getActiveTransaction()
Get the current transaction on this thread.
|
abstract long |
getAllocatedMemory()
Get the quantity of memory allocated to the JVM by the operating system.
|
abstract short |
getCpuUsage()
Get the current CPU usage.
|
abstract File |
getCurrentLogDirectory()
Get the location of the current FusionReactor log directory.
|
abstract File |
getCurrentLogFolder()
Get the location of the current FusionReactor log folder.
|
abstract long |
getDeepObjectSize(Object objectToSize)
Returns an implementation-specific approximation of the total amount of storage consumed by
the specified object by summing the storage recursively of it's fields.
|
abstract long |
getFreeMemory()
Get the quantity of free memory available to the VM, including any not yet allocated.
|
abstract IVersion |
getFRVersion()
Returns an implementation of the
IVersion interface to expose FusionReactor version
information. |
static FRAPI |
getInstance()
Get a concrete instance of the FusionReactor API, on which further calls can be made.
|
abstract File |
getLogfile(String name)
Gets a
File object representing the named log. |
abstract int |
getLogFileVersion()
Get a string containing the version of the log files.
|
abstract long |
getNextRotationTime()
Get the next rotation time.
|
abstract long |
getObjectSize(Object objectToSize)
Returns an implementation-specific approximation of the amount of storage consumed by the
specified object.
|
abstract long |
getProbeInterval()
Gets the interval, in milliseconds, of the internal resource-gathering probes.
|
abstract IFusionRequestSurrogate[] |
getRecentRequests()
Query FusionReactor for the a list of historic WebRequests currently held by FusionReactor.
|
abstract IFusionRequestSurrogate |
getRequest(long id)
Get a request by ID.
|
abstract ConfigurationSurrogate |
getRunningConfiguration()
Return a deep clone of the currently running configuration.
|
abstract IFusionRequestSurrogate[] |
getRunningRequests()
Return an array containing objects representing all requests currently being tracked by
FusionReactor.
|
abstract double |
getSeriesAverage(String seriesId)
Get the mean value of the currently-held values for the series.
|
abstract double |
getSeriesCount(String seriesId)
Get the count of values currently held for this series.
|
abstract double |
getSeriesSum(String seriesId)
Get the sum of the values currently held for this series.
|
static Map |
getSharedMap()
Non-api: clients must not call this method.
|
abstract long |
getStartedAt()
Returns the Java epoch time at which the system was started.
|
abstract long |
getStartTime()
Get the time in milliseconds since the epoch at which the server was started.
|
abstract String |
getStartTimeString()
Get the system uptime as a date/time string of the form
HH:mm:ss dd-MMM-yyyy |
abstract long |
getTotalMemory()
Get the quantity of memory available to the JVM, including any not yet allocated to it by the
JVM.
|
abstract String |
getUemTrackingScript()
Gets a set of JavaScript that can be injected into a page to provide User Experience,
Management and Tracking metrics for FusionReactor's transaction engine.
|
abstract long |
getUptime()
Get the number of milliseconds since FusionReactor was last started.
|
abstract long |
getUsedMemory()
Get the quantity of memory currently allocated by the JVM to Java objects.
|
abstract String |
getUserCookieName()
Gets the name of the cookie used for authentication.
|
abstract String |
getUserCookieValue(String role,
String password)
Gets the value of the cookie used for authentication.
|
abstract boolean |
isFusionReactorRunning()
Attempt to locate FusionReactor in memory and return a boolean indicating success or failure.
|
abstract boolean |
isInitialized()
Gets a boolean indicating whether FR has started up and is ready for FRAPI requests.
|
abstract boolean |
isMemoryProtectionActive()
Get a boolean describing whether Crash Protection's Memory Protection feature is enabled.
|
abstract boolean |
isRequestProtectionActive()
Get a boolean describing whether Crash Protection's Request Protection feature is enabled.
|
abstract boolean |
isTimeoutProtectionActive()
Get a boolean describing whether Crash Protection's Timeout Protection feature is enabled.
|
abstract int |
kill(long fusionRequestId,
String userTraceMarker)
Kill a running request.
|
abstract void |
log(String filename,
String text)
Write an INFORMATION entry to a log file.
|
abstract void |
log(String filename,
String level,
String text)
Write a message to a log, with a given level.
|
abstract void |
postMetric(String seriesId,
Object payload)
Post an untyped metric to Metro.
|
abstract void |
postNumericAggregateMetric(String seriesId,
float value)
Post a numeric metric to metro, and create a standard set of aggregators on that series.
|
abstract void |
postNumericAggregateMetric(String seriesId,
long value)
Post a numeric metric to metro, and create a standard set of aggregators on that series.
|
abstract void |
postNumericAggregateMetricFloat(String seriesId,
float value)
Post a floating point value to a series.
|
abstract void |
postNumericAggregateMetricLong(String seriesId,
long value)
Post an integral value to a series.
|
abstract void |
postNumericAggregateMetrics(Map<String,Number> values)
Post a collection of numeric metrics to metro, and create a standard set of aggregators on each series.
|
abstract void |
postNumericMetric(String seriesId,
float value)
Post a numeric metric to metro.
|
abstract void |
postNumericMetric(String seriesId,
long value)
Post a numeric metric to metro.
|
abstract void |
postNumericMetricFloat(String seriesId,
float value)
Post a floating point value to a series.
|
abstract void |
postNumericMetricLong(String seriesId,
long value)
Post an integral value to a series.
|
abstract IProbiCallback.ICallbackRegistration |
registerCallback(IProbiCallback callback,
long period)
Register a callback for a sampler.
|
abstract long |
registerNotification(String title,
String message,
short severity)
Generate a notification.
|
abstract long |
registerNotification(String title,
String message,
short severity,
String origin)
Version of
registerNotification(String, String, short) which allows the client to
set the origin string for the notification. |
abstract void |
rotateLogs()
Requests an immediate log rotation.
|
abstract boolean |
sendOsgiEventAsync(com.intergral.fusionreactor.capi.event.IEvent event)
Sends an event into the OSGi (Plugin) subsystem.
|
abstract com.intergral.fusionreactor.capi.event.IEvent |
sendOsgiEventSync(com.intergral.fusionreactor.capi.event.IEvent event,
String replyTopic,
long timeout)
Sends an event into the OSGi (Plugin) framework.
|
abstract void |
setPageTimeout(int seconds)
Reset the timeout value for this page.
|
abstract void |
setRequestCaptureFolder(String fullPath)
Change the location to which Request Capture will store request and response data.
|
static void |
setSharedMap(Map map)
Non-api: clients must not call this method.
|
abstract void |
setTransactionApplicationName(String name)
Set the application name for the master transaction on this thread.
|
abstract void |
setTransactionName(String name)
Set the transaction name for the master transaction on this thread.
|
abstract void |
setVMOption(String name,
String value)
Set an option on the Java Virtual Machine.
|
abstract void |
subscribeOsgiEvent(String topic,
com.intergral.fusionreactor.capi.event.IEventHandler handler)
Subscribes an
IEventHandler within the OSGi plugin subsystem. |
abstract void |
trace(Object object)
Attach an object to this request as a trace element.
|
abstract void |
trace(String traceString)
Attach a user trace string to this request.
|
abstract void |
unsubscribeOsgiEvent(com.intergral.fusionreactor.capi.event.IEventHandler handler)
Unsubscribe a given handler from the OSGi event system.
|
abstract boolean |
wasShutdownCleanly()
Gets a boolean indicating whether FR was shutdown cleanly last time.
|
public static final int KILL_STATUS_ALREADY_DISPOSED
public static final int KILL_STATUS_ALREADY_NOTIFIED
public static final int KILL_STATUS_KILLED
public static final int KILL_STATUS_UNABLE
public static final int KILL_STATUS_NOT_KILLED
public static final String TRACE_CONTEXT_ID
public static final String TRACE_CONTEXT_NAME
public FRAPI()
getInstance()
.public static final FRAPI getInstance()
Get a concrete instance of the FusionReactor API, on which further calls can be made.
public abstract void trace(String traceString)
Attach a user trace string to this request. These strings are available within the FusionReactor GUI in the Request Details page, and also appear in the FusionReactor debug console.
If FusionReactor is not running, this method does nothing.
traceString
- The string to be attached to this request.TRACE_CONTEXT_ID
.public abstract void trace(Object object)
Attach an object to this request as a trace element. The semantics of this method are the
same as trace(String)
, except that the object is attached to the request instead of
a string.
When FusionReactor displays the object, it will use the Object.toString()
method to
produce a string for display.
Caution: because of the way Traces are now implemented (as Transit Contexts), the lifetime of this object cannot be easily calculated. You should therefore ensure that the object has as few efferent references as possible.
object
- the object to be attached to this request for tracing.public abstract boolean isFusionReactorRunning()
public abstract void setPageTimeout(int seconds)
Reset the timeout value for this page. If Timeout Protection is not active within FusionReactor, calls to this method have no effect. If Timeout Protection is active, the value passed to this method overrides the value configured in FusionReactor.
If FusionReactor is not running, this method does nothing.
seconds
- the timeout in seconds after which this page will be aborted.public abstract IFusionRequestSurrogate[] getRunningRequests()
Return an array containing objects representing all requests currently being tracked by FusionReactor. There is a small time penalty associated with this method, since it must temporarily lock FusionReactor to obtain the list of running requests.
N.b. By the time your code uses the objects returned by this method, they may have completed.
IFusionRequestSurrogate
objects representing all
running tracked requests, or a zero-length array if FusionReactor was not detected.public abstract IFusionRequestSurrogate[] getRecentRequests()
Query FusionReactor for the a list of historic WebRequests currently held by FusionReactor.
N.b. By the time your code uses the objects returned by this method, they may no longer be in FusionReactor.
IFusionRequestSurrogate
objects representing all
requests that are currently held in the FusionReactor history, or null
if FusionReactor cannot be found.public abstract ConfigurationSurrogate getRunningConfiguration()
ConfigurationSurrogate
object constructed as a deep-clone of the
running configuration, which may be manipulated safely.public abstract void setRequestCaptureFolder(String fullPath) throws ConfigurationInvalidExceptionSurrogate, IOException
fullPath
- a full path specifying a folder which exists on the system.ConfigurationInvalidExceptionSurrogate
- with a descriptive message, if FusionReactor could not adopt the new
configuration.IOException
- if FusionReactor could not open write a new configuration prior to adopting it.public abstract int kill(long fusionRequestId, String userTraceMarker)
fusionRequestId
- the ID of the request which is to be killed.userTraceMarker
- if non-null and not an empty string, this trace marker will be stored with the
request.KILL_STATUS_*
set of enumeration
defined in this type.public abstract String explainKillStatus(int killStatus)
killStatus
- the status to be explained.public abstract long getFreeMemory()
OutOfMemoryError
. This value is commonly influenced using the -Xmx
JVM
parameter.long
representing the quantity of unused memory in bytes.public abstract long getTotalMemory()
Get the quantity of memory available to the JVM, including any not yet allocated to it by the
JVM. This value is commonly influenced using the -Xmx
JVM parameter.
long
representing the total quantity of memory available to the JVM in
bytes.public abstract long getUsedMemory()
long
representing the total quantity of memory allocated to Java
objects in bytes.public abstract long getAllocatedMemory()
long
representing the quantity of allocated memory in bytes.public abstract short getCpuUsage()
Get the current CPU usage.
short
describing the JVMs processor occupancy in percent, across all
cores. If CPU sampling is not supported on this platform, -1 is returned.public abstract long getStartTime()
public abstract String getStartTimeString()
HH:mm:ss dd-MMM-yyyy
public abstract long getUptime()
public abstract boolean isRequestProtectionActive()
public abstract boolean isTimeoutProtectionActive()
public abstract boolean isMemoryProtectionActive()
public abstract int getLogFileVersion()
public abstract IFusionRequestSurrogate getRequest(long id)
id
- the ID of the request being sought.IFusionRequestSurrogate
if the request could be located in the running
transaction structure, or the history list. If not, or Transit is not available,
null
.public abstract void log(String filename, String level, String text)
filename
- filename of the log to write to.level
- one of INFO, WARN or SEVERE. null
means a log level will not be written.text
- text entry to write to the log.public abstract void log(String filename, String text)
filename
- filename of the log to write to.text
- text entry to write to the log.public abstract void setVMOption(String name, String value)
Set an option on the Java Virtual Machine.
name
- name of the option to set.value
- value for the option.public abstract long getStartedAt()
Returns the Java epoch time at which the system was started.
public abstract void rotateLogs()
Requests an immediate log rotation.
public abstract long getProbeInterval()
public abstract File getCurrentLogFolder()
public abstract File getCurrentLogDirectory()
public abstract long getNextRotationTime()
-1
if the rotation task is not active (log engine is in legacy
mode) or has stopped.public abstract String getUserCookieName()
public abstract String getUserCookieValue(String role, String password)
role
- the role for which a cookie is required, one of "Administrator", "Manager" or
"Observer"password
- the password which will be stored in the cookiepublic abstract boolean isInitialized()
public abstract boolean wasShutdownCleanly()
true
if the system was shutdown cleanly, otherwise false
.public abstract File getLogfile(String name)
File
object representing the named log.name
- the named of the log for which a file is requiredFile
representing the named log (which may not exist yet)public abstract boolean deleteLog(String name)
name
- the name of the log being deleted.true
if the log was deleted, otherwise false
.public abstract boolean sendOsgiEventAsync(com.intergral.fusionreactor.capi.event.IEvent event)
If no Event Admin service was available in the OSGi framework, the method returns
false
.
event
- the event to be placed on the OSGi event bus.true
if the event was sent.public abstract com.intergral.fusionreactor.capi.event.IEvent sendOsgiEventSync(com.intergral.fusionreactor.capi.event.IEvent event, String replyTopic, long timeout)
timeout
milliseconds.
Any bundle may generate the reply event. If more than one reply event is sent by a bundle, the first one is used.
Although the method is able to wait indefinitely for a reply, this is strongly discouraged since OSGi bundles can be removed and restarted with no notice.
event
- the event to be placed on the OSGi event bus.replyTopic
- the topic of the event to be waited for in replytimeout
- a timeout value in milliseconds. If no reply is received after this timeout,
null
is returned. -1
signifies the method should wait
indefinitely.public abstract void subscribeOsgiEvent(String topic, com.intergral.fusionreactor.capi.event.IEventHandler handler)
IEventHandler
within the OSGi plugin subsystem. Whenever a topic is
raised with the given passed string, the event handler is called.
Any bundle may generate the given event. The passed topic may conform to any valid OSGi topic string, i.e. may contain a single trailing wildcard.
If no Event Admin service was available in the OSGi framework, no events will be raised.
topic
- the topic being subscribed to.handler
- an IEventHandler
capable of receiving events.public abstract void unsubscribeOsgiEvent(com.intergral.fusionreactor.capi.event.IEventHandler handler)
If the given handler is not actually subscribed to any events, the method returns immediately.
handler
- the handler being unsubscribed.public abstract long registerNotification(String title, String message, short severity)
title
- a terse string containing the title of the notification.message
- a more verbose string consisting of plain text, describing the notification.severity
- 0 = INFO, 1 = WARNING, 2 = SEVERE (as defined in
com.intergral.fusionreactor.notifications.INotification
public abstract long registerNotification(String title, String message, short severity, String origin)
registerNotification(String, String, short)
which allows the client to
set the origin string for the notification.origin
- a terse string containing the origin of the notification (e.g. page name or
application subsystem).title
- a terse string containing the title of the notification.message
- a more verbose string consisting of plain text, describing the notification.severity
- 0 = INFO, 1 = WARNING, 2 = SEVERE (as defined in
com.intergral.fusionreactor.notifications.INotification
public abstract void deregisterNotification(long id)
id
- the ID supplied as the return value of
registerNotification(String, String, short)
public abstract void postMetric(String seriesId, Object payload)
seriesId
- the ID of the series tracking this metric. This will be created if it does not
exist.payload
- the object to be posted.public abstract void postNumericMetric(String seriesId, long value)
seriesId
- the ID of the series tracking this metric. This will be created if it does not
exist. The series will not have a standard set of aggregators at 5s, 1m and
1h.value
- the value to be tracked.public abstract void postNumericMetric(String seriesId, float value)
seriesId
- the ID of the series tracking this metric. This will be created if it does not
exist. The series will not have a standard set of aggregators at 5s, 1m and
1h.value
- the value to be tracked.public abstract void postNumericMetricFloat(String seriesId, float value)
postNumericMetric(String, float)
, but is supplied here to provide an unambiguous
signature for scripting languages which automatically select methods incorrectly.seriesId
- the ID of the series tracking this metric. This will be created if it does not
exist. The series will not have a standard set of aggregators at 5s, 1m and
1h.value
- the value to be tracked.public abstract void postNumericMetricLong(String seriesId, long value)
postNumericMetric(String, long)
, but is supplied here to provide an unambiguous
signature for scripting languages which automatically select methods incorrectly.seriesId
- the ID of the series tracking this metric. This will be created if it does not
exist. The series will not have a standard set of aggregators at 5s, 1m and
1h.value
- the value to be tracked.public abstract void postNumericAggregateMetricFloat(String seriesId, float value)
postNumericMetric(String, float)
, but is supplied here to provide an unambiguous
signature for scripting languages which automatically select methods incorrectly.seriesId
- the ID of the series tracking this metric. This will be created if it does not
exist. The series will have a standard set of aggregators at 5s, 1m and 1h.value
- the value to be tracked.public abstract void postNumericAggregateMetricLong(String seriesId, long value)
postNumericMetric(String, long)
, but is supplied here to provide an unambiguous
signature for scripting languages which automatically select methods incorrectly.seriesId
- the ID of the series tracking this metric. This will be created if it does not
exist. The series will have a standard set of aggregators at 5s, 1m and 1h.value
- the value to be tracked.public abstract void postNumericAggregateMetric(String seriesId, long value)
seriesId
- the ID of the series tracking this metric. This will be created if it does not
exist. The series will have a standard set of aggregators at 5s, 1m and 1h.value
- the value to be tracked.public abstract void postNumericAggregateMetric(String seriesId, float value)
seriesId
- the ID of the series tracking this metric. This will be created if it does not
exist. The series will have a standard set of aggregators at 5s, 1m and 1h.value
- the value to be tracked.public abstract void postNumericAggregateMetrics(Map<String,Number> values)
values
- the collection of values to post to metro, where the key is the seriesId.public abstract void enableCloudMetric(String seriesId)
If this metric does not exist, it will be created as a numeric, aggregating metric. If this metric exists, it must be a numeric, aggregating metric.
seriesId
- the metric to be transferredpublic abstract double getSeriesAverage(String seriesId)
seriesId
- the series for which a value is required.-1
if the series does not
exist or Metro is not available.public abstract double getSeriesCount(String seriesId)
seriesId
- the series for which a value is required.-1
if the series does not
exist or Metro is not available.public abstract double getSeriesSum(String seriesId)
seriesId
- the series for which a value is required.-1
if the series does not
exist or Metro is not available.public abstract String getUemTrackingScript()
public abstract com.intergral.apm.transit.txn.BaseTransaction createTransaction(String flavor) throws com.intergral.apm.transit.api.gate.GateException, IllegalArgumentException
new BaseTransaction( flavor )
. The transaction flavor will not be tracked in Metro.
The thrown exception must be handled as Exception
, since the GateException hierarchy
is not yet exposed in FRAPI.
flavor
- the type of transaction required.BaseTransaction
with the given flavor.com.intergral.apm.transit.api.gate.GateTimeoutException
- if the transaction timed out while traversing Transit input gates.com.intergral.apm.transit.api.gate.GateRejectionException
- if the transaction was rejected immediately by any Transit input gate.com.intergral.apm.transit.api.gate.GateException
- if the transaction couldn't be created due to a Transit transaction gate refusing
the request.IllegalArgumentException
- if the provided flavor is null or an empty stringpublic abstract com.intergral.apm.transit.txn.TrackedTransaction createTrackedTransaction(String flavor) throws com.intergral.apm.transit.api.gate.GateException, IllegalArgumentException
new BaseTransaction( flavor )
. The transaction flavor will be tracked in Metro.
The thrown exception must be handled as Exception
, since the GateException hierarchy
is not yet exposed in FRAPI.
flavor
- the type of transaction required.BaseTransaction
with the given flavor.com.intergral.apm.transit.api.gate.GateTimeoutException
- if the transaction timed out while traversing Transit input gates.com.intergral.apm.transit.api.gate.GateRejectionException
- if the transaction was rejected immediately by any Transit input gate.com.intergral.apm.transit.api.gate.GateException
- if the transaction couldn't be created due to a Transit transaction gate refusing
the request.IllegalArgumentException
- if the provided flavor is null or an empty stringpublic abstract com.intergral.apm.transit.txn.BaseTransaction getActiveTransaction()
BaseTransaction
on this thread or null if no transaction is
active, for instance if the page is exempt from FusionReactor tracking by
restrictions.public abstract com.intergral.apm.transit.txn.BaseTransaction getActiveMasterTransaction()
BaseTransaction
on this thread or null if no transaction is
active.public abstract void setTransactionName(String name) throws IllegalStateException, IllegalArgumentException
name
- name of the transactionIllegalStateException
- if no transaction is active on this threadIllegalArgumentException
- if name is null
or is an empty stringpublic abstract void setTransactionApplicationName(String name) throws IllegalStateException, IllegalArgumentException
name
- name of the applicationIllegalStateException
- if no transaction is active on this threadIllegalArgumentException
- if name is null
or is an empty stringpublic abstract long getObjectSize(Object objectToSize) throws IllegalStateException
objectToSize
- the object to sizeIllegalStateException
- if Java Instrumentation is not availablepublic abstract long getDeepObjectSize(Object objectToSize) throws IllegalStateException
objectToSize
- the object to sizeIllegalStateException
- if Java Instrumentation is not availableRuntimeException
- if a field on an object cannot be accessedpublic abstract IVersion getFRVersion()
IVersion
interface to expose FusionReactor version
information.IVersion
interface. Will return null
if a
instance of IVersion cannot be found.public abstract IProbiCallback.ICallbackRegistration registerCallback(IProbiCallback callback, long period)
callback
- the call back implementation you want to use.period
- the period in milliseconds between calls. Minimum period of 1000 milliseconds.
The stated period is not guaranteed to be accurate, and will be adjusted to the
nearest second during calls. Any value that is not a multiple of 1000 will be
rounded up to the next second.public static void setSharedMap(Map map)
map
- the map that will be set as a shared mappublic static Map getSharedMap()
Copyright © 2005-2017 Intergral Information Solutions GmbH. All Rights Reserved.