• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java AsyncBucket类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中com.couchbase.client.java.AsyncBucket的典型用法代码示例。如果您正苦于以下问题:Java AsyncBucket类的具体用法?Java AsyncBucket怎么用?Java AsyncBucket使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



AsyncBucket类属于com.couchbase.client.java包,在下文中一共展示了AsyncBucket类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: getById

import com.couchbase.client.java.AsyncBucket; //导入依赖的package包/类
@SuppressWarnings({"unchecked", "rawtypes" })
@Test
public void getById() throws Exception {
  Class entityClass = Entity.class;
  Long id = 7L;
  new MockUnit(AsyncBucket.class, AsyncRepository.class, Function.class, JacksonMapper.class)
      .expect(unit -> {
        AsyncRepository repo = unit.get(AsyncRepository.class);
        expect(repo.get(N1Q.qualifyId(entityClass, id), entityClass))
            .andReturn(document(new Entity(id)));
      })
      .run(unit -> {
        Entity e = (Entity) new AsyncDatastoreImpl(unit.get(AsyncBucket.class),
            unit.get(AsyncRepository.class),
            unit.get(Function.class), unit.get(JacksonMapper.class))
                .get(entityClass, id)
                .toBlocking()
                .single();
        assertNotNull(e);
        assertEquals(id, e.id);
      });
}
 
开发者ID:jooby-project,项目名称:jooby,代码行数:23,代码来源:AsyncDatastoreImplTest.java


示例2: getFromReplica

import com.couchbase.client.java.AsyncBucket; //导入依赖的package包/类
@SuppressWarnings({"unchecked", "rawtypes" })
@Test
public void getFromReplica() throws Exception {
  Class entityClass = Entity.class;
  Long id = 7L;
  new MockUnit(AsyncBucket.class, AsyncRepository.class, Function.class, JacksonMapper.class)
      .expect(unit -> {
        AsyncRepository repo = unit.get(AsyncRepository.class);
        expect(
            repo.getFromReplica(N1Q.qualifyId(entityClass, id), ReplicaMode.FIRST, entityClass))
                .andReturn(document(new Entity(id)));
      })
      .run(unit -> {
        Entity e = (Entity) new AsyncDatastoreImpl(unit.get(AsyncBucket.class),
            unit.get(AsyncRepository.class),
            unit.get(Function.class), unit.get(JacksonMapper.class))
                .getFromReplica(entityClass, id, ReplicaMode.FIRST)
                .toBlocking()
                .single();
        assertNotNull(e);
        assertEquals(id, e.id);
      });
}
 
开发者ID:jooby-project,项目名称:jooby,代码行数:24,代码来源:AsyncDatastoreImplTest.java


示例3: getAndTouch

import com.couchbase.client.java.AsyncBucket; //导入依赖的package包/类
@SuppressWarnings({"unchecked", "rawtypes" })
@Test
public void getAndTouch() throws Exception {
  Class entityClass = Entity.class;
  Long id = 7L;
  new MockUnit(AsyncBucket.class, AsyncRepository.class, Function.class, JacksonMapper.class)
      .expect(unit -> {
        AsyncRepository repo = unit.get(AsyncRepository.class);
        expect(repo.getAndTouch(N1Q.qualifyId(entityClass, id), 5, entityClass))
            .andReturn(document(new Entity(id)));
      })
      .run(unit -> {
        Entity e = (Entity) new AsyncDatastoreImpl(unit.get(AsyncBucket.class),
            unit.get(AsyncRepository.class),
            unit.get(Function.class), unit.get(JacksonMapper.class))
                .getAndTouch(entityClass, id, 5)
                .toBlocking()
                .single();
        assertNotNull(e);
        assertEquals(id, e.id);
      });
}
 
开发者ID:jooby-project,项目名称:jooby,代码行数:23,代码来源:AsyncDatastoreImplTest.java


示例4: getAndLock

