You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by Gerhard Froehlich <g-...@gmx.de> on 2002/01/15 18:26:54 UTC

[simplestore] enhancements (was: [simplestore] inital check in)

Juozas 

>From: Juozas Baliuka [mailto:baliuka@mwm.lt]
>
>Hi,
>I think simple store is too simple :).

:)

>I see some things to do for simple store.
>1. Add meaningful exception classes

+1 on this!

>2. Add some helper key class for keys like Class + OID :
>  Object key = new OID( myClass, someKey  );

Hmm, don't get you here. Can you explain that in detail?

>3.Add simple finders and batch to store interface for optimizations:
>  store(Map map);
>  Iterator find( String myRegistredProcedure, String property);
>// " SELECT it_is_from_procedure_descriptor FROM Some_Table WHERE 
>myProc(property) = 1 "
>  Iterator find(Collection idCollection);
>4. Ability to register and call stored procedures  on sorage :
>  registerProcedure(String alias,ProcedureDescriptor p);
>  Object retValueOrValues = call(alias,paramArray);
>5. Tranzaction listeners.

Point 3,4 and 5 seems to be more a Database Management as a simple
Store. But maybe I habe lost you here. Can give some further information!
But keep in mind I want some thin and fast Cache which is ease to plug.

TIA
  Gerhard
 
----------------------------
I just found the last bug...
----------------------------


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


RE: [simplestore] enhancements (was: [simplestore] inital check in)

Posted by Juozas Baliuka <ba...@mwm.lt>.
>
>When the number of items reaches a set maximum, I'd like to remove the
>reference to them from the hashtable and spool them to disk.  Reaching
>the set item number limit, the cache should overflow onto disk.  It is a
>rough swap that's all.
>
>This technique doesn't endlessly leak memory.

I believe your OS does this job "Virtual Memory Management", no JVM no JAVA 
application must do this.
It is impossible for OS to do this if JVM  allocates not moveable memory, I 
believe it don't.
I think it is not very meaningful to dublicate OS functionality in JAVA 
application, It can be meaningful
if single application with single thread runs on your machine.



--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


RE: [simplestore] enhancements (was: [simplestore] inital check in)

Posted by Aaron Smuts <aa...@verizon.net>.

> -----Original Message-----
> From: Juozas Baliuka [mailto:baliuka@mwm.lt]
> Sent: Wednesday, January 16, 2002 10:44 AM
 
> I think methods like "memory.overflow()" has no meaning in JAVA.
> You will never implement the best memory manager in JAVA application
or
> Application container, because
> JVM + GC will be better :).
> Use java.lang.ref.* there is no better way in JAVA at this time.
> 
 
When the number of items reaches a set maximum, I'd like to remove the
reference to them from the hashtable and spool them to disk.  Reaching
the set item number limit, the cache should overflow onto disk.  It is a
rough swap that's all.  

This technique doesn't endlessly leak memory.

Aaron




--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


RE: [simplestore] enhancements (was: [simplestore] inital check in)

Posted by Juozas Baliuka <ba...@mwm.lt>.
At 08:51 AM 1/16/2002 -0500, you wrote:
>
>The example prompts a few points.  You'd be creating some sort of
>secondary session.  How would you go about getting the attribute name
>list?  Would you really want to tie the store to the user and have a
>half baked session?  Why even have a special servlet?  You just get a
>store instance and use it.  If you want to do session like work then you
>are going to need wrappers and some group functionality.  I'm working on
>the same stuff today in JCS.  I'm trying to clean up the distributed
>sessions.
There are a lot of ways to wrap HttpSession, HttpContext in Filer,
and you can implement ditributed, presistent session or both of them,
depends on situation and then it useful. I am not competent at this time.
It is not very trivial to implement transparent clustering, example was not 
about this.

>Oh, if you come up with a good memory store, I'd like to talk about the
>API.  I made the memory manager pluggable in JCS.  The memory manager
>needs to be able to call an overflow method on the cache hub though.  It
>should at least call some sort of overflow() method in itself when it
>needs to clean up the list, so an extended class could implement it.

I think methods like "memory.overflow()" has no meaning in JAVA.
You will never implement the best memory manager in JAVA application or 
Application container, because
JVM + GC will be better :).
Use java.lang.ref.* there is no better way in JAVA at this time.


>--
>To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
>For additional commands, e-mail: <ma...@jakarta.apache.org>



--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


RE: [simplestore] enhancements (was: [simplestore] inital check in)

Posted by Aaron Smuts <aa...@verizon.net>.
 
> 
> Good candidate for example is javax.servlet.http.HttpSession
> implementation :
> 
>   public class  PersistentHttpSession implements
> javax.servlet.http.HttpSession{
>     .....................................
>   public   PersistentHttpSession( javax.servlet.http.HttpSession
> session,Store store){
>        this.session = session;
>        this.store = store;
>   }
> 
> public void setAttribute(String key,Object value){
> 
>     store.store( new KeyPair(session.getId(),key),value);
>   // it is answer why KeyPair is useful. You can use new String(
> session.getId() +" somethig to separate "+ key ) here,
> // but this will not work for all types of keys and all cases
> 
> }
> 
> 
>
........................................................................
> 
> }
 
The example prompts a few points.  You'd be creating some sort of
secondary session.  How would you go about getting the attribute name
list?  Would you really want to tie the store to the user and have a
half baked session?  Why even have a special servlet?  You just get a
store instance and use it.  If you want to do session like work then you
are going to need wrappers and some group functionality.  I'm working on
the same stuff today in JCS.  I'm trying to clean up the distributed
sessions. 

