KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > caucho > server > cluster > ClusterPort


1 /*
2  * Copyright (c) 1998-2006 Caucho Technology -- all rights reserved
3  *
4  * This file is part of Resin(R) Open Source
5  *
6  * Each copy or derived work must preserve the copyright notice and this
7  * notice unmodified.
8  *
9  * Resin Open Source is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation; either version 2 of the License, or
12  * (at your option) any later version.
13  *
14  * Resin Open Source is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, or any warranty
17  * of NON-INFRINGEMENT. See the GNU General Public License for more
18  * details.
19  *
20  * You should have received a copy of the GNU General Public License
21  * along with Resin Open Source; if not, write to the
22  *
23  * Free Software Foundation, Inc.
24  * 59 Temple Place, Suite 330
25  * Boston, MA 02111-1307 USA
26  *
27  * @author Scott Ferguson
28  */

29
30 package com.caucho.server.cluster;
31
32 import com.caucho.server.hmux.HmuxProtocol;
33 import com.caucho.server.port.Port;
34 import com.caucho.util.L10N;
35
36 import javax.annotation.PostConstruct;
37
38 /**
39  * Represents a protocol connection.
40  */

41 public class ClusterPort extends Port {
42   private static final L10N L = new L10N(ClusterPort.class);
43
44   private ClusterServer _server;
45   
46   private int _clientWeight = 100;
47
48   public ClusterPort(ClusterServer server)
49   {
50     _server = server;
51     
52     try {
53       setAddress("127.0.0.1");
54       setPort(6800);
55       
56       setProtocol(new HmuxProtocol());
57     } catch (Exception JavaDoc e) {
58       throw new RuntimeException JavaDoc(e);
59     }
60   }
61
62   /**
63    * Returns the cluster server.
64    */

65   public ClusterServer getClusterServer()
66   {
67     return _server;
68   }
69
70   /**
71    * Returns the session index for the srun.
72    */

73   public int getIndex()
74   {
75     return _server.getIndex();
76   }
77
78   /**
79    * Set the client weight.
80    */

81   public void setClientWeight(int weight)
82   {
83     _clientWeight = weight;
84   }
85
86   /**
87    * Return the client weight.
88    */

89   public int getClientWeight()
90   {
91     return _clientWeight;
92   }
93
94   @PostConstruct
95   public void init()
96   {
97   }
98
99   public String JavaDoc toString()
100   {
101     if (getAddress() != null)
102       return "ClusterPort[address=" + getAddress() + ",port=" + getPort() + "]";
103     else
104       return "ClusterPort[address=*,port=" + getPort() + "]";
105   }
106 }
107
Popular Tags