[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 19:00

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 18: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 21:5030
522.3What works for me - create the MIR files only if they don't already existCOOKIE::KITTELLRichard - Architected Info MgmtFri Dec 07 1990 14: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 12:2512