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

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

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

Bucket.bucketManager介绍

[英]Provides access to the BucketManager for administrative access. The manager lets you perform operations such as flushing a bucket or creating and managing design documents.
[中]提供BucketManager的管理访问权限。管理器允许您执行诸如刷新铲斗或创建和管理设计文档等操作。

代码示例

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

@Test
  public void shouldCreateView() {
    View view = DefaultView.create(VIEW_NAME, VIEW_FUNCTION);
    DesignDocument document = DesignDocument.create(VIEW_NAME, Lists.newArrayList(view));
    getBucket().bucketManager().insertDesignDocument(document);
    DesignDocument result = getBucket().bucketManager().getDesignDocument(VIEW_NAME);
    Assert.assertEquals(1, result.views().size());
    View resultView = result.views().get(0);
    Assert.assertEquals(VIEW_NAME, resultView.name());
  }
}

代码示例来源: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: Impetus/Kundera

/**
 * Creates the id index.
 *
 * @param bucketName
 *            the bucket name
 */
private void createIdIndex(String bucketName)
{
  Bucket bucket = null;
  try
  {
    bucket = CouchbaseBucketUtils.openBucket(cluster, bucketName, csmd.getBucketProperty("bucket.password"));
    /*
     * Ignoring if indexes pre-exist
     */
    bucket.bucketManager().createN1qlPrimaryIndex(buildIndexName(bucketName), true, false);
    LOGGER.debug("Niql primary Index are created for bucket [" + bucketName + "].");
  }
  catch (CouchbaseException cex)
  {
    LOGGER.error("Not able to create Niql primary index for bucket [" + bucketName + "].", cex);
    throw new KunderaException("Not able to create Niql primary index for bucket [" + bucketName + "].", cex);
  }
  finally
  {
    CouchbaseBucketUtils.closeBucket(bucket);
  }
}

代码示例来源:origin: lordofthejars/nosql-unit

private static String nextUniqueViewName(final Bucket bucket) {
    int i = 0;
    while (true) {
      final String proposal = (DESIGN_DOC_INTERNAL + (i++));
      final DesignDocument designDocument = bucket.bucketManager().getDesignDocument(proposal);
      if (designDocument == null) {
        return proposal;
      }
      LOGGER.trace("Invalid doc, keep trying. Now trying with {} " + proposal);
    }
  }
}

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

public ClusterInfo(final Bucket bucket) {
 this.template = new RestTemplate();
 this.bucket = bucket;
 this.info = bucket.bucketManager().info();
}

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

public ClientInfo(final Bucket bucket) {
 this.bucket = bucket;
 this.info = bucket.bucketManager().info();
}

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

public ClusterInfo(final Bucket bucket) {
 this.template = new RestTemplate();
 this.bucket = bucket;
 this.info = bucket.bucketManager().info();
}

代码示例来源:origin: org.arquillian.ape/arquillian-ape-nosql-couchbase

@Override
public void clean() {
  bucket.bucketManager().flush();
}

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

public ClientInfo(final Bucket bucket) {
 this.bucket = bucket;
 this.info = bucket.bucketManager().info();
}

代码示例来源:origin: rpatil26/webutilities

@Override
public void invalidateAll() {
  bucket.bucketManager().flush();
}

代码示例来源:origin: lordofthejars/nosql-unit

private static void deleteDesignDoc(final String freeDesignDocName, final Bucket bucket) {
  bucket.bucketManager().removeDesignDocument(freeDesignDocName);
}

代码示例来源:origin: lordofthejars/nosql-unit

private void removeDatabase() {
  bucket.bucketManager().flush();
}

代码示例来源:origin: lordofthejars/nosql-unit

private static DesignDocument createDesignDocAndView(final String freeDesignDocName, final Bucket bucket) {
  final String json = "function (doc, meta) {" + System.lineSeparator() +
      "   emit(null, null);" + System.lineSeparator() +
      "}";
  final List<View> views = Arrays.asList(DefaultView.create("allDocs", json));
  final DesignDocument designDocument = DesignDocument.create(freeDesignDocName, views);
  bucket.bucketManager().insertDesignDocument(designDocument);
  return designDocument;
}

代码示例来源:origin: ff4j/ff4j

/** {@inheritDoc} */
@Override
public void clear() {
  getFeatureBucket().bucketManager().flush();
}

代码示例来源:origin: ff4j/ff4j

/** {@inheritDoc} */
@Override
public void clear() {
  getPropertyBucket().bucketManager().flush();
}

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

private void createMapReduceViews(Bucket bucket, CouchbaseBuildDefinition buildDefinition) {
  LOG.debug("Creating {} views in '{}'", buildDefinition.getDesignDocuments().size(), buildDefinition.getBucketName());
  // Insert design document into the bucket
  BucketManager bucketManager = bucket.bucketManager();
  buildDefinition.getDesignDocuments().forEach(designDoc -> bucketManager.upsertDesignDocument(designDoc));
  LOG.debug("Views created in '{}'", buildDefinition.getBucketName());
}

代码示例来源:origin: org.jasig.cas/cas-server-support-couchbase-core

/**
 * Ensures that all views exists in the database.
 *
 * @param documentName the name of the design document.
 * @param views the views to ensure exists in the database.
 */
private void doEnsureIndexes(final String documentName, final List<View> views) {
  logger.debug("Ensure that indexes exist in bucket {}.", bucket.name());
  final DesignDocument newDocument = DesignDocument.create(documentName, views);
  if (!newDocument.equals(bucket.bucketManager().getDesignDocument(documentName))) {
    logger.warn("Missing indexes in bucket {} for document {}, creating new.", bucket.name(), documentName);
    bucket.bucketManager().upsertDesignDocument(newDocument);
  }
}

代码示例来源:origin: org.apereo.cas/cas-server-support-couchbase-core

private void createDesignDocumentAndViewIfNeeded() {
  if (this.views != null && this.designDocument != null) {
    LOGGER.debug("Ensure that indexes exist in bucket [{}]", this.bucket.name());
    val bucketManager = this.bucket.bucketManager();
    val newDocument = DesignDocument.create(this.designDocument, new ArrayList<>(views));
    try {
      if (!newDocument.equals(bucketManager.getDesignDocument(this.designDocument))) {
        LOGGER.warn("Missing indexes in bucket [{}] for document [{}]", this.bucket.name(), this.designDocument);
        bucketManager.upsertDesignDocument(newDocument);
      }
    } catch (final DesignDocumentDoesNotExistException e) {
      LOGGER.debug("Design document in bucket [{}] for document [{}] should be created", this.bucket.name(), this.designDocument);
      bucketManager.upsertDesignDocument(newDocument);
    } catch (final Exception e) {
      throw new IllegalArgumentException(e.getMessage(), e);
    }
  }
}

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

private void createSpatialViews(Bucket bucket, CouchbaseBuildDefinition buildDefinition) {
  if (buildDefinition.getSpatialViews().size() == 0) {
    // No views to create
    return;
  }
  LOG.debug("Creating {} views in '{}'", buildDefinition.getSpatialViews().size(), buildDefinition.getBucketName());
  // Initialize design document
  DesignDocument designDoc = DesignDocument.create(
      buildDefinition.getSpatialDesignDocumentName(),
      buildDefinition.getSpatialViews());
  // Insert design document into the bucket
  BucketManager bucketManager = bucket.bucketManager();
  bucketManager.upsertDesignDocument(designDoc);
  LOG.debug("Views created in '{}'", buildDefinition.getBucketName());
}

代码示例来源:origin: com.github.differentway/couchbase-testcontainer

@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();
  }
}

相关文章