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

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

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

Bucket.name介绍

[英]The name of the Bucket.
[中]桶的名称。

代码示例

代码示例来源:origin: apache/nifi

/**
 * Generate a transit url.
 *
 * @param bucket the target bucket
 * @return a transit url based on the bucket name and the CouchbaseClusterControllerService name
 */
protected String getTransitUrl(final Bucket bucket, final String docId) {
  return "couchbase://" + bucket.name() + "/" + docId;
}

代码示例来源:origin: testcontainers/testcontainers-java

@Override
  protected void waitUntilReady() {
    log.info("Waiting for {} seconds for QUERY service", startupTimeout.getSeconds());

    // try to connect to the URL
    try {
      retryUntilSuccess((int) startupTimeout.getSeconds(), TimeUnit.SECONDS, () -> {
        getRateLimiter().doWhenReady(() -> {
          GetClusterConfigResponse clusterConfig = bucket.core()
            .<GetClusterConfigResponse>send(new GetClusterConfigRequest())
            .toBlocking().single();
          boolean queryServiceEnabled = clusterConfig.config()
            .bucketConfig(bucket.name())
            .serviceEnabled(ServiceType.QUERY);
          if (!queryServiceEnabled) {
            throw new ContainerLaunchException("Query service not ready yet");
          }
        });
        return true;
      });
    } catch (TimeoutException e) {
      throw new ContainerLaunchException("Timed out waiting for QUERY service");
    }
  }
}

代码示例来源:origin: testcontainers/testcontainers-java

@After
public void clear() {
  if (getCouchbaseContainer().isIndex() && getCouchbaseContainer().isQuery() && getCouchbaseContainer().isPrimaryIndex()) {
    getBucket().query(
      N1qlQuery.simple(String.format("DELETE FROM `%s`", getBucket().name()),
        N1qlParams.build().consistency(ScanConsistency.STATEMENT_PLUS)));
  } else {
    getBucket().bucketManager().flush();
  }
}

代码示例来源:origin: apache/nifi

updatedAttrs.put(CouchbaseAttributes.Bucket.key(), bucket.name());
updatedAttrs.put(CouchbaseAttributes.DocId.key(), docId);
updatedAttrs.put(CouchbaseAttributes.Cas.key(), String.valueOf(doc.cas()));

代码示例来源:origin: apache/nifi

updatedAttrs.put(CouchbaseAttributes.Bucket.key(), bucket.name());
updatedAttrs.put(CouchbaseAttributes.DocId.key(), docId);
updatedAttrs.put(CouchbaseAttributes.Cas.key(), String.valueOf(doc.cas()));

代码示例来源:origin: Impetus/Kundera

/**
 * Close bucket.
 *
 * @param bucket
 *            the bucket
 */
public static void closeBucket(Bucket bucket)
{
  if (bucket != null)
  {
    if (!bucket.close())
    {
      LOGGER.error("Not able to close bucket [" + bucket.name() + "].");
      throw new KunderaException("Not able to close bucket [" + bucket.name() + "].");
    }
    else
    {
      LOGGER.debug("Bucket [" + bucket.name() + "] is closed!");
    }
  }
}

代码示例来源:origin: Impetus/Kundera

@Override
protected void delete(Object entity, Object pKey)
{
  EntityMetadata entityMetadata = KunderaMetadataManager.getEntityMetadata(kunderaMetadata, entity.getClass());
  String id = generateJsonDocId(entityMetadata.getTableName(), pKey.toString());
  bucket.remove(id);
  LOGGER.debug("Deleted document with ID : " + id + " from the " + bucket.name() + " Bucket");
}

代码示例来源:origin: Impetus/Kundera

@Override
protected void onPersist(EntityMetadata entityMetadata, Object entity, Object id, List<RelationHolder> rlHolders)
{
  JsonDocument doc = handler.getDocumentFromEntity(entityMetadata, entity, kunderaMetadata);
  if (!isUpdate)
  {
    bucket.insert(doc);
    LOGGER.debug("Inserted document with ID : " + doc.id() + " in the " + bucket.name() + " Bucket");
  }
  else
  {
    bucket.upsert(doc);
    LOGGER.debug("Updated document with ID : " + doc.id() + " in the " + bucket.name() + " Bucket");
  }
}

