How to validate GemFire disk stores using a Java command with a custom classpath
search cancel

How to validate GemFire disk stores using a Java command with a custom classpath

book

Article ID: 294017

calendar_today

Updated On:

Products

VMware Tanzu Gemfire

Issue/Introduction

After making backups for the persistent data from members to a specified directory, you may want to validate that those backups are healthy.

You can use gfsh to perform such a validation, as discussed in validate offline-disk-store. However, if gfsh is not available, you can also validate disk stores using a Java command.

This article shows you how to validate disk stores using the Java command and how to use this approach to add a custom classpath.

Resolution

Besides using the aforementioned gfsh commands you can also use the following Java command to validate disk stores:

java -Dlog4j.configurationFile=classpath:log4j2-cli.xml -classpath /path/to/lib/gfsh-dependencies.jar:/path/to/extensions/* org.apache.geode.management.internal.cli.util.DiskStoreValidater data_store /path/to/disk_store


If there are custom objects or classes associated with the regions in the disk stores, you may encounter a ClassNotFoundException when validating the offline disk store if you have not included them in the CLASSPATH, as shown in the following example:

Cluster-1 gfsh>validate offline-disk-store --name=data-disk-store --disk-dirs=/path/to/disk-store/dir
Validating data-disk-store
/app-product-details: entryCount=0
/app-network: entryCount=0
/app-code-master: entryCount=0
/app-search-index entryCount=0 bucketCount=7
/app-cot entryCount=0 bucketCount=3
/app-source-pid-xref entryCount=0 bucketCount=7
/app-ext-system-entity-xref entryCount=0 bucketCount=7
/app-membership entryCount=0 bucketCount=7
/app-indicator entryCount=0 bucketCount=7
/app-genkey-xref entryCount=0 bucketCount=7
/app-person entryCount=0 bucketCount=7
/app-coverage-ancillary entryCount=0 bucketCount=8
/app-person-pid-xref entryCount=0 bucketCount=7
/app-person-attributes entryCount=0 bucketCount=7
Error in validating disk store data-disk-store is : A ClassNotFoundException was thrown while trying to deserialize cached value


In order to avoid the above ClassNotFoundException, you need to add those custom objects or classes associated with the regions in the disk stores to the classpath. This is done by adding the "-classpath" option to the Java command:

java -Dlog4j.configurationFile=classpath:log4j2-cli.xml -classpath /path/to/lib/gfsh-dependencies.jar:/path/to/classes:/path/to/extensions/* org.apache.geode.management.internal.cli.util.DiskStoreValidater data_store /path/to/disk_store


When using gfsh, this can be achieved by setting the CLASSPATH environmental variable as discussed in How to add classpath when validating offline diskstore using gfsh in VMware GemFire.