import com.couchbase.client.java.AsyncBucket; //导入依赖的package包/类
@SuppressWarnings({"unchecked", "rawtypes" })
@Test
public void getAndLock() throws Exception {
  Class entityClass = Entity.class;
  Long id = 7L;
  new MockUnit(AsyncBucket.class, AsyncRepository.class, Function.class, JacksonMapper.class)
      .expect(unit -> {
        AsyncRepository repo = unit.get(AsyncRepository.class);
        expect(repo.getAndLock(N1Q.qualifyId(entityClass, id), 5, entityClass))
            .andReturn(document(new Entity(id)));
      })
      .run(unit -> {
        Entity e = (Entity) new AsyncDatastoreImpl(unit.get(AsyncBucket.class),
            unit.get(AsyncRepository.class),
            unit.get(Function.class), unit.get(JacksonMapper.class))
                .getAndLock(entityClass, id, 5)
                .toBlocking()
                .single();
        assertNotNull(e);
        assertEquals(id, e.id);
      });
}
 
开发者ID:jooby-project,项目名称:jooby,代码行数:23,代码来源:AsyncDatastoreImplTest.java


示例5: queryFailure

import com.couchbase.client.java.AsyncBucket; //导入依赖的package包/类
@SuppressWarnings({"unchecked" })
@Test(expected = QueryExecutionException.class)
public void queryFailure() throws Exception {
  new MockUnit(AsyncBucket.class, AsyncRepository.class, Function.class, JacksonMapper.class,
      N1qlQuery.class, AsyncN1qlQueryResult.class, AsyncN1qlQueryRow.class)
          .expect(unit -> {
            AsyncN1qlQueryRow row = unit.get(AsyncN1qlQueryRow.class);

            AsyncN1qlQueryResult result = unit.get(AsyncN1qlQueryResult.class);
            expect(result.rows()).andReturn(Observable.just(row));
            expect(result.errors())
                .andReturn(Observable.just(JsonObject.create().put("foo", "bar")));
            expect(result.finalSuccess()).andReturn(Observable.just(false));

            AsyncBucket bucket = unit.get(AsyncBucket.class);
            expect(bucket.query(unit.get(N1qlQuery.class))).andReturn(Observable.just(result));
          })
          .run(unit -> {
            new AsyncDatastoreImpl(unit.get(AsyncBucket.class),
                unit.get(AsyncRepository.class),
                unit.get(Function.class), unit.get(JacksonMapper.class))
                    .<Entity> query(unit.get(N1qlQuery.class))
                    .toBlocking()
                    .single();
          });
}
 
开发者ID:jooby-project,项目名称:jooby,代码行数:27,代码来源:AsyncDatastoreImplTest.java


示例6: queryFailureNoError

import com.couchbase.client.java.AsyncBucket; //导入依赖的package包/类
@SuppressWarnings({"unchecked" })
@Test(expected = QueryExecutionException.class)
public void queryFailureNoError() throws Exception {
  new MockUnit(AsyncBucket.class, AsyncRepository.class, Function.class, JacksonMapper.class,
      N1qlQuery.class, AsyncN1qlQueryResult.class, AsyncN1qlQueryRow.class)
          .expect(unit -> {
            AsyncN1qlQueryRow row = unit.get(AsyncN1qlQueryRow.class);

            AsyncN1qlQueryResult result = unit.get(AsyncN1qlQueryResult.class);
            expect(result.rows()).andReturn(Observable.just(row));
            expect(result.errors()).andReturn(Observable.empty());
            expect(result.finalSuccess()).andReturn(Observable.just(false));

            AsyncBucket bucket = unit.get(AsyncBucket.class);
            expect(bucket.query(unit.get(N1qlQuery.class))).andReturn(Observable.just(result));
          })
          .run(unit -> {
            new AsyncDatastoreImpl(unit.get(AsyncBucket.class),
                unit.get(AsyncRepository.class),
                unit.get(Function.class), unit.get(JacksonMapper.class))
                    .<Entity> query(unit.get(N1qlQuery.class))
                    .toBlocking()
                    .single();
          });
}
 
