ManagedConnection.java
001 /*
002  *
003  * Licensed to the Apache Software Foundation (ASF) under one
004  * or more contributor license agreements.  See the NOTICE file
005  * distributed with this work for additional information
006  * regarding copyright ownership.  The ASF licenses this file
007  * to you under the Apache License, Version 2.0 (the
008  * "License"); you may not use this file except in compliance
009  * with the License.  You may obtain a copy of the License at
010  
011  *   http://www.apache.org/licenses/LICENSE-2.0
012  
013  * Unless required by applicable law or agreed to in writing,
014  * software distributed under the License is distributed on an
015  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
016  * KIND, either express or implied.  See the License for the
017  * specific language governing permissions and limitations
018  * under the License.
019  *
020  */
021 
022 package org.apache.qpid.server.protocol;
023 
024 import java.io.IOException;
025 import java.util.Date;
026 import java.security.Principal;
027 
028 import javax.management.JMException;
029 import javax.management.MBeanOperationInfo;
030 import javax.management.openmbean.TabularData;
031 
032 import org.apache.qpid.server.management.MBeanAttribute;
033 import org.apache.qpid.server.management.MBeanOperation;
034 import org.apache.qpid.server.management.MBeanOperationParameter;
035 
036 /**
037  * The management interface exposed to allow management of Connections.
038  @author   Bhupendra Bhardwaj
039  @version  0.1
040  */
041 public interface ManagedConnection
042 {
043     static final String TYPE = "Connection";
044 
045     @MBeanAttribute(name = "ClientId", description = "Client Id")
046     String getClientId();
047 
048     @MBeanAttribute(name = "AuthorizedId", description = "User Name")
049     String getAuthorizedId();
050 
051     @MBeanAttribute(name = "Version", description = "Client Version")
052     String getVersion();
053 
054     /**
055      * Tells the remote address of this connection.
056      @return  remote address
057      */
058     @MBeanAttribute(name="RemoteAddress", description=TYPE + " Address")
059     String getRemoteAddress();
060 
061     /**
062      * Tells the last time, the IO operation was done.
063      @return last IO time.
064      */
065     @MBeanAttribute(name="LastIOTime", description="The last time, the IO operation was done")
066     Date getLastIoTime();
067 
068     /**
069      * Tells the total number of bytes written till now.
070      @return number of bytes written.
071      *
072     @MBeanAttribute(name="WrittenBytes", description="The total number of bytes written till now")
073     Long getWrittenBytes();
074     */
075     /**
076      * Tells the total number of bytes read till now.
077      @return number of bytes read.
078      *
079     @MBeanAttribute(name="ReadBytes", description="The total number of bytes read till now")
080     Long getReadBytes();
081     */
082 
083     /**
084      * Threshold high value for no of channels.  This is useful in setting notifications or
085      * taking required action is there are more channels being created.
086      @return threshold limit for no of channels
087      */
088     Long getMaximumNumberOfChannels();
089 
090     /**
091      * Sets the threshold high value for number of channels for a connection
092      @param value
093      */
094     @MBeanAttribute(name="MaximumNumberOfChannels", description="The threshold high value for number of channels for this connection")
095     void setMaximumNumberOfChannels(Long value);
096 
097     //********** Operations *****************//
098 
099     /**
100      * channel details of all the channels opened for this connection.
101      @return general channel details
102      @throws IOException
103      @throws JMException
104      */
105     @MBeanOperation(name="channels", description="Channel details for this connection")
106     TabularData channels() throws IOException, JMException;
107 
108     /**
109      * Commits the transactions if the channel is transactional.
110      @param channelId
111      @throws JMException
112      */
113     @MBeanOperation(name="commitTransaction",
114                     description="Commits the transactions for given channel Id, if the channel is transactional",
115                     impact= MBeanOperationInfo.ACTION)
116     void commitTransactions(@MBeanOperationParameter(name="channel Id", description="channel Id")int channelIdthrows JMException;
117 
118     /**
119      * Rollsback the transactions if the channel is transactional.
120      @param channelId
121      @throws JMException
122      */
123     @MBeanOperation(name="rollbackTransactions",
124                     description="Rollsback the transactions for given channel Id, if the channel is transactional",
125                     impact= MBeanOperationInfo.ACTION)
126     void rollbackTransactions(@MBeanOperationParameter(name="channel Id", description="channel Id")int channelIdthrows JMException;
127 
128     /**
129      * Closes all the related channels and unregisters this connection from managed objects.
130      */
131     @MBeanOperation(name="closeConnection",
132                     description="Closes this connection and all related channels",
133                     impact= MBeanOperationInfo.ACTION)
134     void closeConnection() throws Exception;
135 }