001: /*
002: * Copyright (c) 1998-2008 Caucho Technology -- all rights reserved
003: *
004: * This file is part of Resin(R) Open Source
005: *
006: * Each copy or derived work must preserve the copyright notice and this
007: * notice unmodified.
008: *
009: * Resin Open Source is free software; you can redistribute it and/or modify
010: * it under the terms of the GNU General Public License as published by
011: * the Free Software Foundation; either version 2 of the License, or
012: * (at your option) any later version.
013: *
014: * Resin Open Source is distributed in the hope that it will be useful,
015: * but WITHOUT ANY WARRANTY; without even the implied warranty of
016: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, or any warranty
017: * of NON-INFRINGEMENT. See the GNU General Public License for more
018: * details.
019: *
020: * You should have received a copy of the GNU General Public License
021: * along with Resin Open Source; if not, write to the
022: *
023: * Free Software Foundation, Inc.
024: * 59 Temple Place, Suite 330
025: * Boston, MA 02111-1307 USA
026: *
027: * @author Scott Ferguson
028: */
029:
030: package com.caucho.server.cluster;
031:
032: import java.util.*;
033: import java.util.logging.*;
034: import com.caucho.util.*;
035:
036: /**
037: * Represents a machine in a cluster. Contains multiple servers.
038: */
039: public class Machine {
040: private static final Logger log = Logger.getLogger(Machine.class
041: .getName());
042: private static final L10N L = new L10N(Machine.class);
043:
044: private Cluster _cluster;
045: private String _id = "";
046: private int _index;
047:
048: private ArrayList<ClusterServer> _serverList = new ArrayList<ClusterServer>();
049:
050: public Machine(Cluster cluster) {
051: _cluster = cluster;
052: _index = cluster.getMachineList().size();
053: }
054:
055: /**
056: * Gets the server identifier.
057: */
058: public String getId() {
059: return _id;
060: }
061:
062: /**
063: * Sets the server identifier.
064: */
065: public void setId(String id) {
066: _id = id;
067: }
068:
069: /**
070: * Returns the machine index.
071: */
072: public int getIndex() {
073: return _index;
074: }
075:
076: /**
077: * Sets the machine index.
078: */
079: void setIndex(int index) {
080: _index = index;
081: }
082:
083: /**
084: * Returns the cluster.
085: */
086: public Cluster getCluster() {
087: return _cluster;
088: }
089:
090: /**
091: * Creates a new ClusterServer.
092: */
093: public ClusterServer createServer() {
094: ClusterServer server = new ClusterServer(this );
095:
096: _serverList.add(server);
097:
098: return _cluster.createServer(server);
099: }
100:
101: /**
102: * Creates a new ClusterServer.
103: */
104: public void addServer(ClusterServer server) {
105: _cluster.addServer(server);
106: }
107:
108: /**
109: * Returns the list of servers.
110: */
111: public ArrayList<ClusterServer> getServerList() {
112: return _serverList;
113: }
114:
115: public String toString() {
116: return ("Machine[id=" + getId() + "]");
117: }
118: }
|