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


Java RefCounted.incref方法代码示例

本文整理汇总了Java中org.apache.solr.util.RefCounted.incref方法的典型用法代码示例。如果您正苦于以下问题:Java RefCounted.incref方法的具体用法?Java RefCounted.incref怎么用?Java RefCounted.incref使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.solr.util.RefCounted的用法示例。


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

示例1: newHolder

import org.apache.solr.util.RefCounted; //导入方法依赖的package包/类
private RefCounted<SolrIndexSearcher> newHolder(SolrIndexSearcher newSearcher, final List<RefCounted<SolrIndexSearcher>> searcherList) {
  RefCounted<SolrIndexSearcher> holder = new RefCounted<SolrIndexSearcher>(newSearcher) {
    @Override
    public void close() {
      try {
        synchronized(searcherLock) {
          // it's possible for someone to get a reference via the _searchers queue
          // and increment the refcount while RefCounted.close() is being called.
          // we check the refcount again to see if this has happened and abort the close.
          // This relies on the RefCounted class allowing close() to be called every
          // time the counter hits zero.
          if (refcount.get() > 0) return;
          searcherList.remove(this);
        }
        resource.close();
      } catch (Exception e) {
        // do not allow decref() operations to fail since they are typically called in finally blocks
        // and throwing another exception would be very unexpected.
        SolrException.log(log, "Error closing searcher:" + this, e);
      }
    }
  };
  holder.incref();  // set ref count to 1 to account for this._searcher
  return holder;
}
 
开发者ID:europeana,项目名称:search,代码行数:26,代码来源:SolrCore.java

示例2: newHolder

import org.apache.solr.util.RefCounted; //导入方法依赖的package包/类
private RefCounted<SolrIndexSearcher> newHolder(SolrIndexSearcher newSearcher, final List<RefCounted<SolrIndexSearcher>> searcherList) {
  RefCounted<SolrIndexSearcher> holder = new RefCounted<SolrIndexSearcher>(newSearcher) {
    @Override
    public void close() {
      try {
        synchronized(searcherLock) {
          // it's possible for someone to get a reference via the _searchers queue
          // and increment the refcount while RefCounted.close() is being called.
          // we check the refcount again to see if this has happened and abort the close.
          // This relies on the RefCounted class allowing close() to be called every
          // time the counter hits zero.
          if (refcount.get() > 0) return;
          searcherList.remove(this);
        }
        resource.close();
      } catch (Throwable e) {
        // do not allow decref() operations to fail since they are typically called in finally blocks
        // and throwing another exception would be very unexpected.
        SolrException.log(log, "Error closing searcher:" + this, e);
      }
    }
  };
  holder.incref();  // set ref count to 1 to account for this._searcher
  return holder;
}
 
开发者ID:pkarmstr,项目名称:NYBC,代码行数:26,代码来源:SolrCore.java

示例3: newHolder

import org.apache.solr.util.RefCounted; //导入方法依赖的package包/类
private RefCounted<SolrIndexSearcher> newHolder(SolrIndexSearcher newSearcher, final List<RefCounted<SolrIndexSearcher>> searcherList) {
	RefCounted<SolrIndexSearcher> holder = new RefCounted<SolrIndexSearcher>(newSearcher) {
		@Override
		public void close() {
			try {
				synchronized(searcherLock) {
					// it's possible for someone to get a reference via the _searchers queue
					// and increment the refcount while RefCounted.close() is being called.
					// we check the refcount again to see if this has happened and abort the close.
					// This relies on the RefCounted class allowing close() to be called every
					// time the counter hits zero.
					if(refcount.get() > 0)
						return;
					searcherList.remove(this);
				}
				resource.close();
			} catch(Throwable e) {
				// do not allow decref() operations to fail since they are typically called in finally blocks
				// and throwing another exception would be very unexpected.
				SolrException.log(log, "Error closing searcher:" + this, e);
			}
		}
	};
	holder.incref(); // set ref count to 1 to account for this._searcher
	return holder;
}
 
开发者ID:netboynb,项目名称:search-core,代码行数:27,代码来源:SolrCore.java

示例4: getNewestSearcher

import org.apache.solr.util.RefCounted; //导入方法依赖的package包/类
/**
 * Return the newest normal {@link RefCounted}&lt;{@link SolrIndexSearcher}&gt; with
 * the reference count incremented.  It <b>must</b> be decremented when no longer needed.
 * If no searcher is currently open, then if openNew==true a new searcher will be opened,
 * or null is returned if openNew==false.
 */
public RefCounted<SolrIndexSearcher> getNewestSearcher(boolean openNew) {
  synchronized (searcherLock) {
    if (!_searchers.isEmpty()) {
      RefCounted<SolrIndexSearcher> newest = _searchers.getLast();
      newest.incref();
      return newest;
    }
  }

  return openNew ? getRealtimeSearcher() : null;
}
 
开发者ID:europeana,项目名称:search,代码行数:18,代码来源:SolrCore.java

示例5: getNewestSearcher

import org.apache.solr.util.RefCounted; //导入方法依赖的package包/类
/**
 * Return the newest normal {@link RefCounted}&lt;{@link SolrIndexSearcher}&gt; with the
 * reference count incremented. It <b>must</b> be decremented when no longer needed. If no
 * searcher is currently open, then if openNew==true a new searcher will be opened, or null is
 * returned if openNew==false.
 */
public RefCounted<SolrIndexSearcher> getNewestSearcher(boolean openNew) {
	synchronized(searcherLock) {
		if(!_searchers.isEmpty()) {
			RefCounted<SolrIndexSearcher> newest = _searchers.getLast();
			newest.incref();
			return newest;
		}
	}

	return openNew ? getRealtimeSearcher() : null;
}
 
开发者ID:netboynb,项目名称:search-core,代码行数:18,代码来源:SolrCore.java


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