| 1 |
package org.apache.commons.jcs3.utils.discovery; |
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
import java.io.Serializable; |
| 23 |
import java.util.ArrayList; |
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
public class UDPDiscoveryMessage |
| 29 |
implements Serializable |
| 30 |
{ |
| 31 |
|
| 32 |
private static final long serialVersionUID = -5332377899560951793L; |
| 33 |
|
| 34 |
public enum BroadcastType |
| 35 |
{ |
| 36 |
|
| 37 |
|
| 38 |
|
| 39 |
|
| 40 |
PASSIVE, |
| 41 |
|
| 42 |
|
| 43 |
|
| 44 |
|
| 45 |
REQUEST, |
| 46 |
|
| 47 |
|
| 48 |
|
| 49 |
|
| 50 |
REMOVE |
| 51 |
} |
| 52 |
|
| 53 |
|
| 54 |
private BroadcastType messageType = BroadcastType.PASSIVE; |
| 55 |
|
| 56 |
|
| 57 |
private int port = 6789; |
| 58 |
|
| 59 |
|
| 60 |
private String host = "228.5.6.7"; |
| 61 |
|
| 62 |
|
| 63 |
private long requesterId; |
| 64 |
|
| 65 |
|
| 66 |
private ArrayList<String> cacheNames = new ArrayList<>(); |
| 67 |
|
| 68 |
|
| 69 |
|
| 70 |
|
| 71 |
public void setPort( final int port ) |
| 72 |
{ |
| 73 |
this.port = port; |
| 74 |
} |
| 75 |
|
| 76 |
|
| 77 |
|
| 78 |
|
| 79 |
public int getPort() |
| 80 |
{ |
| 81 |
return port; |
| 82 |
} |
| 83 |
|
| 84 |
|
| 85 |
|
| 86 |
|
| 87 |
public void setHost( final String host ) |
| 88 |
{ |
| 89 |
this.host = host; |
| 90 |
} |
| 91 |
|
| 92 |
|
| 93 |
|
| 94 |
|
| 95 |
public String getHost() |
| 96 |
{ |
| 97 |
return host; |
| 98 |
} |
| 99 |
|
| 100 |
|
| 101 |
|
| 102 |
|
| 103 |
public void setRequesterId( final long requesterId ) |
| 104 |
{ |
| 105 |
this.requesterId = requesterId; |
| 106 |
} |
| 107 |
|
| 108 |
|
| 109 |
|
| 110 |
|
| 111 |
public long getRequesterId() |
| 112 |
{ |
| 113 |
return requesterId; |
| 114 |
} |
| 115 |
|
| 116 |
|
| 117 |
|
| 118 |
|
| 119 |
public void setMessageType( final BroadcastType messageType ) |
| 120 |
{ |
| 121 |
this.messageType = messageType; |
| 122 |
} |
| 123 |
|
| 124 |
|
| 125 |
|
| 126 |
|
| 127 |
public BroadcastType getMessageType() |
| 128 |
{ |
| 129 |
return messageType; |
| 130 |
} |
| 131 |
|
| 132 |
|
| 133 |
|
| 134 |
|
| 135 |
public void setCacheNames( final ArrayList<String> cacheNames ) |
| 136 |
{ |
| 137 |
this.cacheNames = cacheNames; |
| 138 |
} |
| 139 |
|
| 140 |
|
| 141 |
|
| 142 |
|
| 143 |
public ArrayList<String> getCacheNames() |
| 144 |
{ |
| 145 |
return cacheNames; |
| 146 |
} |
| 147 |
|
| 148 |
|
| 149 |
|
| 150 |
|
| 151 |
@Override |
| 152 |
public String toString() |
| 153 |
{ |
| 154 |
final StringBuilder buf = new StringBuilder(); |
| 155 |
buf.append( "\n host = [" + host + "]" ); |
| 156 |
buf.append( "\n port = [" + port + "]" ); |
| 157 |
buf.append( "\n requesterId = [" + requesterId + "]" ); |
| 158 |
buf.append( "\n messageType = [" + messageType + "]" ); |
| 159 |
buf.append( "\n Cache Names" ); |
| 160 |
for (final String name : cacheNames) |
| 161 |
{ |
| 162 |
buf.append( " cacheName = [" + name + "]" ); |
| 163 |
} |
| 164 |
return buf.toString(); |
| 165 |
} |
| 166 |
} |