本文整理汇总了Java中com.mongodb.async.SingleResultCallback类的典型用法代码示例。如果您正苦于以下问题:Java SingleResultCallback类的具体用法?Java SingleResultCallback怎么用?Java SingleResultCallback使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SingleResultCallback类属于com.mongodb.async包,在下文中一共展示了SingleResultCallback类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: getLatestOplogTimestamp
import com.mongodb.async.SingleResultCallback; //导入依赖的package包/类
/**
* Returns the timestamp of the latest oplog entry.
*
* @param collection The oplog {@link MongoCollection}
* @return The latest timestamp or {@code null} if no entry is available
*/
public static BsonTimestamp getLatestOplogTimestamp(MongoCollection<BsonDocument> collection) {
final AtomicReference<BsonTimestamp> timestamp = new AtomicReference<>();
final AtomicReference<Throwable> error = new AtomicReference<>();
final CountDownLatch waiter = new CountDownLatch(1);
collection.find().sort(new Document("$natural", -1)).limit(1).first(new SingleResultCallback<BsonDocument>() {
@Override
public void onResult(BsonDocument document, Throwable throwable) {
if (throwable != null)
error.set(throwable);
if (document != null)
timestamp.set(document.getTimestamp("ts"));
waiter.countDown();
}
});
ConcurrentUtils.safeAwait(waiter);
Throwable realError = error.get();
if (realError != null)
throw Throwables.propagate(realError);
return timestamp.get();
}
开发者ID:maxikg,项目名称:mongowg,代码行数:27,代码来源:OpLogUtils.java
示例2: getWithinBoundingBox
import com.mongodb.async.SingleResultCallback; //导入依赖的package包/类
public List<JSONObject> getWithinBoundingBox(double btm, double tp, double rght, double lft) {
List<JSONObject> finalList = Collections.synchronizedList(new ArrayList<>());
MongoCollection<Document> roadsNodes = this.database.getCollection("ollie_roads");
Block<Document> getBlock = new Block<Document>() {
@Override
public void apply(final Document document) {
finalList.add(new JSONObject(document));
}
};
SingleResultCallback<Void> callbackWhenFinished = new SingleResultCallback<Void>() {
@Override
public void onResult(final Void result, final Throwable t) {
latch.countDown();
}
};
roadsNodes.find(and(gte("startNode.latitude", btm), lte("startNode.latitude", tp), gte("startNode.longitude", lft), lte("startNode.longitude", rght),
gte("endNode.latitude", btm), lte("endNode.latitude", tp), gte("endNode.longitude", lft), lte("endNode.longitude", rght))).
forEach(getBlock, callbackWhenFinished);
try {
latch.await();
} catch (InterruptedException e) {
e.printStackTrace();
}
return finalList;
}
开发者ID:OliMac1,项目名称:durafficpark,代码行数:32,代码来源:BoundingBoxNodes.java
示例3: convertCallback
import com.mongodb.async.SingleResultCallback; //导入依赖的package包/类
/**
*
* @param resultHandler
* @param converter
* @param <T>
* @param <R>
* @return
*/
private <T, R> SingleResultCallback<T> convertCallback(Handler<AsyncResult<R>> resultHandler, Function<T, R> converter) {
Context context = mongi.vertx.getOrCreateContext();
return (result, error) -> {
context.runOnContext(v -> {
if (error != null) {
resultHandler.handle(Future.failedFuture(error));
} else {
resultHandler.handle(Future.succeededFuture(converter.apply(result)));
}
});
};
}
开发者ID:stump201,项目名称:mongiORM,代码行数:21,代码来源:QueryAsync.java
示例4: createView
import com.mongodb.async.SingleResultCallback; //导入依赖的package包/类
@Override
public Publisher<Success> createView(final String viewName, final String viewOn, final List<? extends Bson> pipeline,
final CreateViewOptions createViewOptions) {
return new ObservableToPublisher<Success>(observe(new Block<SingleResultCallback<Success>>() {
@Override
public void apply(final SingleResultCallback<Success> callback) {
wrapped.createView(viewName, viewOn, pipeline, createViewOptions, voidToSuccessCallback(callback));
}
}));
}
开发者ID:mongodb,项目名称:mongo-java-driver-reactivestreams,代码行数:11,代码来源:MongoDatabaseImpl.java
示例5: close
import com.mongodb.async.SingleResultCallback; //导入依赖的package包/类
@Override
public Observable<Success> close() {
return RxObservables.create(Observables.observe(new Block<SingleResultCallback<Success>>() {
@Override
public void apply(final SingleResultCallback<Success> callback) {
wrapped.close(voidToSuccessCallback(callback));
}
}), observableAdapter);
}
开发者ID:mongodb,项目名称:mongo-java-driver-rx,代码行数:10,代码来源:GridFSUploadStreamImpl.java
示例6: abort
import com.mongodb.async.SingleResultCallback; //导入依赖的package包/类
@Override
public Observable<Success> abort() {
return RxObservables.create(Observables.observe(new Block<SingleResultCallback<Success>>() {
@Override
public void apply(final SingleResultCallback<Success> callback) {
wrapped.abort(voidToSuccessCallback(callback));
}
}), observableAdapter);
}
开发者ID:mongodb,项目名称:mongo-java-driver-rx,代码行数:10,代码来源:GridFSUploadStreamImpl.java
示例7: delete
import com.mongodb.async.SingleResultCallback; //导入依赖的package包/类
@Override
public Publisher<Success> delete(final ClientSession clientSession, final BsonValue id) {
return new ObservableToPublisher<Success>(observe(new Block<SingleResultCallback<Success>>() {
@Override
public void apply(final SingleResultCallback<Success> callback) {
wrapped.delete(clientSession, id, voidToSuccessCallback(callback));
}
}));
}
开发者ID:mongodb,项目名称:mongo-java-driver-reactivestreams,代码行数:10,代码来源:GridFSBucketImpl.java
示例8: bulkWrite
import com.mongodb.async.SingleResultCallback; //导入依赖的package包/类
@Override
public Observable<BulkWriteResult> bulkWrite(final List<? extends WriteModel<? extends TDocument>> requests,
final BulkWriteOptions options) {
return RxObservables.create(Observables.observe(new Block<SingleResultCallback<BulkWriteResult>>() {
@Override
public void apply(final SingleResultCallback<BulkWriteResult> callback) {
wrapped.bulkWrite(requests, options, callback);
}
}), observableAdapter);
}
开发者ID:mongodb,项目名称:mongo-java-driver-rx,代码行数:11,代码来源:MongoCollectionImpl.java
示例9: insertOne
import com.mongodb.async.SingleResultCallback; //导入依赖的package包/类
@Override
public Observable<Success> insertOne(final TDocument document, final InsertOneOptions options) {
return RxObservables.create(Observables.observe(new Block<SingleResultCallback<Success>>() {
@Override
public void apply(final SingleResultCallback<Success> callback) {
wrapped.insertOne(document, options, voidToSuccessCallback(callback));
}
}), observableAdapter);
}
开发者ID:mongodb,项目名称:mongo-java-driver-rx,代码行数:10,代码来源:MongoCollectionImpl.java
示例10: insertMany
import com.mongodb.async.SingleResultCallback; //导入依赖的package包/类
@Override
public Observable<Success> insertMany(final List<? extends TDocument> documents, final InsertManyOptions options) {
return RxObservables.create(Observables.observe(new Block<SingleResultCallback<Success>>() {
@Override
public void apply(final SingleResultCallback<Success> callback) {
wrapped.insertMany(documents, options, voidToSuccessCallback(callback));
}
}), observableAdapter);
}
开发者ID:mongodb,项目名称:mongo-java-driver-rx,代码行数:10,代码来源:MongoCollectionImpl.java
示例11: deleteOne
import com.mongodb.async.SingleResultCallback; //导入依赖的package包/类
@Override
public Observable<DeleteResult> deleteOne(final Bson filter) {
return RxObservables.create(Observables.observe(new Block<SingleResultCallback<DeleteResult>>() {
@Override
public void apply(final SingleResultCallback<DeleteResult> callback) {
wrapped.deleteOne(filter, callback);
}
}), observableAdapter);
}
开发者ID:mongodb,项目名称:mongo-java-driver-rx,代码行数:10,代码来源:MongoCollectionImpl.java
示例12: callResult
import com.mongodb.async.SingleResultCallback; //导入依赖的package包/类
<T> void callResult(final SingleResultCallback<T> callback) {
Object response = responses.remove(0);
if (response instanceof Throwable) {
callback.onResult(null, (Throwable) response);
} else {
callback.onResult((T) response, null);
}
}
开发者ID:mongodb,项目名称:mongo-java-driver-reactivestreams,代码行数:9,代码来源:TestOperationExecutor.java
示例13: deleteMany
import com.mongodb.async.SingleResultCallback; //导入依赖的package包/类
@Override
public Observable<DeleteResult> deleteMany(final Bson filter) {
return RxObservables.create(Observables.observe(new Block<SingleResultCallback<DeleteResult>>() {
@Override
public void apply(final SingleResultCallback<DeleteResult> callback) {
wrapped.deleteMany(filter, callback);
}
}), observableAdapter);
}
开发者ID:mongodb,项目名称:mongo-java-driver-rx,代码行数:10,代码来源:MongoCollectionImpl.java
示例14: replaceOne
import com.mongodb.async.SingleResultCallback; //导入依赖的package包/类
@Override
public Observable<UpdateResult> replaceOne(final Bson filter, final TDocument replacement, final UpdateOptions options) {
return RxObservables.create(Observables.observe(new Block<SingleResultCallback<UpdateResult>>() {
@Override
public void apply(final SingleResultCallback<UpdateResult> callback) {
wrapped.replaceOne(filter, replacement, options, callback);
}
}), observableAdapter);
}
开发者ID:mongodb,项目名称:mongo-java-driver-rx,代码行数:10,代码来源:MongoCollectionImpl.java
示例15: updateOne
import com.mongodb.async.SingleResultCallback; //导入依赖的package包/类
@Override
public Observable<UpdateResult> updateOne(final Bson filter, final Bson update, final UpdateOptions options) {
return RxObservables.create(Observables.observe(new Block<SingleResultCallback<UpdateResult>>() {
@Override
public void apply(final SingleResultCallback<UpdateResult> callback) {
wrapped.updateOne(filter, update, options, callback);
}
}), observableAdapter);
}
开发者ID:mongodb,项目名称:mongo-java-driver-rx,代码行数:10,代码来源:MongoCollectionImpl.java
示例16: updateMany
import com.mongodb.async.SingleResultCallback; //导入依赖的package包/类
@Override
public Observable<UpdateResult> updateMany(final Bson filter, final Bson update, final UpdateOptions options) {
return RxObservables.create(Observables.observe(new Block<SingleResultCallback<UpdateResult>>() {
@Override
public void apply(final SingleResultCallback<UpdateResult> callback) {
wrapped.updateMany(filter, update, options, callback);
}
}), observableAdapter);
}
开发者ID:mongodb,项目名称:mongo-java-driver-rx,代码行数:10,代码来源:MongoCollectionImpl.java
示例17: findOneAndDelete
import com.mongodb.async.SingleResultCallback; //导入依赖的package包/类
@Override
public Observable<TDocument> findOneAndDelete(final Bson filter, final FindOneAndDeleteOptions options) {
return RxObservables.create(Observables.observe(new Block<SingleResultCallback<TDocument>>() {
@Override
public void apply(final SingleResultCallback<TDocument> callback) {
wrapped.findOneAndDelete(filter, options, callback);
}
}), observableAdapter);
}
开发者ID:mongodb,项目名称:mongo-java-driver-rx,代码行数:10,代码来源:MongoCollectionImpl.java
示例18: downloadToStream
import com.mongodb.async.SingleResultCallback; //导入依赖的package包/类
@Override
public Publisher<Long> downloadToStream(final ClientSession clientSession, final ObjectId id, final AsyncOutputStream destination) {
return new ObservableToPublisher<Long>(observe(new Block<SingleResultCallback<Long>>() {
@Override
public void apply(final SingleResultCallback<Long> callback) {
wrapped.downloadToStream(clientSession, id, toCallbackAsyncOutputStream(destination), callback);
}
}));
}
开发者ID:mongodb,项目名称:mongo-java-driver-reactivestreams,代码行数:10,代码来源:GridFSBucketImpl.java
示例19: findOneAndUpdate
import com.mongodb.async.SingleResultCallback; //导入依赖的package包/类
@Override
public Observable<TDocument> findOneAndUpdate(final Bson filter, final Bson update, final FindOneAndUpdateOptions options) {
return RxObservables.create(Observables.observe(new Block<SingleResultCallback<TDocument>>() {
@Override
public void apply(final SingleResultCallback<TDocument> callback) {
wrapped.findOneAndUpdate(filter, update, options, callback);
}
}), observableAdapter);
}
开发者ID:mongodb,项目名称:mongo-java-driver-rx,代码行数:10,代码来源:MongoCollectionImpl.java
示例20: drop
import com.mongodb.async.SingleResultCallback; //导入依赖的package包/类
@Override
public Publisher<Success> drop(final ClientSession clientSession) {
return new ObservableToPublisher<Success>(observe(new Block<SingleResultCallback<Success>>() {
@Override
public void apply(final SingleResultCallback<Success> callback) {
wrapped.drop(clientSession, voidToSuccessCallback(callback));
}
}));
}
开发者ID:mongodb,项目名称:mongo-java-driver-reactivestreams,代码行数:10,代码来源:GridFSBucketImpl.java
注:本文中的com.mongodb.async.SingleResultCallback类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论