View Javadoc
1   /*
2    * Licensed to The Apereo Foundation under one or more contributor license
3    * agreements. See the NOTICE file distributed with this work for additional
4    * information regarding copyright ownership.
5    *
6    *
7    * The Apereo Foundation licenses this file to you under the Educational
8    * Community License, Version 2.0 (the "License"); you may not use this file
9    * except in compliance with the License. You may obtain a copy of the License
10   * at:
11   *
12   *   http://opensource.org/licenses/ecl2.txt
13   *
14   * Unless required by applicable law or agreed to in writing, software
15   * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
16   * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
17   * License for the specific language governing permissions and limitations under
18   * the License.
19   *
20   */
21  
22  package org.opencastproject.serviceregistry.api;
23  
24  public class HostRegistrationInMemory implements HostRegistration {
25  
26    private String baseUrl;
27  
28    private float maxLoad;
29  
30    private int cores;
31  
32    private long memory;
33  
34    private boolean online;
35  
36    private boolean active;
37  
38    private boolean maintenanceMode;
39  
40    private String address;
41  
42    private String nodeName;
43  
44    public HostRegistrationInMemory(String baseUrl, String address, String nodeName, float maxLoad, int cores,
45        long memory) {
46      this.baseUrl = baseUrl;
47      this.address = address;
48      this.nodeName = nodeName;
49      this.maxLoad = maxLoad;
50      this.online = true;
51      this.active = true;
52      this.maintenanceMode = false;
53      this.cores = cores;
54      this.memory = memory;
55    }
56  
57    @Override
58    public Long getId() {
59      return (long) baseUrl.hashCode();
60    }
61  
62    @Override
63    public String getBaseUrl() {
64      return baseUrl;
65    }
66  
67    @Override
68    public void setBaseUrl(String baseUrl) {
69      this.baseUrl = baseUrl;
70    }
71  
72    @Override
73    public float getMaxLoad() {
74      return maxLoad;
75    }
76  
77    @Override
78    public void setMaxLoad(float maxLoad) {
79      this.maxLoad = maxLoad;
80    }
81  
82    @Override
83    public boolean isActive() {
84      return active;
85    }
86  
87    @Override
88    public void setActive(boolean active) {
89      this.active = active;
90    }
91  
92    @Override
93    public boolean isOnline() {
94      return online;
95    }
96  
97    @Override
98    public void setOnline(boolean online) {
99      this.online = online;
100   }
101 
102   @Override
103   public boolean isMaintenanceMode() {
104     return maintenanceMode;
105   }
106 
107   @Override
108   public void setMaintenanceMode(boolean maintenanceMode) {
109     this.maintenanceMode = maintenanceMode;
110   }
111 
112   @Override
113   public String getIpAddress() {
114     return address;
115   }
116 
117   @Override
118   public void setIpAddress(String address) {
119     this.address = address;
120   }
121 
122   @Override
123   public long getMemory() {
124     return memory;
125   }
126 
127   @Override
128   public void setMemory(long memory) {
129     this.memory = memory;
130   }
131 
132   @Override
133   public int getCores() {
134     return cores;
135   }
136 
137   @Override
138   public void setCores(int cores) {
139     this.cores = cores;
140   }
141 
142   @Override
143   public String getNodeName() {
144     return nodeName;
145   }
146 
147   @Override
148   public void setNodeName(String nodeName) {
149     this.nodeName = nodeName;
150   }
151 }