Message Passing Node ID

Disabled Algorithm

1. Remove obsolete check_parents parameter
C++ and Java code have to use disabled() algorithm with the only parameter pointing to the partition object. Second parameter check_parents has to be removed (note, the second parameter was optional in C++). The disable status of parents is always taken inot account.

2. Implement why_disabled() algorithm in Java
As requested by https://savannah.cern.ch/bugs/?34962, the Component class implements why_disabled() algorithm to provide textual description of a reason to disable given resource or segment, e.g.:
See dal/jexamples/TestDisabled.java for example of usage.

3. Set used disabled and enabled components in Java
Like in C++, DAL implements two dal.Partition algorithms to set temporarily disabled or enabled components:

    /**
     *  The method temporarily marks given components as 'disabled'
     *  without modifying partition object in database.
     *  Above is overwritten by consequent set_disabled() call.
     *  It is automatically clean when database is updated or reload.
     *
     *  @param objs  vector of components to be temporarily disabled.
     */


  public void set_disabled(dal.Component objs[]) ...

    /**
     *  The method temporarily marks given components as 'enabled'
     *  without modifying partition object in database.
     *  Above is overwritten by consequent set_enabled() call.
     *  It is automatically clean when database is updated or reload.
     *
     *  @p
aram objs  vector of components to be temporarily enabled.
     */

  public void set_enabled(dal.Component objs[]) ...


See dal/jexamples/TestDisabled.java for example of usage.

4. Multiple configuration objects and user enabling/disabling in Java code
Since by efficiency reasons the dal.Component.disabled() algorithm uses singleton map to keep information about disabled status of components, a user disabling/enabling changes status of components application wide. Also, there is a problem, when Java application creates more than one configuration objects and call disabled() algorithm on them (e.g. disabling status should be different, when IGUI works with RDB and RDB_RW servers and changes disabling on RDB_RW) or uses different partition objects.

The problem can be solved using an object of dal.Resources class used to implement above mentioned singleton map. Each object of dal.Resources class can be used separately with configuration object, partition and user disabled/enabled components. In such case instead of using DAL algorithms of of Component and Partition class, use appropriate methods of dal.Resources class:

DAL algorithm
Appropriate method of dal.Resources class
dal.Partition.set_disabled() public void set_disabled(dal.Component objs[])
dal.Partition.set_enabled() public void set_enabled(dal.Component objs[])
dal.Componet.disabled() public boolean get_disabled(dal.Component obj, dal.Partition p, config.Configuration db) throws config.SystemException, config.NotFoundException
dal.Componet.why_disabled() public String why_disabled(dal.Component c, config.Configuration db, String prefix, boolean recursive) throws config.SystemException

For more info see file dal/jsrc/dal/Resources.java

Example of simultaneous usage of default and user-specific Resources object:
config.Configuration db = new config.Configuration("rdbconfig:RDB");
dal.Partition p = dal.Algorithms.get_partition(db, "be_test");

config.Configuration db2 = new config.Configuration("rdbconfig:RDB_RW");
dal.Partition p2 = dal.Algorithms.get_partition(db2, "be_test");

dal.Resources resources = new dal.Resources(); // will use with
db2 scope

  // disable in db2 scope resources "r1" and "r2"

dal.Component[] disabled_objs = new dal.Component[2];
disabled_objs[0] = dal.Component_Helper.get(db2,"r1");

disabled_objs[1] = dal.Component_Helper.get(db2,"r2");
resources.set_disabled(disabled_objs);

  // check status of "r1" in db and report why if disabled:
dal.Component r1 = dal.Component_Helper.get(db,"r1");
if(r1
.disabled(p)) {
 
System.out.println("object r1 in db1 is disabled because " + r1.why_disabled("  ", true));
}

  // check status of "r1" in db2 and report why if disabled:
dal.Component r1_2 = dal.Component_Helper.get(db2,"r1");
if(resources.get_disabled(r1_2, p2, db2)) {
 
System.out.println("object r1 in db2 is disabled because " + resources.why_disabled(r1_2, db2, "  ", true));