Java 类org.apache.commons.collections.map.LRUMap 实例源码

项目:tajo    文件:QueryMaster.java   
@Override
public void serviceInit(Configuration conf) throws Exception {

  this.systemConf = TUtil.checkTypeAndGet(conf, TajoConf.class);
  this.manager = RpcClientManager.getInstance();
  this.rpcClientParams = RpcParameterFactory.get(this.systemConf);

  querySessionTimeout = systemConf.getIntVar(TajoConf.ConfVars.QUERY_SESSION_TIMEOUT);
  queryMasterContext = new QueryMasterContext(systemConf);

  clock = new SystemClock();
  finishedQueryMasterTasksCache = new LRUMap(systemConf.getIntVar(TajoConf.ConfVars.HISTORY_QUERY_CACHE_SIZE));

  this.dispatcher = new AsyncDispatcher();
  addIfService(dispatcher);

  globalPlanner = new GlobalPlanner(systemConf, workerContext);

  dispatcher.register(QueryStartEvent.EventType.class, new QueryStartEventHandler());
  dispatcher.register(QueryStopEvent.EventType.class, new QueryStopEventHandler());
  super.serviceInit(conf);
  LOG.info("QueryMaster inited");
}
项目:tajo    文件:QueryManager.java   
@Override
public void serviceInit(Configuration conf) throws Exception {
  try {
    this.dispatcher = new AsyncDispatcher();
    addService(this.dispatcher);

    this.dispatcher.register(QueryJobEvent.Type.class, new QueryJobManagerEventHandler());

    TajoConf tajoConf = TUtil.checkTypeAndGet(conf, TajoConf.class);
    this.historyCache = new LRUMap(tajoConf.getIntVar(TajoConf.ConfVars.HISTORY_QUERY_CACHE_SIZE));
  } catch (Exception e) {
    LOG.error("Failed to init service " + getName() + " by exception " + e, e);
  }

  super.serviceInit(conf);
}
项目:ilves    文件:InMemoryCache.java   
/**
 * Constructor defining time to live, cache evict expired intervals and maximum cached items.
 *
 * @param timeToLiveMillis      the time to live in milliseconds
 * @param evictIntervalMillis the clean up interval in milliseconds
 * @param maxItems              the maximum number of cached items.
 */
public InMemoryCache(final long timeToLiveMillis, final long evictIntervalMillis, final int maxItems) {
    this.timeToLiveMillis = timeToLiveMillis;

    cacheMap = new LRUMap(maxItems);

    if (this.timeToLiveMillis > 0 && evictIntervalMillis > 0) {

        final Thread evictThread = new Thread(new Runnable() {
            public void run() {
                while (true) {
                    try {
                        Thread.sleep(evictIntervalMillis);
                    } catch (final InterruptedException e) {
                    }
                    evictExpired();
                }
            }
        });

        evictThread.setDaemon(true);
        evictThread.start();
    }
}
项目:weixin_api    文件:OpenApi.java   
/**
 * 初始化,只需要一次。主要工作是创建各类服务线程,例如Ticket获取线程。
 * 
 * @param config
 *            参数配置
 */
public void init(OpenApiConfig config) {
    if (inited) {
        return;
    }
    inited = true;
    this.config = config;
    this.distinctMsgIdCache = new LRUMap(config.getDistinctMsgIdCacheSize());

    runtime = new OpenApiRuntime(config.getRuntimeStorage());

    // 创建工作线程池。
    worker = new ScheduledThreadPoolExecutor(config.getWorkerThreadPoolSize());
}
项目:directory-mavibot    文件:PersistedBTree.java   
/**
 * Initialize the BTree.
 *
 * @throws IOException If we get some exception while initializing the BTree
 */
