Ignore:
Timestamp:
10/09/13 17:35:41 (11 years ago)
Author:
stoda
Message:

Idea of thread supervisor done

TODO test the idea, change the remote properties, etc

Location:
branches/supervisor/src/main/java/omq/server
Files:
1 added
2 edited

Legend:

Unmodified
Added
Removed
  • branches/supervisor/src/main/java/omq/server/InvocationThread.java

    r96 r100  
    3737        private String UID;
    3838        private Properties env;
     39        private boolean idle;
     40        private long lastExec;
     41
     42        private RemoteThreadPool pool; // TODO posar això bé
    3943
    4044        // Broker
     
    5458                this.broker = broker;
    5559                this.serializer = broker.getSerializer();
     60                this.lastExec = 0;
     61                this.idle = true;
    5662        }
    5763
     
    7379                                // Get the delivery
    7480                                Delivery delivery = consumer.nextDelivery();
     81
     82                                // This thread gets busy
     83                                pool.getBusy().incrementAndGet();
     84                                idle = false;
    7585
    7686                                String serializerType = delivery.getProperties().getType();
     
    112122
    113123                                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
    114130                        } catch (InterruptedException i) {
    115131                                logger.error(i);
     
    231247        }
    232248
     249        public long getLastExecution() {
     250                return lastExec;
     251        }
     252
     253        public boolean isIdle() {
     254                return idle;
     255        }
     256
    233257}
  • branches/supervisor/src/main/java/omq/server/RemoteObject.java

    r96 r100  
    3333        private Properties env;
    3434        private transient Broker broker;
     35        private transient RemoteThreadPool pool;
    3536        private transient Map<String, List<Class<?>>> params;
    3637        private transient List<InvocationThread> invocationList;
Note: See TracChangeset for help on using the changeset viewer.