Project

General

Profile

Actions

Feature #177

open

New storage backend

Added by anbr about 15 years ago. Updated over 13 years ago.

Status:
New
Priority:
Normal
Assignee:
Target version:
Start date:
10/17/2009
Due date:
% Done:

0%

Estimated time:

Description

Here is a patch to provide a new storage backend. This backend use mysql to cache teletext pages.

mysql database as cache system:
This additional feature should actived during building "make plugins HAVE_MYSQL=1"
At runtime called with "vdr -P'osdteletext --cache-system=mysql'
Define database connection with "$ETCVDR/PLUGINS/osdteletext.cnf"
A example it placed inside subdirectory "mysql".

This cache method used too by XXV integrated teletext viewer and fulltext search. (xxx.berlios.de)


Files

Actions #1

Updated by SPAM about 15 years ago

The patch adds a lot of code and some complexity but does not document any benefits for using MySQL as the storage system. Please add some words somewhere in the patch why one would like to use it over the other options.

There are some xxv references in the patch that should probably be changed to osdteletext.

The "top pages" feature doesn't seem dependent on MySQL or the rest of the patch, could you submit that separately first?

Actions #2

Updated by anbr about 15 years ago

Sorry, i forget to tell about small improvements

This small patch let the plugin don't save "unviewable" pages (pages with hexadecimal number A-F)
It's reduce the load to store pages, otherwise with option --toptext the plugin store pages with hexadecimal number.

