/** * Get the major version of Couchbase server, that is 4.x or 5.x * * @return */ protected int getMajorVersion() { return this.cluster.authenticate(this.passwordAuthenticator).clusterManager().info(5,TimeUnit.SECONDS).getMinVersion().major(); }
private void checkN1ql() { if (!getCouchbaseClusterInfo().checkAvailable(CouchbaseFeature.N1QL)) { throw new UnsupportedCouchbaseFeatureException("Detected usage of N1QL in template, which is unsupported on this cluster", CouchbaseFeature.N1QL); } }
private void checkN1ql() { if (!getCouchbaseClusterInfo().checkAvailable(CouchbaseFeature.N1QL)) { throw new UnsupportedCouchbaseFeatureException("Detected usage of N1QL in template, which is unsupported on this cluster", CouchbaseFeature.N1QL); } }
public static int getVersion(CouchbaseContainer couchbase) { return couchbase.getCouchbaseCluster().clusterManager(USERNAME, PASSWORD).info(1, TimeUnit.SECONDS).getMinVersion().major(); }
/** * Returns the base class for the repository being constructed. Two categories of repositories can be produced by * this factory: {@link SimpleReactiveCouchbaseRepository} and {@link ReactiveN1qlCouchbaseRepository}. This method checks if N1QL * is available to choose between the two, but the actual concrete class is determined respectively by * {@link #getSimpleBaseClass(RepositoryMetadata)} and {@link #getN1qlBaseClass(RepositoryMetadata)}. * * Override these methods if you want to change the base class for all your repositories. * * @param repositoryMetadata metadata for the repository. * * @return the base class. */ @Override protected final Class<?> getRepositoryBaseClass(final RepositoryMetadata repositoryMetadata) { RxJavaCouchbaseOperations couchbaseOperations = couchbaseOperationsMapping.resolve(repositoryMetadata.getRepositoryInterface(), repositoryMetadata.getDomainType()); boolean isN1qlAvailable = couchbaseOperations.getCouchbaseClusterInfo().checkAvailable(CouchbaseFeature.N1QL); if (isN1qlAvailable) { return getN1qlBaseClass(repositoryMetadata); } return getSimpleBaseClass(repositoryMetadata); }
public static Version requireCouchbaseVersion(CouchbaseCluster cluster, Version requiredVersion) { final Version actualVersion = cluster.clusterManager().info().getMinVersion(); if (actualVersion.compareTo(requiredVersion) < 0) { throw new RuntimeException("Couchbase Server version " + requiredVersion + " or later required; actual version is " + actualVersion); } return actualVersion; } }
/** * Returns the base class for the repository being constructed. Two categories of repositories can be produced by * this factory: {@link SimpleCouchbaseRepository} and {@link N1qlCouchbaseRepository}. This method checks if N1QL * is available to choose between the two, but the actual concrete class is determined respectively by * {@link #getSimpleBaseClass(RepositoryMetadata)} and {@link #getN1qlBaseClass(RepositoryMetadata)}. * * Override these methods if you want to change the base class for all your repositories. * * @param repositoryMetadata metadata for the repository. * * @return the base class. */ @Override protected final Class<?> getRepositoryBaseClass(final RepositoryMetadata repositoryMetadata) { CouchbaseOperations couchbaseOperations = couchbaseOperationsMapping.resolve(repositoryMetadata.getRepositoryInterface(), repositoryMetadata.getDomainType()); boolean isN1qlAvailable = couchbaseOperations.getCouchbaseClusterInfo().checkAvailable(CouchbaseFeature.N1QL); if (isN1qlAvailable) { return getN1qlBaseClass(repositoryMetadata); } return getSimpleBaseClass(repositoryMetadata); }
@SuppressWarnings("unchecked") public static Gauge<String> registerCouchbaseVersionGauge(CouchbaseCluster cluster) { return Metrics.gauge("couchbaseVersion", () -> () -> { final ClusterInfo couchbaseClusterInfo = cluster.clusterManager().info(2, TimeUnit.SECONDS); return couchbaseClusterInfo.getMinVersion().toString(); }); }
/** * Returns the base class for the repository being constructed. Two categories of repositories can be produced by * this factory: {@link SimpleCouchbaseRepository} and {@link N1qlCouchbaseRepository}. This method checks if N1QL * is available to choose between the two, but the actual concrete class is determined respectively by * {@link #getSimpleBaseClass(RepositoryMetadata)} and {@link #getN1qlBaseClass(RepositoryMetadata)}. * * Override these methods if you want to change the base class for all your repositories. * * @param repositoryMetadata metadata for the repository. * * @return the base class. */ @Override protected final Class<?> getRepositoryBaseClass(final RepositoryMetadata repositoryMetadata) { CouchbaseOperations couchbaseOperations = couchbaseOperationsMapping.resolve(repositoryMetadata.getRepositoryInterface(), repositoryMetadata.getDomainType()); boolean isN1qlAvailable = couchbaseOperations.getCouchbaseClusterInfo().checkAvailable(CouchbaseFeature.N1QL); if (isN1qlAvailable) { return getN1qlBaseClass(repositoryMetadata); } return getSimpleBaseClass(repositoryMetadata); }
/** * Returns the base class for the repository being constructed. Two categories of repositories can be produced by * this factory: {@link SimpleReactiveCouchbaseRepository} and {@link ReactiveN1qlCouchbaseRepository}. This method checks if N1QL * is available to choose between the two, but the actual concrete class is determined respectively by * {@link #getSimpleBaseClass(RepositoryMetadata)} and {@link #getN1qlBaseClass(RepositoryMetadata)}. * * Override these methods if you want to change the base class for all your repositories. * * @param repositoryMetadata metadata for the repository. * * @return the base class. */ @Override protected final Class<?> getRepositoryBaseClass(final RepositoryMetadata repositoryMetadata) { RxJavaCouchbaseOperations couchbaseOperations = couchbaseOperationsMapping.resolve(repositoryMetadata.getRepositoryInterface(), repositoryMetadata.getDomainType()); boolean isN1qlAvailable = couchbaseOperations.getCouchbaseClusterInfo().checkAvailable(CouchbaseFeature.N1QL); if (isN1qlAvailable) { return getN1qlBaseClass(repositoryMetadata); } return getSimpleBaseClass(repositoryMetadata); }
/** * Returns a new Repository based on the metadata. Two categories of repositories can be instantiated: * {@link SimpleCouchbaseRepository} and {@link N1qlCouchbaseRepository}. * * This method performs feature checks to decide which of the two categories can be instantiated (eg. is N1QL available?). * Instantiation is done via reflection, see {@link #getRepositoryBaseClass(RepositoryMetadata)}. * * @param metadata the repository metadata. * * @return a new created repository. */ @Override protected final Object getTargetRepository(final RepositoryInformation metadata) { CouchbaseOperations couchbaseOperations = couchbaseOperationsMapping.resolve(metadata.getRepositoryInterface(), metadata.getDomainType()); boolean isN1qlAvailable = couchbaseOperations.getCouchbaseClusterInfo().checkAvailable(CouchbaseFeature.N1QL); ViewIndexed viewIndexed = AnnotationUtils.findAnnotation(metadata.getRepositoryInterface(), ViewIndexed.class); N1qlPrimaryIndexed n1qlPrimaryIndexed = AnnotationUtils.findAnnotation(metadata.getRepositoryInterface(), N1qlPrimaryIndexed.class); N1qlSecondaryIndexed n1qlSecondaryIndexed = AnnotationUtils.findAnnotation(metadata.getRepositoryInterface(), N1qlSecondaryIndexed.class); checkFeatures(metadata, isN1qlAvailable, n1qlPrimaryIndexed, n1qlSecondaryIndexed); indexManager.buildIndexes(metadata, viewIndexed, n1qlPrimaryIndexed, n1qlSecondaryIndexed, couchbaseOperations); CouchbaseEntityInformation<?, Serializable> entityInformation = getEntityInformation(metadata.getDomainType()); SimpleCouchbaseRepository repo = getTargetRepositoryViaReflection(metadata, entityInformation, couchbaseOperations); repo.setViewMetadataProvider(viewPostProcessor.getViewMetadataProvider()); return repo; }
/** * Returns a new Repository based on the metadata. Two categories of repositories can be instantiated: * {@link SimpleReactiveCouchbaseRepository} and {@link ReactiveN1qlCouchbaseRepository}. * * This method performs feature checks to decide which of the two categories can be instantiated (eg. is N1QL available?). * Instantiation is done via reflection, see {@link #getRepositoryBaseClass(RepositoryMetadata)}. * * @param metadata the repository metadata. * * @return a new created repository. */ @Override protected final Object getTargetRepository(final RepositoryInformation metadata) { RxJavaCouchbaseOperations couchbaseOperations = couchbaseOperationsMapping.resolve(metadata.getRepositoryInterface(), metadata.getDomainType()); boolean isN1qlAvailable = couchbaseOperations.getCouchbaseClusterInfo().checkAvailable(CouchbaseFeature.N1QL); ViewIndexed viewIndexed = AnnotationUtils.findAnnotation(metadata.getRepositoryInterface(), ViewIndexed.class); N1qlPrimaryIndexed n1qlPrimaryIndexed = AnnotationUtils.findAnnotation(metadata.getRepositoryInterface(), N1qlPrimaryIndexed.class); N1qlSecondaryIndexed n1qlSecondaryIndexed = AnnotationUtils.findAnnotation(metadata.getRepositoryInterface(), N1qlSecondaryIndexed.class); checkFeatures(metadata, isN1qlAvailable, n1qlPrimaryIndexed, n1qlSecondaryIndexed); indexManager.buildIndexes(metadata, viewIndexed, n1qlPrimaryIndexed, n1qlSecondaryIndexed, couchbaseOperations); CouchbaseEntityInformation<?, Serializable> entityInformation = getEntityInformation(metadata.getDomainType()); SimpleReactiveCouchbaseRepository repo = getTargetRepositoryViaReflection(metadata, entityInformation, couchbaseOperations); repo.setViewMetadataProvider(viewPostProcessor.getViewMetadataProvider()); return repo; }
/** * Returns a new Repository based on the metadata. Two categories of repositories can be instantiated: * {@link SimpleCouchbaseRepository} and {@link N1qlCouchbaseRepository}. * * This method performs feature checks to decide which of the two categories can be instantiated (eg. is N1QL available?). * Instantiation is done via reflection, see {@link #getRepositoryBaseClass(RepositoryMetadata)}. * * @param metadata the repository metadata. * * @return a new created repository. */ @Override protected final Object getTargetRepository(final RepositoryInformation metadata) { CouchbaseOperations couchbaseOperations = couchbaseOperationsMapping.resolve(metadata.getRepositoryInterface(), metadata.getDomainType()); boolean isN1qlAvailable = couchbaseOperations.getCouchbaseClusterInfo().checkAvailable(CouchbaseFeature.N1QL); ViewIndexed viewIndexed = AnnotationUtils.findAnnotation(metadata.getRepositoryInterface(), ViewIndexed.class); N1qlPrimaryIndexed n1qlPrimaryIndexed = AnnotationUtils.findAnnotation(metadata.getRepositoryInterface(), N1qlPrimaryIndexed.class); N1qlSecondaryIndexed n1qlSecondaryIndexed = AnnotationUtils.findAnnotation(metadata.getRepositoryInterface(), N1qlSecondaryIndexed.class); checkFeatures(metadata, isN1qlAvailable, n1qlPrimaryIndexed, n1qlSecondaryIndexed); indexManager.buildIndexes(metadata, viewIndexed, n1qlPrimaryIndexed, n1qlSecondaryIndexed, couchbaseOperations); CouchbaseEntityInformation<?, Serializable> entityInformation = getEntityInformation(metadata.getDomainType()); SimpleCouchbaseRepository repo = getTargetRepositoryViaReflection(metadata, entityInformation, couchbaseOperations); repo.setViewMetadataProvider(viewPostProcessor.getViewMetadataProvider()); return repo; }
/** * Returns a new Repository based on the metadata. Two categories of repositories can be instantiated: * {@link SimpleReactiveCouchbaseRepository} and {@link ReactiveN1qlCouchbaseRepository}. * * This method performs feature checks to decide which of the two categories can be instantiated (eg. is N1QL available?). * Instantiation is done via reflection, see {@link #getRepositoryBaseClass(RepositoryMetadata)}. * * @param metadata the repository metadata. * * @return a new created repository. */ @Override protected final Object getTargetRepository(final RepositoryInformation metadata) { RxJavaCouchbaseOperations couchbaseOperations = couchbaseOperationsMapping.resolve(metadata.getRepositoryInterface(), metadata.getDomainType()); boolean isN1qlAvailable = couchbaseOperations.getCouchbaseClusterInfo().checkAvailable(CouchbaseFeature.N1QL); ViewIndexed viewIndexed = AnnotationUtils.findAnnotation(metadata.getRepositoryInterface(), ViewIndexed.class); N1qlPrimaryIndexed n1qlPrimaryIndexed = AnnotationUtils.findAnnotation(metadata.getRepositoryInterface(), N1qlPrimaryIndexed.class); N1qlSecondaryIndexed n1qlSecondaryIndexed = AnnotationUtils.findAnnotation(metadata.getRepositoryInterface(), N1qlSecondaryIndexed.class); checkFeatures(metadata, isN1qlAvailable, n1qlPrimaryIndexed, n1qlSecondaryIndexed); indexManager.buildIndexes(metadata, viewIndexed, n1qlPrimaryIndexed, n1qlSecondaryIndexed, couchbaseOperations); CouchbaseEntityInformation<?, Serializable> entityInformation = getEntityInformation(metadata.getDomainType()); SimpleReactiveCouchbaseRepository repo = getTargetRepositoryViaReflection(metadata, entityInformation, couchbaseOperations); repo.setViewMetadataProvider(viewPostProcessor.getViewMetadataProvider()); return repo; }