Tuesday, April 24, 2012

FAST ESP 5.3 - change the index location

Steps to move the FAST ESP v5.3 index to another drive or path. This was tested with the FSIA version of FAST but should be applicable to other implementations.

Note that AFAIK the drive and path must be consistent between all index/search nodes (due to rtssearchrc) and data_fixml and data_index still have to be on the same drive (which is a shame).

A. Stop all indexer and search processes on all nodes.

B. On Admin node, edit the webcluster file:

  1. \esp\etc\config_data\RTSearch\webcluster\rtsearchrc.xml
Change the $RTROOT variable to a hard coded path in
  •     fixmlPath="E:\esp\data\data_fixml"
  •     indexDir="E:\esp\data\data_index"
C. On EACH of the index and or search nodes update the following two files:
  1. \esp\etc\searchrc-1.xml
  • indexpath= "E:\esp\data\data_index"
  1. \esp\etc\rtsplatformrc.xml
  • indexDir = "E:\esp\data\data_index"
  • fixmlDir = "E:\esp\data\data_fixml"
D. Restart indexer and search processes.

Thursday, April 19, 2012

Reflection: Dynamically instantiating a class

The requirement was for a command line utility that accepted a "function" name and a list of parameters, where the parameters could be different for each function.

This is a fairly common requirement, which I don't want to have to look up again, so I thought I'd document my solution here.

My first thought was a switch on the function name, but that quickly became messy with the variable parameters. After consideration, it was simpler to implement each function as a class, then use reflection to instantiate the class and pass in command line parameters. To support dynamically creating the class, I used a common Interface with a Run method that accepted the command line parameters.

 namespace CodeExamples  
 {  
   interface IExample  
   {  
     void Run(string[] args);  
   }    
   class Program  
   {  
     static void Main(string[] args)  
     {  
       try  
       {  
         if (args.Length < 1)  
         {  
           Console.WriteLine("Syntax: CodeExample typeName [args]");  
         }  
         else  
         {  
           string assemblyName = "CodeExamples.";  
           string typeName = args[0];  
           Assembly = System.Reflection.Assembly.GetExecutingAssembly();  
           Type type = assembly.GetType(assemblyName + typeName);  
           IExample example = (IExample)Activator.CreateInstance(type);  
           example.Run(args);  
         }  
       }  
       catch (Exception e)  
       {  
         Console.WriteLine("\nEXCEPTION: {0}\n{1}", e.Message, e.StackTrace);  
       }  
     }  
   }  
 }