当前位置: 首页>>代码示例>>Java>>正文


Java ExpiringMap类代码示例

本文整理汇总了Java中net.jodah.expiringmap.ExpiringMap的典型用法代码示例。如果您正苦于以下问题:Java ExpiringMap类的具体用法?Java ExpiringMap怎么用?Java ExpiringMap使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


ExpiringMap类属于net.jodah.expiringmap包,在下文中一共展示了ExpiringMap类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: initializeStack

import net.jodah.expiringmap.ExpiringMap; //导入依赖的package包/类
/**
 * Initialize the SS7 stack
 * 
 * @param ipChannelType TCP or UDP
 */
public void initializeStack(IpChannelType ipChannelType) throws Exception {
    
    if (SS7FirewallConfig.firewallPolicy == SS7FirewallConfig.FirewallPolicy.DNAT_TO_HONEYPOT) {
        dnat_sessions = ExpiringMap.builder()
                                            .expiration(SS7FirewallConfig.honeypot_dnat_session_expiration_timeout, TimeUnit.SECONDS)
                                            .build();
    }   

    this.initSCTP(ipChannelType);

    // Initialize M3UA first
    this.initM3UA();

    // Initialize SCCP
    this.initSCCP();
    
    // Initialize MAP
    this.initMAP();

    // 7. Start ASP
    serverM3UAMgmt.startAsp("RASP1");
    clientM3UAMgmt.startAsp("ASP1");

    logger.debug("[[[[[[[[[[    Started SctpFirewall       ]]]]]]]]]]");
}
 
开发者ID:P1sec,项目名称:SigFW,代码行数:31,代码来源:SS7Firewall.java

示例2: put

import net.jodah.expiringmap.ExpiringMap; //导入依赖的package包/类
/**
 * Puts given value into the cache with nested key of {@code firstKey}.{@code key}<br>
 *
 * @param firstKey         The first key of the cache
 * @param key              The key
 * @param value            The value
 * @param duration         The duration
 * @param unit             The time unit for the duration
 * @param removalListeners The listeners when the value is removed from the cache
 * @return The result
 */
public boolean put(F firstKey, K key, V value,
                   ExpiringMap.ExpirationPolicy policy, long duration, TimeUnit unit,
                   Consumer<V>... removalListeners) {
    if(firstKey == null || key == null || value == null) return false;
    ExpiringMap<K, V> expiringMap = handle.getIfPresent(firstKey);
    if(expiringMap == null) {
        expiringMap = buildExpiringMap();
    }
    if(duration == -1 || unit == null || policy == null) {
        expiringMap.put(key, value);
    }
    else {
        expiringMap.put(key, value, policy, duration, unit);
    }
    handle.put(firstKey, expiringMap);

    removalListenerMap.put(key, Arrays.asList(removalListeners));
    return true;
}
 
开发者ID:Superioz,项目名称:MooProject,代码行数:31,代码来源:MultiCache.java

示例3: Microcloud

import net.jodah.expiringmap.ExpiringMap; //导入依赖的package包/类
public Microcloud(Cloud cloud, ScheduledExecutorService executor) {
    this.cloud = cloud;
    this.cloud.addSynchronousListener(new Cloud.Listener() {
        @Override
        public void onMessage(Message message) {
            try {
                doProcess(message);
            } catch (MsnosException e) {
                log.error("Error processing message {}", e);
            }
        }
    });

    remoteServices = new ConcurrentHashMap<Iden, RemoteMicroservice>();
    passiveServices = new ConcurrentHashMap<UUID, PassiveService>();
    apis = new ApiRepository();

    this.executor = executor;
    this.enquiries = ExpiringMap.builder().expiration(ENQUIRY_EXPIRE, TimeUnit.SECONDS).build();

    Healthchecker healthcheck = new Healthchecker(this, executor);
    healthcheck.start();
}
 
开发者ID:workshare,项目名称:ms-nos,代码行数:24,代码来源:Microcloud.java

示例4: Cloud

