0

I'm using SymmetricDS for doing file synchronization between client and server node, I want to fetch the file sync target path from my database or file which is different for each client node.

I researched about it and find out that we can use shell script to change parameters like targetBaseDir , targetFileName, targetRelativeDir etc. inside before_copy_script or after_copy_script Please see http://www.symmetricds.org/doc/3.5/html/configuration.html#filesync-beanshell

Here I have the targetRelativeDir path of each node in one of my database tables, and I have to fetch it and set it to the parameter targetRelativeDir using beanshell

Please give me any direction to accomplish this.

1 Answers1

1

Your BSH will look similar to the following.

String nodeId = engine.getNodeService().findIdentityNodeId();
targetRelativeDir  = engine.getSqlTemplate().queryForString(
    "select targetRelativeDir from myTable where target_node=?", new Object[] {nodeId});

I assume this will work but I have not tested it.

Austin Brougher
  • 516
  • 2
  • 9
  • Thanks Austin. I want to know, whether we can make the base dir dynamic using bsh, i.e. the base dir for a client node will be different from the base dir of another client node. – Binyamin Melepat Mar 03 '14 at 09:15
  • Yes you can. This is why the variable was exposed in the BSH. – Austin Brougher Mar 03 '14 at 12:45
  • The variables exposed in BSH are the following:- targetBaseDir,targetFileName,targetRelativeDir,targetRelativeDir,processFile,sourceFileName,sourceFilePath,batchDir,engine,sourceNodeId,log. But the new requirement is to change the source base dir (represented by base_dir field in file_trigger table) for each store node when syncing files from store nodes to corp node. – Binyamin Melepat Mar 03 '14 at 13:32