public void init( BTree<K, V> parentBTree )
{
    if ( parentBTree == null )
    {
        // This is not a subBtree, we have to initialize the cache

        // Create the queue containing the pending read transactions
        readTransactions = new ConcurrentLinkedQueue<ReadTransaction<K, V>>();

        if ( cacheSize < 1 )
        {
            cacheSize = DEFAULT_CACHE_SIZE;
        }

        cache = new LRUMap( cacheSize );
    }
    else
    {
        this.cache = ( ( PersistedBTree<K, V> ) parentBTree ).getCache();
        this.readTransactions = ( ( PersistedBTree<K, V> ) parentBTree ).getReadTransactions();
    }

    // Initialize the txnManager thread
    //FIXME we should NOT create a new transaction manager thread for each BTree
    //createTransactionManager();
}
项目:scribe    文件:CRMSessionCache.java   
public CRMSessionCache(final long timeToLive, final long accessTimeout, final long timerInterval, final int maximumCachedQuantity) {
  ttl = timeToLive;
  ato = accessTimeout;
  tiv = timerInterval;
  cacheMap = new LRUMap(maximumCachedQuantity);

  if (logger.isDebugEnabled()) {
    logger.debug("----Inside CRMSessionCache: initialization started Time to live:" + ttl + " & Access timeout:" + ato + " & Cache timer interval: "
        + tiv + " & Maximum allowed cached quantity: " + maximumCachedQuantity);
  }
  initialize();
}
项目:cloud-meter    文件:AbstractJDBCTestElement.java   
private PreparedStatement getPreparedStatement(Connection conn, boolean callable) throws SQLException {
    Map<String, PreparedStatement> preparedStatementMap = perConnCache.get(conn);
    if (null == preparedStatementMap ) {
        @SuppressWarnings("unchecked") // LRUMap is not generic
        Map<String, PreparedStatement> lruMap = new LRUMap(MAX_OPEN_PREPARED_STATEMENTS) {
            private static final long serialVersionUID = 1L;
            @Override
            protected boolean removeLRU(LinkEntry entry) {
                PreparedStatement preparedStatement = (PreparedStatement)entry.getValue();
                close(preparedStatement);
                return true;
            }
        };
        preparedStatementMap = Collections.<String, PreparedStatement>synchronizedMap(lruMap);
        // As a connection is held by only one thread, we cannot already have a 
        // preparedStatementMap put by another thread
        perConnCache.put(conn, preparedStatementMap);
    }
    PreparedStatement pstmt = preparedStatementMap.get(getQuery());
    if (null == pstmt) {
        if (callable) {
            pstmt = conn.prepareCall(getQuery());
        } else {
            pstmt = conn.prepareStatement(getQuery());
        }
        pstmt.setQueryTimeout(getQueryTimeout());
        // PreparedStatementMap is associated to one connection so 
        //  2 threads cannot use the same PreparedStatement map at the same time
        preparedStatementMap.put(getQuery(), pstmt);
    } else {
        int timeoutInS = getQueryTimeout();
        if(pstmt.getQueryTimeout() != timeoutInS) {
            pstmt.setQueryTimeout(getQueryTimeout());
        }
    }
    pstmt.clearParameters();
    return pstmt;
}
项目:cloud-meter    文件:CacheManager.java   
private void clearCache() {
    log.debug("Clear cache");
    threadCache = new InheritableThreadLocal<Map<String, CacheEntry>>(){
        @Override
        protected Map<String, CacheEntry> initialValue(){
            // Bug 51942 - this map may be used from multiple threads
            @SuppressWarnings("unchecked") // LRUMap is not generic currently
            Map<String, CacheEntry> map = new LRUMap(getMaxSize());
            return Collections.<String, CacheEntry>synchronizedMap(map);
        }
    };
}
项目:graml    文件:GraphSectionImpl.java   
/**
 * Instantiate this class with a map constrained to the graph section.
 *
 * @param section
 * @param classmap
 * @param vertexProps
 * @param edgeProps
 */