import net.jodah.expiringmap.ExpiringMap; //导入依赖的package包/类
Cloud(final UUID uuid, String signid, Signer signer, Sender sender, Receiver receiver, Set<Gateway> gates, Multicaster multicaster, ScheduledExecutorService executor) {
    this.iden = new Iden(Iden.Type.CLD, uuid);

    this.enquiries = ExpiringMap.builder().expiration(ENQUIRY_EXPIRE, TimeUnit.SECONDS).build();

    this.localAgents = new IdentifiablesList<LocalAgent>();
    this.remoteAgents = new IdentifiablesList<RemoteAgent>(onRemoteAgentsChange());
    this.remoteClouds = new IdentifiablesList<RemoteEntity>();

    this.gates = Collections.unmodifiableSet(gates);
    this.internal = new Internal();

    this.signer = signer;
    this.signid = signid;
    this.ring = calculateRing(gates);
    this.validators = new MessageValidators(this.internal);
    
    final Router router = new Router(this, gates);
    this.sender = (sender != null) ? sender : new Sender(router);
    this.receiver = (receiver != null) ? receiver : new Receiver(this, gates, multicaster, router);

    addShutdownHook(uuid);

    startAgentWatchdog(executor);
}
 
开发者ID:workshare,项目名称:ms-nos,代码行数:26,代码来源:Cloud.java

示例5: shouldNeverSeenMessage

import net.jodah.expiringmap.ExpiringMap; //导入依赖的package包/类
private Validator shouldNeverSeenMessage() {
    return new AbstractMessageValidator(Reason.DUPLICATE) {
        
        private final ExpiringMap<UUID, Message> messages = ExpiringMap.builder()
                    .expiration(getMessageLifetime(), TimeUnit.SECONDS)
                    .build();            

        @Override
        public Result isValid(Message message) {
            if (messages.containsKey(message.getUuid()))
                return failure;
            
            messages.put(message.getUuid(), message);
            return SUCCESS;
        }
    };
}
 
开发者ID:workshare,项目名称:ms-nos,代码行数:18,代码来源:MessageValidators.java

示例6: removeSimilar

import net.jodah.expiringmap.ExpiringMap; //导入依赖的package包/类
/**
 * Removes every value which key is starts with the prefix given
 *
 * @param firstKey The firstkey
 * @param prefix   The prefix
 */
public void removeSimilar(F firstKey, String prefix) {
    if(firstKey == null || prefix == null) return;
    ExpiringMap<K, V> cache = handle.getIfPresent(firstKey);
    if(cache == null) return;

    for(K key : cache.keySet()) {
        String s = key + "";
        if(s.startsWith(prefix)) cache.remove(key);
    }
}
 
开发者ID:Superioz,项目名称:MooProject,代码行数:17,代码来源:MultiCache.java

示例7: buildExpiringMap

import net.jodah.expiringmap.ExpiringMap; //导入依赖的package包/类
/**
 * Builds a new expiring map
 *
 * @return The map
 */
private ExpiringMap<K, V> buildExpiringMap() {
    return ExpiringMap.builder()
            .variableExpiration()
            .expirationListener((ExpiringMap.ExpirationListener<K, V>) (k, v) -> {
                List<Consumer<V>> consumers = removalListenerMap.get(k);
                if(consumers != null) {
                    for(Consumer<V> c : consumers) {
                        c.accept(v);
                    }
                    removalListenerMap.remove(k);
                }
            }).build();
}
 
开发者ID:Superioz,项目名称:MooProject,代码行数:19,代码来源:MultiCache.java

示例8: cycleChoice

import net.jodah.expiringmap.ExpiringMap; //导入依赖的package包/类
/**
 * Creates a command choice<br>
 * Use {@link #choice(String, Object...)} for using the builder
 *
 * @param choice The command choice
 * @throws CommandException For sending the message to the user
 */
