--
You received this message because you are subscribed to the Google Groups "vert.x" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vertx+un...@googlegroups.com.
Visit this group at http://groups.google.com/group/vertx.
To view this discussion on the web, visit https://groups.google.com/d/msgid/vertx/5c72f2e7-7577-4993-b7af-f2e15959cb0f%40googlegroups.com.
<backup-count>0</backup-count>
--
You received this message because you are subscribed to the Google Groups "vert.x" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vertx+un...@googlegroups.com.
Visit this group at http://groups.google.com/group/vertx.
To view this discussion on the web, visit https://groups.google.com/d/msgid/vertx/07adc389-d28f-404f-ae63-4b39f7fb5c4d%40googlegroups.com.
class CustomHazelcastClusterManager extends HazelcastClusterManager {
@Autowired
private Vertx vertx
@Autowired
private HazelcastInstance hazelcast
private String nodeID
private String membershipListenerId
private volatile boolean active
private Config conf
/**
* Constructor - gets config from classpath
*/
public CustomHazelcastClusterManager() {
// We have our own shutdown hook and need to ensure ours runs before Hazelcast is shutdown
super()
}
/**
* Constructor - config supplied
* @param conf
*/
public CustomHazelcastClusterManager(Config conf) {
super(conf)
}
@Override
public synchronized void join(Handler<AsyncResult<Void>> resultHandler) {
log.error("**************** Calling our custom implementation")
vertx.executeBlocking({ fut ->
if (!active) {
active = true
if (conf == null) {
conf = loadConfigFromClasspath()
if (conf == null) {
log.warn("Cannot find cluster configuration on classpath and none specified programmatically. Using default hazelcast configuration")
}
}
log.error("%%%%%%%%%Hazelcast set ${hazelcast}")
if (hazelcast == null) {
hazelcast = Hazelcast.getOrCreateHazelcastInstance(conf)
}
log.error("%%%%%%%%%Hazelcast set ${hazelcast}")
nodeID = hazelcast.getCluster().getLocalMember().getUuid()
membershipListenerId = hazelcast.getCluster().addMembershipListener(this)
fut.complete()
}
}, resultHandler)
}
}
customManager = new CustomHazelcastClusterManager();
// ... join happens in here...
System.out.println( customManager.getNodeID() ); // I would expect that to print null, not the node ID you stored in the join method - because the superclass doesn't have access to your copy of nodeID.
That would be ideal if that would work, but I didn't think Java would allow that... I would also expect the 'hazelcast' field in the superclass to be null, which would stop most of it from working. If I do everything as you showed, I just get NullPointer exceptions from the HazelcastClusterManager class whenever I try to access anything like shared maps etc. This is because the 'hazelcast' field on the superclass is never actually set (which is what I expected to happen).
Anyway, if it works for you, that's awesome... I was just expecting that you would need all those fields to be either changed to 'protected' or have getters/setters on the HazelcastClusterManager class for the extend to work.