Michele Orsi
Michele Orsi

Reputation: 762

Force JDO full initialization (with datanucleus lib)

I am working on warmup request to minimize my requests latency: https://developers.google.com/appengine/docs/java/config/appconfig#Warmup_Requests

During that initialization I perform:

PersistenceManager pm = PMF.get().getPersistenceManager();

.. but from the logs I see it doesn't parse all the .jdo files where the class metadata are stored. They are parsed only the first time I call this function "getObjectById" (for example) ..

Is it possible to force datanucleus to fully read all the metadata in order to be completely ready when the first getObjectById hits the PersistenceManager?

Thank you, Michele

============================================================================== UPDATE: I tried with this persistence.xml file:

<persistence-unit name="my-transaction">
        <mapping-file><path-to-first-jdo-file></mapping-file>
        <mapping-file><path-to-second-jdo-file></mapping-file>
        <mapping-file><path-to-third-jdo-file></mapping-file>
        <properties>
            <property name="datanucleus.NontransactionalRead" value="true"/>
            <property name="datanucleus.NontransactionalWrite" value="true"/>
            <property name="datanucleus.ConnectionURL" value="appengine"/>
        </properties>
    </persistence-unit>

that is associated with jdoconfig.xml:

<persistence-manager-factory name="my-transaction">
    <property name="javax.jdo.PersistenceManagerFactoryClass" value="org.datanucleus.store.appengine.jdo.DatastoreJDOPersistenceManagerFactory" />
    <property name="javax.jdo.option.ConnectionURL" value="appengine" />
    <property name="javax.jdo.option.NontransactionalRead" value="true" />
    <property name="javax.jdo.option.NontransactionalWrite" value="true" />
    <property name="javax.jdo.option.RetainValues" value="true" />
    <property name="datanucleus.appengine.autoCreateDatastoreTxns" value="true" />
    <property name="datanucleus.appengine.allowMultipleRelationsOfSameType" value="true" />
    <property name="datanucleus.appengine.datastoreReadConsistency" value="STRONG" />
    <property name="datanucleus.appengine.ignorableMetaDataBehavior" value="ERROR" />
    <property name="javax.jdo.option.Multithreaded" value="true"/>
    <property name="javax.jdo.option.Optimistic" value="false" />

</persistence-manager-factory>

.. but I continue to see in the logs the previuos behaviour. During loading request:

org.datanucleus.store.types.TypeManager addJavaType: Adding support for Java type <class>

.. and during the first request that really needs a class mapping (getObjectById for example):

org.datanucleus.metadata.xml.MetaDataParser parseMetaDataStream: Parsing MetaData file <class>.jdo

So the first request that retrieves the object is longer than the following ones because it needs to parse the XML file. What's wrong?

I am using datanucleus 1.1.5

Thank you

Upvotes: 0

Views: 402

Answers (1)

DataNucleus
DataNucleus

Reputation: 15577

Specify a "persistence.xml" defining all classes/mapping files. This is then read/loaded at startup. Also ancient version of DataNucleus aren't supported, so use the newer version of the GAE JPA plugin with DataNucleus v3.x

Upvotes: 1

Related Questions