代码示例来源:origin: Impetus/Kundera

@Override
public void destroy()
{
  indexManager.close();
  if (schemaManager != null)
  {
    schemaManager.dropSchema();
  }
  if (bucket != null)
  {
    LOGGER.info("Closing bucket " + bucket.name() + ".");
    CouchbaseBucketUtils.closeBucket(bucket);
    LOGGER.info("Closed bucket " + bucket.name() + ".");
  }
  if (cluster != null)
  {
    LOGGER.info("Closing connection to couchbase.");
    cluster.disconnect();
    LOGGER.info("Closed connection to couchbase.");
  }
  else
  {
    LOGGER.warn("Can't close connection to Couchbase, it was already disconnected");
  }
  externalProperties = null;
  schemaManager = null;
}

代码示例来源:origin: Impetus/Kundera

/**
 * Execute native query.
 *
 * @param n1qlQuery
 *            the n1ql query
 * @param em
 *            the entity manager
 * @return the list
 */
public List executeNativeQuery(String n1qlQuery, EntityMetadata em)
{
  N1qlQueryResult result = bucket
      .query(N1qlQuery.simple(n1qlQuery, N1qlParams.build().consistency(ScanConsistency.REQUEST_PLUS)));
  LOGGER.debug("Executed query : " + n1qlQuery + " on the " + bucket.name() + " Bucket");
  validateQueryResults(n1qlQuery, result);
  return result.allRows();
}

代码示例来源:origin: Impetus/Kundera

@Override
public Object find(Class entityClass, Object key)
{
  EntityMetadata entityMetadata = KunderaMetadataManager.getEntityMetadata(kunderaMetadata, entityClass);
  JsonDocument doc;
  String id = generateJsonDocId(entityMetadata.getTableName(), key.toString());
  doc = bucket.get(id);
  LOGGER.debug("Found result for ID : " + key.toString() + " in the " + bucket.name() + " Bucket");
  if (doc == null)
  {
    return null;
  }
  else
  {
    MetamodelImpl metaModel = (MetamodelImpl) kunderaMetadata.getApplicationMetadata()
        .getMetamodel(entityMetadata.getPersistenceUnit());
    EntityType entityType = metaModel.entity(entityMetadata.getEntityClazz());
    return handler.getEntityFromDocument(entityClass, doc.content(), entityType);
  }
}

代码示例来源:origin: Impetus/Kundera

/**
 * Execute query.
 *
 * @param stmt
 *            the statement
 * @param em
 *            the entity manager
 * @return the list
 */
public List executeQuery(Statement stmt, EntityMetadata em)
{
  N1qlQuery query = N1qlQuery.simple(stmt, N1qlParams.build().consistency(ScanConsistency.REQUEST_PLUS));
  N1qlQueryResult list = bucket.query(query);
  LOGGER.debug("Executed query : " + query.toString() + " on the " + bucket.name() + " Bucket");
  validateQueryResults(stmt.toString(), list);
  List records = new ArrayList<>();
  for (N1qlQueryRow row : list)
  {
    MetamodelImpl metaModel = (MetamodelImpl) kunderaMetadata.getApplicationMetadata()
        .getMetamodel(em.getPersistenceUnit());
    EntityType entityType = metaModel.entity(em.getEntityClazz());
    JsonObject jsonObj = row.value().containsKey(em.getSchema()) ? row.value().getObject(em.getSchema())
        : row.value();
    records.add(handler.getEntityFromDocument(em.getEntityClazz(), jsonObj, entityType));
  }
  return records;
}

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

@Override
  public void call(ClusterConfig config) {
    bucketConfig.set(config.bucketConfig(bucket.name()));
  }
});

代码示例来源:origin: couchbase/couchbase-elasticsearch-connector

public static CouchbaseBucketConfig getBucketConfig(Bucket bucket) {
 final GetClusterConfigResponse response = (GetClusterConfigResponse) bucket.core().send(
   new GetClusterConfigRequest()).toBlocking().single();
 return (CouchbaseBucketConfig) response.config().bucketConfig(bucket.name());
}

代码示例来源:origin: org.slinkyframework/slinky-environment-builder-couchbase

