Skip to content

Commit

Permalink
use unique hazelcast name
Browse files Browse the repository at this point in the history
  • Loading branch information
teosarca committed Sep 28, 2017
1 parent d8a49c6 commit fb3d488
Showing 1 changed file with 19 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
package de.metas.ui.web.config;

import java.util.UUID;

import org.adempiere.util.net.IHostIdentifier;
import org.adempiere.util.net.NetUtils;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Profile;
Expand All @@ -25,11 +29,11 @@
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this program. If not, see
* License along with this program. If not, see
* <http://www.gnu.org/licenses/gpl-2.0.html>.
* #L%
*/
Expand All @@ -48,6 +52,19 @@ public HazelcastHttpSessionConfig()
public HazelcastInstance embeddedHazelcast()
{
final Config hazelcastConfig = new Config();
hazelcastConfig.getGroupConfig().setName(generateGroupName());
return Hazelcast.newHazelcastInstance(hazelcastConfig);
}

private static final String generateGroupName()
{
final IHostIdentifier localhost = NetUtils.getLocalHost();
String hostname = localhost.getHostName();
if (hostname == null)
{
hostname = localhost.getIP();
}

return hostname + "-webapi-" + UUID.randomUUID();
}
}

0 comments on commit fb3d488

Please sign in to comment.