Search in sources :

Example 1 with RawClient

use of io.pravega.client.netty.impl.RawClient in project pravega by pravega.

the class SegmentMetadataClientImpl method getPropertyAsync.

private CompletableFuture<WireCommands.SegmentAttribute> getPropertyAsync(UUID attributeId, String delegationToken) {
    long requestId = requestIdGenerator.get();
    log.debug("Getting segment attribute: {}", attributeId);
    RawClient connection = getConnection();
    return connection.sendRequest(requestId, new GetSegmentAttribute(requestId, segmentId.getScopedName(), attributeId, delegationToken)).thenApply(r -> transformReply(r, WireCommands.SegmentAttribute.class));
}
Also used : GetSegmentAttribute(io.pravega.shared.protocol.netty.WireCommands.GetSegmentAttribute) UpdateSegmentAttribute(io.pravega.shared.protocol.netty.WireCommands.UpdateSegmentAttribute) RawClient(io.pravega.client.netty.impl.RawClient) GetSegmentAttribute(io.pravega.shared.protocol.netty.WireCommands.GetSegmentAttribute)

Example 2 with RawClient

use of io.pravega.client.netty.impl.RawClient in project pravega by pravega.

the class SegmentMetadataClientImpl method updatePropertyAsync.

private CompletableFuture<SegmentAttributeUpdated> updatePropertyAsync(UUID attributeId, long expected, long value, String delegationToken) {
    long requestId = requestIdGenerator.get();
    log.trace("Updating segment attribute: {}", attributeId);
    RawClient connection = getConnection();
    return connection.sendRequest(requestId, new UpdateSegmentAttribute(requestId, segmentId.getScopedName(), attributeId, value, expected, delegationToken)).thenApply(r -> transformReply(r, SegmentAttributeUpdated.class));
}
Also used : UpdateSegmentAttribute(io.pravega.shared.protocol.netty.WireCommands.UpdateSegmentAttribute) SegmentAttributeUpdated(io.pravega.shared.protocol.netty.WireCommands.SegmentAttributeUpdated) RawClient(io.pravega.client.netty.impl.RawClient)

Example 3 with RawClient

use of io.pravega.client.netty.impl.RawClient in project pravega by pravega.

the class SegmentMetadataClientImpl method closeConnection.

private void closeConnection(Reply badReply) {
    log.info("Closing connection as a result of receiving: {}", badReply);
    RawClient c;
    synchronized (lock) {
        c = client;
        client = null;
    }
    if (c != null) {
        try {
            c.close();
        } catch (Exception e) {
            log.warn("Exception tearing down connection: ", e);
        }
    }
}
Also used : RawClient(io.pravega.client.netty.impl.RawClient) ConnectionFailedException(io.pravega.shared.protocol.netty.ConnectionFailedException) ConnectionClosedException(io.pravega.client.stream.impl.ConnectionClosedException)

Example 4 with RawClient

use of io.pravega.client.netty.impl.RawClient in project pravega by pravega.

the class SegmentMetadataClientImpl method closeConnection.

private void closeConnection(Throwable exceptionToInflightRequests) {
    log.info("Closing connection with exception: {}", exceptionToInflightRequests.getMessage());
    RawClient c;
    synchronized (lock) {
        c = client;
        client = null;
    }
    if (c != null) {
        try {
            c.close();
        } catch (Exception e) {
            log.warn("Exception tearing down connection: ", e);
        }
    }
}
Also used : RawClient(io.pravega.client.netty.impl.RawClient) ConnectionFailedException(io.pravega.shared.protocol.netty.ConnectionFailedException) ConnectionClosedException(io.pravega.client.stream.impl.ConnectionClosedException)

Example 5 with RawClient

use of io.pravega.client.netty.impl.RawClient in project pravega by pravega.

the class SegmentMetadataClientImpl method truncateSegmentAsync.

private CompletableFuture<SegmentTruncated> truncateSegmentAsync(Segment segment, long offset, String delegationToken) {
    long requestId = requestIdGenerator.get();
    log.trace("Truncating segment: {}", segment);
    RawClient connection = getConnection();
    return connection.sendRequest(requestId, new TruncateSegment(requestId, segment.getScopedName(), offset, delegationToken)).thenApply(r -> transformReply(r, SegmentTruncated.class));
}
Also used : SegmentTruncated(io.pravega.shared.protocol.netty.WireCommands.SegmentTruncated) RawClient(io.pravega.client.netty.impl.RawClient) TruncateSegment(io.pravega.shared.protocol.netty.WireCommands.TruncateSegment)

Aggregations

RawClient (io.pravega.client.netty.impl.RawClient)6 ConnectionClosedException (io.pravega.client.stream.impl.ConnectionClosedException)2 ConnectionFailedException (io.pravega.shared.protocol.netty.ConnectionFailedException)2 UpdateSegmentAttribute (io.pravega.shared.protocol.netty.WireCommands.UpdateSegmentAttribute)2 GetSegmentAttribute (io.pravega.shared.protocol.netty.WireCommands.GetSegmentAttribute)1 GetStreamSegmentInfo (io.pravega.shared.protocol.netty.WireCommands.GetStreamSegmentInfo)1 SegmentAttributeUpdated (io.pravega.shared.protocol.netty.WireCommands.SegmentAttributeUpdated)1 SegmentTruncated (io.pravega.shared.protocol.netty.WireCommands.SegmentTruncated)1 StreamSegmentInfo (io.pravega.shared.protocol.netty.WireCommands.StreamSegmentInfo)1 TruncateSegment (io.pravega.shared.protocol.netty.WireCommands.TruncateSegment)1