public GraphSectionImpl(final Map<String, Map<String, Object>> section, final ClassmapSection classmap,
        final VerticesSection vertexProps, final EdgesSection edgeProps) {
    // TODO figure out why Map<String, ?> results in internal groovy compiler error
    if (section == null) {
        throw new GramlException("Missing required graph section.");
    }

    this.classmap = classmap;
    this.vertexProps = vertexProps;
    this.edgeProps = edgeProps;
    this.section = section;
    vertexCache = new LRUMap();
}
项目:imcms    文件:HttpSessionUtils.java   
private static Map getSessionMap(HttpServletRequest request) {
    HttpSession session = request.getSession();
    Map sessionMap = (Map) session.getAttribute(SESSION_ATTRIBUTE_NAME__SESSION_MAP);
    if (null == sessionMap) {
        sessionMap = Collections.synchronizedMap(new LRUMap(MAX_COUNT__SESSION_OBJECTS));
        session.setAttribute(SESSION_ATTRIBUTE_NAME__SESSION_MAP, sessionMap);
    }
    return sessionMap;
}
项目:jmeter-cassandra    文件:AbstractCassandaTestElement.java   
private BoundStatement getPreparedStatement(Session conn, boolean callable) {
    Map<String, PreparedStatement> preparedStatementMap = perConnCache.get(conn);
    if (null == preparedStatementMap ) {
        @SuppressWarnings("unchecked") // LRUMap is not generic
                Map<String, PreparedStatement> lruMap = new LRUMap(MAX_OPEN_PREPARED_STATEMENTS) {
            private static final long serialVersionUID = 1L;
            @Override
            protected boolean removeLRU(LinkEntry entry) {
                PreparedStatement preparedStatement = (PreparedStatement)entry.getValue();
                return true;
            }
        };

        // TODO - This is wrong, but is synchronized
        preparedStatementMap = Collections.<String, PreparedStatement>synchronizedMap(lruMap);
        // As a connection is held by only one thread, we cannot already have a 
        // preparedStatementMap put by another thread
        perConnCache.put(conn, preparedStatementMap);
    }
    PreparedStatement pstmt = preparedStatementMap.get(getQuery());
    if (null == pstmt) {
        pstmt = conn.prepare(getQuery());

        // PreparedStatementMap is associated to one connection so
        //  2 threads cannot use the same PreparedStatement map at the same time
        preparedStatementMap.put(getQuery(), pstmt);
    }

    return pstmt.bind();
}
项目:hadoop-on-lustre2    文件:LeveldbTimelineStore.java   
@Override
@SuppressWarnings("unchecked")
protected void serviceInit(Configuration conf) throws Exception {
  Options options = new Options();
  options.createIfMissing(true);
  options.cacheSize(conf.getLong(
      YarnConfiguration.TIMELINE_SERVICE_LEVELDB_READ_CACHE_SIZE,
      YarnConfiguration.DEFAULT_TIMELINE_SERVICE_LEVELDB_READ_CACHE_SIZE));
  JniDBFactory factory = new JniDBFactory();
  String path = conf.get(YarnConfiguration.TIMELINE_SERVICE_LEVELDB_PATH);
  File p = new File(path);
  if (!p.exists()) {
    if (!p.mkdirs()) {
      throw new IOException("Couldn't create directory for leveldb " +
          "timeline store " + path);
    }
  }
  LOG.info("Using leveldb path " + path);
  db = factory.open(new File(path, FILENAME), options);
  startTimeWriteCache =
      Collections.synchronizedMap(new LRUMap(getStartTimeWriteCacheSize(
          conf)));
  startTimeReadCache =
      Collections.synchronizedMap(new LRUMap(getStartTimeReadCacheSize(
          conf)));

  if (conf.getBoolean(YarnConfiguration.TIMELINE_SERVICE_TTL_ENABLE, true)) {
    deletionThread = new EntityDeletionThread(conf);
    deletionThread.start();
  }

  super.serviceInit(conf);
}
项目:oscar-old    文件:PreventionManager.java   
public PreventionManager() {
    demoPrevs = new LRUMap(MAXITEMS);
    mShell = new HashMap<String,LRUMap>(1);
    mShell.put(PREVS, demoPrevs);
    mShell = Collections.synchronizedMap(mShell);        
    pf = PreventionDS.getInstance();
}
项目:longneck-lookup    文件:TranslateCache.java   
@SuppressWarnings("unchecked")
@Override
public TranslateCache clone() {
    TranslateCache translateCache = (TranslateCache) super.clone();
    translateCache.cache = (Map<String, Field>) (Collections.synchronizedMap(new LRUMap(size)));
    translateCache.translate = translate.clone();
    return translateCache;
}
项目:longneck-weblog    文件:AbstractCachingPostProcessor.java   
@SuppressWarnings("unchecked")
protected void initCache() {
    threadLocalCache = new ThreadLocal<Map<String, List<Field>>>() {
        @Override
        protected Map<String, List<Field>> initialValue() {
            return new LRUMap(100);
        }
    };
}
项目:apache-jmeter-2.10    文件:AbstractJDBCTestElement.java   
private PreparedStatement getPreparedStatement(Connection conn, boolean callable) throws SQLException {
    Map<String, PreparedStatement> preparedStatementMap = perConnCache.get(conn);
    if (null == preparedStatementMap ) {
        @SuppressWarnings("unchecked") // LRUMap is not generic
        Map<String, PreparedStatement> lruMap = new LRUMap(MAX_OPEN_PREPARED_STATEMENTS) {
            private static final long serialVersionUID = 1L;
            @Override
            protected boolean removeLRU(LinkEntry entry) {
                PreparedStatement preparedStatement = (PreparedStatement)entry.getValue();
                close(preparedStatement);
                return true;
            }
        };
        preparedStatementMap = Collections.<String, PreparedStatement>synchronizedMap(lruMap);
        // As a connection is held by only one thread, we cannot already have a 
        // preparedStatementMap put by another thread
        perConnCache.put(conn, preparedStatementMap);
    }
    PreparedStatement pstmt = preparedStatementMap.get(getQuery());
    if (null == pstmt) {
        if (callable) {
            pstmt = conn.prepareCall(getQuery());
        } else {
            pstmt = conn.prepareStatement(getQuery());
        }
        pstmt.setQueryTimeout(getIntegerQueryTimeout());
        // PreparedStatementMap is associated to one connection so 
        //  2 threads cannot use the same PreparedStatement map at the same time
        preparedStatementMap.put(getQuery(), pstmt);
    } else {
        int timeoutInS = getIntegerQueryTimeout();
        if(pstmt.getQueryTimeout() != timeoutInS) {
            pstmt.setQueryTimeout(getIntegerQueryTimeout());
        }
    }
    pstmt.clearParameters();
    return pstmt;
}
项目:apache-jmeter-2.10    文件:CacheManager.java   
private void clearCache() {
    log.debug("Clear cache");
    threadCache = new InheritableThreadLocal<Map<String, CacheEntry>>(){
        @Override
        protected Map<String, CacheEntry> initialValue(){
            // Bug 51942 - this map may be used from multiple threads
            @SuppressWarnings("unchecked") // LRUMap is not generic currently
            Map<String, CacheEntry> map = new LRUMap(getMaxSize());
            return Collections.<String, CacheEntry>synchronizedMap(map);
        }
    };
}
项目:windup    文件:ClassificationServiceCache.java   
/**
 * Keep a cache of items files associated with classification in order to improve performance.
 */
