2 |
2 |
** Module : BrokerManager.java
|
3 |
3 |
** Abstract : server side broker manager implementation.
|
4 |
4 |
**
|
5 |
|
** Copyright (c) 2014-2017, Golden Code Development Corporation.
|
|
5 |
** Copyright (c) 2014-2020, Golden Code Development Corporation.
|
6 |
6 |
|
7 |
7 |
**
|
8 |
8 |
** -#- -I- --Date-- ---------------------------------Description----------------------------------
|
... | ... | |
10 |
10 |
** 002 SBI 20171022 Added dedicated hosts map and changed broker client schedule method to launch
|
11 |
11 |
** remote clients on dedicated hosts, enumerated assigned hosts and added
|
12 |
12 |
** getOrderedNumber to get the host order number.
|
|
13 |
** 003 SBI 20200309 Initialize hosts map first before reading the broker configuration.
|
13 |
14 |
*/
|
14 |
15 |
/*
|
15 |
16 |
** This program is free software: you can redistribute it and/or modify
|
... | ... | |
130 |
131 |
{
|
131 |
132 |
synchronized (activeBrokers)
|
132 |
133 |
{
|
|
134 |
// read hosts file
|
|
135 |
Map<InetAddress, Integer> hostsFileMap;
|
|
136 |
try
|
|
137 |
{
|
|
138 |
hostsFileMap = ClientsToPortsGenerator.readHostsFile(HOSTS_FILE_PATH);
|
|
139 |
}
|
|
140 |
catch (IOException e)
|
|
141 |
{
|
|
142 |
hostsFileMap = new LinkedHashMap<InetAddress, Integer>();
|
|
143 |
try
|
|
144 |
{
|
|
145 |
hostsFileMap.put(InetAddress.getByName(null), 1);
|
|
146 |
}
|
|
147 |
catch (UnknownHostException e1)
|
|
148 |
{
|
|
149 |
}
|
|
150 |
}
|
|
151 |
|
|
152 |
int lastHostNumber = 0;
|
|
153 |
|
|
154 |
for(Entry<InetAddress, Integer> entry : hostsFileMap.entrySet())
|
|
155 |
{
|
|
156 |
hosts.put(entry.getKey(), entry.getValue());
|
|
157 |
if (lastHostNumber < entry.getValue())
|
|
158 |
{
|
|
159 |
lastHostNumber = entry.getValue();
|
|
160 |
}
|
|
161 |
}
|
|
162 |
|
|
163 |
nextRegisteredHost.set(lastHostNumber);
|
|
164 |
|
133 |
165 |
DirectoryService ds = DirectoryService.getInstance();
|
134 |
166 |
|
135 |
167 |
// find brokers path
|
... | ... | |
163 |
195 |
|
164 |
196 |
activeBrokers.put(broker, new Broker(accounts));
|
165 |
197 |
}
|
166 |
|
|
167 |
|
// read hosts file
|
168 |
|
Map<InetAddress, Integer> hostsFileMap;
|
169 |
|
try
|
170 |
|
{
|
171 |
|
hostsFileMap = ClientsToPortsGenerator.readHostsFile(HOSTS_FILE_PATH);
|
172 |
|
}
|
173 |
|
catch (IOException e)
|
174 |
|
{
|
175 |
|
hostsFileMap = new LinkedHashMap<InetAddress, Integer>();
|
176 |
|
try
|
177 |
|
{
|
178 |
|
hostsFileMap.put(InetAddress.getByName(null), 1);
|
179 |
|
}
|
180 |
|
catch (UnknownHostException e1)
|
181 |
|
{
|
182 |
|
}
|
183 |
|
}
|
184 |
|
|
185 |
|
int lastHostNumber = 0;
|
186 |
|
|
187 |
|
for(Entry<InetAddress, Integer> entry : hostsFileMap.entrySet())
|
188 |
|
{
|
189 |
|
hosts.put(entry.getKey(), entry.getValue());
|
190 |
|
if (lastHostNumber < entry.getValue())
|
191 |
|
{
|
192 |
|
lastHostNumber = entry.getValue();
|
193 |
|
}
|
194 |
|
}
|
195 |
|
|
196 |
|
nextRegisteredHost.set(lastHostNumber);
|
197 |
198 |
}
|
198 |
199 |
}
|
199 |
200 |
|