本文整理汇总了Java中com.hazelcast.core.IdGenerator.newId方法的典型用法代码示例。如果您正苦于以下问题:Java IdGenerator.newId方法的具体用法?Java IdGenerator.newId怎么用?Java IdGenerator.newId使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.hazelcast.core.IdGenerator
的用法示例。
在下文中一共展示了IdGenerator.newId方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getDataId
import com.hazelcast.core.IdGenerator; //导入方法依赖的package包/类
public Long getDataId() {
if (this.dataId == null) {
IdGenerator idGen = hazelcastInstance.getIdGenerator("dataId");
this.dataId = idGen.newId();
}
return this.dataId;
}
示例2: start
import com.hazelcast.core.IdGenerator; //导入方法依赖的package包/类
/**
* {@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();
}
示例3: startup
import com.hazelcast.core.IdGenerator; //导入方法依赖的package包/类
@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);
}