001/* 002 * Copyright 2009 Red Hat, Inc. 003 * Red Hat licenses this file to you under the Apache License, version 004 * 2.0 (the "License"); you may not use this file except in compliance 005 * with the License. You may obtain a copy of the License at 006 * http://www.apache.org/licenses/LICENSE-2.0 007 * Unless required by applicable law or agreed to in writing, software 008 * distributed under the License is distributed on an "AS IS" BASIS, 009 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 010 * implied. See the License for the specific language governing 011 * permissions and limitations under the License. 012 */ 013 014package org.hornetq.api.core; 015 016import java.io.Serializable; 017 018import org.hornetq.api.core.client.HornetQClient; 019import org.hornetq.core.logging.Logger; 020import org.hornetq.utils.UUIDGenerator; 021 022/** 023 * A DiscoveryGroupConfiguration 024 * 025 * @author <a href="mailto:tim.fox@jboss.com">Tim Fox</a> 026 * 027 * Created 18 Nov 2008 08:47:30 028 * 029 * 030 */ 031public class DiscoveryGroupConfiguration implements Serializable 032{ 033 private static final long serialVersionUID = 8657206421727863400L; 034 035 private static final Logger log = Logger.getLogger(DiscoveryGroupConfiguration.class); 036 037 038 private String name; 039 040 private String localBindAddress; 041 042 private String groupAddress; 043 044 private int groupPort; 045 046 private long refreshTimeout; 047 048 private long discoveryInitialWaitTimeout; 049 050 public DiscoveryGroupConfiguration(final String name, 051 final String localBindAddress, 052 final String groupAddress, 053 final int groupPort, 054 final long refreshTimeout, 055 final long discoveryInitialWaitTimeout) 056 { 057 this.name = name; 058 this.groupAddress = groupAddress; 059 this.localBindAddress = localBindAddress; 060 this.groupPort = groupPort; 061 this.refreshTimeout = refreshTimeout; 062 this.discoveryInitialWaitTimeout = discoveryInitialWaitTimeout; 063 } 064 065 public DiscoveryGroupConfiguration(final String groupAddress, 066 final int groupPort) 067 { 068 this(UUIDGenerator.getInstance().generateStringUUID(), null, groupAddress, groupPort, HornetQClient.DEFAULT_DISCOVERY_INITIAL_WAIT_TIMEOUT, HornetQClient.DEFAULT_DISCOVERY_INITIAL_WAIT_TIMEOUT); 069 } 070 071 public String getName() 072 { 073 return name; 074 } 075 076 public String getLocalBindAddress() 077 { 078 return localBindAddress; 079 } 080 081 public String getGroupAddress() 082 { 083 return groupAddress; 084 } 085 086 public int getGroupPort() 087 { 088 return groupPort; 089 } 090 091 public long getRefreshTimeout() 092 { 093 return refreshTimeout; 094 } 095 096 /** 097 * @param name the name to set 098 */ 099 public void setName(final String name) 100 { 101 this.name = name; 102 } 103 104 /** 105 * @param localBindAddress the localBindAddress to set 106 */ 107 public void setLocalBindAdress(final String localBindAddress) 108 { 109 this.localBindAddress = localBindAddress; 110 } 111 112 /** 113 * @param groupAddress the groupAddress to set 114 */ 115 public void setGroupAddress(final String groupAddress) 116 { 117 this.groupAddress = groupAddress; 118 } 119 120 /** 121 * @param groupPort the groupPort to set 122 */ 123 public void setGroupPort(final int groupPort) 124 { 125 this.groupPort = groupPort; 126 } 127 128 /** 129 * @param refreshTimeout the refreshTimeout to set 130 */ 131 public void setRefreshTimeout(final long refreshTimeout) 132 { 133 this.refreshTimeout = refreshTimeout; 134 } 135 136 /** 137 * @return the discoveryInitialWaitTimeout 138 */ 139 public long getDiscoveryInitialWaitTimeout() 140 { 141 return discoveryInitialWaitTimeout; 142 } 143 144 /** 145 * @param discoveryInitialWaitTimeout the discoveryInitialWaitTimeout to set 146 */ 147 public void setDiscoveryInitialWaitTimeout(long discoveryInitialWaitTimeout) 148 { 149 this.discoveryInitialWaitTimeout = discoveryInitialWaitTimeout; 150 } 151 152 @Override 153 public boolean equals(Object o) 154 { 155 if (this == o) return true; 156 if (o == null || getClass() != o.getClass()) return false; 157 158 DiscoveryGroupConfiguration that = (DiscoveryGroupConfiguration) o; 159 160 if (discoveryInitialWaitTimeout != that.discoveryInitialWaitTimeout) return false; 161 if (groupPort != that.groupPort) return false; 162 if (refreshTimeout != that.refreshTimeout) return false; 163 if (groupAddress != null ? !groupAddress.equals(that.groupAddress) : that.groupAddress != null) return false; 164 if (localBindAddress != null ? !localBindAddress.equals(that.localBindAddress) : that.localBindAddress != null) 165 return false; 166 if (name != null ? !name.equals(that.name) : that.name != null) return false; 167 168 return true; 169 } 170 171 @Override 172 public int hashCode() 173 { 174 int result = name != null ? name.hashCode() : 0; 175 result = 31 * result + (localBindAddress != null ? localBindAddress.hashCode() : 0); 176 result = 31 * result + (groupAddress != null ? groupAddress.hashCode() : 0); 177 result = 31 * result + groupPort; 178 result = 31 * result + (int) (refreshTimeout ^ (refreshTimeout >>> 32)); 179 result = 31 * result + (int) (discoveryInitialWaitTimeout ^ (discoveryInitialWaitTimeout >>> 32)); 180 return result; 181 } 182 183 /* (non-Javadoc) 184 * @see java.lang.Object#toString() 185 */ 186 @Override 187 public String toString() 188 { 189 return "DiscoveryGroupConfiguration [discoveryInitialWaitTimeout=" + discoveryInitialWaitTimeout + 190 ", groupAddress=" + 191 groupAddress + 192 ", groupPort=" + 193 groupPort + 194 ", localBindAddress=" + 195 localBindAddress + 196 ", name=" + 197 name + 198 ", refreshTimeout=" + 199 refreshTimeout + 200 "]"; 201 } 202 203 204}