Friday, April 27, 2012

Minimalistic file load generator and HAFileAdapter tester

I need to copy over and over the same file (with different file names) to a shared SAMBA folder, to test HAFileAdater in a cluster.

Minimalistic approach, a shell script:

for i in {1..10}
do
    cp myfile.xml target/myfile${i}.xml
done

but when it comes to sleeping, sleep in shell takes only a parameter in SECONDS (no milliseconds). Pathetic.

Why some people use Shell script to do anything more than really basic stuff, I will never understand. Probably they started their career 20 years ago with Shell scripting and they never weaned off.

So I do the same in Python:
import shutil
import time
i = 1
while i < 100:
    shutil.copyfile('myfile.xml', 'target/myfile' + str(i) + '.xml'
    i = i + 1
    time.sleep(0.01)
Here is a JCA file poller.... just change FileAdapter into HAFileAdapter in the JCA file, and the source folder, and add a Report action to trace the file name ($inbound/ctx:transport/ctx:request/tp:headers/jca:jca.file.FileName ) here is $inbound :

  
    Read
  
  
    jca://eis/FileAdapter
    request
    best-effort
    
      
        
        Read
        New Text Document.txt
        C:\pierre\infiles\in3
        0
        IG1OEdhYeSMWsjUbSnFe1NnrVx-2v0YafavtRTvgZGs.
        1
        1335498161556
      
      UTF-8
    
    
      
      0
    
  
  
    
      <anonymous>
    
  




No comments: