// Path: src/main/java/org/tools4j/hoverraft/command/Command.java
// public interface Command extends DirectPayload, Event {
// 
//     CommandKey commandKey();
// 
//     CommandPayload commandPayload();
// 
//     default Command sourceId(final int sourceId) {
//         commandKey().sourceId(sourceId);
//         return this;
//     }
// 
//     default Command commandIndex(final long commandIndex) {
//         commandKey().commandIndex(commandIndex);
//         return this;
//     }
// 
//     default void copyFrom(final Command command) {
//         writeBufferOrNull().putBytes(offset(), command.readBufferOrNull(), command.offset(), command.byteLength());
//     }
// 
//     @Override
//     default Transition accept(final ServerContext serverContext, final EventHandler eventHandler) {
//         return eventHandler.onCommand(serverContext, this);
//     }
// 
// }
// 
// Path: src/main/java/org/tools4j/hoverraft/command/CommandKey.java
// public interface CommandKey extends Comparable<CommandKey> {
//     Comparator<CommandKey> COMPARATOR = (k1, k2) -> {
//         final int sourceCompare = Integer.compare(k1.sourceId(), k2.sourceId());
//         return sourceCompare == 0 ? Long.compare(k1.commandIndex(), k2.commandIndex()) : sourceCompare;
//     };
// 
//     int sourceId();
//     CommandKey sourceId(int sourceId);
// 
//     long commandIndex();
//     CommandKey commandIndex(long commandIndex);
// 
//     @Override
//     default int compareTo(final CommandKey other) {
//         return COMPARATOR.compare(this, other);
//     }
// 
//     default boolean containedIn(final CommandLog commandLog) {
//         return commandLog.contains(this);
//     }
// }
// 
// Path: src/main/java/org/tools4j/hoverraft/command/DirectLogEntry.java
// public class DirectLogEntry extends AbstractDirectPayload implements LogEntry {
//     public static final int EMPTY_COMMAND_BYTE_LENGTH = DirectLogKey.BYTE_LENGTH + DirectCommand.EMPTY_COMMAND_BYTE_LENGTH;
//     private static final int LOG_KEY_OFF = 0;
//     private static final int LOG_KEY_LEN = DirectLogKey.BYTE_LENGTH;
// 
//     private static final int COMMAND_OFF = LOG_KEY_OFF + LOG_KEY_LEN;
// 
//     private DirectLogKey directLogKey = new DirectLogKey();
//     private DirectCommand directCommand = new DirectCommand();
// 
//     @Override
//     public void wrap(final DirectBuffer buffer, final int offset) {
//         super.wrap(buffer, offset);
//         directLogKey.wrap(buffer, offset + LOG_KEY_OFF);
//         directCommand.wrap(buffer, offset + COMMAND_OFF);
//     }
// 
//     @Override
//     public void wrap(final MutableDirectBuffer buffer, final int offset) {
//         super.wrap(buffer, offset);
//         directLogKey.wrap(buffer, offset + LOG_KEY_OFF);
//         directCommand.wrap(buffer, offset + COMMAND_OFF);
//     }
// 
//     @Override
//     public void unwrap() {
//         directLogKey.unwrap();
//         directCommand.unwrap();
//         super.unwrap();
//     }
// 
// 
//     @Override
//     public Command command() {
//         return directCommand;
//     }
// 
//     @Override
//     public LogKey logKey() {
//         return directLogKey;
//     }
// 
//     @Override
//     public int byteLength() {
//         return COMMAND_OFF + directCommand.byteLength();
//     }
// }
// 
// Path: src/main/java/org/tools4j/hoverraft/command/LogEntry.java
// public interface LogEntry extends DirectPayload {
//     LogKey logKey();
// 
//     default LogEntry term(final int term) {
//         logKey().term(term);
//         return this;
//     }
//     default LogEntry index(final long index) {
//         logKey().index(index);
//         return this;
//     }
// 
//     Command command();
// 
//     default void copyFrom(final LogEntry logEntry) {
//         writeBufferOrNull().putBytes(offset(), logEntry.readBufferOrNull(), logEntry.offset(), logEntry.byteLength());
//     }
// }


