Java 类com.hazelcast.core.IdGenerator 实例源码

项目:lannister    文件:Clients.java   
@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);
}
项目:lannister    文件:ClusterDataFactory.java   
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;
    }
}
项目:cms    文件:HazelcastDistributedLockManager.java   
@Override
public IdGenerator getIdGenerator(String value) {
    if (idGenerators.get(value) == null) {
        synchronized (this) {
            if (idGenerators.get(value) == null) {
                return this.hazelcastInstance.getIdGenerator(value);
            }
        }
    }
    return idGenerators.get(value);
}
项目:cms    文件:HazelcastDistributedCacheManager.java   
@Override
public IdGenerator getIdGenerator(String value) {
    if (idGenerators.get(value) == null) {
        synchronized (this) {
            if (idGenerators.get(value) == null) {
                return this.hazelcastInstance.getIdGenerator(value);
            }
        }
    }
    return idGenerators.get(value);
}
项目:cms    文件:HazelcastCacheService.java   
@Override
public String getUID(String region) {
    CRC32 CRC_32 = new CRC32();
    LOG.info("HazelcastCacheService->GET_UID");
    IdGenerator idGenerator = cm.getIdGenerator(region);
    final String uid = String.valueOf(idGenerator.newId()); //assures uniqueness during the life cycle of the cluster
    final String uuid = UUID.randomUUID().toString();
    String ret = new StringBuilder(uuid).append(region).append(uid).toString();
    CRC_32.reset();
    CRC_32.update(ret.getBytes());
    return Long.toHexString(CRC_32.getValue());
}
项目:ahome-tooling-server-hazelcast    文件:HazelcastContextInstance.java   
@Override
public IdGenerator getIdGenerator(String name)
{
    name = Objects.requireNonNull(name);

    final IdGenerator valu = getBeanSafely(name, IdGenerator.class);

    if (null != valu)
    {
        return valu;
    }
    return hz().getIdGenerator(name);
}
项目:predictblty    文件:MLAlgorithm.java   
public Long getDataId() {
    if (this.dataId == null) {
        IdGenerator idGen = hazelcastInstance.getIdGenerator("dataId");
        this.dataId = idGen.newId();
    }
    return this.dataId;
}
项目:predictblty    文件:MLMethod.java   
public Long getDataId() {
    if (this.dataId == null) {
        IdGenerator idGen = hazelcastInstance.getIdGenerator("dataId");
        this.dataId = idGen.newId();
    }
    return this.dataId;
}
项目:andes    文件:CoordinationConfigurableClusterAgent.java   
/**
 * {@inheritDoc}
 */
@Override
public void start(ClusterManager manager) throws AndesException{
    this.manager = manager;

    /**
     * register topic listeners for cluster events. This has to be done
     * after initializing Andes Stores and Manager classes
     */
    //TODO: review
    //HazelcastAgent.getInstance().addTopicListeners();

    Member localMember = hazelcastInstance.getCluster().getLocalMember();
    nodeIdMap.set(localMember.getSocketAddress().toString(), getLocalNodeIdentifier());

    checkForDuplicateNodeId(localMember);

    // Generate a unique id for this node for message id generation
    IdGenerator idGenerator = this.hazelcastInstance.getIdGenerator(
            CoordinationConstants.HAZELCAST_ID_GENERATOR_NAME);
    this.uniqueIdOfLocalMember = (int) idGenerator.newId();
    if (log.isDebugEnabled()) {
        log.debug("Unique ID generation for message ID generation:" + uniqueIdOfLocalMember);
    }

    String thriftCoordinatorServerIP = AndesContext.getInstance().getThriftServerHost();
    int thriftCoordinatorServerPort = AndesContext.getInstance().getThriftServerPort();
    InetSocketAddress thriftAddress = new InetSocketAddress(thriftCoordinatorServerIP, thriftCoordinatorServerPort);
    InetSocketAddress hazelcastAddress = hazelcastInstance.getCluster().getLocalMember().getSocketAddress();

    coordinationStrategy.start(this, getLocalNodeIdentifier(), thriftAddress,
            hazelcastAddress);

    networkPartitionDetector.start();
}
项目:xm-ms-entity    文件:WebConfigurerIntTest.java   
@Override
public IdGenerator getIdGenerator(String s) {
    return null;
}
项目:lannister    文件:Hazelcast.java   
protected IdGenerator getIdGenerator(String name) {
    return substance.getIdGenerator(name);
}
项目:bagri    文件:HzGeneratorImpl.java   
public HzGeneratorImpl(IdGenerator idGen) {
    this.idGen = idGen;
}
项目:Cherry    文件:HazelcastService.java   
@Override
public IdGenerator getIdGenerator(final String name) {
  return getHazelcastInstance().getIdGenerator(name);
}
项目:FogLight-Examples    文件:PhysicalWatcher.java   
@Override
public void startup() {

    Config config = new Config();

    hazelcastInstance = Hazelcast.newHazelcastInstance(config );        

    logger.info("finished hz startup");
    IdGenerator idGen = hazelcastInstance.getIdGenerator("watchKeys");

    id = idGen.newId();
    logger.info("our id is {}",id);


}
项目:cms    文件:DistributedLockManager.java   
/**
 * Get specific id generator.
 *
 * @param value the specific context of id generator
 * @return id generator.
 */
IdGenerator getIdGenerator(String value);
项目:cms    文件:DistributedCacheManager.java   
/**
 * Get specific id generator.
 *
 * @param value the specific context of id generator
 * @return id generator.
 */
IdGenerator getIdGenerator(String value);
项目:ahome-tooling-server-hazelcast    文件:IHazelcastContext.java   
public IdGenerator getIdGenerator(String name);