•
In toamna aceasta am avut un “puseu” de socializare, am cunoscut in cateva saptamani mai multi oameni decat in ani de zile…
si cum in ultima vreme ma tot uit la star trek-uri, incep cumva sa ma identific cu o parte din personaje (mai exact cu toate mai putin Deanna Troi – empatia pur si simplu nu e ceva natural pt mine), si imi dau seama ca abordarea mea a umanului seamana putin cu eforturile lui Data … in stilul lui as putea zice: ca a cunoaste oameni este o experienta minunata, ca vor exista intotdeauna surprize placute, dar si surprize mai putin placute. Simt ca e bine sa le dau oamenilor noi cunoscuti credit, si sa sper ca surprizele neplacute nu vor veni. Si totusi unele “rautati” descoperite intamplator sunt absolut haioase in copilarismul lor (de la barfe, la minciunele, superficialitati si altele), nu mi-as fi inchipuit acum cateva luni cum se comporta unii oameni maturi si responsabili (suspectez ca exemplele sunt de prisos). Dar asta este, si eu sunt om, cu defectele mele, mai mici … sau mai mari, iar per ansamblu, e tare bine sa cunosc oameni noi. Intr-o proportie majoritara, s-au dovedit extraordinari, am invatat insa sa dau oamenilor timp pentru a-i cunoaste cu adevarat.
Si pt ca tot vorbeam de Star Trek, incep sa suspectez ca am ceva (doar putin!) in comun si cu Worf (genul rece si intimidant?) – este pur si simplu un mod de a fi, o aparenta inselatoare ce nu tre luata prea mult in serios
•
After struggling throw a maze of documentation about jboss treecache, here are the things I would have liked to read somewhere, but found out by trial and error (and with the help of Adi and Len, thanks again!):
- to configure a cache for hibernate, the best documentation and source of jars is www.hibernate.org – they struggled to determine a good combination that just works
-in the exact release of hibernate you are using there are the jars for all recommended caches (ehcache, treecache, oscache etc.) and a short file explaining what jars you need for each cache
-a comparison between all caches is found here in the hibernate documentation:
http://www.hibernate.org/hib_docs/v3/reference/en-US/html_single/#performance-cache
For me treecache was the only option, as i needed a “cluster safe” solution. Ehcache documentation mentions distributable feature, but apparently (as it results from hibernate documentation) ehcache in combination with hibernate it is not quite cluster safe.
As I tested with jboss, i downloaded exactly the hibernate version that came with my jboss, and took only jgroups.jar, there was already available the jboss-cache-jdk50.jar and did not copy jboss-cache.jar (i searched for the hibernate jar in jboss installation and looked at the manifest to find the exact version, then downloaded the full release of that version from hibernate.org)
My mbean configuration in hibernate-services.xml (the equivalent of a hibernate.cfg.xml):
<attribute name="CacheProviderClass">org.hibernate.cache.TreeCacheProvider</attribute><attribute name="QueryCacheEnabled">true</attribute>
<attribute name="SecondLevelCacheEnabled">true</attribute>
<attribute name="StatGenerationEnabled">true</attribute>
<attribute name="UseStructuredCacheEntriesEnabled">true</attribute>
The treecache.xml contains the specific cache configuration, I copied it without any change from the etc directory of hibernate release (it is the “pessimistic” configuration) into my .sar root.
Good, after all this, it just works, but do not expect any miracles, in order to actually use the cache, you should make changes in your code and hibernate mappings, as explained in the hibernate documentation. These changes may be particular for the cache you installed, for instance “read-only” usage is not supported by treecache, “transactional” is recommended.
In the class mappings the cache attribute is required for the objects that will use the cache:
<class name="..." table="...">
<cache usage="transactional"/>
...
<bag name="children" table="..." inverse="true">
<cache usage="transactional"/>
<key column="PARENT_FK" />
<one-to-many class="...."/>
</bag>
....
</class>
The queries that shoud have the results cached need to be marked as such (and the query cache shoud be enabled in hibernate configuration):
query.setCacheable(true);
Query query = session.createQuery("...");
query.list();
Hope it helps, I still stick to my opinion that using a cache is a final option, it’s always better not to need it…
•
La inceput de nou an, o mare rezolutie: sa castig lupta cu timpul (daca e posibil, chair sa dispara cu desavarsire lupta si timpul sa nu mai fie marele adversar).
Bun, simplu. Ce sa fac? Sa optimizez … Sa schimb metoda, ca sa mearga lucrurile de la sine. Sa automatizez.
Dupa 2-3 zile de modificari in vederea automatizarii, m-am sesizat ca optimizarea imi mananca tot timpul, chiar mai mult decat inainte… Mai ales ca 20 de operatii manuale nu se transforma intr-una automata, ci trebuie luate una cate una, bibilite, aduse la forma standard, si abia apoi sunt sanse sa mearga optimizarea. Daca inainte imi lua 15 min sa modific ceva, acum a durat 2 zile sa pun la punct procedura automata, si in medie 3h per operatie manuala sa o “normalizez” .. nici nu mai tre sa fac socoteala, de 2 saptamani nu am avut timp sa scriu nimic pe blog
Si de aici dilema mea: ce sa fac, sa consum mult timp de fiecare data gandind un mod optim pt operatiile care tind sa se repete, sau sa le rezolv traditional, cat de cat repede, insa pe termen lung, al naibii de ineficient? Pare ca orice as face, tot pierd lupta cu timpul …