Oh, if you come up with a good memory store, I'd like to talk about the
API.  I made the memory manager pluggable in JCS.  The memory manager
needs to be able to call an overflow method on the cache hub though.  It
should at least call some sort of overflow() method in itself when it
needs to clean up the list, so an extended class could implement it. 

Cheers,

Aaron




--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


RE: [simplestore] enhancements (was: [simplestore] inital check in)

Posted by Juozas Baliuka <ba...@mwm.lt>.
Ok,
But this code is not very useful, It can be an SoftReference usage example.
It is better to implement java.util.Map interface if simplestore is kind of 
cache not Storage.
It is some kind SoftMap implementation in commons collections, but this 
class is not meaningful,
because use public method "purge()" to clear expired entries from map by 
iterating keys.
But idea in commons to implement SoftMap is good, java.util.WeakHashMap is 
not very useful for cache and more
transparent. JispFilesystemStore can be implemented this way too.
You can remove StoreJanitor it can help in some cases, but in the most 
cases it is disadvantage for simplestore.

I think it useful to write documentation for this cache, add examples and 
true tests( test in MemoryStore main method is not solution). It must be 
documented Store advantages and disadvantages. May english
is not good to write documentation,  it is readonly :)
You can document this way :

Advantages for MRUMemoryStore:
1. Speed for write operations.
....................................
Disadvantages:
1. It can't be used for memory sensetive application,
  because it removes enties form Cache, not from memory.
...........................................

Advantages for MemoryStore:
1. Speed for read operations.
...........................................
Disadvantages:
1. Does not work if GC is dissabled or keys have strong references on values.
.........................................................

Good candidate for example is javax.servlet.http.HttpSession implementation :

  public class  PersistentHttpSession implements 
javax.servlet.http.HttpSession{
    .....................................
  public   PersistentHttpSession( javax.servlet.http.HttpSession 
session,Store store){
       this.session = session;
       this.store = store;
  }

public void setAttribute(String key,Object value){

    store.store( new KeyPair(session.getId(),key),value);
  // it is answer why KeyPair is useful. You can use new String( 
session.getId() +" somethig to separate "+ key ) here,
// but this will not work for all types of keys and all cases

}

    ........................................................................

}











At 09:45 PM 1/15/2002 +0100, you wrote:
>Hi Juozas,
>I booked in your two classes as are. I only did
>some code formating.
>
><Could you do me one favour. If you like to contribute
>to this subproject (and I hope so), can you please
>use the Jakarta Code Formating rules. This issue
>caused some flame wars in the past and I don't
>want to repeat it! It's for your self protection ;-)>

I use Ctrl+Shift+F in NetBeans to format code, may this code formater is 
not the
best, or I forgot to press this combination.
Do you use some kind of code formater in jakarta ?




>If you want to progress on your (all) classes then
>send me patches with the diff -u format.
>
>I hope I didn't blame you!
>
>Cheers
>   Gerhard
>
>
>
>--
>To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
>For additional commands, e-mail: <ma...@jakarta.apache.org>



--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


RE: [simplestore] enhancements (was: [simplestore] inital check in)

Posted by Gerhard Froehlich <g-...@gmx.de>.
Hi Juozas,
I booked in your two classes as are. I only did
some code formating.

<Could you do me one favour. If you like to contribute
to this subproject (and I hope so), can you please
use the Jakarta Code Formating rules. This issue 
caused some flame wars in the past and I don't
want to repeat it! It's for your self protection ;-)>

If you want to progress on your (all) classes then
send me patches with the diff -u format.

I hope I didn't blame you!

Cheers
  Gerhard



--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: [simplestore] enhancements (was: [simplestore] inital check in)

Posted by Juozas Baliuka <ba...@mwm.lt>.
Hi,
I have a layer for SQL stored procedures and incomplete JDO implementation.
I use Object o = Database.execute(name,args);
names mapped in properties file:
myProc.flushCahe=true
myProc={call updateSomeTable(?,?)}
if.notSupported.myProc=UPDATE myTABLE set something=? WHERE id=?

It is possible to implement some simple stored procedures this way and it 
is possible to
to implement some API for any storage using internal API primitives ( All 
SQL databeses implemented this way )

BTW I recommend http://aspectj.org for stupid clasess like 
SynchronizedStore ( It is copy/paste style),
java.lang.reflect.Proxy is too slow for me.

At 06:26 PM 1/15/2002 +0100, you wrote:
>Juozas
>
> >From: Juozas Baliuka [mailto:baliuka@mwm.lt]
> >
> >Hi,
> >I think simple store is too simple :).
>
>:)
>
> >I see some things to do for simple store.
> >1. Add meaningful exception classes
>
>+1 on this!
>
> >2. Add some helper key class for keys like Class + OID :
> >  Object key = new OID( myClass, someKey  );
>
>Hmm, don't get you here. Can you explain that in detail?
>
> >3.Add simple finders and batch to store interface for optimizations:
> >  store(Map map);
> >  Iterator find( String myRegistredProcedure, String property);
> >// " SELECT it_is_from_procedure_descriptor FROM Some_Table WHERE
> >myProc(property) = 1 "
> >  Iterator find(Collection idCollection);
> >4. Ability to register and call stored procedures  on sorage :
> >  registerProcedure(String alias,ProcedureDescriptor p);
> >  Object retValueOrValues = call(alias,paramArray);
> >5. Tranzaction listeners.
>
>Point 3,4 and 5 seems to be more a Database Management as a simple
>Store. But maybe I habe lost you here. Can give some further information!
>But keep in mind I want some thin and fast Cache which is ease to plug.
>
>TIA
>   Gerhard
>
>----------------------------
>I just found the last bug...
>----------------------------
>
>
>--
>To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
>For additional commands, e-mail: <ma...@jakarta.apache.org>