void cTelePage::save()
   if(g_StoreTopText ||
      ((page.page & 0xFF) <= 0x99 
      (page.page & 0x0F) <= 0x9 )) {

txtrecv.h:
Follow member of cTxtReceiver was removed

tChannelID chan;

---> Already defined into cTelePage :

bool running;

---> Already defined into cTxtReceiver by cThread:

All other changes around class "storage" are required, to overload functional pointers for mysql-storage backend.

There are some xxv references in the patch that should probably be changed to osdteletext.

This reference are only inside sample file /mysql/osdteletext.cnf to defined a working database setup.
Replace this text inside /mysql/osdteletext.cnf like

#
# Copy this file $ETCVDR/PLUGINS/osdteletext.cnf
#
# to enable privileges into database DBNAME
#
# USE DBNAME;
# GRANT select,insert,update,create,delete ON DBNAME.* TO osdteletext@'localhost';
# SET PASSWORD FOR osdteletext@'localhost'=PASSWORD('alobComhab7');
# FLUSH PRIVILEGES;
#

[client]
user=osdteletext
password=alobComhab7
port = 3306
host = localhost
database = DBNAME

Actions #3

Updated by anbr about 15 years ago

anbr wrote:

[...]
---> Already defined into cTelePage :

That's mean cReceiver
cTxtReceiver::chan = cReceiver::ChannelID()

...

cTxtReceiver::running = cThread::Running()

Actions #4

Updated by anbr about 15 years ago

  • File osdteletext-0.8.3.improvements.patch added
  • File osdteletext-0.8.3-mysqlstorage.patch added

Here a set of splitted patches.

1st patch osdteletext-0.8.3.improvements.patch, remove some double or unused variables

2nd patch add osdteletext-0.8.3-mysqlstorage.patch, add the mysql backend,

Actions #5

Updated by Mreimer about 15 years ago

In which way does it improve the osdteletext plugin, if a mysql backend is added? IMHO the existing caching mechanism should be improved to work better and there shouldn't be added a second one, which also requires a mysql daemon to be running to work.

Actions #6

Updated by anbr about 15 years ago

  • File xxv.png added

Mreimer wrote:

In which way does it improve the osdteletext plugin, if a mysql backend is added? IMHO the existing caching mechanism should be improved to work better and there shouldn't be added a second one, which also requires a mysql daemon to be running to work.

There diffenent way to use osdteletext plugin. A external using will be improved.
Mysql provided a easy way to search and index large quantities of teletext pages then pure file system way.

I'm use osdteletext plugin also as data source for a teletext web frontend. See attached picture, this picture show a full text search, with highlight the token...

Actions #7

Updated by Mreimer about 15 years ago

OK, for external usage and for fast full text search, a SQL database would be an improvement. As long as this is disabled by default, it doesn't matter (but that's only my opinion and I'm not a osdteletext developer, but just someone who is interested in the plugin). I just know that my and probably many other VDRs out there are too slow to be able to run that big mysql daemon, so it would be definetly bad if the built-in file-based cache gets replaced by mysql in future.

Actions #8

Updated by etobi about 15 years ago

I can understand your XXV usecase, but personally I wouldn't be happy with MySQL code in the OSDTeletext sources.

What about using a separate plugin and just refactoring the code, so that the common parts in both plugins can easily be shared? Xeatre.TV also has a "teletextgrabber" plugin (based on osdteletext - looks very much like your code, so it seems Andreas P. borrowed from you or vice versa).

This would have the benefit, that you can add extra functionality, like externally triggered updates of VTX pages.

Or: Making osdteletext just trigger an event when something changes, which an external application can capture to update the database?

On the other side: Your Patch isn't so much intrusive and injecting the storage is a good idea anyway (from a software designe perspective...)

Actions #9

Updated by anbr about 15 years ago

etobi wrote:

I can understand your XXV usecase, but personally I wouldn't be happy with MySQL code in the OSDTeletext sources.

The storage is disabled by default, you must it enable with "make all HAVE_MYSQL=1" at build time. MySQL code reflected only on mysqlstorage.c, so that an plain build have'nt any depends at build and runtime to mysql.

It's add only an third methods. Any other storages methods (packed, single file) are unchanged and full usable.

What about using a separate plugin and just refactoring the code, so that the common parts in both plugins can easily be shared? Xeatre.TV also has a "teletextgrabber" plugin (based on osdteletext - looks very much like your code, so it seems Andreas P. borrowed from you or vice versa).

Sorry, i've never see any public code from xeatre.tv, so that i can only provide and share my own development.
Your refered about a plugin that have a different target (recording based historical teletext logging) that's is'nt really not usable for osdteletext-plugin.

Actions #10

Updated by etobi about 15 years ago

  • Assignee set to etobi
Actions #11

Updated by etobi about 15 years ago

After taking a deeper look into this patch, I have a tiny wish. Please split it a little bit more:

  • Refactoring: Inject storage rather then refering to it statically
  • Refactoring: Use ChannelID() instead of chan
  • Refactoring: Use Running() instead of running instance variable
  • New: Added TopText option
  • New: Add MySQL storage

I also don't like that a static storageOption is introduced. The storageOption / maxStorage is only used for the LegacyStorage. The other storage classes don't need this. My suggestion is: Instantiate the storage classes from cPluginosdtelextc and provid maxStorage for LegacyStorage only. This means getting rid of the static Storage::instance() factory method (and the static system member) and moving the storage instantiation into the cPluginosdtelext or a separate factory class used by cPluginosdtelext. So there should be another refactoring step before adding the mysql storage:

  • Refactoring: Moved storage instantiation into main class

BTW: There seems to be a bug in your patch regarding this issue anyway: You left a Storage::instance() call in the cTxtReceiver ctor. This would mean, two storages get instantiated.

Actions #12

Updated by anbr about 15 years ago

I attach a set of patchs

BTW: There seems to be a bug in your patch regarding this issue anyway: You left a Storage::instance() call in the cTxtReceiver ctor. This would mean, two storages get instantiated.

That's not a bug it's feature. ;-)
1st storage exits only per cPlugin for slow housekeeping, depends maxStorage
2nd storage exits only per cReceiver for fast start up and store

The storageOption / maxStorage is only used for the LegacyStorage.

mysql-storage use "maxStorage" too, as hours of time to life per page.
That parameter only define once by commandline, therefore need none instance a own variable.
But, i don't would rewrite all storage methods.