public CommandChoiceOption cycleChoice(CommandChoice choice) throws CommandException {
    // the player wants to skip the choice (meaning TRUE)
    if(getParamSet().hasFlag(CommandInstance.CHOICE_SKIP_FLAG)) return choice.getOption(0);

    // he chose a choice flag
    String key = getCommand().getLabel() + " " + getParamSet().getRawCommandline();
    if(getParamSet().hasFlag(CommandInstance.CHOICE_FLAG)) {
        // no choice available!
        if(!hasChoice()) {
            // throw exception
            throw new CommandChoiceException(CommandChoiceException.Type.NO_CHOICE);
        }

        // remove from cache
        CHOICE_CACHE.remove(getSendersUniqueId(), key);

        int id = getParamSet().getFlag(CommandInstance.CHOICE_FLAG).getInt(0, 0);
        CommandChoiceOption option = choice.getOption(id);
        if(option.getRunnable() != null) option.getRunnable().run();
        return option;
    }
    if(hasChoice()) return CommandChoiceOption.EMPTY;

    // put choice into cache
    CHOICE_CACHE.put(getSendersUniqueId(), key, choice,
            ExpiringMap.ExpirationPolicy.CREATED, 5, TimeUnit.SECONDS, (Consumer<CommandChoice>) commandChoice -> {
                // choice timed out
                CONTEXT_CACHE.removeSimilar(getSendersUniqueId(), getCommand().getLabel());

                // throw timeout
                EventExecutor.getInstance().execute(new CommandErrorEvent<>(CommandContext.this, CommandContext.this.getCommand(),
                        new CommandChoiceException(CommandChoiceException.Type.TIMEOUT)));
            });

    // send this to the user
    throw new CommandException(CommandException.Type.CUSTOM, choice.getMessage());
}
 
开发者ID:Superioz,项目名称:MooProject,代码行数:45,代码来源:CommandContext.java

示例9: MusicRepository

import net.jodah.expiringmap.ExpiringMap; //导入依赖的package包/类
@Inject
public MusicRepository(Mapper<Playlist,PlaylistEntity> playlistMapper,
                       Mapper<Track,TrackEntity> trackMapper,
                       Mapper<User,UserEntity> userMapper,
                       Mapper<UserDetails,UserDetailsEntity> detailsMapper,
                       RemoteSource remoteSource, LocalSource localSource,
                       PersonalInfo personalInfo, Context context,
                       BaseSchedulerProvider schedulerProvider){
    this.playlistMapper=playlistMapper;
    this.trackMapper=trackMapper;
    this.userMapper=userMapper;
    this.detailsMapper=detailsMapper;
    this.remoteSource=remoteSource;
    this.localSource=localSource;
    this.personalInfo=personalInfo;
    this.schedulerProvider=schedulerProvider;
    this.context=context;
    //initialize cache
    playlistCacheStore = new CacheStore<>(ExpiringMap.builder()
            .maxSize(DEFAULT_CACHE_SIZE)
            .expiration(DEFAULT_CACHE_DURATION, TimeUnit.MINUTES)
            .build());

    trackCacheStore=new CacheStore<>(ExpiringMap.builder()
            .maxSize(DEFAULT_CACHE_SIZE)
            .expiration(DEFAULT_CACHE_DURATION, TimeUnit.MINUTES)
            .build());
    userCacheStore=new CacheStore<>(ExpiringMap.builder()
            .maxSize(DEFAULT_CACHE_SIZE)
            .expiration(DEFAULT_CACHE_DURATION, TimeUnit.MINUTES)
            .build());
}
 
开发者ID:vpaliyX,项目名称:Melophile,代码行数:33,代码来源:MusicRepository.java

示例10: HistoricalSearches

import net.jodah.expiringmap.ExpiringMap; //导入依赖的package包/类
HistoricalSearches() {
	this.historicalMusic = ExpiringMap.builder()
			.expiration(10, TimeUnit.MINUTES)
			.expirationPolicy(ExpirationPolicy.CREATED)
			.build();
	historicalThemeSearchResults = ExpiringMap.builder()
			.expiration(10, TimeUnit.MINUTES)
			.expirationPolicy(ExpirationPolicy.CREATED)
			.build();
}
 
开发者ID:paul-io,项目名称:momo-2,代码行数:11,代码来源:GuildObject.java

示例11: getThemeResults

