本文整理汇总了Java中java.util.concurrent.ConcurrentHashMap.newKeySet方法的典型用法代码示例。如果您正苦于以下问题:Java ConcurrentHashMap.newKeySet方法的具体用法?Java ConcurrentHashMap.newKeySet怎么用?Java ConcurrentHashMap.newKeySet使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.util.concurrent.ConcurrentHashMap
的用法示例。
在下文中一共展示了ConcurrentHashMap.newKeySet方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getMobs
import java.util.concurrent.ConcurrentHashMap; //导入方法依赖的package包/类
public Set<L2ControllableMobInstance> getMobs()
{
if (_mobs == null)
{
_mobs = ConcurrentHashMap.newKeySet();
}
return _mobs;
}
示例2: QueueHandler
import java.util.concurrent.ConcurrentHashMap; //导入方法依赖的package包/类
private QueueHandler(Queue queue) {
this.queue = queue;
unmodifiableQueueView = new UnmodifiableQueueWrapper(queue);
// TODO: take message count from queue configuration
this.redeliveryQueue = new MemQueueImpl(queue.getName(), 1000, false);
this.consumers = ConcurrentHashMap.newKeySet();
consumerIterator = new CyclicConsumerIterator();
}
示例3: Procedure
import java.util.concurrent.ConcurrentHashMap; //导入方法依赖的package包/类
public Procedure(RegisterMessage registerMessage, long registrationId,
boolean isDealerCallerIdentificationFeatureEnabled) {
this.procedure = registerMessage.getProcedure();
this.webSocketSessionId = registerMessage.getWebSocketSessionId();
if (isDealerCallerIdentificationFeatureEnabled) {
this.discloseCaller = registerMessage.isDiscloseCaller();
}
else {
this.discloseCaller = false;
}
this.registrationId = registrationId;
this.pendingInvocations = ConcurrentHashMap.newKeySet();
}
示例4: Subscription
import java.util.concurrent.ConcurrentHashMap; //导入方法依赖的package包/类
Subscription(String topic, MatchPolicy matchPolicy, long subscriptionId) {
this.createdTimeMillis = System.currentTimeMillis();
this.topicMatch = new DestinationMatch(topic, matchPolicy);
this.subscriptionId = subscriptionId;
this.subscribers = ConcurrentHashMap.newKeySet();
}
示例5: addBlockedAbnormalTypes
import java.util.concurrent.ConcurrentHashMap; //导入方法依赖的package包/类
/**
* Adds abnormal types to the blocked buff slot set.
* @param blockedAbnormalTypes the blocked buff slot set to add
*/
public void addBlockedAbnormalTypes(Set<AbnormalType> blockedAbnormalTypes)
{
if (_blockedAbnormalTypes == null)
{
synchronized (this)
{
if (_blockedAbnormalTypes == null)
{
_blockedAbnormalTypes = ConcurrentHashMap.newKeySet(blockedAbnormalTypes.size());
}
}
}
_blockedAbnormalTypes.addAll(blockedAbnormalTypes);
}
示例6: registerUser
import java.util.concurrent.ConcurrentHashMap; //导入方法依赖的package包/类
/**
* Registeres the Learner for processing by SendWorker.
*/
@OnOpen
public void registerUser(Session session) throws IOException {
Long lessonId = Long.valueOf(session.getRequestParameterMap().get(AttributeNames.PARAM_LESSON_ID).get(0));
Set<Websocket> sessionWebsockets = PresenceWebsocketServer.websockets.get(lessonId);
if (sessionWebsockets == null) {
sessionWebsockets = ConcurrentHashMap.newKeySet();
PresenceWebsocketServer.websockets.put(lessonId, sessionWebsockets);
}
Websocket websocket = new Websocket(session);
sessionWebsockets.add(websocket);
Roster roster = PresenceWebsocketServer.rosters.get(lessonId);
if (roster == null) {
boolean imEnabled = Boolean.valueOf(session.getRequestParameterMap().get("imEnabled").get(0));
// build a new roster object
roster = new Roster(lessonId, imEnabled);
PresenceWebsocketServer.rosters.put(lessonId, roster);
}
new Thread(() -> {
try {
// websocket communication bypasses standard HTTP filters, so Hibernate session needs to be initialised manually
HibernateSessionManager.openSession();
SendWorker.send(lessonId, websocket.nickName);
} finally {
HibernateSessionManager.closeSession();
}
}).start();
if (PresenceWebsocketServer.log.isDebugEnabled()) {
PresenceWebsocketServer.log
.debug("User " + websocket.nickName + " entered Presence Chat with lesson ID: " + lessonId);
}
}
示例7: registerUser
import java.util.concurrent.ConcurrentHashMap; //导入方法依赖的package包/类
/**
* Registeres the Learner for processing by SendWorker.
*/
@OnOpen
public void registerUser(Session session) throws IOException {
Long toolSessionId = Long
.valueOf(session.getRequestParameterMap().get(AttributeNames.PARAM_TOOL_SESSION_ID).get(0));
Set<Websocket> sessionWebsockets = LearningWebsocketServer.websockets.get(toolSessionId);
if (sessionWebsockets == null) {
sessionWebsockets = ConcurrentHashMap.newKeySet();
LearningWebsocketServer.websockets.put(toolSessionId, sessionWebsockets);
}
final Set<Websocket> finalSessionWebsockets = sessionWebsockets;
String userName = session.getUserPrincipal().getName();
new Thread(() -> {
try {
// websocket communication bypasses standard HTTP filters, so Hibernate session needs to be initialised manually
HibernateSessionManager.openSession();
ChatUser chatUser = LearningWebsocketServer.getChatService().getUserByLoginNameAndSessionId(userName,
toolSessionId);
Websocket websocket = new Websocket(session, chatUser.getNickname(), chatUser.getUserId(), getPortraitId(chatUser.getUserId()));
finalSessionWebsockets.add(websocket);
// update the chat window immediatelly
SendWorker.send(toolSessionId);
if (LearningWebsocketServer.log.isDebugEnabled()) {
LearningWebsocketServer.log
.debug("User " + userName + " entered Chat with toolSessionId: " + toolSessionId);
}
} finally {
HibernateSessionManager.closeSession();
}
}).start();
}
示例8: registerUser
import java.util.concurrent.ConcurrentHashMap; //导入方法依赖的package包/类
/**
* Registeres the Learner for processing by SendWorker.
*/
@OnOpen
public void registerUser(Session websocket) throws JSONException, IOException {
Long toolSessionId = Long
.valueOf(websocket.getRequestParameterMap().get(AttributeNames.PARAM_TOOL_SESSION_ID).get(0));
Set<Session> sessionWebsockets = LearningWebsocketServer.websockets.get(toolSessionId);
if (sessionWebsockets == null) {
sessionWebsockets = ConcurrentHashMap.newKeySet();
LearningWebsocketServer.websockets.put(toolSessionId, sessionWebsockets);
Map<Long, Map<Long, Boolean>> sessionCache = new TreeMap<>();
LearningWebsocketServer.cache.put(toolSessionId, sessionCache);
}
sessionWebsockets.add(websocket);
if (LearningWebsocketServer.log.isDebugEnabled()) {
LearningWebsocketServer.log.debug("User " + websocket.getUserPrincipal().getName()
+ " entered Scratchie with toolSessionId: " + toolSessionId);
}
}
示例9: registerUser
import java.util.concurrent.ConcurrentHashMap; //导入方法依赖的package包/类
/**
* Registeres the Learner for processing by SendWorker.
*/
@OnOpen
public void registerUser(Session websocket) throws JSONException, IOException {
Long toolSessionId = Long
.valueOf(websocket.getRequestParameterMap().get(AttributeNames.PARAM_TOOL_SESSION_ID).get(0));
Set<Session> sessionWebsockets = LearningWebsocketServer.websockets.get(toolSessionId);
if (sessionWebsockets == null) {
sessionWebsockets = ConcurrentHashMap.newKeySet();
LearningWebsocketServer.websockets.put(toolSessionId, sessionWebsockets);
}
sessionWebsockets.add(websocket);
if (LearningWebsocketServer.log.isDebugEnabled()) {
LearningWebsocketServer.log.debug("User " + websocket.getUserPrincipal().getName()
+ " entered Scribe with toolSessionId: " + toolSessionId);
}
new Thread(() -> {
try {
HibernateSessionManager.openSession();
SendWorker.send(toolSessionId, websocket);
} catch (Exception e) {
log.error("Error while sending messages", e);
} finally {
HibernateSessionManager.closeSession();
}
}).start();
}
示例10: createsNewRule
import java.util.concurrent.ConcurrentHashMap; //导入方法依赖的package包/类
@Test
public void createsNewRule() {
final Builder<RuleSetBuilder, DecisionTreeRuleSet> ruleSetBuilder = getRuleSetBuilder();
final DriverCache cache = new DriverCache();
final Set<ValueGroup> groups = ConcurrentHashMap.newKeySet();
final ValueGroup group = new ValueGroup("CMEGroup", Arrays.asList("CME", "CBOT"));
groups.add(group);
RuleSetBuilder.addValueGroupsToDriverCache(cache, groups);
ruleSetBuilder.with(RuleSetBuilder::setCache, cache);
ruleSetBuilder.with(RuleSetBuilder::groups, groups);
this.ruleSet = ruleSetBuilder.build();
this.builder = RuleChangeBuilder.creator(this.ruleSet, new UUID(0, 9));
this.builder.with(RuleChangeBuilder::input,
Arrays.asList("VOICE", "CME", "ED", "UK", GroupDriver.VG_PREFIX + group.getId()));
this.builder.with(RuleChangeBuilder::output, Collections.singletonMap("Rate", "2.0"));
this.builder.with(RuleChangeBuilder::changeRange,
new DateRange(NOW.minus(Period.ofWeeks(1)), NOW.plus(Period.ofWeeks(1))));
final List<RuleChange> ruleChanges = this.builder.build();
assertThat(ruleChanges, hasSize(1));
final RuleChange change = ruleChanges.get(0);
assertEquals(Type.NEW, change.getType());
assertRuleChange(change, Type.NEW, null, new UUID(0, 9),
new String[]{"VOICE", "CME", "ED", "UK", GroupDriver.VG_PREFIX + group.getId().toString()},
Collections.singletonMap("Rate", "2.0"), NOW.minus(Period.ofWeeks(1)),
NOW.plus(Period.ofWeeks(1)));
final List<String> driverValues =
Arrays.stream(change.getRule().getDrivers()).map(InputDriver::toString).collect(Collectors.toList());
assertThat(driverValues, contains("VOICE", "CME", "ED", "UK", GroupDriver.VG_PREFIX + group.getId()));
}
示例11: getStatusListener
import java.util.concurrent.ConcurrentHashMap; //导入方法依赖的package包/类
/**
* Return the list of L2Character that must be informed of HP/MP updates of this L2Character.<br>
* <B><U>Concept</U>:</B><br>
* Each L2Character owns a list called <B>_statusListener</B> that contains all L2PcInstance to inform of HP/MP updates.<br>
* Players who must be informed are players that target this L2Character.<br>
* When a RegenTask is in progress sever just need to go through this list to send Server->Client packet StatusUpdate.
* @return The list of L2Character to inform or null if empty
*/
public final Set<L2Character> getStatusListener()
{
if (_StatusListener == null)
{
_StatusListener = ConcurrentHashMap.newKeySet();
}
return _StatusListener;
}
示例12: getAttackByList
import java.util.concurrent.ConcurrentHashMap; //导入方法依赖的package包/类
/**
* @return a list of L2Character that attacked.
*/
public final Set<WeakReference<L2Character>> getAttackByList()
{
if (_attackByList == null)
{
synchronized (this)
{
if (_attackByList == null)
{
_attackByList = ConcurrentHashMap.newKeySet();
}
}
}
return _attackByList;
}
示例13: addToWaitingList
import java.util.concurrent.ConcurrentHashMap; //导入方法依赖的package包/类
public void addToWaitingList(L2PcInstance player)
{
if (_waitingList == null)
{
synchronized (this)
{
if (_waitingList == null)
{
_waitingList = ConcurrentHashMap.newKeySet(1);
}
}
}
_waitingList.add(player);
}
示例14: populatedSet
import java.util.concurrent.ConcurrentHashMap; //导入方法依赖的package包/类
static Set<Integer> populatedSet(int n) {
Set<Integer> a = ConcurrentHashMap.<Integer>newKeySet();
assertTrue(a.isEmpty());
for (int i = 0; i < n; i++)
assertTrue(a.add(i));
assertEquals(n == 0, a.isEmpty());
assertEquals(n, a.size());
return a;
}
示例15: JsonBackedNotifiersRepositoryImpl
import java.util.concurrent.ConcurrentHashMap; //导入方法依赖的package包/类
@Autowired
public JsonBackedNotifiersRepositoryImpl(@Value("${notifiers.file}") File notifierFile, ObjectMapper objectMapper) throws IOException {
this.notifierSet = ConcurrentHashMap.newKeySet();
this.notifierFile = notifierFile;
this.objectMapper = objectMapper;
if (notifierFile.exists()) {
loadFromFile();
} else {
notifierFile.createNewFile();
writeToFile();
}
}