Package org.objectweb.speedo.pobjects.userid

Examples of org.objectweb.speedo.pobjects.userid.LinkedIntUserId


    try {
      res.beginTest();
      beginTx(pm, task, threadId, txId);
      // Execute one transaction
      // Do nbWrite access to a persistent
      LinkedIntUserId oUserId;
      int oid;
      String f1 = Alea.randomstring();
      for (int no = 0; no < sctx.nbWrite; no++) {
        oid = Alea.rand(0, sctx.dbSize - 1);
        oUserId = (LinkedIntUserId) pm.getObjectById(sctx.oids[oid], false);
        if (debug) {
          logger.log(BasicLevel.DEBUG, "Writing object " + oid);
        }
        oUserId.writeF1(sctx.nbWritePersistent, f1);
        Assert.assertEquals("Write error", f1, oUserId.getF1());
      }
      commitTx(pm, task, threadId, txId);
      res.endTest();
    } catch (JDOFatalException e) {
      rollbackOnException(pm, e, res, task, threadId, txId);
View Full Code Here


      Query query = pm.newQuery(liui, filter);
      query.declareParameters("Integer min, Integer max");
      Collection cLinkedUsers = (Collection) query.execute(new Integer(min), new Integer(max));
      Iterator iterator = cLinkedUsers.iterator();
      while (iterator.hasNext()) {
        LinkedIntUserId lLinkedIntUserId = (LinkedIntUserId) iterator.next();
        int i = lLinkedIntUserId.getName();
        if (debug) {
          logger.log(BasicLevel.DEBUG, "Thread " + threadId
                  + " Name = " + i);
        }
      }
View Full Code Here

    int nbTx = task.txToExecute.length;
    PersistenceManager pm = getPM(task, threadId, txId);
    try {
      res.beginTest();
      beginTx(pm, task, threadId, txId);
      LinkedIntUserId current=null, next=null;
     
      if (!pctx.linkOnPrepare) {
        if (plus > 0) {
          //The first transaction creates the additional object
          for (int oid = 0; txId == 0 && oid < plus; oid++) {
            current = new LinkedIntUserId(oid, "Obj No " + oid, null);
            pm.makePersistent(current);
            if (pctx.keepOidOnPrepare) {
              pctx.oids[oid] = pm.getObjectId(current);
            }
          }           
        }
        // The other transactions create 'nbCreation' objects
        for (int no = 0; no < NB_CREATION; no++) {
          int oid = (txId * NB_CREATION) + no + plus;
          if (oid < pctx.dbSize) {
            current = new LinkedIntUserId(oid, "Obj No " + oid, null);
            pm.makePersistent(current);
            if (pctx.keepOidOnPrepare) {
              pctx.oids[oid] = pm.getObjectId(current);
            }
          }
        }
      } else if (!pctx.endPrepare) {
         
        /*
         * First : save the oid of objects to be linked between transactions  
         */       
       
        int oid = 0;
        if (plus > 0 && txId == 0) {
          current = new LinkedIntUserId(oid, "Obj No " + oid, null);
          pm.makePersistent(current);
          if (pctx.keepOidOnPrepare) {
            pctx.oids[oid] = pm.getObjectId(current);
          }
         
          oid++;
          next = new LinkedIntUserId(oid, "Obj No " + oid, null);
          pm.makePersistent(next);
          if (pctx.keepOidOnPrepare) {
            pctx.oids[oid] = pm.getObjectId(next);
          }
         
          current.setNext(next);
          pctx.currentsOnPrepare[txId] = pm.getObjectId(current);
         
          //The first transaction creates the additional object
          for (oid = 2; oid < plus; oid++) {       
            current = new LinkedIntUserId(oid, "Obj No " + oid, null);
            pm.makePersistent(current);
            if (pctx.keepOidOnPrepare) {
              pctx.oids[oid] = pm.getObjectId(current);
            }
            next.setNext(current);
            pm.makePersistent(next);
            next = current;           
          }       
        }
       
        // The other transactions create 'nbCreation' objects
        for (int no = 0; no < NB_CREATION; no++) {
          oid = (txId * NB_CREATION) + no + plus;
          if (oid < pctx.dbSize) {         
            current = new LinkedIntUserId(oid, "Obj No " + oid, null);
            pm.makePersistent(current);
            if (no == 0 && pctx.currentsOnPrepare[txId] == null) {
              pctx.currentsOnPrepare[txId] = pm.getObjectId(current);
             
            }
            if (pctx.keepOidOnPrepare) {
              pctx.oids[oid] = pm.getObjectId(current);
            }
            if (next != null) {
              next.setNext(current);
              pm.makePersistent(next);
            }
            next = current;
          }
        }
       
        // save the oid of objects to be linked between transactions
        pctx.nextsOnPrepare[txId] = pm.getObjectId(next);       
       
      } else if (txId == nbTx - 1){ // do it once only
     
        /*
         * Second : link the oid   
         */       
        if (debug) {
          for (int i=0; i < nbTx; i++) {           
            logger.log(BasicLevel.DEBUG, "currentsOnPrepare["+i+"]="+ pctx.currentsOnPrepare[i]);
            logger.log(BasicLevel.DEBUG, "nextsOnPrepare["+i+"]="+ pctx.nextsOnPrepare[i]);         
          }
        }
       
        // make circular list       
        next = (LinkedIntUserId) pm.getObjectById(pctx.currentsOnPrepare[0], false);
        current = (LinkedIntUserId) pm.getObjectById(pctx.nextsOnPrepare[txId], false);
       
        if (plus != 0) {                 
          if (txId == 0) {
            current = (LinkedIntUserId) pm.getObjectById(pctx.nextsOnPrepare[txId], false);
          } else {
            current = (LinkedIntUserId) pm.getObjectById(pctx.nextsOnPrepare[txId-1], false);
          }
        }
       
        current.setNext(next);
        pm.makePersistent(current);           
        if (pctx.keepOidOnPrepare) {
          int indice = (nbTx * NB_CREATION) - 1;
          if (plus != 0) {     
            indice = (txId * NB_CREATION) + plus - 1;
          }         
          pctx.oids[indice] = pm.getObjectId(current);
        }
       
       
        // link objects between transactions
        for (int no = 0; no < nbTx - 1; no++) {                       
          if (pctx.currentsOnPrepare[no+1] != null) {
            next = (LinkedIntUserId) pm.getObjectById(pctx.currentsOnPrepare[no+1], false);         
            current = (LinkedIntUserId) pm.getObjectById(pctx.nextsOnPrepare[no], false);         
            current.setNext(next);           
          }
        }
       
        // verify all
        for (int i=0; i<pctx.oids.length-1; i++) {
          Assert.assertNotNull("i="+i, pctx.oids[i]);     
          Assert.assertNotNull("i="+i+1, pctx.oids[i+1]);
          current = (LinkedIntUserIdpm.getObjectById(pctx.oids[i], false);
          next = (LinkedIntUserIdpm.getObjectById(pctx.oids[i+1], false);
          Assert.assertEquals("name="+current.getName(), current.getNext().getName(), next.getName());
        }
        next = (LinkedIntUserIdpm.getObjectById(pctx.oids[0], false);
        current = (LinkedIntUserIdpm.getObjectById(pctx.oids[pctx.oids.length-1], false);
        Assert.assertEquals("name="+current.getName(), current.getNext().getName(), next.getName());
       
       
      }
      commitTx(pm, task, threadId, txId);
      res.endTest();
View Full Code Here

    PersistenceManager pm = getPM(task, threadId, txId);
    try {
      res.beginTest();
      beginTx(pm, task, threadId, txId);
      // Execute one transaction: do nbRead access to a persistent
      LinkedIntUserId oUserId;
      for (int no = 0; no < gctx.nbRead; no++) {
        int oid = Alea.rand(0, gctx.dbSize - 1);
        gctx.stat.touch(new Integer(oid));
        if (debug) {
          logger.log(BasicLevel.DEBUG, "Reading object " + oid);
        }
        oUserId = (LinkedIntUserId)
                pm.getObjectById(gctx.oids[oid], false);
        assertNotNull("Null object (oid = " + oid + ")", oUserId);
        oUserId.readName(gctx.nbReadPersistent);
      }
      commitTx(pm, task, threadId, txId);
      res.endTest();
    } catch (JDOFatalException e) {
      rollbackOnException(pm, e, res, task, threadId, txId);
View Full Code Here

      int name = -1;
      if (debug) {
        logger.log(BasicLevel.DEBUG, "first= " + first);
        logger.log(BasicLevel.DEBUG, "nbRead= " + nbRead);
      }
      LinkedIntUserId current = (LinkedIntUserId) pm.getObjectById(nctx.oids[first], false);
      for (int no = 0; no < nbRead; no++) {
        Assert.assertNotNull("first=" + first + " nbRead=" + nbRead, current);
        name = current.getName();
        if (debug) {
          logger.log(BasicLevel.DEBUG, "Obj " + name);
        }
        current = current.getNext();
      }
      commitTx(pm, task, threadId, txId);
      res.endTest();
    } catch (JDOFatalException e) {
      rollbackOnException(pm, e, res, task, threadId, txId);
View Full Code Here

TOP

Related Classes of org.objectweb.speedo.pobjects.userid.LinkedIntUserId

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.