Skip to content

Commit

Permalink
ATS-12 re-suse cleint if present, shutdown instance on destroy()
Browse files Browse the repository at this point in the history
  • Loading branch information
madness-inc committed Jun 25, 2019
1 parent a5b0e5f commit a3f13d9
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
Expand Up @@ -28,6 +28,12 @@ public class HazelcastPersistentManager extends PersistentManagerBase {

protected void destroyInternal() throws LifecycleException {
super.destroyInternal();
getStore().destroy();
}

@Override
public HazelcastStore getStore() {
return (HazelcastStore) super.getStore();
}

@Override
Expand Down
Expand Up @@ -117,8 +117,12 @@ protected void initInternal() {
for (String address : addressArr) {
clientConfig.getNetworkConfig().addAddress(address.trim());
}
instance = HazelcastClient.newHazelcastClient(clientConfig);
break;
instance = HazelcastClient.getHazelcastClientByName(instanceName);
if (null == instance) {
instance = HazelcastClient.newHazelcastClient(clientConfig);
}
log.info(String.format("Using client, connecting to %s", clientConfig.getNetworkConfig().getAddresses()));
return;

case "tcp":
joinConfig.getTcpIpConfig().setEnabled(true);
Expand All @@ -141,6 +145,12 @@ protected void initInternal() {
}
log.info(String.format("Using instance %s", instance));
}

@Override
protected void destroyInternal() {
log.info(String.format("Shutting down instance %s", instance));
instance.shutdown();
}

public void save(Session session) throws IOException {
try (ByteArrayOutputStream bos = new ByteArrayOutputStream();
Expand Down

0 comments on commit a3f13d9

Please sign in to comment.