import net.jodah.expiringmap.ExpiringMap; //导入依赖的package包/类
public static Map<String, ArrayList<Theme>> getThemeResults(String search) throws NoSearchResultException, IOException, NoAPIKeyException {
	Map<String, ArrayList<Theme>> toReturn = ExpiringMap.builder()
			  .expiration(15, TimeUnit.MINUTES)
			  .build();

	String searchUrl = baseThemeUrl + "key=" + Bot.getInstance().getApiKeys().get("themes") + "&search=" + search;
	JsonValue jv = Util.jsonFromUrl(searchUrl);
	JsonArray ja = jv.asArray();
	if(ja.size() == 0) {
		throw new NoSearchResultException();
	}
	
	for(JsonValue jv2 : ja) {
		JsonObject jo = jv2.asObject();
		ArrayList<Theme> temp = new ArrayList<Theme>();
		for(JsonValue jv3 : jo.get("data").asArray()) {
			JsonObject jo2 = jv3.asObject();
			temp.add(new Theme(jo.getInt("malId", 1),
					jo2.getString("type", "OP"),
					jo2.getString("link", "https://my.mixtape.moe/cggknn.webm"),
					jo2.getString("songTitle", "Tank!"),
					jo.getString("animeName", "Cowboy Bebop")));
		}
		toReturn.put(jo.getString("animeName", "Cowboy Bebop"), temp);
	}
	return toReturn;
}
 
开发者ID:paul-io,项目名称:momo-2,代码行数:28,代码来源:Theme.java

示例12: InMemorySlidingWindowRequestRateLimiter

import net.jodah.expiringmap.ExpiringMap; //导入依赖的package包/类
public InMemorySlidingWindowRequestRateLimiter(Set<RequestLimitRule> rules, TimeSupplier timeSupplier) {
    requireNonNull(rules, "rules can not be null");
    requireNonNull(rules, "time supplier can not be null");
    this.rules = rules;
    this.timeSupplier = timeSupplier;
    this.expiringKeyMap = ExpiringMap.builder().variableExpiration().build();
}
 
开发者ID:mokies,项目名称:ratelimitj,代码行数:8,代码来源:InMemorySlidingWindowRequestRateLimiter.java

示例13: checkForMissingRunningUnits

import net.jodah.expiringmap.ExpiringMap; //导入依赖的package包/类
private void checkForMissingRunningUnits() {
    checkins.forEach((c, m) -> {
        numberOfServersLast15Minutes.putIfAbsent(c, ExpiringMap.builder().maxSize(15).expirationPolicy(ExpirationPolicy.CREATED).build());
        int lowestNumberOfServersLast15Minutes = numberOfServersLast15Minutes.get(c).entrySet().stream().mapToInt(Map.Entry::getValue).min().orElse(0);
        int numberOfServersNow = m.size();
        if (numberOfServersNow < lowestNumberOfServersLast15Minutes) {
            slackClient.indicateFewerRunningUnits(c, lowestNumberOfServersLast15Minutes, numberOfServersNow);
            pagerdutyClient.indicateFewerRunningUnits(c, lowestNumberOfServersLast15Minutes, numberOfServersNow);
        } else if (numberOfServersNow > lowestNumberOfServersLast15Minutes) {
            pagerdutyClient.indicateMoreRunningUnits(c, lowestNumberOfServersLast15Minutes, numberOfServersNow);
        }
        numberOfServersLast15Minutes.get(c).put(LocalDateTime.now(), numberOfServersNow);
    });
}
 
开发者ID:Espenhh,项目名称:panopticon,代码行数:15,代码来源:MissingRunningUnitsAlerter.java

示例14: InMemoryTokenCache

import net.jodah.expiringmap.ExpiringMap; //导入依赖的package包/类
/**
 * Create new in-memory cache instance
 */
@SuppressWarnings("WeakerAccess")
public InMemoryTokenCache() {
    this.cacheMap = ExpiringMap.builder()
            .variableExpiration()
            .build();
}
 
开发者ID:Scalepoint,项目名称:oauth-token-java-client,代码行数:10,代码来源:InMemoryTokenCache.java

示例15: NotificationPreProcessor

import net.jodah.expiringmap.ExpiringMap; //导入依赖的package包/类
public NotificationPreProcessor() {
    this.currentMessages = new ArrayList<>();
    this.expiresMessages = ExpiringMap.builder()
            .expiration(1, TimeUnit.HOURS)
            .build();
    this.subscribe();
}
 
开发者ID:Exslims,项目名称:MercuryTrade,代码行数:8,代码来源:NotificationPreProcessor.java


注:本文中的net.jodah.expiringmap.ExpiringMap类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。