@Override public void sendFenceResponse(long tableID, long fenceTimestamp, Channel c, MonitoringContext monCtx) { TSOProto.Response.Builder builder = TSOProto.Response.newBuilder(); TSOProto.FenceResponse.Builder fenceBuilder = TSOProto.FenceResponse.newBuilder(); fenceBuilder.setTableId(tableID); fenceBuilder.setFenceId(fenceTimestamp); builder.setFenceResponse(fenceBuilder.build()); c.write(builder.build()); monCtx.timerStop("reply.processor.fence.latency"); fenceMeter.mark(); }
private void handleResponse(ResponseEvent response) { TSOProto.Response resp = response.getParam(); if (resp.hasTimestampResponse()) { if (timestampRequests.size() == 0) { LOG.debug("Received timestamp response when no requests outstanding"); e.getRequest().success(resp.getTimestampResponse().getStartTimestamp()); if (e.getTimeout() != null) { e.getTimeout().cancel(); } else if (resp.hasCommitResponse()) { long startTimestamp = resp.getCommitResponse().getStartTimestamp(); RequestAndTimeout e = commitRequests.remove(startTimestamp); if (e == null) { e.getTimeout().cancel(); if (resp.getCommitResponse().getAborted()) { e.getRequest().error(new AbortException()); } else { e.getRequest().success(resp.getCommitResponse().getCommitTimestamp()); } else if (resp.hasFenceResponse()) { long tableID = resp.getFenceResponse().getTableId(); RequestAndTimeout e = fenceRequests.remove(tableID); if (e == null) { e.getRequest().success(resp.getFenceResponse().getFenceId());
pipeline.addLast("lengthbaseddecoder", new LengthFieldBasedFrameDecoder(8 * 1024, 0, 4, 0, 4)); pipeline.addLast("lengthprepender", new LengthFieldPrepender(4)); pipeline.addLast("protobufdecoder", new ProtobufDecoder(TSOProto.Response.getDefaultInstance())); pipeline.addLast("protobufencoder", new ProtobufEncoder()); pipeline.addLast("handler", new Handler(fsm));
pipeline.addLast("lengthbaseddecoder", new LengthFieldBasedFrameDecoder(8 * 1024, 0, 4, 0, 4)); pipeline.addLast("lengthprepender", new LengthFieldPrepender(4)); pipeline.addLast("protobufdecoder", new ProtobufDecoder(TSOProto.Response.getDefaultInstance())); pipeline.addLast("protobufencoder", new ProtobufEncoder()); pipeline.addLast("handler", new Handler(fsm));
private void handleResponse(ResponseEvent response) { TSOProto.Response resp = response.getParam(); if (resp.hasTimestampResponse()) { if (timestampRequests.size() == 0) { LOG.debug("Received timestamp response when no requests outstanding"); return; } RequestAndTimeout e = timestampRequests.remove(); e.getRequest().success(resp.getTimestampResponse().getStartTimestamp()); if (e.getTimeout() != null) { e.getTimeout().cancel(); } } else if (resp.hasCommitResponse()) { long startTimestamp = resp.getCommitResponse().getStartTimestamp(); RequestAndTimeout e = commitRequests.remove(startTimestamp); if (e == null) { LOG.debug("Received commit response for request that doesn't exist. Start TS: {}", startTimestamp); return; } if (e.getTimeout() != null) { e.getTimeout().cancel(); } if (resp.getCommitResponse().getAborted()) { e.getRequest().error(new AbortException()); } else { e.getRequest().success(resp.getCommitResponse().getCommitTimestamp()); } } }
public Builder toBuilder() { return newBuilder(this); }
public Builder newBuilderForType() { return newBuilder(); } public static Builder newBuilder(org.apache.omid.proto.TSOProto.Response prototype) {
public Builder mergeFrom(org.apache.omid.proto.TSOProto.Response other) { if (other == org.apache.omid.proto.TSOProto.Response.getDefaultInstance()) return this; if (other.hasTimestampResponse()) { mergeTimestampResponse(other.getTimestampResponse()); } if (other.hasCommitResponse()) { mergeCommitResponse(other.getCommitResponse()); } if (other.hasHandshakeResponse()) { mergeHandshakeResponse(other.getHandshakeResponse()); } if (other.hasFenceResponse()) { mergeFenceResponse(other.getFenceResponse()); } this.mergeUnknownFields(other.getUnknownFields()); return this; }
private void checkHandshake(final ChannelHandlerContext ctx, TSOProto.HandshakeRequest request) { TSOProto.HandshakeResponse.Builder response = TSOProto.HandshakeResponse.newBuilder(); if (request.hasClientCapabilities()) { response.setClientCompatible(true) .setServerCapabilities(TSOProto.Capabilities.newBuilder().build()); TSOChannelContext tsoCtx = new TSOChannelContext(); tsoCtx.setHandshakeComplete(); ctx.setAttachment(tsoCtx); } else { response.setClientCompatible(false); } response.setLowLatency(config.getLowLatency()); ctx.getChannel().write(TSOProto.Response.newBuilder().setHandshakeResponse(response.build()).build()); }
public org.apache.omid.proto.TSOProto.Response getDefaultInstanceForType() { return org.apache.omid.proto.TSOProto.Response.getDefaultInstance(); }
private void checkHandshake(final ChannelHandlerContext ctx, TSOProto.HandshakeRequest request) { TSOProto.HandshakeResponse.Builder response = TSOProto.HandshakeResponse.newBuilder(); if (request.hasClientCapabilities()) { response.setClientCompatible(true) .setServerCapabilities(TSOProto.Capabilities.newBuilder().build()); TSOChannelContext tsoCtx = new TSOChannelContext(); tsoCtx.setHandshakeComplete(); ctx.setAttachment(tsoCtx); } else { response.setClientCompatible(false); } ctx.getChannel().write(TSOProto.Response.newBuilder().setHandshakeResponse(response.build()).build()); }
public StateMachine.State handleEvent(ResponseEvent e) { lowLatency = e.getParam().getHandshakeResponse().getLowLatency(); if (e.getParam().hasHandshakeResponse() && e.getParam().getHandshakeResponse().getClientCompatible()) { if (timeout != null) { timeout.cancel(); } return new ConnectedState(fsm, channel, timeoutExecutor); } else { cleanupState(); LOG.error("Client incompatible with server"); return new HandshakeFailedState(fsm, new HandshakeFailedException()); } }
@Override public void sendTimestampResponse(long startTimestamp, Channel c, MonitoringContext monCtx) { TSOProto.Response.Builder builder = TSOProto.Response.newBuilder(); TSOProto.TimestampResponse.Builder respBuilder = TSOProto.TimestampResponse.newBuilder(); respBuilder.setStartTimestamp(startTimestamp); builder.setTimestampResponse(respBuilder.build()); c.write(builder.build()); timestampMeter.mark(); monCtx.timerStop("reply.processor.timestamp.latency"); }
@Override public void sendCommitResponse(long startTimestamp, long commitTimestamp, Channel c, MonitoringContext monCtx) { TSOProto.Response.Builder builder = TSOProto.Response.newBuilder(); TSOProto.CommitResponse.Builder commitBuilder = TSOProto.CommitResponse.newBuilder(); commitBuilder.setAborted(false) .setStartTimestamp(startTimestamp) .setCommitTimestamp(commitTimestamp); builder.setCommitResponse(commitBuilder.build()); c.write(builder.build()); commitMeter.mark(); monCtx.timerStop("reply.processor.commit.latency"); }
@Override public void sendAbortResponse(long startTimestamp, Channel c) { TSOProto.Response.Builder builder = TSOProto.Response.newBuilder(); TSOProto.CommitResponse.Builder commitBuilder = TSOProto.CommitResponse.newBuilder(); commitBuilder.setAborted(true); commitBuilder.setStartTimestamp(startTimestamp); builder.setCommitResponse(commitBuilder.build()); c.write(builder.build()); abortMeter.mark(); }
@Override public void sendCommitResponse(long startTimestamp, long commitTimestamp, Channel c) { TSOProto.Response.Builder builder = TSOProto.Response.newBuilder(); TSOProto.CommitResponse.Builder commitBuilder = TSOProto.CommitResponse.newBuilder(); commitBuilder.setAborted(false) .setStartTimestamp(startTimestamp) .setCommitTimestamp(commitTimestamp); builder.setCommitResponse(commitBuilder.build()); c.write(builder.build()); commitMeter.mark(); }
@Override public void sendAbortResponse(long startTimestamp, Channel c) { TSOProto.Response.Builder builder = TSOProto.Response.newBuilder(); TSOProto.CommitResponse.Builder commitBuilder = TSOProto.CommitResponse.newBuilder(); commitBuilder.setAborted(true); commitBuilder.setStartTimestamp(startTimestamp); builder.setCommitResponse(commitBuilder.build()); c.write(builder.build()); }
@Override public void sendCommitResponse(long startTimestamp, long commitTimestamp, Channel c) { TSOProto.Response.Builder builder = TSOProto.Response.newBuilder(); TSOProto.CommitResponse.Builder commitBuilder = TSOProto.CommitResponse.newBuilder(); commitBuilder.setAborted(false) .setStartTimestamp(startTimestamp) .setCommitTimestamp(commitTimestamp); builder.setCommitResponse(commitBuilder.build()); c.write(builder.build()); }
@Override public void sendTimestampResponse(long startTimestamp, Channel c) { TSOProto.Response.Builder builder = TSOProto.Response.newBuilder(); TSOProto.TimestampResponse.Builder respBuilder = TSOProto.TimestampResponse.newBuilder(); respBuilder.setStartTimestamp(startTimestamp); builder.setTimestampResponse(respBuilder.build()); c.write(builder.build()); timestampMeter.mark(); }
public StateMachine.State handleEvent(ResponseEvent e) { if (e.getParam().hasHandshakeResponse() && e.getParam().getHandshakeResponse().getClientCompatible()) { if (timeout != null) { timeout.cancel(); } return new ConnectedState(fsm, channel, timeoutExecutor); } else { cleanupState(); LOG.error("Client incompatible with server"); return new HandshakeFailedState(fsm, new HandshakeFailedException()); } }