mdsplus icon indicating copy to clipboard operation
mdsplus copied to clipboard

ALIAS not working with remote trees

Open alkhwarizmi opened this issue 4 years ago • 9 comments

Dear all (or dear zack-vii),

in my current set-up I have two productive windows machines running locally their MDS+ server each one recording data of two experiments, A and B. For simplicity, I call the MDS+ trees where this data is stored 'expaon' and 'expbon', respectively.

Periodically, runs (shots) from A and B are moved from these two servers to a MDS+ long term data storage server C, and MDS+ data files are renamed expa. and expb. (dropping the suffix "on") in the process.

The point is that it would be very convenient for us if the server C could route a request towards A or B for run numbers not yet moved on the long term data storage, in order to ease life for the users. To achieve this, following the instructions here, I have currently set up this configuration:

Server A

expaon_path=D:\MDSplusTrees\expaon
expa_path=ALIAS:expaon

Server B

expbon_path=D:\MDSplusTrees\expbon
expb_path=ALIAS:expbon

Server C

expa_path=/MDSplusTrees/expa;<server A address>:8000::
expb_path=/MDSplusTrees/expb;<server B address>:8000::

When a request for a run that is not yet archived reaches server C, I expect the server to route the request to server A or B, with treename equal to "expa" and "expb", respectively. Those servers, via the alias should transform the three name adding the suffix "on", finding the data.

Unfortunately this does not work. Also, if I connect to A or B directly from the server C, I cannot get the data via "expa" or "expb", instead I can using the original names "expaon" or "expbon". The error I receive is something like No 'treename'_path or default_tree_path environment variables defined which is technically not true (unless I need to restart the service upon creation of those variables) because the variable is defined as an alias.

I sees that the ALIAS feature is broken or I don't get how to use it. Let me know...

Sincerely,

alkhwarizmi avatar Aug 23 '21 17:08 alkhwarizmi

Hm looks like the syntax is without the : i.e. expoa_path=ALIASexpaon I am not sure it the doc is wrong or the code.. we would need to check the behavior of older MDSplus versions. @joshStillerman : do you remember this being used ever. if the implementation has changed someone would have reported it, no? one the other hand i like the documented implementation better as it properly separates the keyword from the target tree name.

zack-vii avatar Sep 01 '21 09:09 zack-vii

I also would prefer the version with a separator : or something else. Let me know, however. I can't believe the feature has never been used: despite I deal with "small" experiments, for me it would be very convenient.

alkhwarizmi avatar Sep 01 '21 09:09 alkhwarizmi

i went back as far as 2405cbf7168514ec7ad92aa8d747db61730a1b45 2005 where this feature was added. looks like the ':' must be omitted.

zack-vii avatar Sep 01 '21 09:09 zack-vii

I would wait a couple of days to hear from other core developers or site users (I really like most the syntax in the manual :) ).

Cheers,

alkhwarizmi avatar Sep 01 '21 09:09 alkhwarizmi

i fixed the documentation. @joshStillerman the change to ALIAS: would be in TreeOpen.c :161

     char *treepath = TreePath(tree, 0);
-    if (treepath && (strlen(treepath) > 5) &&
-        (strncmp(treepath, "ALIAS", 5) == 0))
-      tree = &treepath[5];
+#define ALIAS_PREFIX "ALIAS:"
+    if (treepath && (strlen(treepath) > sizeof(ALIAS_PREFIX)) &&
+        (strncmp(treepath, ALIAS_PREFIX, sizeof(ALIAS_PREFIX)) == 0))
+      tree = &treepath[sizeof(ALIAS_PREFIX)];
     if ((buflen - strlen(ans)) < (strlen(tree) + 1))

zack-vii avatar Sep 01 '21 10:09 zack-vii

If we want to change it we can revert the update to the documentation.

zack-vii avatar Sep 01 '21 10:09 zack-vii

Hi Zack-vii,

I switched to expa_path=ALIASexpaon and expb_path=ALIASexpbon on my servers but nothing changes.

I noticed that on line 161 of TreeOpen.c, the TreePath function returns something that COULD BE lowercase (depends on what the TranslateLogical does).

If this is the case, it is an error to look for ALIAS in uppercase. In general it would be nice to write down what the processing steps of the tree variables are. As far as I can tell:

  1. treePath variable should be cleaned from blanks (trimmed?) and placed in uppercase (in RemoveBlanksAndUpcase function)
  2. Then within replaceAliasTrees it is tokenized via , and in each token TreePath function is called BEFORE removing the ALIAS prefix
  3. In the TreePath function ONLY the first 12 characters are set to lower (I guess any tree name can be maximum 12 characters but here we have the problem that we still have the ALIAS characters in front of it...) and the TREE_PATH_SUFFIX is appended (which I guess is _path) and then a form of trimming is done before returning control to replaceAliasTrees .

If I understood correctly what should it do, the thing is quite messy and could contain errors.

Let me know,

alkhwarizmi avatar Sep 02 '21 08:09 alkhwarizmi

hm well the tree resolution is pretty simple.. it just seems the alias resolution is not done in treePath and hence only affective for local trees. so you should be able to use it with thin client but it will fail when using thick or dirstributed. we would need to add it to RemoteAccess.c.

zack-vii avatar Sep 02 '21 09:09 zack-vii

well, that said what you are trying to do may be bad anyway. as many programs expect the tree name to be fixed. it is stored in the database. if this would be done dynamically (required is for remote access) a lot of features mmay break. May i ask why you wish to rename the trees in the ffirst place. why not using the final names for new shots as well

zack-vii avatar Sep 02 '21 09:09 zack-vii

This feature will likely be removed in a future version, and we do not recommend using it.

WhoBrokeTheBuild avatar Mar 30 '23 19:03 WhoBrokeTheBuild