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="Container specific Channel factory class name")
076            public String getChannelFactoryName();
077            
078            @MBeanAttribute(description="Maximum number of channels that may be queued in the Gravity pool")
079        public int getQueueCapacity();
080        
081            @MBeanAttribute(description=
082                    "Number of channels that the Gravity pool queue can ideally (in the absence of " +
083                    "memory or resource constraints) accept without blocking")
084        public int getQueueRemainingCapacity();
085        
086            @MBeanAttribute(description="Number of channels in the Gravity pool queue waiting for execution")
087        public int getQueueSize();
088    
089            @MBeanAttribute(description="Number of threads to keep in the Gravity pool, even if they are idle")
090        public int getCorePoolSize();
091            public void setCorePoolSize(
092                    @MBeanParameter(name="corePoolSize", description="New core pool size")
093                    int corePoolSize
094            );
095    
096            @MBeanAttribute(description="Maximum number of threads to allow in the Gravity pool")
097            public int getMaximumPoolSize();
098            public void setMaximumPoolSize(
099                    @MBeanParameter(name="maximumPoolSize", description="New maximum pool size")
100                    int maximumPoolSize
101            );
102    
103        @MBeanAttribute(description=
104            "When the number of threads is greater than the core, this is the maximum " +
105            "time that excess idle threads will wait for new tasks before terminating")
106            public long getKeepAliveTimeMillis();
107        public void setKeepAliveTimeMillis(
108            @MBeanParameter(name="keepAliveTimeMillis", description="New keep alive time in milliseconds")
109            long keepAliveTimeMillis
110        );
111    
112            @MBeanAttribute(description="Tell if this Gravity has been succefully started")
113        public boolean isStarted();
114    
115            ///////////////////////////////////////////////////////////////////////////
116            // Operations.
117        
118            @MBeanOperation(description="Start Gravity", impact=Impact.ACTION)
119        public void start() throws Exception;
120        
121            @MBeanOperation(description="Restart Gravity", impact=Impact.ACTION)
122        public void restart() throws Exception;
123        
124            @MBeanOperation(
125                    description="Attempts to stop all actively executing channels and halts the processing of waiting channels",
126                    impact=Impact.ACTION
127            )
128        public void stop() throws Exception;
129    }