Package org.snmp4j.agent.db
Class MOXodusPersistenceProvider
java.lang.Object
org.snmp4j.agent.db.MOXodusPersistenceProvider
- All Implemented Interfaces:
AutoCloseable,org.snmp4j.agent.io.MOPersistenceProvider,org.snmp4j.cfg.EngineBootsProvider,org.snmp4j.cfg.EngineIdProvider
public class MOXodusPersistenceProvider
extends Object
implements org.snmp4j.agent.io.MOPersistenceProvider, org.snmp4j.cfg.EngineBootsProvider, org.snmp4j.cfg.EngineIdProvider
The
MOXodusPersistenceProvider implements a MOPersistenceProvider that uses a JetBrains Xodus
database for persistent storage of RandomAccessManagedObjects.
Using RandomAccessManagedObject persistence with this MOXodusPersistenceProvider has
the following advantages:
- Less disk space usage than with
DefaultMOPersistenceProvider - Any Managed object changes are store via
MOChangeListenerandMOTableRowListenerpersistently into the database immediately. - Concurrent access to storage is safe.
MOServerPersistence for sample code and further usage details.
To release the locks created on the Xodus database hold by the default persistence provider, close() need
to be called explicitly.- Version:
- 3.7.2
- Author:
- Frank Fock
-
Constructor Summary
ConstructorsConstructorDescriptionMOXodusPersistenceProvider(MOXodusPersistence defaultPersistence) Creates aMOXodusPersistenceProviderbased with a provided defaultMOXodusPersistencehandler that provides the default storage access operations and listens forRandomAccessManagedObjectupdate events (seeMOXodusPersistence.registerChangeListenersWithServer(MOServer)for details). -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Close the Xodus environment (DB) used by the default persistence located atgetDefaultURI().Gets the URI of the default persistent storage for this provider.intReturns current engine boot counter value.org.snmp4j.smi.OctetStringgetEngineId(org.snmp4j.smi.OctetString defaultEngineID) Returns a unique ID of the persistence provider which should identify the format and type of the persistence provider.booleanisValidPersistenceURI(String uriString) Checks whether the supplied URI string is valid for this persistence provider.voidresetEngineId(org.snmp4j.smi.OctetString engineId) voidRestore (load) agent state from the specified URI (can be as simple as a file path).voidRestore (load) agent state from the specified URI (can be as simple as a file path).voidStores the current agent state to persistent storage specified by the supplied URI.voidintReturns the current engine boot counter value incremented by one.
-
Constructor Details
-
MOXodusPersistenceProvider
Creates aMOXodusPersistenceProviderbased with a provided defaultMOXodusPersistencehandler that provides the default storage access operations and listens forRandomAccessManagedObjectupdate events (seeMOXodusPersistence.registerChangeListenersWithServer(MOServer)for details). AdditionalMOXodusPersistencecan be created on the fly, withstore(String).- Parameters:
defaultPersistence- the default persistence handler.
-
-
Method Details
-
restore
Restore (load) agent state from the specified URI (can be as simple as a file path).- Specified by:
restorein interfaceorg.snmp4j.agent.io.MOPersistenceProvider- Parameters:
uri- a string pointing to the persistent storage from which the agent state should be restored from. The format of the string is specified by the persistence provider. Anullvalue can be specified to let the persistence provider use its default URI. If that default URI isnulltoo, aNullPointerExceptionwill be thrown.importMode- specifies how the agent's current state should be update while restoring a previous state.- Throws:
IOException- if the restore operation fails.- Since:
- 1.2
-
restore
public void restore(String uri, int importMode, org.snmp4j.agent.mo.MOPriorityProvider priorityProvider) throws IOException Restore (load) agent state from the specified URI (can be as simple as a file path).- Specified by:
restorein interfaceorg.snmp4j.agent.io.MOPersistenceProvider- Parameters:
uri- a string pointing to the persistent storage from which the agent state should be restored from. The format of he string is specified by the persistence provider. Anullvalue can be specified to let the persistence provider use its default URI. If that default URI isnulltoo, aNullPointerExceptionwill be thrown.importMode- specifies how the agent's current state should be update while restoring a previous state.priorityProvider- if notnull, this parameter specifies in which order theManagedObjects are restored and which object contains the latest restore configuration which has to be restored at first to be able to restore the rest.- Throws:
IOException- if the restore operation fails.- Since:
- 3.5.0
-
store
Stores the current agent state to persistent storage specified by the supplied URI.- Specified by:
storein interfaceorg.snmp4j.agent.io.MOPersistenceProvider- Parameters:
uri- a string pointing to the persistent storage from which the agent state should be stored to. The format of the string is specified by the persistence provider. Anullvalue can be specified to let the persistence provider use its default URI. If that default URI isnulltoo, aNullPointerExceptionwill be thrown.- Throws:
IOException- if the store operation fails.- Since:
- 1.2
-
store
public void store(String uri, org.snmp4j.agent.mo.MOPriorityProvider priorityProvider) throws IOException - Specified by:
storein interfaceorg.snmp4j.agent.io.MOPersistenceProvider- Throws:
IOException
-
isValidPersistenceURI
Checks whether the supplied URI string is valid for this persistence provider.- Specified by:
isValidPersistenceURIin interfaceorg.snmp4j.agent.io.MOPersistenceProvider- Parameters:
uriString- a string identifying a persistent storage location for this storage provider.- Returns:
trueif theuriis valid,falseotherwise.- Since:
- 1.2
-
getPersistenceProviderID
Returns a unique ID of the persistence provider which should identify the format and type of the persistence provider.- Specified by:
getPersistenceProviderIDin interfaceorg.snmp4j.agent.io.MOPersistenceProvider- Returns:
- an 1-32 character long string that identifies the persistence provider.
- Since:
- 1.2
-
getDefaultURI
Gets the URI of the default persistent storage for this provider.- Specified by:
getDefaultURIin interfaceorg.snmp4j.agent.io.MOPersistenceProvider- Returns:
- the URI (e.g. file path) for the default persistent storage location of
this provider. A provider may use a different one. A
nullvalue indicates that there is no default location.
-
updateEngineBoots
public int updateEngineBoots()Returns the current engine boot counter value incremented by one. If that number would by greater than 2^31-1 then one is returned. The engine boots provider has to make sure that the returned value is persistently stored before the method returns.- Specified by:
updateEngineBootsin interfaceorg.snmp4j.cfg.EngineBootsProvider- Returns:
- the last engine boots counter incremented by one.
-
getEngineBoots
public int getEngineBoots()Returns current engine boot counter value.- Specified by:
getEngineBootsin interfaceorg.snmp4j.cfg.EngineBootsProvider- Returns:
- the last engine boots counter.
-
getEngineId
public org.snmp4j.smi.OctetString getEngineId(org.snmp4j.smi.OctetString defaultEngineID) - Specified by:
getEngineIdin interfaceorg.snmp4j.cfg.EngineIdProvider
-
resetEngineId
public void resetEngineId(org.snmp4j.smi.OctetString engineId) - Specified by:
resetEngineIdin interfaceorg.snmp4j.cfg.EngineIdProvider
-
close
Close the Xodus environment (DB) used by the default persistence located atgetDefaultURI(). That environment is then no longer usable.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceorg.snmp4j.agent.io.MOPersistenceProvider- Throws:
Exception- If there is an error on closing the environment. This should never happen with current Xodus releases.- Since:
- 3.7.2
-