Search in sources :

Example 16 with Synchronized

use of lombok.Synchronized in project pravega by pravega.

the class ClusterZKImpl method registerHost.

/**
 * Register Host to cluster.
 *
 * @param host Host to be part of cluster.
 */
@Override
@Synchronized
public void registerHost(Host host) {
    Preconditions.checkNotNull(host, "host");
    Exceptions.checkArgument(!entryMap.containsKey(host), "host", "host is already registered to cluster.");
    String hostPath = ZKPaths.makePath(getPathPrefix(), host.toString());
    PersistentNode node = new PersistentNode(client, CreateMode.EPHEMERAL, false, hostPath, SerializationUtils.serialize(host));
    // start creation of ephemeral node in background.
    node.start();
    entryMap.put(host, node);
}
Also used : PersistentNode(org.apache.curator.framework.recipes.nodes.PersistentNode) Synchronized(lombok.Synchronized)

Example 17 with Synchronized

use of lombok.Synchronized in project pravega by pravega.

the class ClusterZKImpl method deregisterHost.

/**
 * Remove Host from cluster.
 *
 * @param host Host to be removed from cluster.
 */
@Override
@Synchronized
public void deregisterHost(Host host) {
    Preconditions.checkNotNull(host, "host");
    PersistentNode node = entryMap.get(host);
    Preconditions.checkNotNull(node, "Host is not present in cluster.");
    entryMap.remove(host);
    close(node);
}
Also used : PersistentNode(org.apache.curator.framework.recipes.nodes.PersistentNode) Synchronized(lombok.Synchronized)

Example 18 with Synchronized

use of lombok.Synchronized in project pravega by pravega.

the class MockStreamTransactionMetadataTasks method createTxn.

@Override
@Synchronized
public CompletableFuture<Pair<VersionedTransactionData, List<Segment>>> createTxn(final String scope, final String stream, final long lease, final long scaleGracePeriod, final OperationContext contextOpt) {
    final OperationContext context = contextOpt == null ? streamMetadataStore.createContext(scope, stream) : contextOpt;
    final UUID txnId = UUID.randomUUID();
    return streamMetadataStore.createTransaction(scope, stream, txnId, lease, 10 * lease, scaleGracePeriod, context, executor).thenCompose(txData -> {
        log.info("Created transaction {} with version {}", txData.getId(), txData.getVersion());
        return streamMetadataStore.getActiveSegments(scope, stream, context, executor).thenApply(segmentList -> new ImmutablePair<>(txData, segmentList));
    });
}
Also used : OperationContext(io.pravega.controller.store.stream.OperationContext) UUID(java.util.UUID) Synchronized(lombok.Synchronized)

Example 19 with Synchronized

use of lombok.Synchronized in project pravega by pravega.

the class SegmentSelector method updateSegments.

@Synchronized
private List<PendingEvent> updateSegments(StreamSegments newSteamSegments, Consumer<Segment> segmentSealedCallBack) {
    currentSegments = newSteamSegments;
    createMissingWriters(segmentSealedCallBack, newSteamSegments.getDelegationToken());
    List<PendingEvent> toResend = new ArrayList<>();
    Iterator<Entry<Segment, SegmentOutputStream>> iter = writers.entrySet().iterator();
    while (iter.hasNext()) {
        Entry<Segment, SegmentOutputStream> entry = iter.next();
        if (!currentSegments.getSegments().contains(entry.getKey())) {
            SegmentOutputStream writer = entry.getValue();
            iter.remove();
            try {
                writer.close();
            } catch (SegmentSealedException e) {
                log.info("Caught segment sealed while refreshing on segment {}", entry.getKey());
            }
            toResend.addAll(writer.getUnackedEventsOnSeal());
        }
    }
    return toResend;
}
Also used : Entry(java.util.Map.Entry) SegmentOutputStream(io.pravega.client.segment.impl.SegmentOutputStream) ArrayList(java.util.ArrayList) SegmentSealedException(io.pravega.client.segment.impl.SegmentSealedException) Segment(io.pravega.client.segment.impl.Segment) Synchronized(lombok.Synchronized)

Example 20 with Synchronized

use of lombok.Synchronized in project pravega by pravega.

the class MockController method createStream.

@Override
@Synchronized
public CompletableFuture<Boolean> createStream(StreamConfiguration streamConfig) {
    Stream stream = new StreamImpl(streamConfig.getScope(), streamConfig.getStreamName());
    if (createdStreams.get(stream) != null) {
        return CompletableFuture.completedFuture(false);
    }
    if (createdScopes.get(streamConfig.getScope()) == null) {
        return Futures.failedFuture(new IllegalArgumentException("Scope does not exit."));
    }
    createdStreams.put(stream, streamConfig);
    createdScopes.get(streamConfig.getScope()).add(stream);
    for (Segment segment : getSegmentsForStream(stream)) {
        createSegment(segment.getScopedName(), new PravegaNodeUri(endpoint, port));
    }
    return CompletableFuture.completedFuture(true);
}
Also used : PravegaNodeUri(io.pravega.shared.protocol.netty.PravegaNodeUri) StreamImpl(io.pravega.client.stream.impl.StreamImpl) Stream(io.pravega.client.stream.Stream) CreateSegment(io.pravega.shared.protocol.netty.WireCommands.CreateSegment) Segment(io.pravega.client.segment.impl.Segment) DeleteSegment(io.pravega.shared.protocol.netty.WireCommands.DeleteSegment) Synchronized(lombok.Synchronized)

Aggregations

Synchronized (lombok.Synchronized)22 IOException (java.io.IOException)6 Segment (io.pravega.client.segment.impl.Segment)4 ArrayList (java.util.ArrayList)4 S3Exception (com.emc.object.s3.S3Exception)3 CreateSegment (io.pravega.shared.protocol.netty.WireCommands.CreateSegment)3 DeleteSegment (io.pravega.shared.protocol.netty.WireCommands.DeleteSegment)3 ScheduledReporter (com.codahale.metrics.ScheduledReporter)2 Stream (io.pravega.client.stream.Stream)2 StreamImpl (io.pravega.client.stream.impl.StreamImpl)2 PravegaNodeUri (io.pravega.shared.protocol.netty.PravegaNodeUri)2 ByteArrayInputStream (java.io.ByteArrayInputStream)2 InputStream (java.io.InputStream)2 ByteBuffer (java.nio.ByteBuffer)2 FileChannel (java.nio.channels.FileChannel)2 Path (java.nio.file.Path)2 SneakyThrows (lombok.SneakyThrows)2 PersistentNode (org.apache.curator.framework.recipes.nodes.PersistentNode)2 ChainingMetadataResolver (org.opensaml.saml.metadata.resolver.ChainingMetadataResolver)2 JmxReporter (com.codahale.metrics.JmxReporter)1