private void createPrimaryIndex(Bucket bucket, CouchbaseBuildDefinition buildDefinition) {
  LOG.debug("Creating primary index in bucket '{}'", buildDefinition.getBucketName());
  N1qlQueryResult result = bucket.query(N1qlQuery.simple(
      Index.createPrimaryIndex().on(bucket.name())
  ));
  if (!result.finalSuccess()) {
    LOG.error("Failed to create primary index: {}", result.errors());
    throw new EnvironmentBuilderException("Failed to create primary index for " + buildDefinition.getBucketName());
  }
  LOG.debug("Primary index created in bucket '{}'", buildDefinition.getBucketName());
}

代码示例来源:origin: spring-projects/spring-data-couchbase

public ReactiveStringN1qlBasedQuery(String statement,
                  CouchbaseQueryMethod queryMethod,
                  RxJavaCouchbaseOperations couchbaseOperations,
                  SpelExpressionParser spelParser,
                  QueryMethodEvaluationContextProvider evaluationContextProvider) {
  super(queryMethod, couchbaseOperations);
  this.queryParser = new StringBasedN1qlQueryParser(statement, queryMethod,
      getCouchbaseOperations().getCouchbaseBucket().name(), getCouchbaseOperations().getConverter(), getTypeField(), getTypeValue());
  this.parser = spelParser;
  this.evaluationContextProvider = evaluationContextProvider;
}

代码示例来源:origin: org.springframework.data/spring-data-couchbase

public StringN1qlBasedQuery(String statement, CouchbaseQueryMethod queryMethod, CouchbaseOperations couchbaseOperations,
              SpelExpressionParser spelParser, QueryMethodEvaluationContextProvider evaluationContextProvider) {
 super(queryMethod, couchbaseOperations);
 this.queryParser = new StringBasedN1qlQueryParser(statement, queryMethod,
     getCouchbaseOperations().getCouchbaseBucket().name(), getCouchbaseOperations().getConverter(), getTypeField(), getTypeValue());
 this.parser = spelParser;
 this.evaluationContextProvider = evaluationContextProvider;
}

代码示例来源:origin: org.springframework.data/spring-data-couchbase

public ReactiveStringN1qlBasedQuery(String statement,
                  CouchbaseQueryMethod queryMethod,
                  RxJavaCouchbaseOperations couchbaseOperations,
                  SpelExpressionParser spelParser,
                  QueryMethodEvaluationContextProvider evaluationContextProvider) {
  super(queryMethod, couchbaseOperations);
  this.queryParser = new StringBasedN1qlQueryParser(statement, queryMethod,
      getCouchbaseOperations().getCouchbaseBucket().name(), getCouchbaseOperations().getConverter(), getTypeField(), getTypeValue());
  this.parser = spelParser;
  this.evaluationContextProvider = evaluationContextProvider;
}

代码示例来源:origin: spring-projects/spring-data-couchbase

public StringN1qlBasedQuery(String statement, CouchbaseQueryMethod queryMethod, CouchbaseOperations couchbaseOperations,
              SpelExpressionParser spelParser, QueryMethodEvaluationContextProvider evaluationContextProvider) {
 super(queryMethod, couchbaseOperations);
 this.queryParser = new StringBasedN1qlQueryParser(statement, queryMethod,
     getCouchbaseOperations().getCouchbaseBucket().name(), getCouchbaseOperations().getConverter(), getTypeField(), getTypeValue());
 this.parser = spelParser;
 this.evaluationContextProvider = evaluationContextProvider;
}

代码示例来源:origin: spring-projects/spring-data-couchbase

@Override
protected Statement getCount(ParameterAccessor accessor, Object[] runtimeParameters) {
 Expression bucket = i(getCouchbaseOperations().getCouchbaseBucket().name());
 WherePath countFrom = select(count("*").as(CountFragment.COUNT_ALIAS)).from(bucket);
 N1qlCountQueryCreator queryCountCreator = new N1qlCountQueryCreator(partTree, accessor, countFrom,
   getCouchbaseOperations().getConverter(), getQueryMethod());
 Statement statement = queryCountCreator.createQuery();
 this.placeHolderValues = queryCountCreator.getPlaceHolderValues();
 return statement;
}

相关文章