开发者ID:jooby-project,项目名称:jooby,代码行数:26,代码来源:AsyncDatastoreImplTest.java


示例7: openBucket

import com.couchbase.client.java.AsyncBucket; //导入依赖的package包/类
private Single<SharedResource<AsyncBucket>> openBucket() {
  return vertx.rxExecuteBlocking(fut -> {
    SharedResources sharedResources = SharedResources.INSTANCE;
    SharedResource<AsyncBucket> asyncBucket = sharedResources.getOrCreate("commentsBucket", () -> {
      return couchbaseCluster.get().openBucket("album-comments").toSingle().toBlocking().value();
    }, bucket -> {
      bucket.close().toSingle().toBlocking().value();
    });
    fut.complete(asyncBucket);
  });
}
 
开发者ID:tsegismont,项目名称:vertx-musicstore,代码行数:12,代码来源:MusicStoreVerticle.java


示例8: AsyncDatastoreImpl

import com.couchbase.client.java.AsyncBucket; //导入依赖的package包/类
public AsyncDatastoreImpl(final AsyncBucket bucket, final AsyncRepository repo,
    final Function<Object, Object> idGen, final JacksonMapper converter) {
  this.bucket = bucket;
  this.repo = repo;
  this.idGen = idGen;
  this.converter = converter;
}
 
开发者ID:jooby-project,项目名称:jooby,代码行数:8,代码来源:AsyncDatastoreImpl.java


示例9: openBucket

import com.couchbase.client.java.AsyncBucket; //导入依赖的package包/类
private Block openBucket(final String name, final String password, final boolean goasync) {
  return unit -> {
    Bucket bucket = unit.mock(Bucket.class);
    unit.registerMock(Bucket.class, bucket);
    if (goasync) {
      AsyncBucket asyncBucket = unit.mock(AsyncBucket.class);
      unit.registerMock(AsyncBucket.class, asyncBucket);
      expect(bucket.async()).andReturn(asyncBucket);
    }

    CouchbaseCluster cluster = unit.get(CouchbaseCluster.class);
    expect(cluster.openBucket(name, password)).andReturn(bucket);
  };
}
 
开发者ID:jooby-project,项目名称:jooby,代码行数:15,代码来源:CouchbaseTest.java


示例10: query

import com.couchbase.client.java.AsyncBucket; //导入依赖的package包/类
@SuppressWarnings({"unchecked" })
@Test
public void query() throws Exception {
  byte[] bytes = ("{\"class\": \"" + Entity.class.getName()
      + "\",id: 1}").getBytes(StandardCharsets.UTF_8);
  Entity entity = new Entity(1);
  new MockUnit(AsyncBucket.class, AsyncRepository.class, Function.class, JacksonMapper.class,
      N1qlQuery.class, AsyncN1qlQueryResult.class, AsyncN1qlQueryRow.class)
          .expect(unit -> {
            JacksonMapper mapper = unit.get(JacksonMapper.class);
            expect(mapper.fromBytes(bytes)).andReturn(entity);
          })
          .expect(unit -> {
            AsyncN1qlQueryRow row = unit.get(AsyncN1qlQueryRow.class);
            expect(row.byteValue()).andReturn(bytes);

            AsyncN1qlQueryResult result = unit.get(AsyncN1qlQueryResult.class);
            expect(result.rows()).andReturn(Observable.just(row));
            expect(result.errors()).andReturn(Observable.empty());
            expect(result.finalSuccess()).andReturn(Observable.just(true));

            AsyncBucket bucket = unit.get(AsyncBucket.class);
            expect(bucket.query(unit.get(N1qlQuery.class))).andReturn(Observable.just(result));
          })
          .run(unit -> {
            List<Entity> entities = new AsyncDatastoreImpl(unit.get(AsyncBucket.class),
                unit.get(AsyncRepository.class),
                unit.get(Function.class), unit.get(JacksonMapper.class))
                    .<Entity> query(unit.get(N1qlQuery.class))
                    .toBlocking()
                    .single();
            assertNotNull(entities);
            assertEquals(entity, entities.get(0));
          });
}
 
