Home Help Center

FreezeMap lazy initialize

xdmxdm La Coruña, SpainAdministrators, ZeroC Staff Jose Gutierrez de la ConchaOrganization: ZeroC, Inc.Project: Ice Developer ZeroC Staff
Hi

I have a problem related to initialice a FreezeMap

I have a servant Implementation in c++ that has same persitent attributes defined in is the slice class and a Freeze::Connection and Freeze::Map defined in the servant implementation header.

i wan to store this servant using Freeze::Evictor and initialize the Freeze::Conection and Freeze::Map with a servant initializer

the problem i see to do this is that i don't know how create a default constructor for my class. and leave the inizialization of Connection and Map to the servant initializer.

any ideas ?

thanks in advance

Comments

  • bernardbernard Jupiter, FLAdministrators, ZeroC Staff Bernard NormierOrganization: ZeroC, Inc.Project: Ice ZeroC Staff
    Hi Jose,

    I don't see the issue with this initialization. Maybe you could illustrate with a code sample?

    Since you want to contruct the Freeze Map object later, you need to allocate it dynamically, e.g. use a auto_ptr<MapType> data member and in the initialize function write something like:
    servant->_map.reset(new MapType(servant->_connection, servant->mapName));

    Since Freeze connections are single-threaded, it's also very common to create your Connection and Map on the stack in each operation implementation. In this situation, you could also keep a Map data member to prevent Freeze from closing the underlying Berkeley DB database.

    Cheers,
    Bernard
  • xdmxdm La Coruña, SpainAdministrators, ZeroC Staff Jose Gutierrez de la ConchaOrganization: ZeroC, Inc.Project: Ice Developer ZeroC Staff
    Thanks a lot bernard your coment about auto_ptr solve my problem.

    Now i want that tow services access the same FreezeMap

    one service is c++ and add new objects to the map, the other is a java service and retrieve the last object add it to a lucene index and erase it from the FreezeMap.

    first of all, is this posible?

    How the java service can know that are new objects in the map?
    i think in run it periodicaly but i don't know if there is a better way

    any considerations needed for serialized the access to the freeze map from tow services?

    thanks in advance
  • bernardbernard Jupiter, FLAdministrators, ZeroC Staff Bernard NormierOrganization: ZeroC, Inc.Project: Ice ZeroC Staff
    Hi Jose,

    With Freeze, you can't share the same database environment between several processes, whether C++ or Java.
    You could however use the same database environment from a C++ and a Java process--just not at the same time.

    If both processes are running the same time, the best solution is to have just one access the database environment and let the other process access the data through a Slice interface implemented by the first process.

    Cheers,
    Bernard
Sign In or Register to comment.