import org.tools4j.hoverraft.message.direct.*;
import org.agrona.ExpandableArrayBuffer;
import org.agrona.MutableDirectBuffer;
import org.tools4j.hoverraft.command.Command;
import org.tools4j.hoverraft.command.CommandKey;
import org.tools4j.hoverraft.command.DirectLogEntry;
import org.tools4j.hoverraft.command.LogEntry;
import org.tools4j.hoverraft.message.*;
    @Override
    public VoteResponse voteResponse() {
        final DirectVoteResponse directVoteResponse = new DirectVoteResponse();
        directVoteResponse.wrap(newBuffer(DirectVoteResponse.BYTE_LENGTH), 0);
        return directVoteResponse;
    }

    @Override
    public TimeoutNow timeoutNow() {
        final DirectTimeoutNow directTimeoutNow = new DirectTimeoutNow();
        directTimeoutNow.wrap(newBuffer(DirectTimeoutNow.BYTE_LENGTH), 0);
        return null;
    }

    @Override
    public CommandKey commandKey() {
        final DirectCommandKey directCommandKey = new DirectCommandKey();
        directCommandKey.wrap(newBuffer(DirectCommandKey.BYTE_LENGTH), 0);
        return directCommandKey;
    }

    @Override
    public Command command() {
        final DirectCommand directCommand = new DirectCommand();
        directCommand.wrap(newBuffer(DirectCommand.EMPTY_COMMAND_BYTE_LENGTH), 0);
        return directCommand;
    }

    @Override
    public LogEntry logEntry() {
// Path: src/main/java/org/tools4j/hoverraft/command/Command.java
// public interface Command extends DirectPayload, Event {
// 
//     CommandKey commandKey();
// 
//     CommandPayload commandPayload();
// 
//     default Command sourceId(final int sourceId) {
//         commandKey().sourceId(sourceId);
//         return this;
//     }
// 
//     default Command commandIndex(final long commandIndex) {
//         commandKey().commandIndex(commandIndex);
//         return this;
//     }
// 
//     default void copyFrom(final Command command) {
//         writeBufferOrNull().putBytes(offset(), command.readBufferOrNull(), command.offset(), command.byteLength());
//     }
// 
//     @Override
//     default Transition accept(final ServerContext serverContext, final EventHandler eventHandler) {
//         return eventHandler.onCommand(serverContext, this);
//     }
// 
// }
// 
// Path: src/main/java/org/tools4j/hoverraft/command/CommandKey.java
// public interface CommandKey extends Comparable<CommandKey> {
//     Comparator<CommandKey> COMPARATOR = (k1, k2) -> {
//         final int sourceCompare = Integer.compare(k1.sourceId(), k2.sourceId());
//         return sourceCompare == 0 ? Long.compare(k1.commandIndex(), k2.commandIndex()) : sourceCompare;
//     };
// 
//     int sourceId();
//     CommandKey sourceId(int sourceId);
// 
//     long commandIndex();
//     CommandKey commandIndex(long commandIndex);
// 
//     @Override
//     default int compareTo(final CommandKey other) {
//         return COMPARATOR.compare(this, other);
//     }
// 
//     default boolean containedIn(final CommandLog commandLog) {
//         return commandLog.contains(this);
//     }
// }
// 
// Path: src/main/java/org/tools4j/hoverraft/command/DirectLogEntry.java
// public class DirectLogEntry extends AbstractDirectPayload implements LogEntry {
//     public static final int EMPTY_COMMAND_BYTE_LENGTH = DirectLogKey.BYTE_LENGTH + DirectCommand.EMPTY_COMMAND_BYTE_LENGTH;
//     private static final int LOG_KEY_OFF = 0;
//     private static final int LOG_KEY_LEN = DirectLogKey.BYTE_LENGTH;
// 
//     private static final int COMMAND_OFF = LOG_KEY_OFF + LOG_KEY_LEN;
// 
//     private DirectLogKey directLogKey = new DirectLogKey();
//     private DirectCommand directCommand = new DirectCommand();
// 
//     @Override
//     public void wrap(final DirectBuffer buffer, final int offset) {
//         super.wrap(buffer, offset);
//         directLogKey.wrap(buffer, offset + LOG_KEY_OFF);
//         directCommand.wrap(buffer, offset + COMMAND_OFF);
//     }
// 
//     @Override
//     public void wrap(final MutableDirectBuffer buffer, final int offset) {
//         super.wrap(buffer, offset);
//         directLogKey.wrap(buffer, offset + LOG_KEY_OFF);
//         directCommand.wrap(buffer, offset + COMMAND_OFF);
//     }
// 
//     @Override
//     public void unwrap() {
//         directLogKey.unwrap();
//         directCommand.unwrap();
//         super.unwrap();
//     }
// 
// 
//     @Override
//     public Command command() {
//         return directCommand;
//     }
// 
//     @Override
//     public LogKey logKey() {
//         return directLogKey;
//     }
// 
//     @Override
//     public int byteLength() {
//         return COMMAND_OFF + directCommand.byteLength();
//     }
// }
// 
// Path: src/main/java/org/tools4j/hoverraft/command/LogEntry.java
// public interface LogEntry extends DirectPayload {
//     LogKey logKey();
// 
//     default LogEntry term(final int term) {
//         logKey().term(term);
//         return this;
//     }
//     default LogEntry index(final long index) {
//         logKey().index(index);
//         return this;
//     }
// 
//     Command command();
// 
//     default void copyFrom(final LogEntry logEntry) {
//         writeBufferOrNull().putBytes(offset(), logEntry.readBufferOrNull(), logEntry.offset(), logEntry.byteLength());
//     }
// }


// Path: src/main/java/org/tools4j/hoverraft/direct/AllocatingDirectFactory.java
import org.tools4j.hoverraft.message.direct.*;
import org.agrona.ExpandableArrayBuffer;
import org.agrona.MutableDirectBuffer;
import org.tools4j.hoverraft.command.Command;
import org.tools4j.hoverraft.command.CommandKey;
import org.tools4j.hoverraft.command.DirectLogEntry;
import org.tools4j.hoverraft.command.LogEntry;
import org.tools4j.hoverraft.message.*;

    @Override
    public VoteResponse voteResponse() {
        final DirectVoteResponse directVoteResponse = new DirectVoteResponse();
        directVoteResponse.wrap(newBuffer(DirectVoteResponse.BYTE_LENGTH), 0);
        return directVoteResponse;
    }

    @Override
    public TimeoutNow timeoutNow() {
        final DirectTimeoutNow directTimeoutNow = new DirectTimeoutNow();
        directTimeoutNow.wrap(newBuffer(DirectTimeoutNow.BYTE_LENGTH), 0);
        return null;
    }

    @Override
    public CommandKey commandKey() {
        final DirectCommandKey directCommandKey = new DirectCommandKey();
        directCommandKey.wrap(newBuffer(DirectCommandKey.BYTE_LENGTH), 0);
        return directCommandKey;
    }

    @Override
    public Command command() {
        final DirectCommand directCommand = new DirectCommand();
        directCommand.wrap(newBuffer(DirectCommand.EMPTY_COMMAND_BYTE_LENGTH), 0);
        return directCommand;
    }

    @Override
    public LogEntry logEntry() {
        final DirectLogEntry directCommandLogEntry = new DirectLogEntry();