com.hazelcast.core.IdGenerator Java Examples
The following examples show how to use
com.hazelcast.core.IdGenerator.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: Clients.java From lannister with Apache License 2.0 | 5 votes |
@Override public String service() { IdGenerator idgen = ClusterDataFactory.INSTANCE.createIdGenerator("CLIENT_ID_GENERATOR"); String clientId = null; while (clientId == null) { clientId = String.format("laniClientId%011d", idgen.newId()); if (Session.NEXUS.get(clientId) != null) { clientId = null; } } return String.format("{\"id\":\"%s\"}", clientId); }
Example #2
Source File: ClusterDataFactory.java From lannister with Apache License 2.0 | 5 votes |
public IdGenerator createIdGenerator(String name) { switch (Settings.INSTANCE.clusteringMode()) { case HAZELCAST: return Hazelcast.INSTANCE.getIdGenerator(name); case IGNITE: case SINGLE: return new SingleIdGenerator(name); default: return null; } }
Example #3
Source File: ServerNode.java From tutorials with MIT License | 5 votes |
public static void main(String[] args) { HazelcastInstance hazelcastInstance = Hazelcast.newHazelcastInstance(); Map<Long, String> map = hazelcastInstance.getMap("data"); IdGenerator idGenerator = hazelcastInstance.getIdGenerator("newid"); for (int i = 0; i < 10; i++) { map.put(idGenerator.newId(), "message" + 1); } }
Example #4
Source File: WebConfigurerTest.java From flair-engine with Apache License 2.0 | 4 votes |
@Override public IdGenerator getIdGenerator(String s) { return null; }
Example #5
Source File: Hazelcast.java From lannister with Apache License 2.0 | 4 votes |
protected IdGenerator getIdGenerator(String name) { return substance.getIdGenerator(name); }