开发者ID:jooby-project,项目名称:jooby,代码行数:36,代码来源:AsyncDatastoreImplTest.java


示例11: queryStmt

import com.couchbase.client.java.AsyncBucket; //导入依赖的package包/类
@SuppressWarnings({"unchecked" })
@Test
public void queryStmt() throws Exception {
  byte[] bytes = ("{\"class\": \"" + Entity.class.getName()
      + "\",id: 1}").getBytes(StandardCharsets.UTF_8);
  Entity entity = new Entity(1);
  new MockUnit(AsyncBucket.class, AsyncRepository.class, Function.class, JacksonMapper.class,
      Statement.class, AsyncN1qlQueryResult.class, AsyncN1qlQueryRow.class)
          .expect(unit -> {
            JacksonMapper mapper = unit.get(JacksonMapper.class);
            expect(mapper.fromBytes(bytes)).andReturn(entity);
          })
          .expect(unit -> {
            AsyncN1qlQueryRow row = unit.get(AsyncN1qlQueryRow.class);
            expect(row.byteValue()).andReturn(bytes);

            AsyncN1qlQueryResult result = unit.get(AsyncN1qlQueryResult.class);
            expect(result.rows()).andReturn(Observable.just(row));
            expect(result.errors()).andReturn(Observable.empty());
            expect(result.finalSuccess()).andReturn(Observable.just(true));

            AsyncBucket bucket = unit.get(AsyncBucket.class);
            expect(bucket.query(unit.capture(N1qlQuery.class)))
                .andReturn(Observable.just(result));
          })
          .run(unit -> {
            List<Entity> entities = new AsyncDatastoreImpl(unit.get(AsyncBucket.class),
                unit.get(AsyncRepository.class),
                unit.get(Function.class), unit.get(JacksonMapper.class))
                    .<Entity> query(unit.get(Statement.class))
                    .toBlocking()
                    .single();
            assertNotNull(entities);
            assertEquals(entity, entities.get(0));
          });
}
 
开发者ID:jooby-project,项目名称:jooby,代码行数:37,代码来源:AsyncDatastoreImplTest.java


示例12: queryMappingFaiulre

import com.couchbase.client.java.AsyncBucket; //导入依赖的package包/类
@SuppressWarnings({"unchecked" })
@Test(expected = QueryExecutionException.class)
public void queryMappingFaiulre() throws Exception {
  byte[] bytes = ("{\"class\": \"" + Entity.class.getName()
      + "\",id: 1}").getBytes(StandardCharsets.UTF_8);
  new MockUnit(AsyncBucket.class, AsyncRepository.class, Function.class, JacksonMapper.class,
      N1qlQuery.class, AsyncN1qlQueryResult.class, AsyncN1qlQueryRow.class)
          .expect(unit -> {
            JacksonMapper mapper = unit.get(JacksonMapper.class);
            expect(mapper.fromBytes(bytes)).andThrow(new IOException("intentional err"));
          })
          .expect(unit -> {
            AsyncN1qlQueryRow row = unit.get(AsyncN1qlQueryRow.class);
            expect(row.byteValue()).andReturn(bytes);

            AsyncN1qlQueryResult result = unit.get(AsyncN1qlQueryResult.class);
            expect(result.rows()).andReturn(Observable.just(row));
            expect(result.errors()).andReturn(Observable.empty());
            expect(result.finalSuccess()).andReturn(Observable.just(true));

            AsyncBucket bucket = unit.get(AsyncBucket.class);
            expect(bucket.query(unit.get(N1qlQuery.class))).andReturn(Observable.just(result));
          })
          .run(unit -> {
            new AsyncDatastoreImpl(unit.get(AsyncBucket.class),
                unit.get(AsyncRepository.class),
                unit.get(Function.class), unit.get(JacksonMapper.class))
                    .<Entity> query(unit.get(N1qlQuery.class))
                    .toBlocking()
                    .single();
          });
}
 
