@Override public void sendAsync(RowMap r, AbstractAsyncProducer.CallbackCompleter cc) throws Exception { String key = this.partitioner.getKinesisKey(r); String value = r.toJSON(outputConfig); int vsize = value.length(); ByteBuffer encodedValue = ByteBuffer.wrap(value.getBytes("UTF-8")); // release the reference to ease memory pressure if(!KinesisCallback.logger.isDebugEnabled()) { value = null; } FutureCallback<UserRecordResult> callback = new KinesisCallback(cc, r.getNextPosition(), key, value, this.succeededMessageCount, this.failedMessageCount, this.succeededMessageMeter, this.failedMessageMeter, this.context); try { ListenableFuture<UserRecordResult> future = kinesisProducer.addUserRecord(kinesisStream, key, encodedValue); Futures.addCallback(future, callback); } catch(IllegalArgumentException t) { callback.onFailure(t); logger.error("Database:" + r.getDatabase() + ", Table:" + r.getTable() + ", PK:" + r.getRowIdentity().toConcatString() + ", Size:" + Integer.toString(vsize)); } }
@Override public void onFailure(Throwable t) { resourceCallback.onFailure(t); } });
@Override public void onFailure(Throwable t) { if (shouldProcess()) { callback.onFailure(t); } } };
@Override public void onFailure(Throwable t) { if (shouldProcess()) { callback.onFailure(t); } } };
@Override public void onFailure(Throwable t) { try { callback.onFailure(t); } finally { asyncSemaphore.release(); } } };
@Override public void onFailure(Throwable t) { if (isRunning()) { callback.onFailure(t); } } };
@Override public void onFailure(Throwable t) { if (isRunning()) { callback.onFailure(t); } } };
@Override public void operationComplete(Future<Object> future) throws Exception { if (future.isSuccess()) { this.callback.onSuccess(null); } else { this.callback.onFailure(future.cause()); } }
@Override public void operationComplete(ChannelFuture future) throws Exception { if (future.isSuccess()) { this.observer.onSuccess(null); } else { this.observer.onFailure(future.cause()); } } }
@Override public void verifyCallbackCalledWithException(Exception exception) { waitForCallback(); verify(callback).onFailure(exception); }
void failedPreCommit(final Exception cause) { if (LOG.isTraceEnabled()) { LOG.trace("Transaction {} failed to prepare", transaction, cause); } else { LOG.error("Transaction {} failed to prepare", transactionId, cause); } userCohorts.abort(); switchState(State.FAILED).onFailure(cause); }
@Override public void onFailure(Throwable t) { log.warn("Channel could not be opened, so will be terminated prematurely.", t); fire(NettyNetworkChannelEvent.CLOSE, this.context); this.context.getCallback().onFailure(t); }
@Override public void disconnect(FutureCallback<Void> callback) { if (isConnected()) { NettyNetworkChannelTransitionContext transitionContext = new NettyNetworkChannelTransitionContext().setCallback(callback); this.fsm.fire(NettyNetworkChannelEvent.DISCONNECT, transitionContext); } else { // TODO handle inside FSM Listener callback.onFailure(new IllegalStateException("Channel is not connected.")); } }
@Override public void close(FutureCallback<Void> callback) { if (isOpen()) { NettyNetworkChannelTransitionContext transitionContext = new NettyNetworkChannelTransitionContext().setCallback(callback); this.fsm.fire(NettyNetworkChannelEvent.CLOSE, transitionContext); } else { // TODO handle inside FSM Listener callback.onFailure(new IllegalStateException("Channel is already closed.")); } }
@Override public void disconnect(FutureCallback<Void> callback) { if (isConnected()) { NettyNetworkChannelTransitionContext transitionContext = new NettyNetworkChannelTransitionContext().setCallback(callback); this.fsm.fire(NettyNetworkChannelEvent.DISCONNECT, transitionContext); } else { // TODO handle inside FSM Listener callback.onFailure(new IllegalStateException("Channel is not connected.")); } }
@Override public void bind(SocketAddress localAddress, FutureCallback<Void> callback) { if (isBound()) { // TODO handle inside FSM Listener callback.onFailure(new IllegalStateException("Channel is already bound.")); } else { this.context.setLocalAddress(localAddress); NettyNetworkChannelTransitionContext transitionContext = new NettyNetworkChannelTransitionContext().setCallback(callback); this.fsm.fire(NettyNetworkChannelEvent.BIND, transitionContext); } }
@Override public void connect(SocketAddress remoteAddress, FutureCallback<Void> callback) { if (isConnected()) { // TODO handle inside FSM Listener callback.onFailure(new IllegalStateException("Channel is already bound.")); } else { this.context.setRemoteAddress(remoteAddress); NettyNetworkChannelTransitionContext transitionContext = new NettyNetworkChannelTransitionContext().setCallback(callback); this.fsm.fire(NettyNetworkChannelEvent.CONNECT, transitionContext); } }