- Timestamp:
- 10/09/13 17:35:41 (11 years ago)
- Location:
- branches/supervisor
- Files:
-
- 1 added
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/supervisor/.project
r84 r100 1 1 <?xml version="1.0" encoding="UTF-8"?> 2 2 <projectDescription> 3 <name>objectmq </name>3 <name>objectmq_supervisor</name> 4 4 <comment></comment> 5 5 <projects> -
branches/supervisor/src/main/java/omq/common/broker/HasObject.java
r91 r100 12 12 private String reference; 13 13 private boolean hasObject; 14 private int numThreads; 14 15 15 public HasObject(String brokerName, String reference, boolean hasObject ) {16 public HasObject(String brokerName, String reference, boolean hasObject, int numThreads) { 16 17 this.brokerName = brokerName; 17 18 this.reference = reference; 18 19 this.hasObject = hasObject; 20 this.numThreads = numThreads; 19 21 } 20 22 … … 43 45 } 44 46 47 public int getNumThreads() { 48 return numThreads; 49 } 50 51 public void setNumThreads(int numThreads) { 52 this.numThreads = numThreads; 53 } 54 45 55 } -
branches/supervisor/src/main/java/omq/server/InvocationThread.java
r96 r100 37 37 private String UID; 38 38 private Properties env; 39 private boolean idle; 40 private long lastExec; 41 42 private RemoteThreadPool pool; // TODO posar això bé 39 43 40 44 // Broker … … 54 58 this.broker = broker; 55 59 this.serializer = broker.getSerializer(); 60 this.lastExec = 0; 61 this.idle = true; 56 62 } 57 63 … … 73 79 // Get the delivery 74 80 Delivery delivery = consumer.nextDelivery(); 81 82 // This thread gets busy 83 pool.getBusy().incrementAndGet(); 84 idle = false; 75 85 76 86 String serializerType = delivery.getProperties().getType(); … … 112 122 113 123 channel.basicAck(delivery.getEnvelope().getDeliveryTag(), false); 124 125 // The thread is now idle 126 lastExec = System.currentTimeMillis(); 127 idle = true; 128 pool.getBusy().decrementAndGet(); 129 114 130 } catch (InterruptedException i) { 115 131 logger.error(i); … … 231 247 } 232 248 249 public long getLastExecution() { 250 return lastExec; 251 } 252 253 public boolean isIdle() { 254 return idle; 255 } 256 233 257 } -
branches/supervisor/src/main/java/omq/server/RemoteObject.java
r96 r100 33 33 private Properties env; 34 34 private transient Broker broker; 35 private transient RemoteThreadPool pool; 35 36 private transient Map<String, List<Class<?>>> params; 36 37 private transient List<InvocationThread> invocationList; -
branches/supervisor/src/main/java/omq/supervisor/SupervisorThread.java
r94 r100 4 4 import java.util.Set; 5 5 6 import org.apache.log4j.Logger; 7 6 8 import com.rabbitmq.client.AMQP.Queue.DeclareOk; 7 9 import com.rabbitmq.client.Channel; 8 10 9 11 public class SupervisorThread extends Thread { 12 private static final Logger logger = Logger.getLogger(SupervisorThread.class.getName()); 10 13 11 14 private long sleep; … … 46 49 int minMessages = settings.getMinNumQueued(); 47 50 48 // TODO treure merda...51 49 52 Channel channel = supervisor.getBroker().getChannel(); 50 53 DeclareOk dok = channel.queueDeclarePassive(reference); … … 55 58 System.out.println("Num Consumers: " + numConsumers + ", num Messages: " + numMessages); 56 59 57 if (maxMessages < numMessages || numConsumers < minObjects 58 System.out.println("SPAWN TIME!!");60 if (maxMessages < numMessages || numConsumers < minObjects) { 61 logger.info("SPAWN TIME!!"); 59 62 supervisor.spawnObject(settings); 60 // spawn:61 // pregunta a tots i qui no t�� l'objecte li poses62 63 } else if (numMessages < minMessages && minObjects < numConsumers) { 63 System.out.println("Unbinding object!!!");64 logger.info("Unbinding object!!!"); 64 65 supervisor.unbindObject(settings); 65 // delete:66 // pregunta a tots i qui t�� l'objecte li treus67 66 } 68 67 }
Note: See TracChangeset
for help on using the changeset viewer.