开发者ID:jooby-project,项目名称:jooby,代码行数:33,代码来源:AsyncDatastoreImplTest.java


示例13: AddAlbumCommentHandler

import com.couchbase.client.java.AsyncBucket; //导入依赖的package包/类
public AddAlbumCommentHandler(AsyncBucket albumCommentsBucket) {
  this.albumCommentsBucket = albumCommentsBucket;
}
 
开发者ID:tsegismont,项目名称:vertx-musicstore,代码行数:4,代码来源:AddAlbumCommentHandler.java


示例14: AjaxAlbumCommentsHandler

import com.couchbase.client.java.AsyncBucket; //导入依赖的package包/类
public AjaxAlbumCommentsHandler(AsyncBucket albumCommentsBucket, Properties couchbaseQueries, FreeMarkerTemplateEngine templateEngine) {
  this.albumCommentsBucket = albumCommentsBucket;
  this.findRecentCommentsByAlbum = couchbaseQueries.getProperty("findRecentCommentsByAlbum");
  this.templateEngine = templateEngine;
}
 
开发者ID:tsegismont,项目名称:vertx-musicstore,代码行数:6,代码来源:AjaxAlbumCommentsHandler.java


示例15: runAsync

import com.couchbase.client.java.AsyncBucket; //导入依赖的package包/类
private <R> R runAsync(Function<AsyncBucket, Observable<R>> function) {
    return single(function.apply(bucket.async())
            .retryWhen(getRetryStrategy()));
}
 
开发者ID:differentway,项目名称:couchmove,代码行数:5,代码来源:CouchbaseRepositoryImpl.java


示例16: getAsyncBucket

import com.couchbase.client.java.AsyncBucket; //导入依赖的package包/类
public AsyncBucket getAsyncBucket(BucketInfo bucketInfo) {
    return getBucket(bucketInfo).async();
}
 
开发者ID:ylemoigne,项目名称:ratpack-couchbase,代码行数:4,代码来源:CouchbaseService.java


示例17: asyncBucket

import com.couchbase.client.java.AsyncBucket; //导入依赖的package包/类
@Bean(destroyMethod = "close")
@Autowired
AsyncBucket asyncBucket(final Bucket bucket) {
  return bucket.async();
}
 
开发者ID:jloisel,项目名称:reactive-couchbase,代码行数:6,代码来源:CouchbaseConfig.java


示例18: asyncBucket

import com.couchbase.client.java.AsyncBucket; //导入依赖的package包/类
@Bean
public AsyncBucket asyncBucket() {
	return cluster().openBucket(bucket, password).async();
}
 
开发者ID:ldoguin,项目名称:couchbase-java-importer,代码行数:5,代码来源:Database.java


示例19: boot

