1 19 package fr.dyade.aaa.agent; 20 21 import java.io.IOException ; 22 import java.util.Hashtable ; 23 import java.util.Enumeration ; 24 import java.util.Vector ; 25 26 import org.objectweb.util.monolog.api.BasicLevel; 27 import org.objectweb.util.monolog.api.Logger; 28 29 import fr.dyade.aaa.util.*; 30 31 35 final class GCEngine extends Engine { 36 37 int loop = 0; 38 int NbMaxLoop = 50; 39 40 GCEngine() throws Exception { 41 super(); 42 43 NbMaxLoop = Integer.getInteger("NbMaxLoop", NbMaxLoop).intValue(); 44 needToBeCommited = false; 45 } 46 47 56 void commit() throws Exception { 57 if (logmon.isLoggable(BasicLevel.DEBUG)) { 58 logmon.log(BasicLevel.DEBUG, getName() + ", commit reaction"); 59 } 60 loop += 1; 61 62 AgentServer.getTransaction().begin(); 63 qin.pop(); 65 msg.delete(); 67 msg.free(); 69 for (int i=0; i<mq.size(); ) { 71 Message m = (Message) mq.elementAt(i); 72 if (logmon.isLoggable(BasicLevel.DEBUG)) { 73 logmon.log(BasicLevel.DEBUG, getName() + ", dispatch: " + m); 74 } 75 if (m.to.getTo() == AgentServer.getServerId()) { 76 post(m); 79 mq.removeElementAt(i); 80 } else { 81 i += 1; 82 } 83 } 84 validate(); 87 88 if (agent != null) agent.save(); 90 91 if (needToBeCommited || (qin.size() == 0) || (loop > NbMaxLoop)) { 92 if (logmon.isLoggable(BasicLevel.INFO)) { 93 logmon.log(BasicLevel.INFO, getName() + ", commit: " + loop); 94 } 95 loop = 0; 96 97 dispatch(); 100 AgentServer.getTransaction().commit(); 101 Channel.validate(); 103 } 104 AgentServer.getTransaction().release(); 105 } 106 } 107 | Popular Tags |