Querying and invalidating data

You can use the query interfaces in the monitoring console and in the xscmd utility to retrieve small sets of keys from a map and invalidate sets of data.

Before you begin

  • If you are using xscmd to query and invalidate data, set up the xscmd utility. For more information, see Administering with the xscmd utility.

About this task

You can use the console or the xscmd utility to query data grid contents. You can query the data by running a regular expression on the data key. You can then use the same query to invalidate data.
A regular expression is a structured string that is used to match other strings. Some examples of common regular expressions follow:
Regular expression Description
. Finds any one character.
.* Finds any one character zero or more times.
A.* Finds all keys that start with "A".
.*A Finds all keys that end with "A".
A? Finds "A", zero or one time.
A* Finds "A", zero or many times.
A+ Finds "A", one time or many times.
A?B*C+ Finds any one character, followed by zero or one A, followed by zero or many Bs, followed by one or many Cs
[ABC].* Finds keys that start with the letters "A", or "B", or "C".
.*ABC.* Finds keys with the string "ABC" somewhere in the string.
(ABC|DEF).* Finds keys that start with the string "ABC" or "DEF".
See the java.util.regex.Pattern API documentation for the full regular expression syntax.

Procedure

  • Query or invalidate data with the console.
    1. Go to the query page in the console. In the user interface, click Data Management > Query Data Grid Contents.
    2. Search or filter the data in the map. You can use one of the following options to search or filter the data:
      • Type a regular expression in the field and click the Search button (Search). A list of keys that match the regular expression displays. The list of data could be a subset of all of the matching data.
      • To filter the results on a set of partitions, click the Filter button (Filter...). You can then type a regular expression and choose a range of partitions on which you want to filter the results.
    3. Invalidate data. When you invalidate the data, the data is permanently removed from the data grid.
      Selected keys
      You can select keys from the table to invalidate. You can either click entries individually or click the select all checkbox, which selects a maximum of 500 entries that are in the table. When you have the entries selected that you want to remove, click Invalidate > Selected keys.
      All keys matching query
      You can also invalidate all the data that matches your regular expression. Using this option deletes all data in the data grid that matches the regular expression, not just the maximum of 500 entries that is displayed in the console. To invalidate entries with the selected regular expression, click Invalidate > All keys matching query.
  • Query or invalidate data with the xscmd utility.
    Query data:
    xscmd.sh –c findbykey –g <data_grid> -m <map> 
    -fs <find_string> [-fp <partitionid>]
    You must include the data grid, map, and regular expression for the find string value. You can also filter on the partition ID. The result returns a subset of the entire query.
    Invalidate data:
    Include the -inv argument in the command to invalidate the data that is selected by the query.
    xscmd –c findbykey –g <data_grid> -m <map> 
    -fs <find_string> [-fp <partitionid>] -inv
    You must include the data grid, map, and regular expression for the find string value. You can also filter on the partition ID. When you run the invalidation, all matching values are invalidated, not just the small set that is returned by the query.
    [Unix][Linux] Important: If your regular expression starts with the characters .*, the characters might not process correctly when you run the command. To resolve this issue, format your regular expression in one of the following ways:
    • Enclose your regular expression with apostrophe characters: -fs '.*'
    • Use a backslash to escape the asterisk character: -fs .\*
    Example:
    The following example looks for all entries in the Grid data grid and Map1 map.
    xscmd -c findbykey -g Grid -m Map1 -fs ".*"
    The command returns the following results:
    3 matching keys were found.
    
    Partition Key
    --------- ---
    2         keyghi
    4         keydef
    6         keyabc
Parent topic: Administering data grids
Related tasks:
Administering with the xscmd utility
Related reference:
xscmd utility reference