Interface SzDiagnostic
Defines the interface to the Senzing diagnostic functions.
public interface SzDiagnostic
Examples
An SzDiagnostic
instance is typically obtained from an
SzEnvironment instance via the
GetDiagnostic() method as follows.
For example:
// How to obtain an SzDiagnostic instance
try
{
// obtain the SzEnvironment (varies by application)
SzEnvironment env = GetEnvironment();
SzDiagnostic diagnostic = env.GetDiagnostic();
. . .
}
catch (SzException e)
{
// handle or rethrow the exception
LogError("Failed to get SzDiagnostic.", e);
}
Remarks
The Senzing diagnostic functions provide diagnostics and statistics pertaining to the host system and the Senzing repository.
Methods
CheckRepositoryPerformance(int)
Conducts a rudimentary repository test to gauge I/O and network performance.
string CheckRepositoryPerformance(int secondsToRun)
Parameters
secondsToRun
intHow long to run the database performance test.
Returns
- string
The JSON
string
describing the results of the performance test.
Examples
Usage:
// How to get repository info via SzDiagnostic
try
{
// obtain the SzEnvironment (varies by application)
SzEnvironment env = GetEnvironment();
// get the diagnostic instance
SzDiagnostic diagnostic = env.GetDiagnostic();
// check the repository performance
string result = diagnostic.CheckRepositoryPerformance(10);
demoResult = result; // @replace
// do something with the returned JSON (varies by application)
Log(result);
}
catch (SzException e)
{
// handle or rethrow the exception
LogError("Failed to check the repository performance.", e);
}
Example Result: (formatted for readability)
{
"numRecordsInserted": 336946,
"insertTime": 10000
}
Remarks
Typically, this is only run when troubleshooting performance. This is a non-destructive test.
Exceptions
- SzException
Thrown if a failure occurs.
GetFeature(long)
Experimental/internal for Senzing support use.
string GetFeature(long featureID)
Parameters
featureID
longThe identifier for the feature.
Returns
- string
The feature definition describing the feature for the specified feature ID.
Examples
Usage:
// How to get a feature by its feature ID
try
{
// obtain the SzEnvironment (varies by application)
SzEnvironment env = GetEnvironment();
// get the diagnostic instance
SzDiagnostic diagnostic = env.GetDiagnostic();
// get a valid feature (varies by application)
long featureID = GetFeatureID();
// get the feature for the feature ID
string result = diagnostic.GetFeature(featureID);
demoResult = result; // @replace
// do something with the returned JSON
Log(result);
}
catch (SzException e)
{
// handle or rethrow the exception
LogError("Failed to purge the repository.", e);
}
Example Result: (formatted for readability)
{
"LIB_FEAT_ID": 6,
"FTYPE_CODE": "PHONE_KEY",
"ELEMENTS": [
{
"FELEM_CODE": "EXPRESSION",
"FELEM_VALUE": "7025551212"
}
]
}
Exceptions
- SzException
Thrown if a failure occurs.
GetRepositoryInfo()
Returns overview information about the repository.
string GetRepositoryInfo()
Returns
- string
A JSON
string
describing the datastore.
Examples
Usage:
// How to get repository info via SzDiagnostic
try
{
// obtain the SzEnvironment (varies by application)
SzEnvironment env = GetEnvironment();
// get the diagnostic instance
SzDiagnostic diagnostic = env.GetDiagnostic();
// get the repository info
string info = diagnostic.GetRepositoryInfo();
demoResult = info; // @replace
// do something with the returned JSON (varies by application)
Log(info);
}
catch (SzException e)
{
// handle or rethrow the exception
LogError("Failed to get the repository info.", e);
}
Example Result: (formatted for readability)
{
"dataStores": [
{
"id": "CORE",
"type": "sqlite3",
"location": "/tmp/sz-example-c663b342-17f7-4a73-85bf-1e0952c46823/G2C.db"
}
]
}
Exceptions
- SzException
Thrown if a failure occurs.
PurgeRepository()
Permanently deletes all data in the repository, except the configuration.
void PurgeRepository()
Examples
Usage:
// How to purge the Senzing repository
try
{
// obtain the SzEnvironment (varies by application)
SzEnvironment env = GetEnvironment();
// get the diagnostic instance
SzDiagnostic diagnostic = env.GetDiagnostic();
// purge the repository (MAKE SURE YOU WANT TO DO THIS)
if (ConfirmPurge())
{
diagnostic.PurgeRepository();
}
}
catch (SzException e)
{
// handle or rethrow the exception
LogError("Failed to purge the repository.", e);
}
Remarks
WARNING: This method is destructive, it will delete all loaded records and entity resolution decisions. Senzing does not provide a means to the restore the data. The only means of recovery would be restoring from a database backup.
Exceptions
- SzException
Thrown if a failure occurs.
- See Also