public class PersistenceToolsHelper extends Object
Modifier and Type | Field and Description |
---|---|
static String |
ARCHIVE_SNAPSHOT
JMX operation to archive a snapshot
|
static String |
CREATE_SNAPSHOT
JMX operation to create a snapshot.
|
static String |
FORCE_RECOVERY
JMX operation to force recovery.
|
static String |
RECOVER_SNAPSHOT
JMX operation to recover a snapshot.
|
static String |
REMOVE_ARCHIVED_SNAPSHOT
JMX operation to remove an archived snapshot
|
static String |
REMOVE_SNAPSHOT
JMX operation to remove a snapshot.
|
static String |
RESUME_SERVICE
JMX operation to resume a service.
|
static String |
RETRIEVE_ARCHIVED_SNAPSHOT
JMX operation to retrieve an archived snapshot
|
static String |
SUSPEND_SERVICE
JMX operation to suspend a service.
|
Constructor and Description |
---|
PersistenceToolsHelper()
Construct a new PersistenceToolsHelper which can be used to issue
persistence related commands from CohQL.
|
PersistenceToolsHelper(PrintWriter out)
Construct a new PersistenceToolsHelper which can be used to issue
persistence related commands from CohQL.
|
Modifier and Type | Method and Description |
---|---|
boolean |
archivedSnapshotExists(String sServiceName,
String sSnapshotName)
Validate that an archived snapshot exists for a given service.
|
static CohQLException |
ensureCohQLException(Throwable eCause,
String sMsg)
Return a CohQLException with the given cause.
|
static PersistenceToolsHelper |
ensurePersistenceToolsHelper(ExecutionContext ctx)
Ensure a
PersistenceToolsHelper exists within the CohQL ExecutionContext
which can be used to issue cluster related Persistence commands. |
void |
ensureReady(boolean fWait,
String sServiceToCheck)
Ensures that the specified service is in a ready state to begin snapshot operations.
|
void |
ensureReady(ExecutionContext ctx,
String sService)
Ensures that the services are in a ready state to begin snapshot operations.
|
String |
getArchiver(String sServiceName)
Return the archiver configured for the given service.
|
static Term |
getNextTerm(OPScanner s,
String sName,
String sDescription,
String sCommand)
Return a term for a given scanner representing the specified name.
|
String |
getOperationStatus(String sServiceName) |
String |
getPersistenceMBean(String sServiceName)
Return the PersistenceManager MBean name.
|
String |
getServiceMBean(String sServiceName,
Member member)
Return the Service MBean name.
|
static File |
getSnapshotDirectory(ConfigurableCacheFactory ccf,
String sSnapshot,
String sServiceName)
Return the snapshot directory for a given service and snapshot.
|
void |
invokeOperation(String sOperation,
String sServiceName,
Object[] aoParams,
String[] asParamTypes)
Invoke an operation against a PersistenceManagerMBean associated to the
given service name.
|
void |
invokeOperationWithWait(String sOperation,
String sSnapshot,
String sServiceName)
Issue an operation and wait for the operation to be complete by
polling the "Idle" attribute of the PersistenceCoordinator for the service.
|
boolean |
isTraceEnabled()
Return if trace is enabled.
|
Map<String,String[]> |
listArchivedSnapshots()
List the archived snapshots for all services.
|
String[] |
listArchivedSnapshots(String sServiceName)
Return a list of archived snapshots for a given service.
|
Map<String,String[]> |
listServices()
List all the services configured for active or on-demand mode and information
about them including: persistence-mode, QuorumStatus and current operation status
from the PersistenceSnapshotMBean.
|
List<String> |
listServicesEnvironment()
List all the services configured for active or on-demand mode and display the
persistence environment implementation.
|
Map<String,String[]> |
listSnapshots()
List the snapshots for all services.
|
String[] |
listSnapshots(String sServiceName)
List the snapshots for the specified service.
|
void |
resumeService(String sServiceName)
Resume a given service.
|
boolean |
serviceExists(String sServiceName)
Validate that a service name exists for the current cluster.
|
void |
setPrintWriter(PrintWriter out)
Set the
PrintWriter for any messages to go to. |
boolean |
snapshotExists(String sServiceName,
String sSnapshotName)
Validate that a snapshot exists for a given service.
|
void |
suspendService(String sServiceName)
Suspend a given service.
|
void |
validateArchivedSnapshotExistsForAllServices(String sSnapshotName)
Validate that an archived snapshot exists across all services to ensure
success for a retrieve or purge operation.
|
void |
validateSnapshotExistsForAllServices(String sSnapshotName)
Validate that a snapshot exists across all services.
|
public static final String CREATE_SNAPSHOT
public static final String RECOVER_SNAPSHOT
public static final String REMOVE_SNAPSHOT
public static final String ARCHIVE_SNAPSHOT
public static final String RETRIEVE_ARCHIVED_SNAPSHOT
public static final String REMOVE_ARCHIVED_SNAPSHOT
public static final String SUSPEND_SERVICE
public static final String RESUME_SERVICE
public static final String FORCE_RECOVERY
public PersistenceToolsHelper()
public PersistenceToolsHelper(PrintWriter out)
out
- the PrintWriter to write trace messages topublic static PersistenceToolsHelper ensurePersistenceToolsHelper(ExecutionContext ctx) throws CohQLException
PersistenceToolsHelper
exists within the CohQL ExecutionContext
which can be used to issue cluster related Persistence commands.
If it doesn't, then create a new one.ctx
- current CohQL ExecutionContext
CohQLException
- if we are unable to retrieve a new APIpublic void invokeOperationWithWait(String sOperation, String sSnapshot, String sServiceName) throws MBeanException
try (Timeout t = Timeout.after(120, TimeUnit.SECONDS)) { helper.invokeOperationWithWait("createSnapshot", "snapshot", "Service"); }When called from CohQL, the TIMEOUT value set in CohQL will be used to interrupt the operation if it has not completed.
sOperation
- the operation to executesSnapshot
- the snapshot namesServiceName
- the name of the service to execute operation onMBeanException
- if any MBean related errorspublic void invokeOperation(String sOperation, String sServiceName, Object[] aoParams, String[] asParamTypes) throws MBeanException
sOperation
- the operation to executesServiceName
- the name of the service to execute operation onaoParams
- the parameters of the operationasParamTypes
- the parameter types of the operationMBeanException
- if an error occurred invoking the MBeanpublic boolean serviceExists(String sServiceName)
sServiceName
- the service name to checkpublic boolean snapshotExists(String sServiceName, String sSnapshotName)
sServiceName
- the service name to checksSnapshotName
- the snapshot name to checkpublic boolean archivedSnapshotExists(String sServiceName, String sSnapshotName)
sServiceName
- the service name to checksSnapshotName
- the archived snapshot name to checkpublic void validateSnapshotExistsForAllServices(String sSnapshotName)
sSnapshotName
- the snapshot name to checkCohQLException
- if the condition is not metpublic void validateArchivedSnapshotExistsForAllServices(String sSnapshotName)
sSnapshotName
- the archived snapshot name to checkCohQLException
- if the condition is metpublic Map<String,String[]> listServices()
Map
of services and related informationpublic List<String> listServicesEnvironment()
List
of services and related informationpublic String[] listSnapshots(String sServiceName)
sServiceName
- the name of the service to list snapshots forpublic Map<String,String[]> listSnapshots()
Map
of services and their snapshots.public String[] listArchivedSnapshots(String sServiceName)
sServiceName
- the name of the service to queryString
[] of archived snapshots for the given servicepublic Map<String,String[]> listArchivedSnapshots()
Map
of services and their archived snapshots.public String getArchiver(String sServiceName)
sServiceName
- the name of the service to querypublic void resumeService(String sServiceName)
sServiceName
- the service to resumepublic void suspendService(String sServiceName)
sServiceName
- the service to suspendpublic void ensureReady(boolean fWait, String sServiceToCheck)
fWait
- if true and the service is not Idle then wait, otherwise
throw an exceptionsServiceToCheck
- the service to check for or null for all servicesCohQLException
- if any services are not in a proper statepublic void ensureReady(ExecutionContext ctx, String sService)
ctx
- contextsService
- the service to wait to be ready or if null, then all servicesCohQLException
- if any services are not in a proper statepublic static CohQLException ensureCohQLException(Throwable eCause, String sMsg)
eCause
- an optional causesMsg
- an optional detail messagepublic String getPersistenceMBean(String sServiceName)
sServiceName
- the name of the service to return the name forpublic String getServiceMBean(String sServiceName, Member member)
sServiceName
- the name of the service to return the name formember
- the member of the service to return the name forpublic static Term getNextTerm(OPScanner s, String sName, String sDescription, String sCommand)
s
- OPScanner to usesName
- the name to assign the new termsDescription
- a description for any exceptionsCommand
- the command nameCohQLException
- if end of statement is reachedpublic static File getSnapshotDirectory(ConfigurableCacheFactory ccf, String sSnapshot, String sServiceName)
ccf
- ConfigurableCacheFactory to use to get dependenciessSnapshot
- the snapshot name to usesServiceName
- the service name to usepublic void setPrintWriter(PrintWriter out)
PrintWriter
for any messages to go to.out
- the PrintWriter
to usepublic boolean isTraceEnabled()