-
Notifications
You must be signed in to change notification settings - Fork 214
/
DittoSplitBrainResolverProvider.java
63 lines (54 loc) · 2.12 KB
/
DittoSplitBrainResolverProvider.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
/*
* Copyright (c) 2022 Contributors to the Eclipse Foundation
*
* See the NOTICE file(s) distributed with this work for additional
* information regarding copyright ownership.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0
*
* SPDX-License-Identifier: EPL-2.0
*/
package org.eclipse.ditto.base.service.cluster;
import org.eclipse.ditto.internal.utils.config.DittoConfigError;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.apache.pekko.actor.ActorSystem;
import org.apache.pekko.actor.Props;
import org.apache.pekko.cluster.DowningProvider;
import org.apache.pekko.cluster.sbr.SplitBrainResolverProvider;
import scala.Option;
import scala.concurrent.duration.FiniteDuration;
/**
* This provider is providing the props of {@link DittoSplitBrainResolver}.
*/
@SuppressWarnings("unused")
final class DittoSplitBrainResolverProvider extends DowningProvider {
private static final Logger LOGGER = LoggerFactory.getLogger(DittoSplitBrainResolverProvider.class);
private final SplitBrainResolverProvider splitBrainResolverProvider;
/**
* This constructor is called by pekko.
*
* @param actorSystem the actor system used to instantiate this provider.
*/
@SuppressWarnings("unused")
DittoSplitBrainResolverProvider(final ActorSystem actorSystem) {
splitBrainResolverProvider = new SplitBrainResolverProvider(actorSystem);
}
@Override
public FiniteDuration downRemovalMargin() {
return splitBrainResolverProvider.downRemovalMargin();
}
@Override
public Option<Props> downingActorProps() {
try {
final Props splitBrainResolverProps = splitBrainResolverProvider.downingActorProps().get();
return Option.apply(DittoSplitBrainResolver.props(splitBrainResolverProps));
} catch (final Exception e) {
final String msg = "Could not create Ditto split brain resolver props.";
LOGGER.error(msg, e);
throw new DittoConfigError(msg, e);
}
}
}