import com.couchbase.client.java.AsyncBucket; //导入依赖的package包/类
@Test
public void boot() throws Exception {
  String bucket = "beers";
  new MockUnit(Env.class, Config.class, Binder.class)
      .expect(noenvprops)
      .expect(serviceKey(new Env.ServiceKey()))
      .expect(createEnv)
      .expect(setProperty(bucket))
      .expect(cluster("couchbase://localhost"))
      .expect(bind(bucket, CouchbaseCluster.class))
      .expect(bind(null, CouchbaseCluster.class))
      .expect(noClusterManager)
      // buckets
      .expect(bucketPassword(bucket, null))
      .expect(openBucket(bucket, null))
      .expect(bind(bucket, Bucket.class))
      .expect(bind(null, Bucket.class))
      .expect(bind(bucket, AsyncBucket.class))
      .expect(bind(null, AsyncBucket.class))
      // repository
      .expect(repository(bucket))
      .expect(bind(bucket, Repository.class))
      .expect(bind(null, Repository.class))
      .expect(bind(bucket, AsyncRepository.class))
      .expect(bind(null, AsyncRepository.class))
      // converter hack
      .expect(converterHack)
      // datastore
      .expect(asyncds())
      .expect(bind(bucket, AsyncDatastore.class))
      .expect(bind(null, AsyncDatastore.class))
      .expect(ds())
      .expect(bind(bucket, Datastore.class))
      .expect(bind(null, Datastore.class))
      // session
      .expect(openBucket(bucket, null, false))
      .expect(bucketPassword(bucket, null))
      .expect(bind("session", Bucket.class))
      // onStop
      .expect(onStop)
      .run(unit -> {
        new Couchbase("couchbase://localhost/" + bucket)
            .configure(unit.get(Env.class), unit.get(Config.class), unit.get(Binder.class));
      });
}
 
开发者ID:jooby-project,项目名称:jooby,代码行数:46,代码来源:CouchbaseTest.java


示例20: envproperty

import com.couchbase.client.java.AsyncBucket; //导入依赖的package包/类
@Test
public void envproperty() throws Exception {
  String bucket = "beers";
  Config conf = ConfigFactory.empty()
      .withValue("couchbase.env.kvEndpoints", ConfigValueFactory.fromAnyRef(5));
  new MockUnit(Env.class, Config.class, Binder.class)
      .expect(unit -> {
        Config mock = unit.get(Config.class);
        expect(mock.hasPath("couchbase.env")).andReturn(true);
        expect(mock.getConfig("couchbase.env")).andReturn(conf.getConfig("couchbase.env"));
      })
      .expect(serviceKey(new Env.ServiceKey()))
      .expect(createEnv)
      .expect(cluster("couchbase://localhost"))
      .expect(bind(bucket, CouchbaseCluster.class))
      .expect(bind(null, CouchbaseCluster.class))
      .expect(noClusterManager)
      // buckets
      .expect(bucketPassword(bucket, null))
      .expect(openBucket(bucket, null))
      .expect(bind(bucket, Bucket.class))
      .expect(bind(null, Bucket.class))
      .expect(bind(bucket, AsyncBucket.class))
      .expect(bind(null, AsyncBucket.class))
      // repository
      .expect(repository(bucket))
      .expect(bind(bucket, Repository.class))
      .expect(bind(null, Repository.class))
      .expect(bind(bucket, AsyncRepository.class))
      .expect(bind(null, AsyncRepository.class))
      // converter hack
      .expect(converterHack)
      // datastore
      .expect(asyncds())
      .expect(bind(bucket, AsyncDatastore.class))
      .expect(bind(null, AsyncDatastore.class))
      .expect(ds())
      .expect(bind(bucket, Datastore.class))
      .expect(bind(null, Datastore.class))
      // session
      .expect(openBucket(bucket, null, false))
      .expect(bucketPassword(bucket, null))
      .expect(bind("session", Bucket.class))
      // onStop
      .expect(onStop)
      .run(unit -> {
        new Couchbase("couchbase://localhost/" + bucket)
            .configure(unit.get(Env.class), unit.get(Config.class), unit.get(Binder.class));
        assertEquals("5", System.getProperty("com.couchbase.kvEndpoints"));
      });
}
 
开发者ID:jooby-project,项目名称:jooby,代码行数:52,代码来源:CouchbaseTest.java



注:本文中的com.couchbase.client.java.AsyncBucket类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java DyeColor类代码示例发布时间:2022-05-22
下一篇:
Java BasicOCSPResp类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap