/** * @throws IllegalStateException if candidate is not positive or if term, logIndex or logTerm * are negative */ @Override public VoteRequest build() { super.build(); Assert.stateNot(request.term < 0, "term must not be negative"); Assert.stateNot(request.logIndex < 0, "log index must not be negative"); Assert.stateNot(request.logTerm < 0, "log term must not be negative"); return request; }
/** @throws IllegalStateException if status is OK and members is null */ @Override public RegisterResponse build() { super.build(); Assert.stateNot( response.status == Status.OK && response.members == null, "members cannot be null"); Assert.stateNot( response.status == Status.OK && response.timeout <= 0, "timeout must be positive"); return response; }
/** @throws IllegalStateException if {@code term} is negative */ @Override public VoteResponse build() { super.build(); if (response.status == Response.Status.OK) { Assert.stateNot(response.term < 0, "term cannot be negative"); } return response; }
@Override public Snapshot complete() { Buffer buffer = FileBuffer.allocate(file.file(), SnapshotDescriptor.BYTES); try (SnapshotDescriptor descriptor = new SnapshotDescriptor(buffer)) { Assert.stateNot(descriptor.locked(), "cannot complete locked snapshot descriptor"); descriptor.lock(); } return super.complete(); }
/** @throws IllegalStateException if sequence is less than 1 */ @Override public PublishResponse build() { super.build(); Assert.stateNot(response.version < 0, "version cannot be less than 0"); return response; }