io.vlingo.cluster.model.application.ClusterApplication Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of vlingo-cluster Show documentation
Show all versions of vlingo-cluster Show documentation
Cluster management for reactive, scalable resiliency of JVM tools and applications running on VLINGO XOOM Actors.
// Copyright © 2012-2020 VLINGO LABS. All rights reserved.
//
// This Source Code Form is subject to the terms of the
// Mozilla Public License, v. 2.0. If a copy of the MPL
// was not distributed with this file, You can obtain
// one at https://mozilla.org/MPL/2.0/.
package io.vlingo.cluster.model.application;
import java.util.Collection;
import io.vlingo.actors.Actor;
import io.vlingo.actors.ActorInstantiator;
import io.vlingo.actors.Definition;
import io.vlingo.actors.Stage;
import io.vlingo.actors.Startable;
import io.vlingo.actors.Stoppable;
import io.vlingo.actors.World;
import io.vlingo.cluster.model.Properties;
import io.vlingo.cluster.model.attribute.AttributesProtocol;
import io.vlingo.wire.fdx.outbound.ApplicationOutboundStream;
import io.vlingo.wire.message.RawMessage;
import io.vlingo.wire.node.Id;
import io.vlingo.wire.node.Node;
public interface ClusterApplication extends Startable, Stoppable {
static ClusterApplication instance(
final World world,
final ClusterApplicationInstantiator> instantiator,
final Properties properties,
final Node node) {
final Stage applicationStage =
world.stageNamed(properties.clusterApplicationStageName());
return applicationStage.actorFor(
ClusterApplication.class,
Definition.has(instantiator.type(), instantiator, "cluster-application"));
}
static ClusterApplication instance(final Stage applicationStage, final ActorInstantiator instantator) {
return applicationStage.actorFor(
ClusterApplication.class,
Definition.has(instantator.type(), instantator, "cluster-application"));
}
static abstract class ClusterApplicationInstantiator implements ActorInstantiator {
private static final long serialVersionUID = -2002705648453794614L;
private Node node;
private final Class type;
public ClusterApplicationInstantiator(final Class type) {
this.type = type;
}
public Node node() {
return this.node;
}
public void node(final Node node) {
this.node = node;
}
@Override
public Class type() {
return type;
}
}
static class DefaultClusterApplicationInstantiator extends ClusterApplicationInstantiator {
private static final long serialVersionUID = -4275208628986318945L;
public DefaultClusterApplicationInstantiator() {
super(FakeClusterApplicationActor.class);
}
@Override
public FakeClusterApplicationActor instantiate() {
return new FakeClusterApplicationActor(node());
}
}
void handleApplicationMessage(final RawMessage message);
void informAllLiveNodes(final Collection liveNodes, final boolean isHealthyCluster);
void informLeaderElected(final Id leaderId, final boolean isHealthyCluster, final boolean isLocalNodeLeading);
void informLeaderLost(final Id lostLeaderId, final boolean isHealthyCluster);
void informLocalNodeShutDown(final Id nodeId);
void informLocalNodeStarted(final Id nodeId);
void informNodeIsHealthy(final Id nodeId, final boolean isHealthyCluster);
void informNodeJoinedCluster(final Id nodeId, final boolean isHealthyCluster);
void informNodeLeftCluster(final Id nodeId, final boolean isHealthyCluster);
void informQuorumAchieved();
void informQuorumLost();
void informResponder(final ApplicationOutboundStream responder);
void informAttributesClient(final AttributesProtocol client);
void informAttributeSetCreated(final String attributeSetName);
void informAttributeAdded(final String attributeSetName, final String attributeName);
void informAttributeRemoved(final String attributeSetName, final String attributeName);
void informAttributeSetRemoved(final String attributeSetName);
void informAttributeReplaced(final String attributeSetName, final String attributeName);
}