com.couchbase.client.java.Bucket.isClosed()方法的使用及代码示例

x33g5p2x  于2022-01-16 转载在 其他  
字(1.7k)|赞(0)|评价(0)|浏览(134)

本文整理了Java中com.couchbase.client.java.Bucket.isClosed()方法的一些代码示例,展示了Bucket.isClosed()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Bucket.isClosed()方法的具体详情如下:
包路径:com.couchbase.client.java.Bucket
类名称:Bucket
方法名:isClosed

Bucket.isClosed介绍

[英]Returns true if this bucket is already closed, false if it is still open.
[中]如果此存储桶已关闭,则返回true;如果它仍然打开,则返回false。

代码示例

代码示例来源:origin: apache/incubator-gobblin

@Override
 public void close() {
  if (!_bucket.isClosed()) {
   try {
    _bucket.close();
   } catch (Exception e) {
    log.warn("Failed to close bucket", e);
   }
  }
  try {
   _cluster.disconnect();
  } catch (Exception e) {
   log.warn("Failed to disconnect from cluster", e);
  }
 }
}

代码示例来源:origin: neo4j-contrib/neo4j-apoc-procedures

private List<JsonObject> executeQuery(N1qlQuery query) {
    if(this.bucket.isClosed()){
      throw new RuntimeException("bucket has been closed before performing the query");
    }

    N1qlQueryResult queryResult = this.bucket.query(query);
    List<JsonObject> result = null;
    if (queryResult != null && queryResult.info().errorCount() == 0 && queryResult.info().resultCount() > 0) {
      result = new ArrayList<JsonObject>();
      for (N1qlQueryRow queryRow : queryResult) {
        result.add(queryRow.value());
      }
    }
    return result;
  }
}

代码示例来源:origin: com.couchbase.client/java-client

/**
 * Helper method to get a bucket instead of opening it if it is cached already.
 *
 * @param name the name of the bucket
 * @return the cached bucket if found, null if not.
 */
private Bucket getCachedBucket(final String name) {
  Bucket cachedBucket = bucketCache.get(name);
  if(cachedBucket != null) {
    if (cachedBucket.isClosed()) {
      LOGGER.debug("Not returning cached bucket \"{}\", because it is closed.", name);
      bucketCache.remove(name);
    } else {
      LOGGER.debug("Returning still open, cached bucket \"{}\"", name);
      return cachedBucket;
    }
  }
  return null;
}

相关文章