Many administrative tasks require that the data on which they are operating does not change while that operation is taking place. The most common system-level examples of such operations are system administration tasks such as backups or replication, but data consistency is also required by some administrative Watson Explorer Engine operations, such as using a data export operation to create a new collection from an existing one (discussed in Creating a New Collection by Exporting Existing Collection Data).
Watson Explorer Engine enforces consistency within search collections by providing functions that put search collections into and take them out of read-only mode. When in read-only mode, collections can still respond to queries, but cannot be changed in significant way (including internal changes related to index merging and related optimizations). Read-only mode protects files in the search collection directory that meet one or more of the following criteria:
Watson Explorer Engine's read-only mode functions are the following:
The period of time that the crawler for a collection continues to run when that collection is put into read-only mode can be configured using the read-only-running-time crawl-option. See Crawler Configuration Options for information about this and other options for the Watson Explorer Engine crawler.
Files and directories that can change in a search collection directory when that search collection is in read-only mode are the following:
The following C# code example shows how to put a single search collection into read-only mode using the search-collection-read-only call, where v is the VelocityPortClient object, and collection is a string containing the name of the collection that you want to act on:
SearchCollectionReadOnly ro = new SearchCollectionReadOnly(); ro.Collection = collection; ro.mode = SearchCollectionReadOnlyMode.enable; SearchCollectionReadOnlyResponse ror = v.SearchCollectionReadOnly(ro);
The following code example shows the same task implemented in Java, where vp is the port associated with the service, and collection is a string containing the name of the collection that you want to act on:
SearchCollectionReadOnly ro = new SearchCollectionReadOnly();
ro.setCollection(collection);
ro.setMode("enable");
SearchCollectionReadOnlyResponse ror = vp.searchCollectionReadOnly(ro);
The following C# code example shows how to use the search-collection-read-only-all function to put all of your search collections in read-only mode, do whatever tasks you want to perform, and then return the collections to non-read-only mode:
SearchCollectionReadOnlyAll roa;
SearchCollectionReadOnlyAllResponse roar;
do
{
roa = new SearchCollectionReadOnlyAll();
roa.mode = SearchCollectionReadOnlyAllMode.enable;
roar = v.SearchCollectionReadOnlyAll(roa);
} while (roar.readonlystateall.ndisabled > 0
|| roar.readonlystateall.npending > 0);
// now in read-only mode, do whatever ...
roa.mode = SearchCollectionReadOnlyAllMode.disable;
v.SearchCollectionReadOnlyAll(roa);
The following C# code example illustrates how to check the state that is returned by this function:
foreach (readonlystate ros in roar.readonlystateall.readonlystate)
{
Console.WriteLine(ros.collection + ": " + ros.mode);
if (ro.requestedSpecified)
Console.WriteLine(" Requested: " + ros.requested);
if (ro.acquiredSpecified)
Console.WriteLine (" Granted: " + ros.acquired);
}
The following Java code example shows how to use the search-collection-read-only-all function to put all of your search collections in read-only mode, do whatever tasks you want to perform, and then return the collections to non-read-only mode:
SearchCollectionReadOnlyAll roa;
SearchCollectionReadOnlyAllResponse roar;
do
{
roa = searchCollectionReadOnlyAll();
roa.setMode("enable");
roar = vp.searchCollectionReadOnlyAll(roa);
} while (roar.getNdisabled() > 0
|| roar.getNpending > 0);
// now in read-only mode, do whatever ...
roa.setMode = "disable";
roar = vp.searchCollectionReadOnlyAll(roa);
The following Java code example illustrates how to check the state information that is returned by the search-collection-read-only-all function:
SearchCollectionReadOnlyAllResponse roar;
foreach (ReadOnlyState ros in roar.getReadOnlyState())
{
System.out.println(ro.getCollection + ": " + ros.getMode());
System.out.println(" Requested: " + ros.getRequested());
System.out.println(" Granted: " + ros.getAcquired());}