我正在尝试在aws中设置一个简单的vertx集群。(您可以找到所有代码here)
在pom文件中,我已经添加了我需要的所有功能,包括vertx-hazelcast和aws的hazelcast插件。
对于Main Class来说,这非常简单,并且所有的hazelcast设置都是在Main class中准备的。
public class Main {
public static void main(String[] args) {
Logger log = Logger.getLogger(Main.class.getSimpleName());
Config hazelcastConfig = new Config();
hazelcastConfig.getNetworkConfig().getInterfaces().
setEnabled(true).addInterface("10.0.*.*");
JoinConfig joinConfig = hazelcastConfig.getNetworkConfig().getJoin();
joinConfig.getMulticastConfig().setEnabled(false);
joinConfig.getAwsConfig()
.setEnabled(true)
.setProperty("region", "ap-southeast-1")
.setProperty("tag-key", "aws:cloudformation:stack-name")
.setProperty("tag-value", "EC2ContainerService-test-cluster");
hazelcastConfig.getNetworkConfig().setJoin(joinConfig);
ClusterManager mgr = new HazelcastClusterManager(hazelcastConfig);
String hostAddress = getAddress();
VertxOptions options = new VertxOptions()
.setClusterManager(mgr)
.setHAEnabled(true);
EventBusOptions ebOptions = new EventBusOptions()
.setClustered(true)
.setHost(hostAddress);
options.setEventBusOptions(ebOptions);
Vertx.clusteredVertx(options, handler->{
if(handler.succeeded()){
DeploymentOptions containerOption = new DeploymentOptions().setHa(false);
handler.result().deployVerticle(Verticle.class,containerOption,deployHandler->{
if(handler.succeeded()){
log.info("Verticle Deployed");
}else{
log.severe("Verticle Deployment Failed");
}
});
} else{
log.severe(handler.cause().getMessage());
}
});
}
}
每当我运行胖罐子时,我总是会遇到此错误。
Caused by: com.hazelcast.config.properties.ValidationException: There is no discovery strategy factory to create 'D
iscoveryStrategyConfig{properties={tag-value=EC2ContainerService-test-cluster, region=ap-southeast-1, tag-key=aws:c
loudformation:stack-name}, className='com.hazelcast.aws.AwsDiscoveryStrategy', discoveryStrategyFactory=null}' Is i
t a typo in a strategy classname? Perhaps you forgot to include implementation on a classpath?
我的代码中是否缺少任何内容?
答案 0 :(得分:0)
该错误消息通常表示您在类路径中没有hazelcast-aws.jar插件。
我看到您在Maven依赖项中拥有它,但是请确保:
hazelcast-aws
版本与hazelcast
版本一起使用(可以找到兼容性信息here)。com.hazelcast.aws
包中的类。resources/META-INF/services/com.hazelcast.spi.discovery.DiscoveryStrategyFactory
确实包含条目com.hazelcast.aws.AwsDiscoveryStrategyFactory 如果以上任何内容都不正确,那么您需要重新查看胖JAR的构建方式。拥有全部解决方案之一是依赖于hazelcast-all
(而不是hazelcast
)。这将使您摆脱所有这些问题。