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);
}
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);
}
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));
});
}
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;
}
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);
}
Aggregations