Hi,
I have some code that creates DB, documents and design documents with views and
lists.
When I run views, I don't know why, but it returns nothing and waits for ever.
This is with couchdb1.5.1
When I run the same code against my another couchdb server, only difference
being that the version is 1.5.0, it works perfect. All the views return the
right responses and results.
Can anyone help me here? I am at a loss!
Below is a snippet of my design doc:
def createDesignDocForPerfStats():
design = db.design('perfstats')
resp = design.put(params={
"_id":"_design/perfstats",
"language": "javascript",
"views":
{
"by_server": {
"map": "function(doc) { if ((doc.type == 'performance_stats'))
emit([doc.Hostname,doc.test_id],{ 'Start_time':doc.start_time ,'CPU': doc.CPU,
'Memory': doc.Memory, 'FileSystem':doc.FileSystem }) }"
},
"by_test_id": {
"map": "function(doc) { if ((doc.type == 'performance_stats'))
emit(doc.test_id,{ 'Server Name': doc.Hostname, 'Start_time':doc.start_time,
'CPU': doc.CPU, 'Memory': doc.Memory, 'FileSystem':doc.FileSystem }) }"
},
"by_testid_starttime": {
"map": "function(doc) { if ((doc.type == 'performance_stats'))
emit([doc.test_id, doc.start_time],{ 'Server Name': doc.Hostname,
'TestID':doc.test_id, 'CPU': doc.CPU, 'Memory': doc.Memory,
'FileSystem':doc.FileSystem }) }"
},
#view is
http://10.247.32.71:5984/longevity/_design/perfstats51/_view/server?group=true
"server": {
"map": "function(doc) { if ((doc.type == 'performance_stats'))
emit([doc.test_id, doc.Hostname],null ) }",
"reduce": "function(keys, values) {return (null)}"
},
"cpu": {
"map": "function(doc) { if ((doc.type == 'performance_stats'))
emit(doc.test_id, doc.CPU) }",
"reduce": "function(keys, values) "
"{ "
"avg = Math.round(sum(values)/values.length);"
"return(avg)"
" }"
},
#get avg cpu for all servers per time
#http://10.247.32.72:5984/longevity/_design/perfstats1/_view/cpu_by_starttime?group=true
"cpu_by_starttime": {
"map": "function(doc) { if ((doc.type == 'performance_stats'))
emit([doc.test_id,doc.start_time], doc.CPU) }",
"reduce": "function(keys, values) "
"{ "
"avg = Math.round(sum(values)/values.length);"
"return(avg)"
" }"
},
},
"lists":{
"sort":"function(head, req) {"
"var row;"
"var rows=[];"
"while(row = getRow()) {"
"rows.push(row)"
"};"
"rows.sort(function(a,b) {"
"return b.value-a.value"
"});"
"send(JSON.stringify({\"rows\" : rows[0]}))"
"}"
}
})