Changeset 93 for branches/supervisor/src/main
- Timestamp:
- 10/01/13 15:34:32 (12 years ago)
- Location:
- branches/supervisor/src/main/java/omq/supervisor
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/supervisor/src/main/java/omq/supervisor/Supervisor.java
r92 r93 9 9 public void spawnObject(OmqSettings settings) throws Exception; 10 10 11 public void unbindObject(OmqSettings settings) throws Exception; 12 11 13 } -
branches/supervisor/src/main/java/omq/supervisor/SupervisorImpl.java
r92 r93 44 44 45 45 String reference = settings.getReference(); 46 objectSettings.put(reference, settings); 46 47 if (!objectSettings.containsKey(reference)) { 48 objectSettings.put(reference, settings); 49 } 47 50 48 51 int minObjects = settings.getMinNumberObjects(); … … 69 72 } 70 73 74 } 75 76 @Override 77 public void unbindObject(OmqSettings settings) throws Exception { 78 String reference = settings.getReference(); 79 80 int minObjects = settings.getMinNumberObjects(); 81 82 Channel channel = getBroker().getNewChannel(); 83 84 int numObjects = 0; 85 try { 86 DeclareOk dok = channel.queueDeclarePassive(reference); 87 numObjects = dok.getConsumerCount(); 88 channel.close(); 89 90 for (RemoteBroker broker : brokers) { 91 if (broker.hasObject(reference) && (numObjects - 1) >= minObjects) { 92 broker.deleteObject(reference); 93 } 94 } 95 96 } catch (Exception io) { 97 // The queue doesn't exist & the channel has been closed 98 } 99 100 for (RemoteBroker broker : brokers) { 101 if (!broker.hasObject(reference) && minObjects >= numObjects) { 102 broker.spawnObject(reference, settings.getClassName(), settings.getProps()); 103 numObjects++; 104 if (minObjects >= numObjects) { 105 break; 106 } 107 } 108 } 71 109 } 72 110 -
branches/supervisor/src/main/java/omq/supervisor/SupervisorThread.java
r92 r93 61 61 // pregunta a tots i qui no té l'objecte li poses 62 62 } else if (numMessages < minMessages && minObjects > numConsumers) { 63 supervisor.unbindObject(settings); 63 64 // delete: 64 65 // pregunta a tots i qui té l'objecte li treus
Note: See TracChangeset
for help on using the changeset viewer.