ARTEMIS-243 - fix possible null pointer
https://issues.apache.org/jira/browse/ARTEMIS-243
This commit is contained in:
parent
4eb669f035
commit
38a809fded
|
@ -33,6 +33,11 @@ public class ReplicaPolicy extends BackupPolicy {
|
||||||
|
|
||||||
private boolean restartBackup = ActiveMQDefaultConfiguration.isDefaultRestartBackup();
|
private boolean restartBackup = ActiveMQDefaultConfiguration.isDefaultRestartBackup();
|
||||||
|
|
||||||
|
//used if we create a replicated policy for when we become live.
|
||||||
|
private boolean allowFailback = ActiveMQDefaultConfiguration.isDefaultAllowAutoFailback();
|
||||||
|
|
||||||
|
private long failbackDelay = ActiveMQDefaultConfiguration.getDefaultFailbackDelay();
|
||||||
|
|
||||||
private ReplicatedPolicy replicatedPolicy;
|
private ReplicatedPolicy replicatedPolicy;
|
||||||
|
|
||||||
public ReplicaPolicy() {
|
public ReplicaPolicy() {
|
||||||
|
@ -49,9 +54,9 @@ public class ReplicaPolicy extends BackupPolicy {
|
||||||
this.maxSavedReplicatedJournalsSize = maxSavedReplicatedJournalsSize;
|
this.maxSavedReplicatedJournalsSize = maxSavedReplicatedJournalsSize;
|
||||||
this.groupName = groupName;
|
this.groupName = groupName;
|
||||||
this.restartBackup = restartBackup;
|
this.restartBackup = restartBackup;
|
||||||
|
this.allowFailback = allowFailback;
|
||||||
|
this.failbackDelay = failbackDelay;
|
||||||
this.scaleDownPolicy = scaleDownPolicy;
|
this.scaleDownPolicy = scaleDownPolicy;
|
||||||
//todo check default settings
|
|
||||||
replicatedPolicy = new ReplicatedPolicy(false, allowFailback, failbackDelay, groupName, clusterName, this);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public ReplicaPolicy(String clusterName,
|
public ReplicaPolicy(String clusterName,
|
||||||
|
@ -81,6 +86,9 @@ public class ReplicaPolicy extends BackupPolicy {
|
||||||
}
|
}
|
||||||
|
|
||||||
public ReplicatedPolicy getReplicatedPolicy() {
|
public ReplicatedPolicy getReplicatedPolicy() {
|
||||||
|
if (replicatedPolicy == null) {
|
||||||
|
replicatedPolicy = new ReplicatedPolicy(false, allowFailback, failbackDelay, groupName, clusterName, this);
|
||||||
|
}
|
||||||
return replicatedPolicy;
|
return replicatedPolicy;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -121,6 +129,22 @@ public class ReplicaPolicy extends BackupPolicy {
|
||||||
return scaleDownPolicy != null;
|
return scaleDownPolicy != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isAllowFailback() {
|
||||||
|
return allowFailback;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAllowFailback(boolean allowFailback) {
|
||||||
|
this.allowFailback = allowFailback;
|
||||||
|
}
|
||||||
|
|
||||||
|
public long getFailbackDelay() {
|
||||||
|
return failbackDelay;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFailbackDelay(long failbackDelay) {
|
||||||
|
this.failbackDelay = failbackDelay;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Activation createActivation(ActiveMQServerImpl server,
|
public Activation createActivation(ActiveMQServerImpl server,
|
||||||
boolean wasLive,
|
boolean wasLive,
|
||||||
|
|
|
@ -40,11 +40,12 @@ public class ReplicatedPolicy implements HAPolicy<LiveActivation> {
|
||||||
private long failbackDelay = ActiveMQDefaultConfiguration.getDefaultFailbackDelay();
|
private long failbackDelay = ActiveMQDefaultConfiguration.getDefaultFailbackDelay();
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* this is used as the policy when the server is started after a failover
|
* this are only used as the policy when the server is started as a live after a failover
|
||||||
* */
|
* */
|
||||||
private ReplicaPolicy replicaPolicy;
|
private ReplicaPolicy replicaPolicy;
|
||||||
|
|
||||||
public ReplicatedPolicy() {
|
public ReplicatedPolicy() {
|
||||||
|
replicaPolicy = new ReplicaPolicy(clusterName, -1, groupName, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ReplicatedPolicy(boolean checkForLiveServer, String groupName, String clusterName) {
|
public ReplicatedPolicy(boolean checkForLiveServer, String groupName, String clusterName) {
|
||||||
|
@ -54,7 +55,6 @@ public class ReplicatedPolicy implements HAPolicy<LiveActivation> {
|
||||||
/*
|
/*
|
||||||
* we create this with sensible defaults in case we start after a failover
|
* we create this with sensible defaults in case we start after a failover
|
||||||
* */
|
* */
|
||||||
replicaPolicy = new ReplicaPolicy(clusterName, -1, groupName, this);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public ReplicatedPolicy(boolean checkForLiveServer,
|
public ReplicatedPolicy(boolean checkForLiveServer,
|
||||||
|
@ -100,6 +100,9 @@ public class ReplicatedPolicy implements HAPolicy<LiveActivation> {
|
||||||
}
|
}
|
||||||
|
|
||||||
public ReplicaPolicy getReplicaPolicy() {
|
public ReplicaPolicy getReplicaPolicy() {
|
||||||
|
if (replicaPolicy == null) {
|
||||||
|
replicaPolicy = new ReplicaPolicy(clusterName, -1, groupName, this);
|
||||||
|
}
|
||||||
return replicaPolicy;
|
return replicaPolicy;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -147,6 +150,10 @@ public class ReplicatedPolicy implements HAPolicy<LiveActivation> {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setAllowAutoFailBack(boolean allowAutoFailBack) {
|
||||||
|
this.allowAutoFailBack = allowAutoFailBack;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public LiveActivation createActivation(ActiveMQServerImpl server,
|
public LiveActivation createActivation(ActiveMQServerImpl server,
|
||||||
boolean wasLive,
|
boolean wasLive,
|
||||||
|
|
|
@ -47,7 +47,6 @@ public class SharedStoreSlavePolicy extends BackupPolicy {
|
||||||
this.restartBackup = restartBackup;
|
this.restartBackup = restartBackup;
|
||||||
this.allowAutoFailBack = allowAutoFailBack;
|
this.allowAutoFailBack = allowAutoFailBack;
|
||||||
this.scaleDownPolicy = scaleDownPolicy;
|
this.scaleDownPolicy = scaleDownPolicy;
|
||||||
sharedStoreMasterPolicy = new SharedStoreMasterPolicy(failbackDelay, failoverOnServerShutdown);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public long getFailbackDelay() {
|
public long getFailbackDelay() {
|
||||||
|
@ -67,6 +66,9 @@ public class SharedStoreSlavePolicy extends BackupPolicy {
|
||||||
}
|
}
|
||||||
|
|
||||||
public SharedStoreMasterPolicy getSharedStoreMasterPolicy() {
|
public SharedStoreMasterPolicy getSharedStoreMasterPolicy() {
|
||||||
|
if (sharedStoreMasterPolicy == null) {
|
||||||
|
sharedStoreMasterPolicy = new SharedStoreMasterPolicy(failbackDelay, failoverOnServerShutdown);
|
||||||
|
}
|
||||||
return sharedStoreMasterPolicy;
|
return sharedStoreMasterPolicy;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue