Version 9 (modified by ntj, 10 years ago)
added a section about CORS error

Edelweiss

Edelweiss


How to add extra parameters

  • add the new parameter definition to the CouchDB document with the ID itemlist.
  • add the new parameter to the view definition of get_all_data

Debugging

curl 'http://localhost/adei/services/getdata.php?db_server=edelweiss&db_name=automat_monthly&db_group=edelweiss&window=-5&db_mask=0,3'

http://localhost/adei/services/list.php?target=servers

curl 'http://localhost/adei/services/getdata.php?db_server=edelweiss&db_name=automat_weekly_adei&db_group=edelweiss&window=1307357533-1384790080&db_mask=0,1&resample=86400'

Note

Resample work

Resample works, but very very slow. Why? Because it is querying each data row per http request, for a aggregation with wide interval, this should not be a problem, but as the interval gets smaller, it will be very slow.

Solution: Requires a mapreduce function to do aggregation

Status: Pending

Data Query Speed

Currently the speed of caching is roughly 250kB/s on localhost. Pretty slow. Current approach uses a buffer to request 10 thousand data rows per http request. I feel that this can somewhat still be improve.

Idea: Uses socket

Idea: use multi exec curl

Status: Pending

Possible improvement

Till now CouchDB does not yet shows its strength, I personally think we need to look into how we can integrate better with the current system by using more of the mapreduce function.

Possible Bug

CouchDB does not define its stored filed, hence some float values is saved as string, this is a problem for ADEI caching in MySQL.

Solution: ADEI do a type check and convert it accordingly (cache.php)

Status: Pending (High priority)

Useful Tip

This is mainly about CORS (Cross Origin Resource Sharing). If you have an ADEI setup at your localhost, and you wrote a javascript to fetch data directly from your localhost ADEI, 99% of the time you will be thrown this error:

Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at http://127.0.0.1/adei/services/getdata.php?db_server=wtx_060&db_name=HDCP2&db_group=base&window=1364919175-1364919176&db_mask=0,1,2,3,4,5. This can be fixed by moving the resource to the same domain or enabling CORS.

When you stumbled upon this, firstly, take a deep breath. Then you must know which server you are trying to talk to. In this case, we are trying to getdata from localhost. And ADEI server is basically Apache server.

what does this tell us? Our localhost server is not allowing any remote access to get resources, which is set by default to prevent malicious attacks. We need to tell our apache server to allow this.

So.

Add this line

Header set Access-Control-Allow-Origin "*"

into your .htaccess

and then run

apachectl -t sudo service apache2 reload a2enmod headers

after that it should work. Link: http://enable-cors.org/server_apache.html

Repository

http://adei.info/adei/browser/adei-couchreader

http://adei.info/adei/browser/adei-edelweiss-setup