Skip to content
Snippets Groups Projects
Commit 505c64d1 authored by Ruud Overeem's avatar Ruud Overeem
Browse files

Bug 809: Implemented complete new algorithm for finding the sort order. It...

Bug 809: Implemented complete new algorithm for finding the sort order. It works top down iso bottom up.
parent b1234677
No related branches found
No related tags found
No related merge requests found
...@@ -10,10 +10,6 @@ node StationControl 4.0.0 development 'node constraint' "Main controller fo ...@@ -10,10 +10,6 @@ node StationControl 4.0.0 development 'node constraint' "Main controller fo
#-------------------------------------------------------------------------------------------------------- #--------------------------------------------------------------------------------------------------------
par _hostname I vtext - 10 100 '>>VirtualInstrument.stationList' - "Machine(s) the program should run on, eg. [CS010C,CS016C]" par _hostname I vtext - 10 100 '>>VirtualInstrument.stationList' - "Machine(s) the program should run on, eg. [CS010C,CS016C]"
#########################################################################################################
# -- StationControl --
# name vers qual constr. descr. # name vers qual constr. descr.
#-------------------------------------------------------------------------------------------------------- #--------------------------------------------------------------------------------------------------------
node StationControl 4.0.0 development 'node constraint' "Machine(s) the program should run on, eg. [CS010C,CS016C]"
uses TBBControl 4.0.0 development 'node constraint' "TBBControl settings" uses TBBControl 4.0.0 development 'node constraint' "TBBControl settings"
...@@ -12,5 +12,3 @@ par IPAddress I text - 10 0 '@IPaddress@' ...@@ -12,5 +12,3 @@ par IPAddress I text - 10 0 '@IPaddress@'
par RAM I int RAM 10 0 1024 - 'RAM space on this node' par RAM I int RAM 10 0 1024 - 'RAM space on this node'
par Storage I int DISK 10 0 2048 - 'Storage space on this node' par Storage I int DISK 10 0 2048 - 'Storage space on this node'
...@@ -174,6 +174,7 @@ substitute_station() ...@@ -174,6 +174,7 @@ substitute_station()
done done
substitute_marker /tmp/foo $2 substitute_marker /tmp/foo $2
rm -f /tmp/foo.list
} }
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
# #
# load_components : loads all components in an OTDB database # load_components : loads all components in an OTDB database
# #
# Copyright (C) 2006 # Copyright (C) 2006-2011
# ASTRON (Netherlands Foundation for Research in Astronomy) # ASTRON (Netherlands Foundation for Research in Astronomy)
# P.O.Box 2, 7990 AA Dwingeloo, The Netherlands, seg@astron.nl # P.O.Box 2, 7990 AA Dwingeloo, The Netherlands, seg@astron.nl
# #
...@@ -24,7 +24,7 @@ ...@@ -24,7 +24,7 @@
# #
# $Id$ # $Id$
# #
VERSION="v1.1" VERSION="v2.0" # Implemented complete new algorithm that works top down iso bottom up.
# SyntaxError msg # SyntaxError msg
# #
...@@ -42,22 +42,29 @@ SyntaxError() ...@@ -42,22 +42,29 @@ SyntaxError()
} }
# #
# Add all nodes that are not 'used' to the resultfile (COMPORDERFILE) # Recursive solve the childs of the current node and construct a order-file
# and update the 'node' and 'uses' file by deleting the nodes or childs # during the descent into the tree.
# from these files. #
solve_layer() solveNode()
{ {
echo -n "." echo -n "."
comm -23 ${NODEFILE} ${USESFILE} >>${COMPORDERFILE} nodeFile=`grep "^$1 " ${NODELISTFILE} | cut -d' ' -f2`
comm -23 ${NODEFILE} ${USESFILE} | while read component
# update file admin
grep -v ^${nodeFile} ${UNUSEDFILES} >${WORKFILE}
mv ${WORKFILE} ${UNUSEDFILES}
grep "^uses" $nodeFile | sed "s/\\t/ /g" | sed "s/ / /g" | sed "s/ / /g" | cut -d' ' -f2 | while read nodeName
do do
grep -v ^${component} ${NODEFILE} >tmp nodeFile=`grep "^$nodeName " ${NODELISTFILE} | cut -d' ' -f2`
mv tmp ${NODEFILE} grep "^$nodeFile" ${REVERSORDERFILE} >> /dev/null
grep ^${component} ${RELFILE} | while read parent child if [ $? == 1 ]; then
do # echo $nodeName
grep -v ^${child} ${USESFILE} >tmp echo $nodeFile >>${REVERSORDERFILE}
mv tmp ${USESFILE} solveNode $nodeName
done # else
# echo "Endnode: $nodeName , file=$nodeFile"
fi
done done
} }
...@@ -71,65 +78,42 @@ if [ $# -eq 0 ]; then ...@@ -71,65 +78,42 @@ if [ $# -eq 0 ]; then
fi fi
# We use a lot of tmpfile to make life easier. # We use a lot of tmpfile to make life easier.
NODEFILE=/tmp/node NODELISTFILE=/tmp/nodeList
USESFILE=/tmp/uses REVERSORDERFILE=/tmp/reverseOrder
RELFILE=/tmp/relation RESULTFILE=/tmp/fileOrder
COMPORDERFILE=/tmp/comporder UNUSEDFILES=/tmp/unusedFiles
COMPDEFFILE=/tmp/compdef WORKFILE=/tmp/tmpFile4load_components
FILERELFILE=/tmp/filerel
RESULTFILE=fileOrder
# First construct gcompfile using .base-files.
./create_OTDB_comps ./create_OTDB_comps
# construct a file with 'node uses file' relations # construct a file with 'node file' relations
grep -e '^node' -e '^uses' *comp | cut -d":" -f2 | awk ' grep "^node" *comp | sed "s/:/ /" | sed "s/\\t/ /g" | sed "s/ / /g" | sed "s/ / /g" | cut -d' ' -f1,3 | awk '{ print $2" "$1 }' >${NODELISTFILE}
BEGIN {
node=""; # construct a file with all componentfiles
}; ls -1 *comp >${UNUSEDFILES}
{
if ($1 == "node") {
node = $2;
}
else {
print node" "$2;
}
} ' | sort | uniq >${RELFILE}
# make file with all node-names and all uses-names.
grep -e '^node' *comp | awk '{ print $2 }' | sort | uniq >${NODEFILE}
grep -e '^uses' *comp | awk '{ print $2 }' | sort | uniq >${USESFILE}
# strip off layer for layer # strip off layer for layer
>${COMPORDERFILE}
echo -n "Analysing load order: " echo -n "Analysing load order: "
while [ -s ${USESFILE} ] echo LOFAR.comp >${REVERSORDERFILE}
do solveNode LOFAR
solve_layer
done
cat ${NODEFILE} >>${COMPORDERFILE}
rm ${RELFILE} ${NODEFILE} ${USESFILE}
echo "." echo "."
# we now have a file with components (in reverse) order # we now have a file with components (in reverse) order, swap the order
# add the filenames in which the components are defined, remove duplicates tac ${REVERSORDERFILE} >${RESULTFILE}
# and finally make sure each name only exists once in the resultfile rm -f ${NODELISTFILE} ${REVERSORDERFILE}
grep -e '^node' *comp | sed "s/:/ /" | awk '{ print $3" "$1 }' | sort | uniq >${FILERELFILE}
tac ${COMPORDERFILE} | while read component
do
grep ^${component} ${FILERELFILE}
done | \
awk '{ print $2 }' | uniq | \
awk '{
if (!($1 in names)) {
print $1;
names[$1]=$1;
}
}' >${RESULTFILE}
rm ${COMPORDERFILE} ${FILERELFILE}
databasename=$1 databasename=$1
shift shift
echo ../../build/gnunew_debug/data/bin/load_OTDB_comps $databasename ${RESULTFILE} $* echo ../../build/gnunew_debug/data/bin/load_OTDB_comps $databasename ${RESULTFILE} $*
#../../build/gnunew_debug/data/bin/load_OTDB_comps $databasename ${RESULTFILE} $* #../../build/gnunew_debug/data/bin/load_OTDB_comps $databasename ${RESULTFILE} $*
../../../../../LOFAR/installed/gnu_debug/bin/load_OTDB_comps $databasename ${RESULTFILE} -h RS005 $* ../../../../../LOFAR/installed/gnu_debug/bin/load_OTDB_comps $databasename ${RESULTFILE} -h RS005 $*
rm ${RESULTFILE}
# when there are files we didn't use report that to the user
if [ -s ${UNUSEDFILES} ]; then
echo
echo " The following files are NOT LOADED into the database because they are NOT part of the current defined LOFAR tree:"
cat ${UNUSEDFILES}
fi
rm -f ${UNUSEDFILES} ${RESULTFILE}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment