[Search for users] [Overall Top Noters] [List of all Conferences] [Download this site]

Conference azur::mcc

Title:DECmcc user notes file. Does not replace IPMT.
Notice:Use IPMT for problems. Newsletter location in note 6187
Moderator:TAEC::BEROUD
Created:Mon Aug 21 1989
Last Modified:Wed Jun 04 1997
Last Successful Update:Fri Jun 06 1997
Number of topics:6497
Total number of notes:27359

522.0. "Creation of MIR" by PHONE::HUET () Wed Dec 05 1990 16:00

    I have written the INIT, LOG and PROBE files for my MM and I have got a
    strange result with the behaviour of the MIR.
    
    In the PROBE file I do the following creations as long as the returned
    status for each action is MCC_S_NORMAL:
    
    1: I create an instance MIR by using mcc_mir_create_repository() and it
    returns me an Inst_Repos_ID.
    2: I create an object-instance in the instance MIR by using
    mcc_mir_create_instance() with Inst_Repos_ID and it returns me an Inst_Key.
    
    3: I create an attribute MIR by using mcc_mir_create_repository() and
    it returns me an Attr_Repos_ID.
    4: I write in the attribute MIR the attributes of the instance that I have 
    created above by using mcc_mir_write_attribute_data() with both the
    Inst_key and the Attr_Repos_ID.
    
    The first time I enroll my AM it works without problem. Then I want to
    enroll it a second time because I have made some modifications in my
    code. In order not to receive a message 'already enrolled', I do the
    following things :
    
    a: I replace the mcc_dispatch_table.dat file, which has just been
    created, with an old one which I had stored before to enroll my AM.
    
    b: I delete the file MCC_<module_name>_INSTANCE_MIR.DAT
    
    c: I delete the file MCC_<module_name>_ATTRIBUTE_MIR.dat
    
    and then I enroll my AM again.
    The problem comes here : It creates the instance MIR and the
    object-instance (#1 & #2) , but when it comes to the point 3 it returns
    me : "The Repository already exists" whereas I have deleted it.
    
    Why the behaviours for the Attribute MIR and for the Instance MIR are
    different ?
    
    I guess that MCC stores in an other file (maybe MCC_DICTIONARY.DAT ?) a
    pointer to the Attribute MIR File.
    
    Could anyone explain me exactly what MCC does when it creates the MIR ?
    
    Thank you in advance for your help.
    
    /St�phane-Andr� 
              
T.RTitleUserPersonal
Name
DateLines
522.1Please do not create repositories on every probeTOOK::GUERTINI have an in_e, you have an out_eThu Dec 06 1990 15:0139
    The following steps are done every time you call mcc_mir_create_repository()
    
    1) Check if the repository already exists, if it does,
       1.1) place the repository id in the repos-id argument
       1.2) return MCC_S_REPOSEXIST
    2) If it doesn't
       2.1) generate a unique repository id.
       2.2) add the name and repos-id to the MCC_MIR_DIRECTORY.DAT file.
       2.3) add the location to the MCC_MIR_ATTRIBUTE.DAT file.
       2.4) place the repository id in the repos-id argument.
       2.5) return MCC_S_NORMAL
    
    Once you create a repository, it is more like registering it.  It
    exists even after you exit MCC.  This behavior needs to be better
    documented in the SRM.
    
    The algorithm is generally something like this:
    
    PROBE:
       1) call mcc_mir_get_repository_id() to try and translate a name into
          a number.
       2) If status == MCC_S_NORMAL then it was already created, so just
          use the repository-id you got back
       3) Else
          if you get back MCC_S_NOREPOSEXIST, then
             call mcc_mir_create_repository() to create a new one.
    
       OR:
       1) if you call mcc_mir_create_repository() and it returns
          MCC_S_REPOSEXIST, it ALWAYS places the repository-id which
          it found in the repos-id argument, so you can skip a couple of
          steps, and just use the repository-id that you get back.
    
    Why you are getting success the second time you are trying to create
    the exact same instance repository is beyond me.  I've never seen that
    happen before.  What is the exact name of the instance repository?
    
    -Matt.
    
522.2More detailsOFFHK::HUETThu Dec 06 1990 18:5030
    Thanks Matt for your indications because some explanations about this
    topic are missing in the SRM as you say it.
    
    The exact names of my repositories are :
    MCC_CMEAGT_INSTANCE_MIR.DAT
    and
    MCC_CMEAGT_ATTRIBUTES_MIR.DAT
    
    For the progamming's environment I use the following architecture for
    the directories :
    .SRC.DIR
    .BIN.DIR
    .OBJ.DIR
    .LIS.DIR
    .LIB.DIR
    
    The MIR files are located in the BIN.DIR
    But in that directory I don't find the file MCC_MIR_DIRECTORY.DAT.
    Is it normal ?
    
    Like you, I still don't understand the behaviour of the instance MIR.
    
    I hope you'll find an explanation.
    
    Thanks again.
    
    Best regards,
    
    St�phane-Andr�.
    
522.3What works for me - create the MIR files only if they don't already existCOOKIE::KITTELLRichard - Architected Info MgmtFri Dec 07 1990 11:1070
Define the MCC_SYSTEM logical to be a searchlist of your BIN dir (or whereever
you want your MIR files), MCC_SPECIFIC and MCC_COMMON.

Then, in your ...AM_INIT.C file, 

#define MIR_DIR "MCC_SYSTEM"
#define INSTANCES_MIR_NAME "ATLAS_AM_INSTANCES"  <---- change these for your AM
#define ATTRIBUTES_MIR_NAME "ATLAS_AM_ATTRIBUTES"

/* The id of the instances mir. */
globaldef MCC_T_UNSLONG instances_mir_id = 0;

/* The id of the attributes mir. */
globaldef MCC_T_UNSLONG attributes_mir_id = 0;
 
static MCC_T_Descriptor mir_dir =
    {
       sizeof(MIR_DIR), DSC_K_DTYPE_T, DSC_K_CLASS_S,
       (unsigned char *)MIR_DIR, (sizeof(MIR_DIR) - 1), 0, 1, 0, 0, 0
       }
    ;
static MCC_T_Descriptor instances_mir_name =
    {
       sizeof(INSTANCES_MIR_NAME), DSC_K_DTYPE_T, DSC_K_CLASS_S,
       (unsigned char *)INSTANCES_MIR_NAME,
       (sizeof(INSTANCES_MIR_NAME) - 1), 0, 1, 0, 0, 0
       }
    ;
static MCC_T_Descriptor attributes_mir_name=
    {
       sizeof(ATTRIBUTES_MIR_NAME), DSC_K_DTYPE_T, DSC_K_CLASS_S,
       (unsigned char *)ATTRIBUTES_MIR_NAME,
       (sizeof(ATTRIBUTES_MIR_NAME) - 1), 0, 1, 0, 0, 0
       }
    ;

Then, in both the init and probe routines, make these calls:

    /*
     * Create and initialize, or open, the MIR. These calls
     * must be made in this order, as they set the repository ids.
     */
 
   if (GOOD(status) && !instances_mir_id)
     status = access_mir (&instances_mir_name, MCC_K_DB_FTYPE_ENTDEF,
                           &instances_mir_id);
   if (GOOD(status) && !attributes_mir_id)
      status = access_mir (&attributes_mir_name, MCC_K_DB_FTYPE_ATTRIBUTE,
                           &attributes_mir_id);

Then add this routine:

static MCC_T_MCCError access_mir(MCC_T_Descriptor *name,
                                 MCC_T_UNSLONG type,
                                 MCC_T_UNSLONG *id)
{

   MCC_T_MCCError status;

   /* Try to create the MIR. */
   status = mcc_mir_create_repository (&type, &mir_dir, name,
                                       id, 0);

   /* If the repository already exists, just access it. */
   if (status == MCC_S_REPOSEXIST)
       status = mcc_mir_get_repository_id (name, id, MCC_K_NULL_PTR);

   return (status);
}
522.4ConclusionPHONE::HUETTue Dec 11 1990 09:2512
    Thanks to both of you for your help.
    
    Now with such precautions it works.
    
    I guess, Matt, that the strange results got for the two MIR files come
    from our system : we have upgraded MCC to version T 1.1 and we get
    different results each time we run MCC again...
    
    Some files might be where they shouldn't be...
    
    - St�phane-Andr�.