Actions #13

Updated by etobi about 15 years ago

Thanks! Much more Git-friendly and easier to understand. I'll try to add your patches ASAP, before making a new release.

Actions #14

Updated by anbr about 15 years ago

  • File osdteletext-0.8.3-7th-add-regular-housekeeping.diff added

Here a simple patch to call housekeeping regularly.
Without this patch housekeeping will only once at start up executed.

Actions #15

Updated by anbr about 15 years ago

anbr wrote:

Here a simple patch to call housekeeping regularly.
Without this patch housekeeping will only once at start up executed.

Please ignore that statement and patch, the code at Storage::cleanup/freespace is'nt wrong, but not really optimal code.
  • Cleanup remove once at startup if filesystem over limit.
  • if memory counted pages over limit
  • if filesystem really full and write failed
Actions #16

Updated by gnapheus almost 15 years ago

What about using sqlite instead of mysql ? This would make configuration much easier.

Actions #17

Updated by anbr almost 15 years ago

gnapheus wrote:

What about using sqlite instead of mysql ? This would make configuration much easier.

At moment osdteletext-source include only changes for a more generic storage interface. There none mysql-depends changes merged at upstream release.

You chould create a own new class based on Storage (txtrecv.h)
e.g. for mysql - http://projects.vdr-developer.org/attachments/141/osdteletext-0.8.3-6th-add-mysql.diff

But some people on web-blogs say :
"SQLite is very fast on read operations and slow on write operations comparing to databases like MySQL." ;-)

Actions #18

Updated by gnapheus almost 15 years ago

anbr wrote:

gnapheus wrote:

What about using sqlite instead of mysql ? This would make configuration much easier.

At moment osdteletext-source include only changes for a more generic storage interface. There none mysql-depends changes merged at upstream release.

You chould create a own new class based on Storage (txtrecv.h)
e.g. for mysql - http://projects.vdr-developer.org/attachments/141/osdteletext-0.8.3-6th-add-mysql.diff

Yes, I know that the mysql backend isn't implemented yet. But I think osdteletext needs i new storage backend with more possibilities and maybe a more lightweight solution like sqlite would rather be implemented.

But some people on web-blogs say :
"SQLite is very fast on read operations and slow on write operations comparing to databases like MySQL." ;-)

Do you really think this is of importance for this application?

Actions #19

Updated by Anonymous over 14 years ago

  • File deleted (osdteletext-0.8.3.improvements.patch)
Actions #20

Updated by Anonymous over 14 years ago

  • File deleted (osdteletext-0.8.3-7th-add-regular-housekeeping.diff)
Actions #21

Updated by Anonymous over 14 years ago

  • File deleted (osdteletext-0.8.3-mysqlstorage.diff)
Actions #22

Updated by Anonymous over 14 years ago

  • File deleted (osdteletext-0.8.3-mysqlstorage.patch)
Actions #23

Updated by Anonymous over 14 years ago

  • File deleted (osdteletext-0.8.3-5th-refactoring-storage.diff)
Actions #24

Updated by Anonymous over 14 years ago

  • File deleted (osdteletext-0.8.3-6th-add-mysql.diff)
Actions #25

Updated by Anonymous over 14 years ago

  • File deleted (osdteletext-0.8.3-4rd-do-not-store-unviewable-toptext-as-default.diff)
Actions #26

Updated by Anonymous over 14 years ago

  • File deleted (osdteletext-0.8.3-3rd-remove-double-running.diff)
Actions #27

Updated by Anonymous over 14 years ago

  • File deleted (xxv.png)
Actions #28

Updated by Anonymous over 14 years ago

  • File deleted (osdteletext-0.8.3-1st-remove-unused-variable.diff)
Actions #29

Updated by etobi over 13 years ago

  • Target version changed from 0.8.3 to 1.0.0
Actions

Also available in: Atom PDF