/** * Construct a map decorator that decorates the given map using the given * time-to-live value measured in milliseconds to create and use a * {@link ConstantTimeToLiveExpirationPolicy} expiration policy. * * @param timeToLiveMillis the constant amount of time (in milliseconds) an * entry is available before it expires. A negative value results in * entries that NEVER expire. A zero value results in entries that * ALWAYS expire. */ public PassiveExpiringMap(final long timeToLiveMillis) { this(new ConstantTimeToLiveExpirationPolicy<K, V>(timeToLiveMillis), new HashMap<K, V>()); }
@Override public void start() throws Exception { PassiveExpiringMap.ConstantTimeToLiveExpirationPolicy<String, Map<String, byte[]>> expirePeriod = new PassiveExpiringMap.ConstantTimeToLiveExpirationPolicy<>( 1, TimeUnit.DAYS); this.db = new PassiveExpiringMap<>( expirePeriod, new LinkedHashMap<>() );
public MQTTSession(Vertx vertx, ConfigParser config) { this.vertx = vertx; this.decoder = new MQTTDecoder(); this.encoder = new MQTTEncoder(); this.securityEnabled = config.isSecurityEnabled(); this.retainSupport = config.isRetainSupport(); this.subscriptions = new LinkedHashMap<>(); this.qosUtils = new QOSUtils(); PassiveExpiringMap.ConstantTimeToLiveExpirationPolicy<String, List<Subscription>> expirePeriod = new PassiveExpiringMap.ConstantTimeToLiveExpirationPolicy<>( 30, TimeUnit.MINUTES); this.matchingSubscriptionsCache = new PassiveExpiringMap<>( expirePeriod, new HashMap<>() ); this.topicsManager = new MQTTTopicsManagerOptimized(); this.storeManager = new StoreManager(this.vertx); this.authenticatorAddress = config.getAuthenticatorAddress(); this.queue = new LinkedList<>(); }
/** * Construct a map decorator using the given time-to-live value measured in * milliseconds to create and use a * {@link ConstantTimeToLiveExpirationPolicy} expiration policy. If there * are any elements already in the map being decorated, they will NEVER * expire unless they are replaced. * * @param timeToLiveMillis the constant amount of time (in milliseconds) an * entry is available before it expires. A negative value results in * entries that NEVER expire. A zero value results in entries that * ALWAYS expire. * @param map the map to decorate, must not be null. * @throws NullPointerException if the map is null. */ public PassiveExpiringMap(final long timeToLiveMillis, final Map<K, V> map) { this(new ConstantTimeToLiveExpirationPolicy<K, V>(timeToLiveMillis), map); }