@SuppressWarnings("unchecked")
private static synchronized Map<String, Boolean> getCache(GraphRewrite event)
{
    Map<String, Boolean> result = (Map<String, Boolean>)event.getRewriteContext().get(ClassificationServiceCache.class);
    if (result == null)
    {
        result = Collections.synchronizedMap(new LRUMap(30000));
        event.getRewriteContext().put(ClassificationServiceCache.class, result);
    }
    return result;
}
项目:directory-mavibot    文件:PersistedBTree.java   
/**
 * Return the cache we use in this BTree
 */
/* No qualifier */LRUMap getCache()
{
    return cache;
}
项目:hadoop    文件:TimelineACLsManager.java   
@SuppressWarnings("unchecked")
public TimelineACLsManager(Configuration conf) {
  this.adminAclsManager = new AdminACLsManager(conf);
  aclExts = Collections.synchronizedMap(
      new LRUMap(DOMAIN_ACCESS_ENTRY_CACHE_SIZE));
}
项目:hadoop    文件:LeveldbTimelineStore.java   
@Override
@SuppressWarnings("unchecked")
protected void serviceInit(Configuration conf) throws Exception {
  Preconditions.checkArgument(conf.getLong(
      YarnConfiguration.TIMELINE_SERVICE_TTL_MS,
      YarnConfiguration.DEFAULT_TIMELINE_SERVICE_TTL_MS) > 0,
      "%s property value should be greater than zero",
      YarnConfiguration.TIMELINE_SERVICE_TTL_MS);
  Preconditions.checkArgument(conf.getLong(
      YarnConfiguration.TIMELINE_SERVICE_LEVELDB_TTL_INTERVAL_MS,
      YarnConfiguration.DEFAULT_TIMELINE_SERVICE_LEVELDB_TTL_INTERVAL_MS) > 0,
      "%s property value should be greater than zero",
      YarnConfiguration.TIMELINE_SERVICE_LEVELDB_TTL_INTERVAL_MS);
  Preconditions.checkArgument(conf.getLong(
      YarnConfiguration.TIMELINE_SERVICE_LEVELDB_READ_CACHE_SIZE,
      YarnConfiguration.DEFAULT_TIMELINE_SERVICE_LEVELDB_READ_CACHE_SIZE) >= 0,
      "%s property value should be greater than or equal to zero",
      YarnConfiguration.TIMELINE_SERVICE_LEVELDB_READ_CACHE_SIZE);
  Preconditions.checkArgument(conf.getLong(
      YarnConfiguration.TIMELINE_SERVICE_LEVELDB_START_TIME_READ_CACHE_SIZE,
      YarnConfiguration.DEFAULT_TIMELINE_SERVICE_LEVELDB_START_TIME_READ_CACHE_SIZE) > 0,
      " %s property value should be greater than zero",
      YarnConfiguration.TIMELINE_SERVICE_LEVELDB_START_TIME_READ_CACHE_SIZE);
  Preconditions.checkArgument(conf.getLong(
      YarnConfiguration.TIMELINE_SERVICE_LEVELDB_START_TIME_WRITE_CACHE_SIZE,
      YarnConfiguration.DEFAULT_TIMELINE_SERVICE_LEVELDB_START_TIME_WRITE_CACHE_SIZE) > 0,
      "%s property value should be greater than zero",
      YarnConfiguration.TIMELINE_SERVICE_LEVELDB_START_TIME_WRITE_CACHE_SIZE);

  Options options = new Options();
  options.createIfMissing(true);
  options.cacheSize(conf.getLong(
      YarnConfiguration.TIMELINE_SERVICE_LEVELDB_READ_CACHE_SIZE,
      YarnConfiguration.DEFAULT_TIMELINE_SERVICE_LEVELDB_READ_CACHE_SIZE));
  JniDBFactory factory = new JniDBFactory();
  Path dbPath = new Path(
      conf.get(YarnConfiguration.TIMELINE_SERVICE_LEVELDB_PATH), FILENAME);
  FileSystem localFS = null;
  try {
    localFS = FileSystem.getLocal(conf);
    if (!localFS.exists(dbPath)) {
      if (!localFS.mkdirs(dbPath)) {
        throw new IOException("Couldn't create directory for leveldb " +
            "timeline store " + dbPath);
      }
      localFS.setPermission(dbPath, LEVELDB_DIR_UMASK);
    }
  } finally {
    IOUtils.cleanup(LOG, localFS);
  }
  LOG.info("Using leveldb path " + dbPath);
  db = factory.open(new File(dbPath.toString()), options);
  checkVersion();
  startTimeWriteCache =
      Collections.synchronizedMap(new LRUMap(getStartTimeWriteCacheSize(
          conf)));
  startTimeReadCache =
      Collections.synchronizedMap(new LRUMap(getStartTimeReadCacheSize(
          conf)));

  if (conf.getBoolean(YarnConfiguration.TIMELINE_SERVICE_TTL_ENABLE, true)) {
    deletionThread = new EntityDeletionThread(conf);
    deletionThread.start();
  }

  super.serviceInit(conf);
}
项目:aliyun-oss-hadoop-fs    文件:TimelineACLsManager.java   
@SuppressWarnings("unchecked")
public TimelineACLsManager(Configuration conf) {
  this.adminAclsManager = new AdminACLsManager(conf);
  aclExts = Collections.synchronizedMap(
      new LRUMap(DOMAIN_ACCESS_ENTRY_CACHE_SIZE));
}
项目:aliyun-oss-hadoop-fs    文件:LeveldbTimelineStore.java   
@Override
@SuppressWarnings("unchecked")
protected void serviceInit(Configuration conf) throws Exception {
  Preconditions.checkArgument(conf.getLong(
      YarnConfiguration.TIMELINE_SERVICE_TTL_MS,
      YarnConfiguration.DEFAULT_TIMELINE_SERVICE_TTL_MS) > 0,
      "%s property value should be greater than zero",
      YarnConfiguration.TIMELINE_SERVICE_TTL_MS);
  Preconditions.checkArgument(conf.getLong(
      YarnConfiguration.TIMELINE_SERVICE_LEVELDB_TTL_INTERVAL_MS,
      YarnConfiguration.DEFAULT_TIMELINE_SERVICE_LEVELDB_TTL_INTERVAL_MS) > 0,
      "%s property value should be greater than zero",
      YarnConfiguration.TIMELINE_SERVICE_LEVELDB_TTL_INTERVAL_MS);
  Preconditions.checkArgument(conf.getLong(
      YarnConfiguration.TIMELINE_SERVICE_LEVELDB_READ_CACHE_SIZE,
      YarnConfiguration.DEFAULT_TIMELINE_SERVICE_LEVELDB_READ_CACHE_SIZE) >= 0,
      "%s property value should be greater than or equal to zero",
      YarnConfiguration.TIMELINE_SERVICE_LEVELDB_READ_CACHE_SIZE);
  Preconditions.checkArgument(conf.getLong(
      YarnConfiguration.TIMELINE_SERVICE_LEVELDB_START_TIME_READ_CACHE_SIZE,
      YarnConfiguration.DEFAULT_TIMELINE_SERVICE_LEVELDB_START_TIME_READ_CACHE_SIZE) > 0,
      " %s property value should be greater than zero",
      YarnConfiguration.TIMELINE_SERVICE_LEVELDB_START_TIME_READ_CACHE_SIZE);
  Preconditions.checkArgument(conf.getLong(
      YarnConfiguration.TIMELINE_SERVICE_LEVELDB_START_TIME_WRITE_CACHE_SIZE,
      YarnConfiguration.DEFAULT_TIMELINE_SERVICE_LEVELDB_START_TIME_WRITE_CACHE_SIZE) > 0,
      "%s property value should be greater than zero",
      YarnConfiguration.TIMELINE_SERVICE_LEVELDB_START_TIME_WRITE_CACHE_SIZE);

  Options options = new Options();
  options.createIfMissing(true);
  options.cacheSize(conf.getLong(
      YarnConfiguration.TIMELINE_SERVICE_LEVELDB_READ_CACHE_SIZE,
      YarnConfiguration.DEFAULT_TIMELINE_SERVICE_LEVELDB_READ_CACHE_SIZE));
  JniDBFactory factory = new JniDBFactory();
  Path dbPath = new Path(
      conf.get(YarnConfiguration.TIMELINE_SERVICE_LEVELDB_PATH), FILENAME);
  FileSystem localFS = null;
  try {
    localFS = FileSystem.getLocal(conf);
    if (!localFS.exists(dbPath)) {
      if (!localFS.mkdirs(dbPath)) {
        throw new IOException("Couldn't create directory for leveldb " +
            "timeline store " + dbPath);
      }
      localFS.setPermission(dbPath, LEVELDB_DIR_UMASK);
    }
  } finally {
    IOUtils.cleanup(LOG, localFS);
  }
  LOG.info("Using leveldb path " + dbPath);
  db = factory.open(new File(dbPath.toString()), options);
  checkVersion();
  startTimeWriteCache =
      Collections.synchronizedMap(new LRUMap(getStartTimeWriteCacheSize(
          conf)));
  startTimeReadCache =
      Collections.synchronizedMap(new LRUMap(getStartTimeReadCacheSize(
          conf)));

  if (conf.getBoolean(YarnConfiguration.TIMELINE_SERVICE_TTL_ENABLE, true)) {
    deletionThread = new EntityDeletionThread(conf);
    deletionThread.start();
  }

  super.serviceInit(conf);
}
项目:scribe    文件:CRMSessionCache.java   
public CRMSessionCache() {
  cacheMap = new LRUMap(mcq);
  initialize();
}
项目:scribe    文件:CRMSessionCache.java   
public final void setCacheMap(final LRUMap cacheMap) {
  this.cacheMap = cacheMap;
}
项目:scribe    文件:CRMSessionCache.java   
public final LRUMap getCacheMap() {
  return cacheMap;
}
项目:leopard    文件:SynchronizedLRUMap.java   
@SuppressWarnings("unchecked")
public SynchronizedLRUMap(int initialEntries, int maxEntries) {
    this.map = Collections.synchronizedMap(new LRUMap(maxEntries));
}
项目:leopard    文件:SynchronizedLRUMap.java   
@SuppressWarnings("unchecked")
public SynchronizedLRUMap(int initialEntries, int maxEntries) {
    this.map = Collections.synchronizedMap(new LRUMap(maxEntries));
}
项目:big-c    文件:TimelineACLsManager.java   
@SuppressWarnings("unchecked")
public TimelineACLsManager(Configuration conf) {
  this.adminAclsManager = new AdminACLsManager(conf);
  aclExts = Collections.synchronizedMap(
      new LRUMap(DOMAIN_ACCESS_ENTRY_CACHE_SIZE));
}
项目:big-c    文件:LeveldbTimelineStore.java   
@Override
@SuppressWarnings("unchecked")
protected void serviceInit(Configuration conf) throws Exception {
  Preconditions.checkArgument(conf.getLong(
      YarnConfiguration.TIMELINE_SERVICE_TTL_MS,
      YarnConfiguration.DEFAULT_TIMELINE_SERVICE_TTL_MS) > 0,
      "%s property value should be greater than zero",
      YarnConfiguration.TIMELINE_SERVICE_TTL_MS);
  Preconditions.checkArgument(conf.getLong(
      YarnConfiguration.TIMELINE_SERVICE_LEVELDB_TTL_INTERVAL_MS,
      YarnConfiguration.DEFAULT_TIMELINE_SERVICE_LEVELDB_TTL_INTERVAL_MS) > 0,
      "%s property value should be greater than zero",
      YarnConfiguration.TIMELINE_SERVICE_LEVELDB_TTL_INTERVAL_MS);
  Preconditions.checkArgument(conf.getLong(
      YarnConfiguration.TIMELINE_SERVICE_LEVELDB_READ_CACHE_SIZE,
      YarnConfiguration.DEFAULT_TIMELINE_SERVICE_LEVELDB_READ_CACHE_SIZE) >= 0,
      "%s property value should be greater than or equal to zero",
      YarnConfiguration.TIMELINE_SERVICE_LEVELDB_READ_CACHE_SIZE);
  Preconditions.checkArgument(conf.getLong(
      YarnConfiguration.TIMELINE_SERVICE_LEVELDB_START_TIME_READ_CACHE_SIZE,
      YarnConfiguration.DEFAULT_TIMELINE_SERVICE_LEVELDB_START_TIME_READ_CACHE_SIZE) > 0,
      " %s property value should be greater than zero",
      YarnConfiguration.TIMELINE_SERVICE_LEVELDB_START_TIME_READ_CACHE_SIZE);
  Preconditions.checkArgument(conf.getLong(
      YarnConfiguration.TIMELINE_SERVICE_LEVELDB_START_TIME_WRITE_CACHE_SIZE,
      YarnConfiguration.DEFAULT_TIMELINE_SERVICE_LEVELDB_START_TIME_WRITE_CACHE_SIZE) > 0,
      "%s property value should be greater than zero",
      YarnConfiguration.TIMELINE_SERVICE_LEVELDB_START_TIME_WRITE_CACHE_SIZE);

  Options options = new Options();
  options.createIfMissing(true);
  options.cacheSize(conf.getLong(
      YarnConfiguration.TIMELINE_SERVICE_LEVELDB_READ_CACHE_SIZE,
      YarnConfiguration.DEFAULT_TIMELINE_SERVICE_LEVELDB_READ_CACHE_SIZE));
  JniDBFactory factory = new JniDBFactory();
  Path dbPath = new Path(
      conf.get(YarnConfiguration.TIMELINE_SERVICE_LEVELDB_PATH), FILENAME);
  FileSystem localFS = null;
  try {
    localFS = FileSystem.getLocal(conf);
    if (!localFS.exists(dbPath)) {
      if (!localFS.mkdirs(dbPath)) {
        throw new IOException("Couldn't create directory for leveldb " +
            "timeline store " + dbPath);
      }
      localFS.setPermission(dbPath, LEVELDB_DIR_UMASK);
    }
  } finally {
    IOUtils.cleanup(LOG, localFS);
  }
  LOG.info("Using leveldb path " + dbPath);
  db = factory.open(new File(dbPath.toString()), options);
  checkVersion();
  startTimeWriteCache =
      Collections.synchronizedMap(new LRUMap(getStartTimeWriteCacheSize(
          conf)));
  startTimeReadCache =
      Collections.synchronizedMap(new LRUMap(getStartTimeReadCacheSize(
          conf)));

  if (conf.getBoolean(YarnConfiguration.TIMELINE_SERVICE_TTL_ENABLE, true)) {
    deletionThread = new EntityDeletionThread(conf);
    deletionThread.start();
  }

  super.serviceInit(conf);
}
项目:hadoop-2.6.0-cdh5.4.3    文件:TimelineACLsManager.java   
@SuppressWarnings("unchecked")
public TimelineACLsManager(Configuration conf) {
  this.adminAclsManager = new AdminACLsManager(conf);
  aclExts = Collections.synchronizedMap(
      new LRUMap(DOMAIN_ACCESS_ENTRY_CACHE_SIZE));
}
项目:hadoop-2.6.0-cdh5.4.3    文件:LeveldbTimelineStore.java   
@Override
@SuppressWarnings("unchecked")
protected void serviceInit(Configuration conf) throws Exception {
  Options options = new Options();
  options.createIfMissing(true);
  options.cacheSize(conf.getLong(
      YarnConfiguration.TIMELINE_SERVICE_LEVELDB_READ_CACHE_SIZE,
      YarnConfiguration.DEFAULT_TIMELINE_SERVICE_LEVELDB_READ_CACHE_SIZE));
  JniDBFactory factory = new JniDBFactory();
  Path dbPath = new Path(
      conf.get(YarnConfiguration.TIMELINE_SERVICE_LEVELDB_PATH), FILENAME);
  FileSystem localFS = null;
  try {
    localFS = FileSystem.getLocal(conf);
    if (!localFS.exists(dbPath)) {
      if (!localFS.mkdirs(dbPath)) {
        throw new IOException("Couldn't create directory for leveldb " +
            "timeline store " + dbPath);
      }
      localFS.setPermission(dbPath, LEVELDB_DIR_UMASK);
    }
  } finally {
    IOUtils.cleanup(LOG, localFS);
  }
  LOG.info("Using leveldb path " + dbPath);
  db = factory.open(new File(dbPath.toString()), options);
  checkVersion();
  startTimeWriteCache =
      Collections.synchronizedMap(new LRUMap(getStartTimeWriteCacheSize(
          conf)));
  startTimeReadCache =
      Collections.synchronizedMap(new LRUMap(getStartTimeReadCacheSize(
          conf)));

  if (conf.getBoolean(YarnConfiguration.TIMELINE_SERVICE_TTL_ENABLE, true)) {
    deletionThread = new EntityDeletionThread(conf);
    deletionThread.start();
  }

  super.serviceInit(conf);
}
项目:oiosaml.java    文件:SingleVMSessionHandler.java   
public void resetReplayProtection(int maxNum) {
    usedAssertionIds = new LRUMap(maxNum);
}
项目:oiosaml.java    文件:SingleVMSessionHandler.java   
public void resetReplayProtection(int maxNum) {
    usedAssertionIds = new LRUMap(maxNum);
}
项目:eHMP    文件:AjaxHandlerExceptionResolver.java   
public void setExceptionHistorySize(int size) {
    history = new LRUMap(size);
}
项目:leopard-data    文件:SynchronizedLRUMap.java   
@SuppressWarnings("unchecked")
public SynchronizedLRUMap(int initialEntries, int maxEntries) {
    this.map = Collections.synchronizedMap(new LRUMap(maxEntries));
}
项目:hops    文件:TimelineACLsManager.java   
@SuppressWarnings("unchecked")
public TimelineACLsManager(Configuration conf) {
  this.adminAclsManager = new AdminACLsManager(conf);
  aclExts = Collections.synchronizedMap(
      new LRUMap(DOMAIN_ACCESS_ENTRY_CACHE_SIZE));
}
项目:hops    文件:LeveldbTimelineStore.java   
@Override
@SuppressWarnings("unchecked")
protected void serviceInit(Configuration conf) throws Exception {
  Preconditions.checkArgument(conf.getLong(
      YarnConfiguration.TIMELINE_SERVICE_TTL_MS,
      YarnConfiguration.DEFAULT_TIMELINE_SERVICE_TTL_MS) > 0,
      "%s property value should be greater than zero",
      YarnConfiguration.TIMELINE_SERVICE_TTL_MS);
  Preconditions.checkArgument(conf.getLong(
      YarnConfiguration.TIMELINE_SERVICE_LEVELDB_TTL_INTERVAL_MS,
      YarnConfiguration.DEFAULT_TIMELINE_SERVICE_LEVELDB_TTL_INTERVAL_MS) > 0,
      "%s property value should be greater than zero",
      YarnConfiguration.TIMELINE_SERVICE_LEVELDB_TTL_INTERVAL_MS);
  Preconditions.checkArgument(conf.getLong(
      YarnConfiguration.TIMELINE_SERVICE_LEVELDB_READ_CACHE_SIZE,
      YarnConfiguration.DEFAULT_TIMELINE_SERVICE_LEVELDB_READ_CACHE_SIZE) >= 0,
      "%s property value should be greater than or equal to zero",
      YarnConfiguration.TIMELINE_SERVICE_LEVELDB_READ_CACHE_SIZE);
  Preconditions.checkArgument(conf.getLong(
      YarnConfiguration.TIMELINE_SERVICE_LEVELDB_START_TIME_READ_CACHE_SIZE,
      YarnConfiguration.DEFAULT_TIMELINE_SERVICE_LEVELDB_START_TIME_READ_CACHE_SIZE) > 0,
      " %s property value should be greater than zero",
      YarnConfiguration.TIMELINE_SERVICE_LEVELDB_START_TIME_READ_CACHE_SIZE);
  Preconditions.checkArgument(conf.getLong(
      YarnConfiguration.TIMELINE_SERVICE_LEVELDB_START_TIME_WRITE_CACHE_SIZE,
      YarnConfiguration.DEFAULT_TIMELINE_SERVICE_LEVELDB_START_TIME_WRITE_CACHE_SIZE) > 0,
      "%s property value should be greater than zero",
      YarnConfiguration.TIMELINE_SERVICE_LEVELDB_START_TIME_WRITE_CACHE_SIZE);

  Options options = new Options();
  options.createIfMissing(true);
  options.cacheSize(conf.getLong(
      YarnConfiguration.TIMELINE_SERVICE_LEVELDB_READ_CACHE_SIZE,
      YarnConfiguration.DEFAULT_TIMELINE_SERVICE_LEVELDB_READ_CACHE_SIZE));
  JniDBFactory factory = new JniDBFactory();
  Path dbPath = new Path(
      conf.get(YarnConfiguration.TIMELINE_SERVICE_LEVELDB_PATH), FILENAME);
  FileSystem localFS = null;
  try {
    localFS = FileSystem.getLocal(conf);
    if (!localFS.exists(dbPath)) {
      if (!localFS.mkdirs(dbPath)) {
        throw new IOException("Couldn't create directory for leveldb " +
            "timeline store " + dbPath);
      }
      localFS.setPermission(dbPath, LEVELDB_DIR_UMASK);
    }
  } finally {
    IOUtils.cleanup(LOG, localFS);
  }
  LOG.info("Using leveldb path " + dbPath);
  db = factory.open(new File(dbPath.toString()), options);
  checkVersion();
  startTimeWriteCache =
      Collections.synchronizedMap(new LRUMap(getStartTimeWriteCacheSize(
          conf)));
  startTimeReadCache =
      Collections.synchronizedMap(new LRUMap(getStartTimeReadCacheSize(
          conf)));

  if (conf.getBoolean(YarnConfiguration.TIMELINE_SERVICE_TTL_ENABLE, true)) {
    deletionThread = new EntityDeletionThread(conf);
    deletionThread.start();
  }

  super.serviceInit(conf);
}
项目:imcms    文件:CachingFileLoader.java   
@SuppressWarnings("unchecked")
private <K, V> Map<K, V> createSynchroMapWithInitialSize(int size) {
    return Collections.synchronizedMap((Map<K, V>) new LRUMap(size));
}
项目:registry-core    文件:DescriptionCache.java   
public DescriptionCache(int size) {
    cache = new LRUMap(size);
}