本文整理匯總了Java中com.couchbase.client.core.state.NotConnectedException類的典型用法代碼示例。如果您正苦於以下問題:Java NotConnectedException類的具體用法?Java NotConnectedException怎麽用?Java NotConnectedException使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
NotConnectedException類屬於com.couchbase.client.core.state包,在下文中一共展示了NotConnectedException類的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: closeStream
import com.couchbase.client.core.state.NotConnectedException; //導入依賴的package包/類
public Completable closeStream(final short vbid) {
return Completable.create(new Completable.OnSubscribe() {
@Override
public void call(final CompletableSubscriber subscriber) {
if (state() != LifecycleState.CONNECTED) {
subscriber.onError(new NotConnectedException());
return;
}
LOGGER.debug("Closing Stream against {} with vbid: {}", channel.remoteAddress(), vbid);
int opaque = OPAQUE.incrementAndGet();
ChannelPromise promise = channel.newPromise();
ByteBuf buffer = Unpooled.buffer();
DcpCloseStreamRequest.init(buffer);
DcpCloseStreamRequest.vbucket(buffer, vbid);
DcpCloseStreamRequest.opaque(buffer, opaque);
outstandingPromises.put(opaque, promise);
channel.writeAndFlush(buffer);
promise.addListener(new GenericFutureListener<ChannelFuture>() {
@Override
public void operationComplete(ChannelFuture future) throws Exception {
openStreams.set(vbid, 0);
if (future.isSuccess()) {
LOGGER.debug("Closed Stream against {} with vbid: {}", channel.remoteAddress(), vbid);
subscriber.onCompleted();
} else {
LOGGER.debug("Failed close Stream against {} with vbid: {}", channel.remoteAddress(), vbid);
subscriber.onError(future.cause());
}
}
});
}
});
}
示例2: getSeqnos
import com.couchbase.client.core.state.NotConnectedException; //導入依賴的package包/類
/**
* Returns all seqnos for all vbuckets on that channel.
*/
public Single<ByteBuf> getSeqnos() {
return Single.create(new Single.OnSubscribe<ByteBuf>() {
@Override
public void call(final SingleSubscriber<? super ByteBuf> subscriber) {
if (state() != LifecycleState.CONNECTED) {
subscriber.onError(new NotConnectedException());
return;
}
int opaque = OPAQUE.incrementAndGet();
Promise<ByteBuf> promise = new DefaultPromise<ByteBuf>(channel.eventLoop());
ByteBuf buffer = Unpooled.buffer();
DcpGetPartitionSeqnosRequest.init(buffer);
DcpGetPartitionSeqnosRequest.opaque(buffer, opaque);
DcpGetPartitionSeqnosRequest.vbucketState(buffer, VbucketState.ACTIVE);
outstandingPromises.put(opaque, promise);
channel.writeAndFlush(buffer);
promise.addListener(new GenericFutureListener<Future<ByteBuf>>() {
@Override
public void operationComplete(Future<ByteBuf> future) throws Exception {
if (future.isSuccess()) {
subscriber.onSuccess(future.getNow());
} else {
subscriber.onError(future.cause());
}
}
});
}
});
}
示例3: getFailoverLog
import com.couchbase.client.core.state.NotConnectedException; //導入依賴的package包/類
public Single<ByteBuf> getFailoverLog(final short vbid) {
return Single.create(new Single.OnSubscribe<ByteBuf>() {
@Override
public void call(final SingleSubscriber<? super ByteBuf> subscriber) {
if (state() != LifecycleState.CONNECTED) {
subscriber.onError(new NotConnectedException());
return;
}
int opaque = OPAQUE.incrementAndGet();
Promise<ByteBuf> promise = new DefaultPromise<ByteBuf>(channel.eventLoop());
ByteBuf buffer = Unpooled.buffer();
DcpFailoverLogRequest.init(buffer);
DcpFailoverLogRequest.opaque(buffer, opaque);
DcpFailoverLogRequest.vbucket(buffer, vbid);
outstandingPromises.put(opaque, promise);
outstandingVbucketInfos.put(opaque, vbid);
channel.writeAndFlush(buffer);
LOGGER.debug("Asked for failover log on {} for vbid: {}", channel.remoteAddress(), vbid);
promise.addListener(new GenericFutureListener<Future<ByteBuf>>() {
@Override
public void operationComplete(Future<ByteBuf> future) throws Exception {
if (future.isSuccess()) {
LOGGER.debug("Failover log for vbid {} is {}", vbid, DcpFailoverLogResponse.toString(future.getNow()));
subscriber.onSuccess(future.getNow());
} else {
LOGGER.debug("Failed to ask for failover log on {} for vbid: {}", channel.remoteAddress(), vbid);
subscriber.onError(future.cause());
}
}
});
}
});
}
示例4: getFailoverLog
import com.couchbase.client.core.state.NotConnectedException; //導入依賴的package包/類
@SuppressWarnings("unchecked")
public Single<ByteBuf> getFailoverLog(final short partition) {
return Observable
.just(partition)
.map(new Func1<Short, DcpChannel>() {
@Override
public DcpChannel call(Short aShort) {
return masterChannelByPartition(partition);
}
})
.flatMapSingle(new Func1<DcpChannel, Single<ByteBuf>>() {
@Override
public Single<ByteBuf> call(DcpChannel channel) {
return channel.getFailoverLog(partition);
}
})
.retryWhen(anyOf(NotConnectedException.class)
.max(Integer.MAX_VALUE)
.delay(Delay.fixed(200, TimeUnit.MILLISECONDS))
.doOnRetry(new Action4<Integer, Throwable, Long, TimeUnit>() {
@Override
public void call(Integer integer, Throwable throwable, Long aLong, TimeUnit timeUnit) {
LOGGER.debug("Rescheduling Get Failover Log for vbid {}, not connected (yet).", partition);
}
})
.build()
).toSingle();
}
示例5: startStreamForPartition
import com.couchbase.client.core.state.NotConnectedException; //導入依賴的package包/類
@SuppressWarnings("unchecked")
public Completable startStreamForPartition(final short partition, final long vbuuid, final long startSeqno,
final long endSeqno, final long snapshotStartSeqno, final long snapshotEndSeqno) {
return Observable
.just(partition)
.map(new Func1<Short, DcpChannel>() {
@Override
public DcpChannel call(Short aShort) {
return masterChannelByPartition(partition);
}
})
.flatMapCompletable(new Func1<DcpChannel, Completable>() {
@Override
public Completable call(DcpChannel channel) {
return channel.openStream(partition, vbuuid, startSeqno, endSeqno, snapshotStartSeqno, snapshotEndSeqno);
}
})
.retryWhen(anyOf(NotConnectedException.class)
.max(Integer.MAX_VALUE)
.delay(Delay.fixed(200, TimeUnit.MILLISECONDS))
.doOnRetry(new Action4<Integer, Throwable, Long, TimeUnit>() {
@Override
public void call(Integer integer, Throwable throwable, Long aLong, TimeUnit timeUnit) {
LOGGER.debug("Rescheduling Stream Start for vbid {}, not connected (yet).", partition);
}
})
.build()
)
.toCompletable();
}
示例6: shouldRejectMessageIfNotConnected
import com.couchbase.client.core.state.NotConnectedException; //導入依賴的package包/類
@Test(expected = NotConnectedException.class)
public void shouldRejectMessageIfNotConnected() {
BootstrapAdapter bootstrap = mock(BootstrapAdapter.class);
Endpoint endpoint = new DummyEndpoint(bootstrap, environment);
CouchbaseRequest mockRequest = mock(CouchbaseRequest.class);
Subject<CouchbaseResponse, CouchbaseResponse> subject = AsyncSubject.create();
when(mockRequest.observable()).thenReturn(subject);
endpoint.send(mockRequest);
mockRequest.observable().toBlocking().single();
}
示例7: openStream
import com.couchbase.client.core.state.NotConnectedException; //導入依賴的package包/類
public Completable openStream(final short vbid, final long vbuuid, final long startSeqno, final long endSeqno,
final long snapshotStartSeqno, final long snapshotEndSeqno) {
return Completable.create(new Completable.OnSubscribe() {
@Override
public void call(final CompletableSubscriber subscriber) {
if (state() != LifecycleState.CONNECTED) {
subscriber.onError(new NotConnectedException());
return;
}
LOGGER.debug("Opening Stream against {} with vbid: {}, vbuuid: {}, startSeqno: {}, " +
"endSeqno: {}, snapshotStartSeqno: {}, snapshotEndSeqno: {}",
channel.remoteAddress(), vbid, vbuuid, startSeqno, endSeqno, snapshotStartSeqno, snapshotEndSeqno);
int opaque = OPAQUE.incrementAndGet();
ChannelPromise promise = channel.newPromise();
ByteBuf buffer = Unpooled.buffer();
DcpOpenStreamRequest.init(buffer, vbid);
DcpOpenStreamRequest.opaque(buffer, opaque);
DcpOpenStreamRequest.vbuuid(buffer, vbuuid);
DcpOpenStreamRequest.startSeqno(buffer, startSeqno);
DcpOpenStreamRequest.endSeqno(buffer, endSeqno);
DcpOpenStreamRequest.snapshotStartSeqno(buffer, snapshotStartSeqno);
DcpOpenStreamRequest.snapshotEndSeqno(buffer, snapshotEndSeqno);
outstandingPromises.put(opaque, promise);
outstandingVbucketInfos.put(opaque, vbid);
channel.writeAndFlush(buffer);
promise.addListener(new GenericFutureListener<ChannelFuture>() {
@Override
public void operationComplete(ChannelFuture future) throws Exception {
if (future.isSuccess()) {
LOGGER.debug("Opened Stream against {} with vbid: {}", channel.remoteAddress(), vbid);
openStreams.set(vbid, 1);
subscriber.onCompleted();
} else {
LOGGER.debug("Failed open Stream against {} with vbid: {}", channel.remoteAddress(), vbid);
openStreams.set(vbid, 0);
subscriber.onError(future.cause());
}
}
});
}
});
}