Search in sources :

Example 21 with DirectBuffer

use of org.agrona.DirectBuffer in project zeebe by zeebe-io.

the class ControlMessageRequest method awaitError.

public ErrorResponse awaitError() {
    try (ClientResponse response = responseFuture.join()) {
        final ErrorResponse errorResponse = new ErrorResponse(msgPackHelper);
        final DirectBuffer responseBuffer = response.getResponseBuffer();
        errorResponse.wrap(responseBuffer, 0, responseBuffer.capacity());
        return errorResponse;
    }
}
Also used : MutableDirectBuffer(org.agrona.MutableDirectBuffer) DirectBuffer(org.agrona.DirectBuffer)

Example 22 with DirectBuffer

use of org.agrona.DirectBuffer in project zeebe by zeebe-io.

the class ExecuteCommandRequest method awaitError.

public ErrorResponse awaitError() {
    try (ClientResponse response = responseFuture.join()) {
        final DirectBuffer responseBuffer = response.getResponseBuffer();
        final ErrorResponse result = new ErrorResponse(msgPackHelper);
        result.wrap(responseBuffer, 0, responseBuffer.capacity());
        return result;
    }
}
Also used : MutableDirectBuffer(org.agrona.MutableDirectBuffer) DirectBuffer(org.agrona.DirectBuffer)

Example 23 with DirectBuffer

use of org.agrona.DirectBuffer in project zeebe by zeebe-io.

the class TopologyCreator method createTopology.

public Topology createTopology() {
    LOG.trace("Received topology request.");
    final Iterator<MemberRaftComposite> iterator = clusterManagerContext.getMemberListService().iterator();
    final Topology topology = new Topology();
    while (iterator.hasNext()) {
        final MemberRaftComposite next = iterator.next();
        final ValueArray<TopologyBroker> brokers = topology.brokers();
        final SocketAddress clientApi = next.getClientApi();
        if (clientApi != null) {
            final TopologyBroker nextTopologyBroker = brokers.add();
            nextTopologyBroker.setHost(clientApi.getHostBuffer(), 0, clientApi.hostLength()).setPort(clientApi.port());
            final Iterator<RaftStateComposite> raftTupleIt = next.getRaftIterator();
            while (raftTupleIt.hasNext()) {
                final RaftStateComposite nextRaftState = raftTupleIt.next();
                final DirectBuffer topicName = BufferUtil.cloneBuffer(nextRaftState.getTopicName());
                nextTopologyBroker.partitionStates().add().setPartitionId(nextRaftState.getPartition()).setTopicName(topicName, 0, topicName.capacity()).setState(nextRaftState.getRaftState());
            }
        }
    }
    // LOG.debug("Send topology {} as response.", topology);
    return topology;
}
Also used : DirectBuffer(org.agrona.DirectBuffer) Topology(io.zeebe.broker.clustering.handler.Topology) SocketAddress(io.zeebe.transport.SocketAddress) TopologyBroker(io.zeebe.broker.clustering.handler.TopologyBroker)

Example 24 with DirectBuffer

use of org.agrona.DirectBuffer in project zeebe by zeebe-io.

the class RaftPersistentFileStorage method getMembers.

public List<SocketAddress> getMembers() {
    final List<SocketAddress> members = new ArrayList<>();
    final Iterator<RaftConfigurationMetadataMember> iterator = configuration.membersProp.iterator();
    while (iterator.hasNext()) {
        final RaftConfigurationMetadataMember member = iterator.next();
        final DirectBuffer hostBuffer = member.getHost();
        final SocketAddress socketAddress = new SocketAddress();
        socketAddress.host(hostBuffer, 0, hostBuffer.capacity());
        socketAddress.setPort(member.getPort());
        members.add(socketAddress);
    }
    return members;
}
Also used : MutableDirectBuffer(org.agrona.MutableDirectBuffer) DirectBuffer(org.agrona.DirectBuffer) SocketAddress(io.zeebe.transport.SocketAddress)

Example 25 with DirectBuffer

use of org.agrona.DirectBuffer in project zeebe by zeebe-io.

the class APISyncHandler method onSyncRequest.

@Override
public ActorFuture<Void> onSyncRequest(GossipSyncRequest request) {
    return actor.call(() -> {
        LOG.trace("Got API sync request.");
        final Iterator<MemberRaftComposite> iterator = clusterManagerContext.getMemberListService().iterator();
        while (iterator.hasNext()) {
            final MemberRaftComposite next = iterator.next();
            if (next.hasApis()) {
                final DirectBuffer payload = writeAPIAddressesIntoBuffer(next.getManagementApi(), next.getReplicationApi(), next.getClientApi(), apiAddressBuffer);
                request.addPayload(next.getMember(), payload);
            }
        }
        LOG.trace("Send API sync response.");
    });
}
Also used : DirectBuffer(org.agrona.DirectBuffer)

Aggregations

DirectBuffer (org.agrona.DirectBuffer)102 Header (io.aeron.logbuffer.Header)18 MutableDirectBuffer (org.agrona.MutableDirectBuffer)16 UnsafeBuffer (org.agrona.concurrent.UnsafeBuffer)15 File (java.io.File)14 MappedByteBuffer (java.nio.MappedByteBuffer)11 Test (org.junit.Test)11 MediaDriver (io.aeron.driver.MediaDriver)10 CountersReader (org.agrona.concurrent.status.CountersReader)10 ClusteredService (io.aeron.cluster.service.ClusteredService)8 Publication (io.aeron.Publication)7 ClientSession (io.aeron.cluster.service.ClientSession)7 ExpandableArrayBuffer (org.agrona.ExpandableArrayBuffer)7 ThreadingMode (io.aeron.driver.ThreadingMode)6 FragmentHandler (io.aeron.logbuffer.FragmentHandler)6 ByteBuffer (java.nio.ByteBuffer)6 ClusteredServiceContainer (io.aeron.cluster.service.ClusteredServiceContainer)5 InterruptAfter (io.aeron.test.InterruptAfter)5 ExtendWith (org.junit.jupiter.api.extension.ExtendWith)5 LogBufferDescriptor (io.aeron.logbuffer.LogBufferDescriptor)4