You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@brooklyn.apache.org by al...@apache.org on 2016/11/16 20:46:15 UTC
[1/4] brooklyn-server git commit: BROOKLYN-325: alert if
provisioning/termination aborted on rebind
Repository: brooklyn-server
Updated Branches:
refs/heads/master f1d89ad97 -> be89a8dd2
BROOKLYN-325: alert if provisioning/termination aborted on rebind
Project: http://git-wip-us.apache.org/repos/asf/brooklyn-server/repo
Commit: http://git-wip-us.apache.org/repos/asf/brooklyn-server/commit/829ae6aa
Tree: http://git-wip-us.apache.org/repos/asf/brooklyn-server/tree/829ae6aa
Diff: http://git-wip-us.apache.org/repos/asf/brooklyn-server/diff/829ae6aa
Branch: refs/heads/master
Commit: 829ae6aab90217b6d8f702f8bcb1f27af71d5520
Parents: fbfe2fe
Author: Aled Sage <al...@gmail.com>
Authored: Mon Nov 14 17:42:36 2016 +0000
Committer: Aled Sage <al...@gmail.com>
Committed: Wed Nov 16 12:47:50 2016 +0000
----------------------------------------------------------------------
.../entity/internal/AttributesInternal.java | 12 +++-
.../mgmt/rebind/BasicEntityRebindSupport.java | 56 ++++++++++++++---
.../MachineLifecycleEffectorTasks.java | 13 +++-
...ftwareProcessRebindNotRunningEntityTest.java | 64 +++++++++++++++++---
4 files changed, 122 insertions(+), 23 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/829ae6aa/core/src/main/java/org/apache/brooklyn/core/entity/internal/AttributesInternal.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/brooklyn/core/entity/internal/AttributesInternal.java b/core/src/main/java/org/apache/brooklyn/core/entity/internal/AttributesInternal.java
index 6051e05..7bccb4d 100644
--- a/core/src/main/java/org/apache/brooklyn/core/entity/internal/AttributesInternal.java
+++ b/core/src/main/java/org/apache/brooklyn/core/entity/internal/AttributesInternal.java
@@ -30,12 +30,18 @@ public interface AttributesInternal extends Attributes {
public static final AttributeSensor<ProvisioningTaskState> INTERNAL_PROVISIONING_TASK_STATE = new BasicAttributeSensor<ProvisioningTaskState>(
TypeToken.of(ProvisioningTaskState.class),
"internal.provisioning.task.state",
- "Internal transient sensor (do not use) for tracking the provisioning of a machine (to better handle aborting/rebind)",
- AttributeSensor.SensorPersistenceMode.NONE);
+ "Internal transient sensor (do not use) for tracking the provisioning of a machine (to better handle aborting/rebind)");
+ @Beta
+ public static final AttributeSensor<ProvisioningTaskState> INTERNAL_TERMINATION_TASK_STATE = new BasicAttributeSensor<ProvisioningTaskState>(
+ TypeToken.of(ProvisioningTaskState.class),
+ "internal.termination.task.state",
+ "Internal transient sensor (do not use) for tracking the termination of a machine (to better handle aborting/rebind)");
+
/**
* Used only internally by {@link org.apache.brooklyn.entity.software.base.lifecycle.MachineLifecycleEffectorTasks}
- * to track provisioning, so machine can be terminated if stopped while opaque provision call is being made.
+ * to track provisioning/termination. This is used so the machine can be terminated if stopped while opaque provision
+ * call is being made; and is used to report if termination was prematurely aborted (e.g. during Brooklyn restart).
*/
@Beta
@VisibleForTesting
http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/829ae6aa/core/src/main/java/org/apache/brooklyn/core/mgmt/rebind/BasicEntityRebindSupport.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/brooklyn/core/mgmt/rebind/BasicEntityRebindSupport.java b/core/src/main/java/org/apache/brooklyn/core/mgmt/rebind/BasicEntityRebindSupport.java
index b85b768..f7b5cd8 100644
--- a/core/src/main/java/org/apache/brooklyn/core/mgmt/rebind/BasicEntityRebindSupport.java
+++ b/core/src/main/java/org/apache/brooklyn/core/mgmt/rebind/BasicEntityRebindSupport.java
@@ -26,6 +26,7 @@ import org.apache.brooklyn.api.effector.Effector;
import org.apache.brooklyn.api.entity.Entity;
import org.apache.brooklyn.api.entity.EntityLocal;
import org.apache.brooklyn.api.location.Location;
+import org.apache.brooklyn.api.location.MachineLocation;
import org.apache.brooklyn.api.mgmt.rebind.RebindContext;
import org.apache.brooklyn.api.mgmt.rebind.mementos.EntityMemento;
import org.apache.brooklyn.api.objs.BrooklynObjectType;
@@ -35,15 +36,18 @@ import org.apache.brooklyn.core.enricher.AbstractEnricher;
import org.apache.brooklyn.core.entity.AbstractEntity;
import org.apache.brooklyn.core.entity.Attributes;
import org.apache.brooklyn.core.entity.EntityInternal;
+import org.apache.brooklyn.core.entity.internal.AttributesInternal;
+import org.apache.brooklyn.core.entity.internal.AttributesInternal.ProvisioningTaskState;
import org.apache.brooklyn.core.entity.lifecycle.Lifecycle;
import org.apache.brooklyn.core.entity.lifecycle.ServiceStateLogic;
import org.apache.brooklyn.core.feed.AbstractFeed;
+import org.apache.brooklyn.core.location.Machines;
import org.apache.brooklyn.core.mgmt.rebind.dto.MementosGenerators;
import org.apache.brooklyn.core.objs.AbstractBrooklynObject;
import org.apache.brooklyn.core.policy.AbstractPolicy;
import org.apache.brooklyn.entity.group.AbstractGroupImpl;
-import org.apache.brooklyn.entity.stock.BasicApplication;
import org.apache.brooklyn.util.exceptions.Exceptions;
+import org.apache.brooklyn.util.guava.Maybe;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -245,14 +249,52 @@ public class BasicEntityRebindSupport extends AbstractBrooklynObjectRebindSuppor
Preconditions.checkState(instance == entity, "Expected %s and %s to match, but different objects", instance, entity);
Lifecycle expectedState = ServiceStateLogic.getExpectedState(entity);
if (expectedState == Lifecycle.STARTING || expectedState == Lifecycle.STOPPING) {
- LOG.warn("Entity {} goes on-fire because it was in state {} on rebind", entity, expectedState);
- LOG.warn("not-up-indicators={}", entity.getAttribute(Attributes.SERVICE_NOT_UP_INDICATORS));
- ServiceStateLogic.setExpectedState(entity, Lifecycle.ON_FIRE);
+ // If we were previously "starting" or "stopping", then those tasks will have been
+ // aborted. We don't want to continue showing that state (e.g. the web-console would
+ // then show the it as in-progress with the "spinning" icon).
+ // Therefore we set the entity as on-fire, and add the indicator that says why.
+ markTransitioningEntityOnFireOnRebind((EntityInternal) entity, expectedState);
+ }
+
+ // Clear the provisioning/termination task-state; the task will have been aborted, so wrong to keep this state.
+ ((EntityInternal)entity).sensors().remove(AttributesInternal.INTERNAL_PROVISIONING_TASK_STATE);
+ ((EntityInternal)entity).sensors().remove(AttributesInternal.INTERNAL_TERMINATION_TASK_STATE);
+
+ super.instanceRebind(instance);
+ }
+
+ protected void markTransitioningEntityOnFireOnRebind(EntityInternal entity, Lifecycle expectedState) {
+ LOG.warn("Entity {} being marked as on-fire because it was in state {} on rebind; indicators={}", new Object[] {entity, expectedState, entity.getAttribute(Attributes.SERVICE_NOT_UP_INDICATORS)});
+ ServiceStateLogic.setExpectedState(entity, Lifecycle.ON_FIRE);
+ ServiceStateLogic.ServiceNotUpLogic.updateNotUpIndicator(
+ entity,
+ "Task aborted on rebind",
+ "Set to on-fire (from previous expected state "+expectedState+") because tasks aborted on rebind");
+
+ // Check if we were in the process of provisioning a machine. If so, a VM might have
+ // been left behind. E.g. we might have submitted to jclouds the request to provision
+ // the VM, but not yet received back the id (so have lost details of the VM).
+ // Also see MachineLifecycleEffectorTasks.ProvisionMachineTask.
+ Maybe<MachineLocation> machine = Machines.findUniqueMachineLocation(entity.getLocations());
+ ProvisioningTaskState provisioningState = entity.sensors().get(AttributesInternal.INTERNAL_PROVISIONING_TASK_STATE);
+ if (machine.isAbsent() && provisioningState == ProvisioningTaskState.RUNNING) {
+ LOG.warn("Entity {} was provisioning; VM may have been left running", entity);
ServiceStateLogic.ServiceNotUpLogic.updateNotUpIndicator(
entity,
- "Task aborted on rebind",
- "Set to on-fire (from previous expected state "+expectedState+") because tasks aborted on rebind");
+ "VM may be lost on rebind",
+ "VM provisioning may have been in-progress and now lost, because tasks aborted on rebind");
+ }
+
+ // Similar to the provisioning case, if we were terminating the VM then we may or may
+ // not have finished. This means the VM might have been left running.
+ // Also see MachineLifecycleEffectorTasks.stopAnyProvisionedMachines()
+ ProvisioningTaskState terminationState = entity.sensors().get(AttributesInternal.INTERNAL_TERMINATION_TASK_STATE);
+ if (machine.isAbsent() && terminationState == ProvisioningTaskState.RUNNING) {
+ LOG.warn("Entity {} was terminating; VM may have been left running", entity);
+ ServiceStateLogic.ServiceNotUpLogic.updateNotUpIndicator(
+ entity,
+ "VM may be lost on rebind",
+ "VM termination may have been in-progress and now lost, because tasks aborted on rebind");
}
- super.instanceRebind(instance);
}
}
http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/829ae6aa/software/base/src/main/java/org/apache/brooklyn/entity/software/base/lifecycle/MachineLifecycleEffectorTasks.java
----------------------------------------------------------------------
diff --git a/software/base/src/main/java/org/apache/brooklyn/entity/software/base/lifecycle/MachineLifecycleEffectorTasks.java b/software/base/src/main/java/org/apache/brooklyn/entity/software/base/lifecycle/MachineLifecycleEffectorTasks.java
index 439770a..8748861 100644
--- a/software/base/src/main/java/org/apache/brooklyn/entity/software/base/lifecycle/MachineLifecycleEffectorTasks.java
+++ b/software/base/src/main/java/org/apache/brooklyn/entity/software/base/lifecycle/MachineLifecycleEffectorTasks.java
@@ -1001,10 +1001,17 @@ public abstract class MachineLifecycleEffectorTasks {
log.debug("No decommissioning necessary for "+entity()+" - not a machine location ("+machine+")");
return new StopMachineDetails<Integer>("No machine decommissioning necessary - not a machine ("+machine+")", 0);
}
-
- clearEntityLocationAttributes(machine);
- provisioner.release((MachineLocation)machine);
+ entity().sensors().set(AttributesInternal.INTERNAL_TERMINATION_TASK_STATE, ProvisioningTaskState.RUNNING);
+ try {
+ clearEntityLocationAttributes(machine);
+ provisioner.release((MachineLocation)machine);
+ } finally {
+ // TODO On exception, should we add the machine back to the entity (because it might not really be terminated)?
+ // Do we need a better exception hierarchy for that?
+ entity().sensors().remove(AttributesInternal.INTERNAL_TERMINATION_TASK_STATE);
+ }
+
return new StopMachineDetails<Integer>("Decommissioned "+machine, 1);
}
http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/829ae6aa/software/base/src/test/java/org/apache/brooklyn/entity/software/base/SoftwareProcessRebindNotRunningEntityTest.java
----------------------------------------------------------------------
diff --git a/software/base/src/test/java/org/apache/brooklyn/entity/software/base/SoftwareProcessRebindNotRunningEntityTest.java b/software/base/src/test/java/org/apache/brooklyn/entity/software/base/SoftwareProcessRebindNotRunningEntityTest.java
index e5e7709..89a177a 100644
--- a/software/base/src/test/java/org/apache/brooklyn/entity/software/base/SoftwareProcessRebindNotRunningEntityTest.java
+++ b/software/base/src/test/java/org/apache/brooklyn/entity/software/base/SoftwareProcessRebindNotRunningEntityTest.java
@@ -43,6 +43,7 @@ import org.apache.brooklyn.config.ConfigKey;
import org.apache.brooklyn.core.config.ConfigKeys;
import org.apache.brooklyn.core.entity.Attributes;
import org.apache.brooklyn.core.entity.EntityAsserts;
+import org.apache.brooklyn.core.entity.internal.AttributesInternal;
import org.apache.brooklyn.core.entity.lifecycle.Lifecycle;
import org.apache.brooklyn.core.entity.trait.Startable;
import org.apache.brooklyn.core.location.AbstractLocation;
@@ -75,11 +76,6 @@ import com.google.common.util.concurrent.MoreExecutors;
public class SoftwareProcessRebindNotRunningEntityTest extends RebindTestFixtureWithApp {
- // TODO If we fail during provisioningLocation.obtain() or provisioningLocation.release(), then we
- // should tell the user that a VM might have started being provisioned but been forgotten about; or
- // that termination of the VM may or may not have completed.
- // We could use the Attributes.SERVICE_NOT_UP_INDICATORS to achieve that.
-
private static final Logger LOG = LoggerFactory.getLogger(SoftwareProcessRebindNotRunningEntityTest.class);
private ListeningExecutorService executor;
@@ -243,6 +239,11 @@ public class SoftwareProcessRebindNotRunningEntityTest extends RebindTestFixture
assertMarkedAsOnfire(newEntity, Lifecycle.STARTING);
assertMarkedAsOnfire(newApp, Lifecycle.STARTING);
+ assertMarkedAsVmLost(newEntity, Lifecycle.STARTING);
+
+ // Expect the marker to have been cleared on rebind (sensible because task is not running).
+ EntityAsserts.assertAttributeEquals(newEntity, AttributesInternal.INTERNAL_PROVISIONING_TASK_STATE, null);
+ EntityAsserts.assertAttributeEquals(newEntity, AttributesInternal.INTERNAL_TERMINATION_TASK_STATE, null);
}
@Test
@@ -267,8 +268,14 @@ public class SoftwareProcessRebindNotRunningEntityTest extends RebindTestFixture
TestApplication newApp = rebind();
final VanillaSoftwareProcess newEntity = (VanillaSoftwareProcess) Iterables.find(newApp.getChildren(), Predicates.instanceOf(VanillaSoftwareProcess.class));
-
+
+
assertMarkedAsOnfire(newEntity, Lifecycle.STOPPING);
+ assertMarkedAsVmLost(newEntity, Lifecycle.STOPPING);
+
+ // Expect the marker to have been cleared on rebind (sensible because task is not running).
+ EntityAsserts.assertAttributeEquals(newEntity, AttributesInternal.INTERNAL_PROVISIONING_TASK_STATE, null);
+ EntityAsserts.assertAttributeEquals(newEntity, AttributesInternal.INTERNAL_TERMINATION_TASK_STATE, null);
}
@Test
@@ -299,7 +306,7 @@ public class SoftwareProcessRebindNotRunningEntityTest extends RebindTestFixture
assertNotMarkedOnfire(newEntity, Lifecycle.STARTING);
assertNotMarkedOnfire(newApp, Lifecycle.STARTING);
}
-
+
protected ListenableFuture<Void> startAsync(final Startable entity, final Collection<? extends Location> locs) {
return executor.submit(new Callable<Void>() {
@Override public Void call() throws Exception {
@@ -327,15 +334,24 @@ public class SoftwareProcessRebindNotRunningEntityTest extends RebindTestFixture
return result;
}
- protected void assertMarkedAsOnfire(final Entity entity, final Lifecycle previousState) throws Exception {
+ protected void assertMarkedAsOnfire(Entity entity, Lifecycle previousState) throws Exception {
EntityAsserts.assertAttributeEqualsEventually(entity, Attributes.SERVICE_STATE_ACTUAL, Lifecycle.ON_FIRE);
EntityAsserts.assertAttributeEqualsEventually(entity, Attributes.SERVICE_UP, false);
+ assertNotUpIndicatorIncludesEventually(entity, "Task aborted on rebind",
+ "Set to on-fire (from previous expected state "+previousState+") because tasks aborted on rebind");
+ }
+
+ protected void assertMarkedAsVmLost(Entity entity, Lifecycle previousState) throws Exception {
+ String expectedReason = "VM " + (previousState == Lifecycle.STARTING ? "provisioning" : "termination")
+ + " may have been in-progress and now lost, because tasks aborted on rebind";
+ assertNotUpIndicatorIncludesEventually(entity, "VM may be lost on rebind", expectedReason);
+ }
+
+ protected void assertNotUpIndicatorIncludesEventually(final Entity entity, final String expectedKey, final String expectedVal) throws Exception {
EntityAsserts.assertAttributeEventually(entity, Attributes.SERVICE_NOT_UP_INDICATORS, new Predicate<Map<?,?>>() {
@Override
public boolean apply(Map<?, ?> input) {
if (input == null) return false;
- String expectedKey = "Task aborted on rebind";
- String expectedVal = "Set to on-fire (from previous expected state "+previousState+") because tasks aborted on rebind";
for (Map.Entry<?, ?> entry : input.entrySet()) {
boolean keyMatches = expectedKey.equals(entry.getKey());
boolean valueMatches = expectedVal.equals(entry.getValue());
@@ -363,6 +379,8 @@ public class SoftwareProcessRebindNotRunningEntityTest extends RebindTestFixture
new TypeToken<LocationSpec<SshMachineLocation>>() {},
"machineSpec");
+ protected List<CallInfo> callHistory = Collections.synchronizedList(Lists.<CallInfo>newArrayList());
+
@Override
public MachineProvisioningLocation<SshMachineLocation> newSubLocation(Map<?, ?> newFlags) {
throw new UnsupportedOperationException();
@@ -370,6 +388,8 @@ public class SoftwareProcessRebindNotRunningEntityTest extends RebindTestFixture
@Override
public SshMachineLocation obtain(Map<?,?> flags) throws NoMachinesAvailableException {
+ callHistory.add(new CallInfo("obtain", ImmutableList.of(flags)));
+
CountDownLatch calledLatch = config().get(OBTAIN_CALLED_LATCH);
CountDownLatch blockedLatch = config().get(OBTAIN_BLOCKED_LATCH);
LocationSpec<SshMachineLocation> machineSpec = config().get(MACHINE_SPEC);
@@ -385,6 +405,8 @@ public class SoftwareProcessRebindNotRunningEntityTest extends RebindTestFixture
@Override
public void release(SshMachineLocation machine) {
+ callHistory.add(new CallInfo("release", ImmutableList.of(machine)));
+
CountDownLatch calledLatch = config().get(RELEASE_CALLED_LATCH);
CountDownLatch blockedLatch = config().get(RELEASE_BLOCKED_LATCH);
@@ -400,5 +422,27 @@ public class SoftwareProcessRebindNotRunningEntityTest extends RebindTestFixture
public Map getProvisioningFlags(Collection<String> tags) {
return Collections.emptyMap();
}
+
+ public List<CallInfo> getCallHistory() {
+ synchronized (callHistory) {
+ return ImmutableList.copyOf(callHistory);
+ }
+ }
+
+ public CallInfo getLastCall() {
+ synchronized (callHistory) {
+ return callHistory.get(callHistory.size()-1);
+ }
+ }
+
+ static class CallInfo {
+ public final String name;
+ public final List<? extends Object> args;
+
+ public CallInfo(String name, List<? extends Object> args) {
+ this.name = name;
+ this.args = args;
+ }
+ }
}
}
[3/4] brooklyn-server git commit: BROOKLYN-325: address review
comments
Posted by al...@apache.org.
BROOKLYN-325: address review comments
Project: http://git-wip-us.apache.org/repos/asf/brooklyn-server/repo
Commit: http://git-wip-us.apache.org/repos/asf/brooklyn-server/commit/8bef4c7a
Tree: http://git-wip-us.apache.org/repos/asf/brooklyn-server/tree/8bef4c7a
Diff: http://git-wip-us.apache.org/repos/asf/brooklyn-server/diff/8bef4c7a
Branch: refs/heads/master
Commit: 8bef4c7a3db3584c8c383a32eb1c4a62f90f7272
Parents: 829ae6a
Author: Aled Sage <al...@gmail.com>
Authored: Wed Nov 16 15:46:05 2016 +0000
Committer: Aled Sage <al...@gmail.com>
Committed: Wed Nov 16 15:46:05 2016 +0000
----------------------------------------------------------------------
.../entity/internal/AttributesInternal.java | 17 ++++----
.../mgmt/rebind/BasicEntityRebindSupport.java | 6 +--
.../MachineLifecycleEffectorTasks.java | 4 +-
...ftwareProcessRebindNotRunningEntityTest.java | 44 +++++++++++++-------
...eProcessStopsDuringStartJcloudsLiveTest.java | 2 +-
.../SoftwareProcessStopsDuringStartTest.java | 6 +--
6 files changed, 47 insertions(+), 32 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/8bef4c7a/core/src/main/java/org/apache/brooklyn/core/entity/internal/AttributesInternal.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/brooklyn/core/entity/internal/AttributesInternal.java b/core/src/main/java/org/apache/brooklyn/core/entity/internal/AttributesInternal.java
index 7bccb4d..66004fb 100644
--- a/core/src/main/java/org/apache/brooklyn/core/entity/internal/AttributesInternal.java
+++ b/core/src/main/java/org/apache/brooklyn/core/entity/internal/AttributesInternal.java
@@ -1,4 +1,5 @@
/*
+ * Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
@@ -19,22 +20,21 @@ package org.apache.brooklyn.core.entity.internal;
import org.apache.brooklyn.api.sensor.AttributeSensor;
import org.apache.brooklyn.core.entity.Attributes;
-import org.apache.brooklyn.core.sensor.BasicAttributeSensor;
+import org.apache.brooklyn.core.sensor.Sensors;
import com.google.common.annotations.Beta;
import com.google.common.annotations.VisibleForTesting;
-import com.google.common.reflect.TypeToken;
public interface AttributesInternal extends Attributes {
@Beta
- public static final AttributeSensor<ProvisioningTaskState> INTERNAL_PROVISIONING_TASK_STATE = new BasicAttributeSensor<ProvisioningTaskState>(
- TypeToken.of(ProvisioningTaskState.class),
+ public static final AttributeSensor<ProvisioningTaskState> INTERNAL_PROVISIONING_TASK_STATE = Sensors.newSensor(
+ ProvisioningTaskState.class,
"internal.provisioning.task.state",
"Internal transient sensor (do not use) for tracking the provisioning of a machine (to better handle aborting/rebind)");
@Beta
- public static final AttributeSensor<ProvisioningTaskState> INTERNAL_TERMINATION_TASK_STATE = new BasicAttributeSensor<ProvisioningTaskState>(
- TypeToken.of(ProvisioningTaskState.class),
+ public static final AttributeSensor<ProvisioningTaskState> INTERNAL_TERMINATION_TASK_STATE = Sensors.newSensor(
+ ProvisioningTaskState.class,
"internal.termination.task.state",
"Internal transient sensor (do not use) for tracking the termination of a machine (to better handle aborting/rebind)");
@@ -42,11 +42,12 @@ public interface AttributesInternal extends Attributes {
* Used only internally by {@link org.apache.brooklyn.entity.software.base.lifecycle.MachineLifecycleEffectorTasks}
* to track provisioning/termination. This is used so the machine can be terminated if stopped while opaque provision
* call is being made; and is used to report if termination was prematurely aborted (e.g. during Brooklyn restart).
+ *
+ * @since 0.10.0; before that moved from org.apache.brooklyn.entity.software.base.lifecycle.MachineLifecycleEffectorTasks$ProvisioningTaskState
*/
@Beta
@VisibleForTesting
public enum ProvisioningTaskState {
- RUNNING,
- DONE;
+ RUNNING
}
}
http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/8bef4c7a/core/src/main/java/org/apache/brooklyn/core/mgmt/rebind/BasicEntityRebindSupport.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/brooklyn/core/mgmt/rebind/BasicEntityRebindSupport.java b/core/src/main/java/org/apache/brooklyn/core/mgmt/rebind/BasicEntityRebindSupport.java
index f7b5cd8..4165191 100644
--- a/core/src/main/java/org/apache/brooklyn/core/mgmt/rebind/BasicEntityRebindSupport.java
+++ b/core/src/main/java/org/apache/brooklyn/core/mgmt/rebind/BasicEntityRebindSupport.java
@@ -269,7 +269,7 @@ public class BasicEntityRebindSupport extends AbstractBrooklynObjectRebindSuppor
ServiceStateLogic.ServiceNotUpLogic.updateNotUpIndicator(
entity,
"Task aborted on rebind",
- "Set to on-fire (from previous expected state "+expectedState+") because tasks aborted on rebind");
+ "Set to on-fire (from previous expected state "+expectedState+") because tasks aborted on shutdown");
// Check if we were in the process of provisioning a machine. If so, a VM might have
// been left behind. E.g. we might have submitted to jclouds the request to provision
@@ -282,7 +282,7 @@ public class BasicEntityRebindSupport extends AbstractBrooklynObjectRebindSuppor
ServiceStateLogic.ServiceNotUpLogic.updateNotUpIndicator(
entity,
"VM may be lost on rebind",
- "VM provisioning may have been in-progress and now lost, because tasks aborted on rebind");
+ "VM provisioning may have been in-progress and now lost, because tasks aborted on shutdown");
}
// Similar to the provisioning case, if we were terminating the VM then we may or may
@@ -294,7 +294,7 @@ public class BasicEntityRebindSupport extends AbstractBrooklynObjectRebindSuppor
ServiceStateLogic.ServiceNotUpLogic.updateNotUpIndicator(
entity,
"VM may be lost on rebind",
- "VM termination may have been in-progress and now lost, because tasks aborted on rebind");
+ "VM termination may have been in-progress and now lost, because tasks aborted on shutdown");
}
}
}
http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/8bef4c7a/software/base/src/main/java/org/apache/brooklyn/entity/software/base/lifecycle/MachineLifecycleEffectorTasks.java
----------------------------------------------------------------------
diff --git a/software/base/src/main/java/org/apache/brooklyn/entity/software/base/lifecycle/MachineLifecycleEffectorTasks.java b/software/base/src/main/java/org/apache/brooklyn/entity/software/base/lifecycle/MachineLifecycleEffectorTasks.java
index 8748861..bb7da92 100644
--- a/software/base/src/main/java/org/apache/brooklyn/entity/software/base/lifecycle/MachineLifecycleEffectorTasks.java
+++ b/software/base/src/main/java/org/apache/brooklyn/entity/software/base/lifecycle/MachineLifecycleEffectorTasks.java
@@ -414,7 +414,7 @@ public abstract class MachineLifecycleEffectorTasks {
machine = Tasks.withBlockingDetails("Provisioning machine in " + location, new ObtainLocationTask(location, flags));
entity().sensors().set(INTERNAL_PROVISIONED_MACHINE, machine);
} finally {
- entity().sensors().set(AttributesInternal.INTERNAL_PROVISIONING_TASK_STATE, ProvisioningTaskState.DONE);
+ entity().sensors().remove(AttributesInternal.INTERNAL_PROVISIONING_TASK_STATE);
}
if (machine == null) {
@@ -774,7 +774,7 @@ public abstract class MachineLifecycleEffectorTasks {
@Override
public Boolean call() throws Exception {
ProvisioningTaskState state = entity().sensors().get(AttributesInternal.INTERNAL_PROVISIONING_TASK_STATE);
- return (state == ProvisioningTaskState.DONE);
+ return (state != ProvisioningTaskState.RUNNING);
}})
.backoffTo(Duration.FIVE_SECONDS)
.limitTimeTo(maxWait)
http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/8bef4c7a/software/base/src/test/java/org/apache/brooklyn/entity/software/base/SoftwareProcessRebindNotRunningEntityTest.java
----------------------------------------------------------------------
diff --git a/software/base/src/test/java/org/apache/brooklyn/entity/software/base/SoftwareProcessRebindNotRunningEntityTest.java b/software/base/src/test/java/org/apache/brooklyn/entity/software/base/SoftwareProcessRebindNotRunningEntityTest.java
index 89a177a..9c9987c 100644
--- a/software/base/src/test/java/org/apache/brooklyn/entity/software/base/SoftwareProcessRebindNotRunningEntityTest.java
+++ b/software/base/src/test/java/org/apache/brooklyn/entity/software/base/SoftwareProcessRebindNotRunningEntityTest.java
@@ -47,6 +47,7 @@ import org.apache.brooklyn.core.entity.internal.AttributesInternal;
import org.apache.brooklyn.core.entity.lifecycle.Lifecycle;
import org.apache.brooklyn.core.entity.trait.Startable;
import org.apache.brooklyn.core.location.AbstractLocation;
+import org.apache.brooklyn.core.mgmt.rebind.RebindOptions;
import org.apache.brooklyn.core.mgmt.rebind.RebindTestFixtureWithApp;
import org.apache.brooklyn.core.test.entity.TestApplication;
import org.apache.brooklyn.location.byon.FixedListMachineProvisioningLocation;
@@ -62,6 +63,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
import com.google.common.base.Predicate;
@@ -87,6 +89,11 @@ public class SoftwareProcessRebindNotRunningEntityTest extends RebindTestFixture
// TODO Longer term, we should investigate/fix that so tearDown finishes promptly no matter what!
private List<CountDownLatch> latches;
+ @DataProvider
+ public Object[][] terminateOrigManagementContextProvider() {
+ return new Object[][]{{false}, {true}};
+ }
+
@BeforeMethod(alwaysRun=true)
@Override
public void setUp() throws Exception {
@@ -133,8 +140,8 @@ public class SoftwareProcessRebindNotRunningEntityTest extends RebindTestFixture
return HighAvailabilityMode.MASTER;
}
- @Test
- public void testRebindWhileWaitingForCheckRunning() throws Exception {
+ @Test(dataProvider="terminateOrigManagementContextProvider")
+ public void testRebindWhileWaitingForCheckRunning(boolean terminateOrigManagementContext) throws Exception {
final CountDownLatch checkRunningCalledLatch = newLatch(1);
RecordingSshTool.setCustomResponse(".*myCheckRunning.*", new CustomResponseGenerator() {
@Override
@@ -152,15 +159,15 @@ public class SoftwareProcessRebindNotRunningEntityTest extends RebindTestFixture
EntityAsserts.assertAttributeEquals(entity, Attributes.SERVICE_STATE_ACTUAL, Lifecycle.STARTING);
- TestApplication newApp = rebind();
+ TestApplication newApp = rebind(RebindOptions.create().terminateOrigManagementContext(terminateOrigManagementContext));
final VanillaSoftwareProcess newEntity = (VanillaSoftwareProcess) Iterables.find(newApp.getChildren(), Predicates.instanceOf(VanillaSoftwareProcess.class));
assertMarkedAsOnfire(newEntity, Lifecycle.STARTING);
assertMarkedAsOnfire(newApp, Lifecycle.STARTING);
}
- @Test
- public void testRebindWhileLaunching() throws Exception {
+ @Test(dataProvider="terminateOrigManagementContextProvider")
+ public void testRebindWhileLaunching(boolean terminateOrigManagementContext) throws Exception {
final CountDownLatch launchCalledLatch = newLatch(1);
final CountDownLatch launchBlockedLatch = newLatch(1);
RecordingSshTool.setCustomResponse(".*myLaunch.*", new CustomResponseGenerator() {
@@ -180,15 +187,15 @@ public class SoftwareProcessRebindNotRunningEntityTest extends RebindTestFixture
EntityAsserts.assertAttributeEquals(entity, Attributes.SERVICE_STATE_ACTUAL, Lifecycle.STARTING);
- TestApplication newApp = rebind();
+ TestApplication newApp = rebind(RebindOptions.create().terminateOrigManagementContext(terminateOrigManagementContext));
final VanillaSoftwareProcess newEntity = (VanillaSoftwareProcess) Iterables.find(newApp.getChildren(), Predicates.instanceOf(VanillaSoftwareProcess.class));
assertMarkedAsOnfire(newEntity, Lifecycle.STARTING);
assertMarkedAsOnfire(newApp, Lifecycle.STARTING);
}
- @Test
- public void testRebindWhileStoppingProcess() throws Exception {
+ @Test(dataProvider="terminateOrigManagementContextProvider")
+ public void testRebindWhileStoppingProcess(boolean terminateOrigManagementContext) throws Exception {
final CountDownLatch stopCalledLatch = newLatch(1);
final CountDownLatch stopBlockedLatch = newLatch(1);
RecordingSshTool.setCustomResponse(".*myStop.*", new CustomResponseGenerator() {
@@ -210,7 +217,7 @@ public class SoftwareProcessRebindNotRunningEntityTest extends RebindTestFixture
EntityAsserts.assertAttributeEquals(entity, Attributes.SERVICE_STATE_ACTUAL, Lifecycle.STOPPING);
- TestApplication newApp = rebind();
+ TestApplication newApp = rebind(RebindOptions.create().terminateOrigManagementContext(terminateOrigManagementContext));
final VanillaSoftwareProcess newEntity = (VanillaSoftwareProcess) Iterables.find(newApp.getChildren(), Predicates.instanceOf(VanillaSoftwareProcess.class));
assertMarkedAsOnfire(newEntity, Lifecycle.STOPPING);
@@ -218,6 +225,11 @@ public class SoftwareProcessRebindNotRunningEntityTest extends RebindTestFixture
@Test
public void testRebindWhileProvisioning() throws Exception {
+ testRebindWhileProvisioning(true);
+ }
+
+ @Test(dataProvider="terminateOrigManagementContextProvider")
+ public void testRebindWhileProvisioning(boolean terminateOrigManagementContext) throws Exception {
final CountDownLatch obtainCalledLatch = newLatch(1);
final CountDownLatch obtainBlockedLatch = newLatch(1);
MyProvisioningLocation blockingProvisioner = mgmt().getLocationManager().createLocation(LocationSpec.create(MyProvisioningLocation.class)
@@ -233,8 +245,9 @@ public class SoftwareProcessRebindNotRunningEntityTest extends RebindTestFixture
awaitOrFail(obtainCalledLatch, Asserts.DEFAULT_LONG_TIMEOUT);
EntityAsserts.assertAttributeEquals(entity, Attributes.SERVICE_STATE_ACTUAL, Lifecycle.STARTING);
+ EntityAsserts.assertAttributeEquals(entity, AttributesInternal.INTERNAL_PROVISIONING_TASK_STATE, AttributesInternal.ProvisioningTaskState.RUNNING);
- TestApplication newApp = rebind();
+ TestApplication newApp = rebind(RebindOptions.create().terminateOrigManagementContext(terminateOrigManagementContext));
final VanillaSoftwareProcess newEntity = (VanillaSoftwareProcess) Iterables.find(newApp.getChildren(), Predicates.instanceOf(VanillaSoftwareProcess.class));
assertMarkedAsOnfire(newEntity, Lifecycle.STARTING);
@@ -246,8 +259,8 @@ public class SoftwareProcessRebindNotRunningEntityTest extends RebindTestFixture
EntityAsserts.assertAttributeEquals(newEntity, AttributesInternal.INTERNAL_TERMINATION_TASK_STATE, null);
}
- @Test
- public void testRebindWhileTerminatingVm() throws Exception {
+ @Test(dataProvider="terminateOrigManagementContextProvider")
+ public void testRebindWhileTerminatingVm(boolean terminateOrigManagementContext) throws Exception {
final CountDownLatch releaseCalledLatch = newLatch(1);
final CountDownLatch obtainBlockedLatch = newLatch(1);
MyProvisioningLocation blockingProvisioner = mgmt().getLocationManager().createLocation(LocationSpec.create(MyProvisioningLocation.class)
@@ -265,8 +278,9 @@ public class SoftwareProcessRebindNotRunningEntityTest extends RebindTestFixture
awaitOrFail(releaseCalledLatch, Asserts.DEFAULT_LONG_TIMEOUT);
EntityAsserts.assertAttributeEquals(entity, Attributes.SERVICE_STATE_ACTUAL, Lifecycle.STOPPING);
+ EntityAsserts.assertAttributeEquals(entity, AttributesInternal.INTERNAL_TERMINATION_TASK_STATE, AttributesInternal.ProvisioningTaskState.RUNNING);
- TestApplication newApp = rebind();
+ TestApplication newApp = rebind(RebindOptions.create().terminateOrigManagementContext(terminateOrigManagementContext));
final VanillaSoftwareProcess newEntity = (VanillaSoftwareProcess) Iterables.find(newApp.getChildren(), Predicates.instanceOf(VanillaSoftwareProcess.class));
@@ -338,12 +352,12 @@ public class SoftwareProcessRebindNotRunningEntityTest extends RebindTestFixture
EntityAsserts.assertAttributeEqualsEventually(entity, Attributes.SERVICE_STATE_ACTUAL, Lifecycle.ON_FIRE);
EntityAsserts.assertAttributeEqualsEventually(entity, Attributes.SERVICE_UP, false);
assertNotUpIndicatorIncludesEventually(entity, "Task aborted on rebind",
- "Set to on-fire (from previous expected state "+previousState+") because tasks aborted on rebind");
+ "Set to on-fire (from previous expected state "+previousState+") because tasks aborted on shutdown");
}
protected void assertMarkedAsVmLost(Entity entity, Lifecycle previousState) throws Exception {
String expectedReason = "VM " + (previousState == Lifecycle.STARTING ? "provisioning" : "termination")
- + " may have been in-progress and now lost, because tasks aborted on rebind";
+ + " may have been in-progress and now lost, because tasks aborted on shutdown";
assertNotUpIndicatorIncludesEventually(entity, "VM may be lost on rebind", expectedReason);
}
http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/8bef4c7a/software/base/src/test/java/org/apache/brooklyn/entity/software/base/SoftwareProcessStopsDuringStartJcloudsLiveTest.java
----------------------------------------------------------------------
diff --git a/software/base/src/test/java/org/apache/brooklyn/entity/software/base/SoftwareProcessStopsDuringStartJcloudsLiveTest.java b/software/base/src/test/java/org/apache/brooklyn/entity/software/base/SoftwareProcessStopsDuringStartJcloudsLiveTest.java
index f5dcf5d..9515feb 100644
--- a/software/base/src/test/java/org/apache/brooklyn/entity/software/base/SoftwareProcessStopsDuringStartJcloudsLiveTest.java
+++ b/software/base/src/test/java/org/apache/brooklyn/entity/software/base/SoftwareProcessStopsDuringStartJcloudsLiveTest.java
@@ -142,7 +142,7 @@ public class SoftwareProcessStopsDuringStartJcloudsLiveTest extends BrooklynAppL
}
}, Asserts.DEFAULT_LONG_TIMEOUT.toMilliseconds(), TimeUnit.MILLISECONDS);
EntityAsserts.assertEntityHealthy(entity);
- assertEquals(entity.getAttribute(AttributesInternal.INTERNAL_PROVISIONING_TASK_STATE), AttributesInternal.ProvisioningTaskState.DONE);
+ assertEquals(entity.getAttribute(AttributesInternal.INTERNAL_PROVISIONING_TASK_STATE), null);
assertEquals(entity.getAttribute(MachineLifecycleEffectorTasks.INTERNAL_PROVISIONED_MACHINE), Machines.findUniqueMachineLocation(entity.getLocations(), SshMachineLocation.class).get());
executeInLimitedTime(new Callable<Void>() {
http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/8bef4c7a/software/base/src/test/java/org/apache/brooklyn/entity/software/base/SoftwareProcessStopsDuringStartTest.java
----------------------------------------------------------------------
diff --git a/software/base/src/test/java/org/apache/brooklyn/entity/software/base/SoftwareProcessStopsDuringStartTest.java b/software/base/src/test/java/org/apache/brooklyn/entity/software/base/SoftwareProcessStopsDuringStartTest.java
index 99d9678..095da91 100644
--- a/software/base/src/test/java/org/apache/brooklyn/entity/software/base/SoftwareProcessStopsDuringStartTest.java
+++ b/software/base/src/test/java/org/apache/brooklyn/entity/software/base/SoftwareProcessStopsDuringStartTest.java
@@ -99,7 +99,7 @@ public class SoftwareProcessStopsDuringStartTest extends BrooklynAppUnitTestSupp
entity.start(ImmutableList.<Location>of(loc));
SshMachineLocation machine = Machines.findUniqueMachineLocation(entity.getLocations(), SshMachineLocation.class).get();
- EntityAsserts.assertAttributeEquals(entity, AttributesInternal.INTERNAL_PROVISIONING_TASK_STATE, AttributesInternal.ProvisioningTaskState.DONE);
+ EntityAsserts.assertAttributeEquals(entity, AttributesInternal.INTERNAL_PROVISIONING_TASK_STATE, null);
EntityAsserts.assertAttributeEquals(entity, MachineLifecycleEffectorTasks.INTERNAL_PROVISIONED_MACHINE, machine);
Stopwatch stopwatch = Stopwatch.createStarted();
@@ -120,7 +120,7 @@ public class SoftwareProcessStopsDuringStartTest extends BrooklynAppUnitTestSupp
entity.start(ImmutableList.<Location>of(loc));
SshMachineLocation machine = Machines.findUniqueMachineLocation(entity.getLocations(), SshMachineLocation.class).get();
- EntityAsserts.assertAttributeEquals(entity, AttributesInternal.INTERNAL_PROVISIONING_TASK_STATE, AttributesInternal.ProvisioningTaskState.DONE);
+ EntityAsserts.assertAttributeEquals(entity, AttributesInternal.INTERNAL_PROVISIONING_TASK_STATE, null);
EntityAsserts.assertAttributeEquals(entity, MachineLifecycleEffectorTasks.INTERNAL_PROVISIONED_MACHINE, machine);
entity.stop();
@@ -129,7 +129,7 @@ public class SoftwareProcessStopsDuringStartTest extends BrooklynAppUnitTestSupp
entity.start(ImmutableList.<Location>of(loc));
SshMachineLocation machine2 = Machines.findUniqueMachineLocation(entity.getLocations(), SshMachineLocation.class).get();
- EntityAsserts.assertAttributeEquals(entity, AttributesInternal.INTERNAL_PROVISIONING_TASK_STATE, AttributesInternal.ProvisioningTaskState.DONE);
+ EntityAsserts.assertAttributeEquals(entity, AttributesInternal.INTERNAL_PROVISIONING_TASK_STATE, null);
EntityAsserts.assertAttributeEquals(entity, MachineLifecycleEffectorTasks.INTERNAL_PROVISIONED_MACHINE, machine2);
entity.stop();
[2/4] brooklyn-server git commit: Move
INTERNAL_PROVISIONING_TASK_STATE to AttributesInternal
Posted by al...@apache.org.
Move INTERNAL_PROVISIONING_TASK_STATE to AttributesInternal
So that it can subsequently be used to fix BROOKLYN-325.
Project: http://git-wip-us.apache.org/repos/asf/brooklyn-server/repo
Commit: http://git-wip-us.apache.org/repos/asf/brooklyn-server/commit/fbfe2fef
Tree: http://git-wip-us.apache.org/repos/asf/brooklyn-server/tree/fbfe2fef
Diff: http://git-wip-us.apache.org/repos/asf/brooklyn-server/diff/fbfe2fef
Branch: refs/heads/master
Commit: fbfe2fefa4af329bacf18dc9553938a01230228d
Parents: 5b65fad
Author: Aled Sage <al...@gmail.com>
Authored: Mon Nov 14 17:41:06 2016 +0000
Committer: Aled Sage <al...@gmail.com>
Committed: Wed Nov 16 12:47:50 2016 +0000
----------------------------------------------------------------------
.../entity/internal/AttributesInternal.java | 46 ++++++++++++++++++++
.../deserializingClassRenames.properties | 2 +
.../MachineLifecycleEffectorTasks.java | 31 +++----------
...eProcessStopsDuringStartJcloudsLiveTest.java | 7 +--
.../SoftwareProcessStopsDuringStartTest.java | 13 +++---
5 files changed, 66 insertions(+), 33 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/fbfe2fef/core/src/main/java/org/apache/brooklyn/core/entity/internal/AttributesInternal.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/brooklyn/core/entity/internal/AttributesInternal.java b/core/src/main/java/org/apache/brooklyn/core/entity/internal/AttributesInternal.java
new file mode 100644
index 0000000..6051e05
--- /dev/null
+++ b/core/src/main/java/org/apache/brooklyn/core/entity/internal/AttributesInternal.java
@@ -0,0 +1,46 @@
+/*
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.brooklyn.core.entity.internal;
+
+import org.apache.brooklyn.api.sensor.AttributeSensor;
+import org.apache.brooklyn.core.entity.Attributes;
+import org.apache.brooklyn.core.sensor.BasicAttributeSensor;
+
+import com.google.common.annotations.Beta;
+import com.google.common.annotations.VisibleForTesting;
+import com.google.common.reflect.TypeToken;
+
+public interface AttributesInternal extends Attributes {
+ @Beta
+ public static final AttributeSensor<ProvisioningTaskState> INTERNAL_PROVISIONING_TASK_STATE = new BasicAttributeSensor<ProvisioningTaskState>(
+ TypeToken.of(ProvisioningTaskState.class),
+ "internal.provisioning.task.state",
+ "Internal transient sensor (do not use) for tracking the provisioning of a machine (to better handle aborting/rebind)",
+ AttributeSensor.SensorPersistenceMode.NONE);
+
+ /**
+ * Used only internally by {@link org.apache.brooklyn.entity.software.base.lifecycle.MachineLifecycleEffectorTasks}
+ * to track provisioning, so machine can be terminated if stopped while opaque provision call is being made.
+ */
+ @Beta
+ @VisibleForTesting
+ public enum ProvisioningTaskState {
+ RUNNING,
+ DONE;
+ }
+}
http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/fbfe2fef/core/src/main/resources/org/apache/brooklyn/core/mgmt/persist/deserializingClassRenames.properties
----------------------------------------------------------------------
diff --git a/core/src/main/resources/org/apache/brooklyn/core/mgmt/persist/deserializingClassRenames.properties b/core/src/main/resources/org/apache/brooklyn/core/mgmt/persist/deserializingClassRenames.properties
index 64981fb..300bba2 100644
--- a/core/src/main/resources/org/apache/brooklyn/core/mgmt/persist/deserializingClassRenames.properties
+++ b/core/src/main/resources/org/apache/brooklyn/core/mgmt/persist/deserializingClassRenames.properties
@@ -1434,3 +1434,5 @@ brooklyn.test.entity.BlockingEntityImpl
org.apache.brooklyn.config.ConfigInheritance$None : org.apache.brooklyn.config.ConfigInheritance$Legacy$None
org.apache.brooklyn.config.ConfigInheritance$Always : org.apache.brooklyn.config.ConfigInheritance$Legacy$Always
org.apache.brooklyn.config.ConfigInheritance$Merged : org.apache.brooklyn.config.ConfigInheritance$Legacy$Merged
+
+org.apache.brooklyn.entity.software.base.lifecycle.MachineLifecycleEffectorTasks$ProvisioningTaskState : org.apache.brooklyn.core.entity.internal.AttributesInternal$ProvisioningTaskState
http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/fbfe2fef/software/base/src/main/java/org/apache/brooklyn/entity/software/base/lifecycle/MachineLifecycleEffectorTasks.java
----------------------------------------------------------------------
diff --git a/software/base/src/main/java/org/apache/brooklyn/entity/software/base/lifecycle/MachineLifecycleEffectorTasks.java b/software/base/src/main/java/org/apache/brooklyn/entity/software/base/lifecycle/MachineLifecycleEffectorTasks.java
index fc738b1..439770a 100644
--- a/software/base/src/main/java/org/apache/brooklyn/entity/software/base/lifecycle/MachineLifecycleEffectorTasks.java
+++ b/software/base/src/main/java/org/apache/brooklyn/entity/software/base/lifecycle/MachineLifecycleEffectorTasks.java
@@ -49,6 +49,8 @@ import org.apache.brooklyn.core.entity.Attributes;
import org.apache.brooklyn.core.entity.BrooklynConfigKeys;
import org.apache.brooklyn.core.entity.Entities;
import org.apache.brooklyn.core.entity.EntityInternal;
+import org.apache.brooklyn.core.entity.internal.AttributesInternal;
+import org.apache.brooklyn.core.entity.internal.AttributesInternal.ProvisioningTaskState;
import org.apache.brooklyn.core.entity.lifecycle.Lifecycle;
import org.apache.brooklyn.core.entity.lifecycle.Lifecycle.Transition;
import org.apache.brooklyn.core.entity.lifecycle.ServiceStateLogic;
@@ -90,7 +92,6 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.google.common.annotations.Beta;
-import com.google.common.annotations.VisibleForTesting;
import com.google.common.base.Preconditions;
import com.google.common.base.Supplier;
import com.google.common.base.Suppliers;
@@ -143,30 +144,12 @@ public abstract class MachineLifecycleEffectorTasks {
Duration.minutes(10));
@Beta
- public static final AttributeSensor<ProvisioningTaskState> INTERNAL_PROVISIONING_TASK_STATE = new BasicAttributeSensor<ProvisioningTaskState>(
- TypeToken.of(ProvisioningTaskState.class),
- "internal.provisioning.task.state",
- "Internal transient sensor (do not use) for tracking the provisioning of a machine (to better handle aborting)",
- AttributeSensor.SensorPersistenceMode.NONE);
-
- @Beta
public static final AttributeSensor<MachineLocation> INTERNAL_PROVISIONED_MACHINE = new BasicAttributeSensor<MachineLocation>(
TypeToken.of(MachineLocation.class),
"internal.provisioning.task.machine",
"Internal transient sensor (do not use) for tracking the machine being provisioned (to better handle aborting)",
AttributeSensor.SensorPersistenceMode.NONE);
- /**
- * Used only internally by {@link org.apache.brooklyn.entity.software.base.lifecycle.MachineLifecycleEffectorTasks}
- * to track provisioning, so machine can be terminated if stopped while opaque provision call is being made.
- */
- @Beta
- @VisibleForTesting
- public enum ProvisioningTaskState {
- RUNNING,
- DONE;
- }
-
protected final MachineInitTasks machineInitTasks = new MachineInitTasks();
/** Attaches lifecycle effectors (start, restart, stop) to the given entity post-creation. */
@@ -424,14 +407,14 @@ public abstract class MachineLifecycleEffectorTasks {
if (expectedState != null && (expectedState.getState() == Lifecycle.STOPPING || expectedState.getState() == Lifecycle.STOPPED)) {
throw new IllegalStateException("Provisioning aborted before even begun for "+entity()+" in "+location+" (presumably by a concurrent call to stop");
}
- entity().sensors().set(INTERNAL_PROVISIONING_TASK_STATE, ProvisioningTaskState.RUNNING);
+ entity().sensors().set(AttributesInternal.INTERNAL_PROVISIONING_TASK_STATE, ProvisioningTaskState.RUNNING);
MachineLocation machine;
try {
machine = Tasks.withBlockingDetails("Provisioning machine in " + location, new ObtainLocationTask(location, flags));
entity().sensors().set(INTERNAL_PROVISIONED_MACHINE, machine);
} finally {
- entity().sensors().set(INTERNAL_PROVISIONING_TASK_STATE, ProvisioningTaskState.DONE);
+ entity().sensors().set(AttributesInternal.INTERNAL_PROVISIONING_TASK_STATE, ProvisioningTaskState.DONE);
}
if (machine == null) {
@@ -781,7 +764,7 @@ public abstract class MachineLifecycleEffectorTasks {
// There is some attempt to handle it by ProvisionMachineTask checking if the expectedState
// is stopping/stopped.
Maybe<MachineLocation> machine = Machines.findUniqueMachineLocation(entity().getLocations());
- ProvisioningTaskState provisioningState = entity().sensors().get(INTERNAL_PROVISIONING_TASK_STATE);
+ ProvisioningTaskState provisioningState = entity().sensors().get(AttributesInternal.INTERNAL_PROVISIONING_TASK_STATE);
if (machine.isAbsent() && provisioningState == ProvisioningTaskState.RUNNING) {
Duration maxWait = entity().config().get(STOP_WAIT_PROVISIONING_TIMEOUT);
@@ -790,7 +773,7 @@ public abstract class MachineLifecycleEffectorTasks {
.until(new Callable<Boolean>() {
@Override
public Boolean call() throws Exception {
- ProvisioningTaskState state = entity().sensors().get(INTERNAL_PROVISIONING_TASK_STATE);
+ ProvisioningTaskState state = entity().sensors().get(AttributesInternal.INTERNAL_PROVISIONING_TASK_STATE);
return (state == ProvisioningTaskState.DONE);
}})
.backoffTo(Duration.FIVE_SECONDS)
@@ -801,7 +784,7 @@ public abstract class MachineLifecycleEffectorTasks {
}
machine = Maybe.ofDisallowingNull(entity().sensors().get(INTERNAL_PROVISIONED_MACHINE));
}
- entity().sensors().remove(INTERNAL_PROVISIONING_TASK_STATE);
+ entity().sensors().remove(AttributesInternal.INTERNAL_PROVISIONING_TASK_STATE);
entity().sensors().remove(INTERNAL_PROVISIONED_MACHINE);
Task<List<?>> stoppingProcess = null;
http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/fbfe2fef/software/base/src/test/java/org/apache/brooklyn/entity/software/base/SoftwareProcessStopsDuringStartJcloudsLiveTest.java
----------------------------------------------------------------------
diff --git a/software/base/src/test/java/org/apache/brooklyn/entity/software/base/SoftwareProcessStopsDuringStartJcloudsLiveTest.java b/software/base/src/test/java/org/apache/brooklyn/entity/software/base/SoftwareProcessStopsDuringStartJcloudsLiveTest.java
index a375406..f5dcf5d 100644
--- a/software/base/src/test/java/org/apache/brooklyn/entity/software/base/SoftwareProcessStopsDuringStartJcloudsLiveTest.java
+++ b/software/base/src/test/java/org/apache/brooklyn/entity/software/base/SoftwareProcessStopsDuringStartJcloudsLiveTest.java
@@ -42,6 +42,7 @@ import org.apache.brooklyn.core.entity.Attributes;
import org.apache.brooklyn.core.entity.BrooklynConfigKeys;
import org.apache.brooklyn.core.entity.Entities;
import org.apache.brooklyn.core.entity.EntityAsserts;
+import org.apache.brooklyn.core.entity.internal.AttributesInternal;
import org.apache.brooklyn.core.entity.lifecycle.Lifecycle;
import org.apache.brooklyn.core.entity.trait.Startable;
import org.apache.brooklyn.core.internal.BrooklynProperties;
@@ -141,7 +142,7 @@ public class SoftwareProcessStopsDuringStartJcloudsLiveTest extends BrooklynAppL
}
}, Asserts.DEFAULT_LONG_TIMEOUT.toMilliseconds(), TimeUnit.MILLISECONDS);
EntityAsserts.assertEntityHealthy(entity);
- assertEquals(entity.getAttribute(MachineLifecycleEffectorTasks.INTERNAL_PROVISIONING_TASK_STATE), MachineLifecycleEffectorTasks.ProvisioningTaskState.DONE);
+ assertEquals(entity.getAttribute(AttributesInternal.INTERNAL_PROVISIONING_TASK_STATE), AttributesInternal.ProvisioningTaskState.DONE);
assertEquals(entity.getAttribute(MachineLifecycleEffectorTasks.INTERNAL_PROVISIONED_MACHINE), Machines.findUniqueMachineLocation(entity.getLocations(), SshMachineLocation.class).get());
executeInLimitedTime(new Callable<Void>() {
@@ -152,7 +153,7 @@ public class SoftwareProcessStopsDuringStartJcloudsLiveTest extends BrooklynAppL
}, Asserts.DEFAULT_LONG_TIMEOUT.toMilliseconds(), TimeUnit.MILLISECONDS);
assertEquals(app.getAttribute(Attributes.SERVICE_STATE_ACTUAL), Lifecycle.STOPPED);
assertEquals(app.getAttribute(Attributes.SERVICE_STATE_EXPECTED).getState(), Lifecycle.STOPPED);
- assertEquals(entity.getAttribute(MachineLifecycleEffectorTasks.INTERNAL_PROVISIONING_TASK_STATE), null);
+ assertEquals(entity.getAttribute(AttributesInternal.INTERNAL_PROVISIONING_TASK_STATE), null);
assertEquals(entity.getAttribute(MachineLifecycleEffectorTasks.INTERNAL_PROVISIONED_MACHINE), null);
}
@@ -188,7 +189,7 @@ public class SoftwareProcessStopsDuringStartJcloudsLiveTest extends BrooklynAppL
// Invoke async
@SuppressWarnings("unused")
Task<Void> startTask = Entities.invokeEffector(app, app, Startable.START, ImmutableMap.of("locations", MutableList.of()));
- EntityAsserts.assertAttributeEqualsEventually(entity, MachineLifecycleEffectorTasks.INTERNAL_PROVISIONING_TASK_STATE, MachineLifecycleEffectorTasks.ProvisioningTaskState.RUNNING);
+ EntityAsserts.assertAttributeEqualsEventually(entity, AttributesInternal.INTERNAL_PROVISIONING_TASK_STATE, AttributesInternal.ProvisioningTaskState.RUNNING);
Stopwatch stopwatch = Stopwatch.createStarted();
Entities.destroyCatching(app);
http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/fbfe2fef/software/base/src/test/java/org/apache/brooklyn/entity/software/base/SoftwareProcessStopsDuringStartTest.java
----------------------------------------------------------------------
diff --git a/software/base/src/test/java/org/apache/brooklyn/entity/software/base/SoftwareProcessStopsDuringStartTest.java b/software/base/src/test/java/org/apache/brooklyn/entity/software/base/SoftwareProcessStopsDuringStartTest.java
index eabea4b..99d9678 100644
--- a/software/base/src/test/java/org/apache/brooklyn/entity/software/base/SoftwareProcessStopsDuringStartTest.java
+++ b/software/base/src/test/java/org/apache/brooklyn/entity/software/base/SoftwareProcessStopsDuringStartTest.java
@@ -42,6 +42,7 @@ import org.apache.brooklyn.api.location.LocationSpec;
import org.apache.brooklyn.api.location.MachineProvisioningLocation;
import org.apache.brooklyn.api.location.NoMachinesAvailableException;
import org.apache.brooklyn.core.entity.EntityAsserts;
+import org.apache.brooklyn.core.entity.internal.AttributesInternal;
import org.apache.brooklyn.core.location.AbstractLocation;
import org.apache.brooklyn.core.location.Machines;
import org.apache.brooklyn.core.test.BrooklynAppUnitTestSupport;
@@ -98,14 +99,14 @@ public class SoftwareProcessStopsDuringStartTest extends BrooklynAppUnitTestSupp
entity.start(ImmutableList.<Location>of(loc));
SshMachineLocation machine = Machines.findUniqueMachineLocation(entity.getLocations(), SshMachineLocation.class).get();
- EntityAsserts.assertAttributeEquals(entity, MachineLifecycleEffectorTasks.INTERNAL_PROVISIONING_TASK_STATE, MachineLifecycleEffectorTasks.ProvisioningTaskState.DONE);
+ EntityAsserts.assertAttributeEquals(entity, AttributesInternal.INTERNAL_PROVISIONING_TASK_STATE, AttributesInternal.ProvisioningTaskState.DONE);
EntityAsserts.assertAttributeEquals(entity, MachineLifecycleEffectorTasks.INTERNAL_PROVISIONED_MACHINE, machine);
Stopwatch stopwatch = Stopwatch.createStarted();
entity.stop();
Duration stopDuration = Duration.of(stopwatch);
assertTrue(Asserts.DEFAULT_LONG_TIMEOUT.isLongerThan(stopDuration), "stop took "+stopDuration);
- EntityAsserts.assertAttributeEquals(entity, MachineLifecycleEffectorTasks.INTERNAL_PROVISIONING_TASK_STATE, null);
+ EntityAsserts.assertAttributeEquals(entity, AttributesInternal.INTERNAL_PROVISIONING_TASK_STATE, null);
EntityAsserts.assertAttributeEquals(entity, MachineLifecycleEffectorTasks.INTERNAL_PROVISIONED_MACHINE, null);
assertEquals(loc.getCalls(), ImmutableList.of("obtain", "release"));
@@ -119,20 +120,20 @@ public class SoftwareProcessStopsDuringStartTest extends BrooklynAppUnitTestSupp
entity.start(ImmutableList.<Location>of(loc));
SshMachineLocation machine = Machines.findUniqueMachineLocation(entity.getLocations(), SshMachineLocation.class).get();
- EntityAsserts.assertAttributeEquals(entity, MachineLifecycleEffectorTasks.INTERNAL_PROVISIONING_TASK_STATE, MachineLifecycleEffectorTasks.ProvisioningTaskState.DONE);
+ EntityAsserts.assertAttributeEquals(entity, AttributesInternal.INTERNAL_PROVISIONING_TASK_STATE, AttributesInternal.ProvisioningTaskState.DONE);
EntityAsserts.assertAttributeEquals(entity, MachineLifecycleEffectorTasks.INTERNAL_PROVISIONED_MACHINE, machine);
entity.stop();
- EntityAsserts.assertAttributeEquals(entity, MachineLifecycleEffectorTasks.INTERNAL_PROVISIONING_TASK_STATE, null);
+ EntityAsserts.assertAttributeEquals(entity, AttributesInternal.INTERNAL_PROVISIONING_TASK_STATE, null);
EntityAsserts.assertAttributeEquals(entity, MachineLifecycleEffectorTasks.INTERNAL_PROVISIONED_MACHINE, null);
entity.start(ImmutableList.<Location>of(loc));
SshMachineLocation machine2 = Machines.findUniqueMachineLocation(entity.getLocations(), SshMachineLocation.class).get();
- EntityAsserts.assertAttributeEquals(entity, MachineLifecycleEffectorTasks.INTERNAL_PROVISIONING_TASK_STATE, MachineLifecycleEffectorTasks.ProvisioningTaskState.DONE);
+ EntityAsserts.assertAttributeEquals(entity, AttributesInternal.INTERNAL_PROVISIONING_TASK_STATE, AttributesInternal.ProvisioningTaskState.DONE);
EntityAsserts.assertAttributeEquals(entity, MachineLifecycleEffectorTasks.INTERNAL_PROVISIONED_MACHINE, machine2);
entity.stop();
- EntityAsserts.assertAttributeEquals(entity, MachineLifecycleEffectorTasks.INTERNAL_PROVISIONING_TASK_STATE, null);
+ EntityAsserts.assertAttributeEquals(entity, AttributesInternal.INTERNAL_PROVISIONING_TASK_STATE, null);
EntityAsserts.assertAttributeEquals(entity, MachineLifecycleEffectorTasks.INTERNAL_PROVISIONED_MACHINE, null);
assertEquals(loc.getCalls(), ImmutableList.of("obtain", "release", "obtain", "release"));
[4/4] brooklyn-server git commit: This closes #435
Posted by al...@apache.org.
This closes #435
Project: http://git-wip-us.apache.org/repos/asf/brooklyn-server/repo
Commit: http://git-wip-us.apache.org/repos/asf/brooklyn-server/commit/be89a8dd
Tree: http://git-wip-us.apache.org/repos/asf/brooklyn-server/tree/be89a8dd
Diff: http://git-wip-us.apache.org/repos/asf/brooklyn-server/diff/be89a8dd
Branch: refs/heads/master
Commit: be89a8dd286858d8452c2d58d6d5ce0b7876c5dc
Parents: f1d89ad 8bef4c7
Author: Aled Sage <al...@gmail.com>
Authored: Wed Nov 16 20:45:55 2016 +0000
Committer: Aled Sage <al...@gmail.com>
Committed: Wed Nov 16 20:45:55 2016 +0000
----------------------------------------------------------------------
.../entity/internal/AttributesInternal.java | 53 ++++++++++
.../mgmt/rebind/BasicEntityRebindSupport.java | 56 ++++++++--
.../deserializingClassRenames.properties | 2 +
.../MachineLifecycleEffectorTasks.java | 46 ++++----
...ftwareProcessRebindNotRunningEntityTest.java | 104 +++++++++++++++----
...eProcessStopsDuringStartJcloudsLiveTest.java | 7 +-
.../SoftwareProcessStopsDuringStartTest.java | 13 +--
7 files changed, 214 insertions(+), 67 deletions(-)
----------------------------------------------------------------------