001    /*
002      GRANITE DATA SERVICES
003      Copyright (C) 2011 GRANITE DATA SERVICES S.A.S.
004    
005      This file is part of Granite Data Services.
006    
007      Granite Data Services is free software; you can redistribute it and/or modify
008      it under the terms of the GNU Library General Public License as published by
009      the Free Software Foundation; either version 2 of the License, or (at your
010      option) any later version.
011    
012      Granite Data Services is distributed in the hope that it will be useful, but
013      WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
014      FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License
015      for more details.
016    
017      You should have received a copy of the GNU Library General Public License
018      along with this library; if not, see <http://www.gnu.org/licenses/>.
019    */
020    
021    package org.granite.gravity;
022    
023    import org.granite.jmx.MBean;
024    import org.granite.jmx.MBeanAttribute;
025    import org.granite.jmx.MBeanOperation;
026    import org.granite.jmx.MBeanParameter;
027    import org.granite.jmx.MBeanOperation.Impact;
028    
029    /**
030     * @author Franck WOLFF
031     */
032    @MBean(description="MBean used for Gravity operations")
033    public interface DefaultGravityMBean {
034    
035            ///////////////////////////////////////////////////////////////////////////
036            // Attributes.
037            
038        @MBeanAttribute(description="Factory class name used for intantiating Gravity")
039            public String getGravityFactoryName();
040    
041        @MBeanAttribute(description="Amount of time after which an idle channel may be removed")
042            public long getChannelIdleTimeoutMillis();
043            public void setChannelIdleTimeoutMillis(
044                    @MBeanParameter(name="channelIdleTimeoutMillis", description="New channel's idle timeout")
045                    long channelIdleTimeoutMillis
046            );
047    
048        @MBeanAttribute(description="Long polling timeout in milliseconds (may not work with all containers)")
049            public long getLongPollingTimeoutMillis();
050            public void setLongPollingTimeoutMillis(
051                    @MBeanParameter(name="longPollingTimeoutMillis", description="New long polling timeout")
052                    long longPollingTimeoutMillis
053            );
054    
055        @MBeanAttribute(description="Should unsent messages be kept in the queue on IOExceptions?")
056            public boolean isRetryOnError();
057            public void setRetryOnError(
058                    @MBeanParameter(name="retryOnError", description="New retry on error value")
059                    boolean retryOnError
060            );
061    
062        @MBeanAttribute(description="Channel's queue maximum size")
063            public int getMaxMessagesQueuedPerChannel();
064            public void setMaxMessagesQueuedPerChannel(
065                    @MBeanParameter(name="maxMessagesQueuedPerChannel", description="New maximum messages queued value")
066                    int maxMessagesQueuedPerChannel
067            );
068    
069        @MBeanAttribute(description="Client advice for reconnection interval")
070            public long getReconnectIntervalMillis();
071    
072        @MBeanAttribute(description="Client advice for reconnection max attempts")
073            public int getReconnectMaxAttempts();
074            
075            @MBeanAttribute(description="Maximum number of channels that may be queued in the Gravity pool")
076        public int getQueueCapacity();
077        
078            @MBeanAttribute(description=
079                    "Number of channels that the Gravity pool queue can ideally (in the absence of " +
080                    "memory or resource constraints) accept without blocking")
081        public int getQueueRemainingCapacity();
082        
083            @MBeanAttribute(description="Number of channels in the Gravity pool queue waiting for execution")
084        public int getQueueSize();
085    
086            @MBeanAttribute(description="Number of threads to keep in the Gravity pool, even if they are idle")
087        public int getCorePoolSize();
088            public void setCorePoolSize(
089                    @MBeanParameter(name="corePoolSize", description="New core pool size")
090                    int corePoolSize
091            );
092    
093            @MBeanAttribute(description="Maximum number of threads to allow in the Gravity pool")
094            public int getMaximumPoolSize();
095            public void setMaximumPoolSize(
096                    @MBeanParameter(name="maximumPoolSize", description="New maximum pool size")
097                    int maximumPoolSize
098            );
099    
100        @MBeanAttribute(description=
101            "When the number of threads is greater than the core, this is the maximum " +
102            "time that excess idle threads will wait for new tasks before terminating")
103            public long getKeepAliveTimeMillis();
104        public void setKeepAliveTimeMillis(
105            @MBeanParameter(name="keepAliveTimeMillis", description="New keep alive time in milliseconds")
106            long keepAliveTimeMillis
107        );
108    
109            @MBeanAttribute(description="Tell if this Gravity has been succefully started")
110        public boolean isStarted();
111    
112            ///////////////////////////////////////////////////////////////////////////
113            // Operations.
114        
115            @MBeanOperation(description="Start Gravity", impact=Impact.ACTION)
116        public void start() throws Exception;
117        
118            @MBeanOperation(description="Restart Gravity", impact=Impact.ACTION)
119        public void restart() throws Exception;
120        
121            @MBeanOperation(
122                    description="Attempts to stop all actively executing channels and halts the processing of waiting channels",
123                    impact=Impact.ACTION
124            )
125        public void stop() throws Exception;
126    }