You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@brooklyn.apache.org by ha...@apache.org on 2015/08/01 17:45:54 UTC
[01/21] incubator-brooklyn git commit: Delete deprecated
getTagsSupport, getTags, addTag, etc
Repository: incubator-brooklyn
Updated Branches:
refs/heads/master e85886371 -> ffbd6eff3
Delete deprecated getTagsSupport, getTags, addTag, etc
Project: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/commit/08358465
Tree: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/tree/08358465
Diff: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/diff/08358465
Branch: refs/heads/master
Commit: 08358465d6012bf48a908a0edd0ca2e27ec1b3dc
Parents: 4fc4669
Author: Aled Sage <al...@gmail.com>
Authored: Tue Jul 28 22:33:22 2015 +0100
Committer: Aled Sage <al...@gmail.com>
Committed: Sat Aug 1 00:13:30 2015 +0100
----------------------------------------------------------------------
.../java/brooklyn/basic/BrooklynObject.java | 7 -----
api/src/main/java/brooklyn/entity/Entity.java | 27 --------------------
.../brooklyn/basic/AbstractBrooklynObject.java | 6 -----
.../catalog/internal/CatalogItemDo.java | 6 -----
.../brooklyn/entity/basic/AbstractEntity.java | 19 --------------
.../basic/EntityTransientCopyInternal.java | 3 ---
.../access/PortForwardManagerClient.java | 5 ----
.../brooklyn/entity/basic/EntitiesTest.java | 2 +-
8 files changed, 1 insertion(+), 74 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/08358465/api/src/main/java/brooklyn/basic/BrooklynObject.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/brooklyn/basic/BrooklynObject.java b/api/src/main/java/brooklyn/basic/BrooklynObject.java
index cb80695..bf1e4e7 100644
--- a/api/src/main/java/brooklyn/basic/BrooklynObject.java
+++ b/api/src/main/java/brooklyn/basic/BrooklynObject.java
@@ -57,13 +57,6 @@ public interface BrooklynObject extends Identifiable, Configurable {
*/
TagSupport tags();
- /**
- * @since 0.7.0-M2
- * @deprecated since 0.7.0-M2; use {@link #tags()}
- */
- @Deprecated
- TagSupport getTagSupport();
-
public interface TagSupport {
/**
* @return An immutable copy of the set of tags on this entity.
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/08358465/api/src/main/java/brooklyn/entity/Entity.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/brooklyn/entity/Entity.java b/api/src/main/java/brooklyn/entity/Entity.java
index 0d45a35..d1372fd 100644
--- a/api/src/main/java/brooklyn/entity/Entity.java
+++ b/api/src/main/java/brooklyn/entity/Entity.java
@@ -20,9 +20,7 @@ package brooklyn.entity;
import java.util.Collection;
import java.util.Map;
-import java.util.Set;
-import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import brooklyn.basic.BrooklynObject;
@@ -263,29 +261,4 @@ public interface Entity extends BrooklynObject {
* Adds the given feed to this entity. Also calls feed.setEntity if available.
*/
<T extends Feed> T addFeed(T feed);
-
- /**
- * @since 0.7
- * @deprecated since 0.7; see {@link #tags()}
- */
- @Deprecated
- Set<Object> getTags();
- /**
- * @since 0.7
- * @deprecated since 0.7; see {@link #tags()}
- */
- @Deprecated
- boolean addTag(@Nonnull Object tag);
- /**
- * @since 0.7
- * @deprecated since 0.7; see {@link #tags()}
- */
- @Deprecated
- boolean removeTag(@Nonnull Object tag);
- /**
- * @since 0.7
- * @deprecated since 0.7; see {@link #tags()}
- */
- @Deprecated
- boolean containsTag(@Nonnull Object tag);
}
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/08358465/core/src/main/java/brooklyn/basic/AbstractBrooklynObject.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/brooklyn/basic/AbstractBrooklynObject.java b/core/src/main/java/brooklyn/basic/AbstractBrooklynObject.java
index 9195b35..a020796 100644
--- a/core/src/main/java/brooklyn/basic/AbstractBrooklynObject.java
+++ b/core/src/main/java/brooklyn/basic/AbstractBrooklynObject.java
@@ -200,12 +200,6 @@ public abstract class AbstractBrooklynObject implements BrooklynObjectInternal {
return new BasicTagSupport();
}
- @Override
- @Deprecated
- public TagSupport getTagSupport() {
- return tags();
- }
-
protected class BasicTagSupport implements TagSupport {
@Override
public Set<Object> getTags() {
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/08358465/core/src/main/java/brooklyn/catalog/internal/CatalogItemDo.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/brooklyn/catalog/internal/CatalogItemDo.java b/core/src/main/java/brooklyn/catalog/internal/CatalogItemDo.java
index 1fb0707..50dfba6 100644
--- a/core/src/main/java/brooklyn/catalog/internal/CatalogItemDo.java
+++ b/core/src/main/java/brooklyn/catalog/internal/CatalogItemDo.java
@@ -124,12 +124,6 @@ public class CatalogItemDo<T,SpecT> implements CatalogItem<T,SpecT>, BrooklynObj
}
@Override
- @Deprecated
- public TagSupport getTagSupport() {
- return tags();
- }
-
- @Override
public String getDescription() {
return itemDto.getDescription();
}
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/08358465/core/src/main/java/brooklyn/entity/basic/AbstractEntity.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/brooklyn/entity/basic/AbstractEntity.java b/core/src/main/java/brooklyn/entity/basic/AbstractEntity.java
index d636e47..aa40158 100644
--- a/core/src/main/java/brooklyn/entity/basic/AbstractEntity.java
+++ b/core/src/main/java/brooklyn/entity/basic/AbstractEntity.java
@@ -1723,23 +1723,4 @@ public abstract class AbstractEntity extends AbstractBrooklynObject implements E
super.onTagsChanged();
getManagementSupport().getEntityChangeListener().onTagsChanged();
}
-
- public Set<Object> getTags() {
- return tags().getTags();
- }
-
- @Override
- public boolean addTag(Object tag) {
- return tags().addTag(tag);
- }
-
- @Override
- public boolean removeTag(Object tag) {
- return tags().removeTag(tag);
- }
-
- @Override
- public boolean containsTag(Object tag) {
- return tags().containsTag(tag);
- }
}
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/08358465/core/src/main/java/brooklyn/entity/basic/EntityTransientCopyInternal.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/brooklyn/entity/basic/EntityTransientCopyInternal.java b/core/src/main/java/brooklyn/entity/basic/EntityTransientCopyInternal.java
index 14b9736..9322436 100644
--- a/core/src/main/java/brooklyn/entity/basic/EntityTransientCopyInternal.java
+++ b/core/src/main/java/brooklyn/entity/basic/EntityTransientCopyInternal.java
@@ -83,9 +83,6 @@ public interface EntityTransientCopyInternal {
Maybe<Object> getConfigRaw(ConfigKey<?> key, boolean includeInherited);
Maybe<Object> getConfigRaw(HasConfigKey<?> key, boolean includeInherited);
TagSupport tags();
- @Deprecated TagSupport getTagSupport();
- @Deprecated Set<Object> getTags();
- @Deprecated boolean containsTag(@Nonnull Object tag);
String getCatalogItemId();
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/08358465/core/src/main/java/brooklyn/location/access/PortForwardManagerClient.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/brooklyn/location/access/PortForwardManagerClient.java b/core/src/main/java/brooklyn/location/access/PortForwardManagerClient.java
index c796ef6..e9638fc 100644
--- a/core/src/main/java/brooklyn/location/access/PortForwardManagerClient.java
+++ b/core/src/main/java/brooklyn/location/access/PortForwardManagerClient.java
@@ -394,11 +394,6 @@ public class PortForwardManagerClient implements PortForwardManager {
}
@Override
- public TagSupport getTagSupport() {
- return getDelegate().getTagSupport();
- }
-
- @Override
public <T> T setConfig(ConfigKey<T> key, T val) {
return getDelegate().setConfig(key, val);
}
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/08358465/core/src/test/java/brooklyn/entity/basic/EntitiesTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/brooklyn/entity/basic/EntitiesTest.java b/core/src/test/java/brooklyn/entity/basic/EntitiesTest.java
index 9c3236c..851d556 100644
--- a/core/src/test/java/brooklyn/entity/basic/EntitiesTest.java
+++ b/core/src/test/java/brooklyn/entity/basic/EntitiesTest.java
@@ -125,7 +125,7 @@ public class EntitiesTest extends BrooklynAppUnitTestSupport {
Assert.assertTrue(entity.tags().containsTag(entity.getParent()));
Assert.assertFalse(entity.tags().containsTag(entity));
- entity.removeTag(2);
+ entity.tags().removeTag(2);
Assert.assertEquals(entity.tags().getTags(), MutableSet.of(app));
}
[02/21] incubator-brooklyn git commit: Delete deprecated
Entity/Policy.getAllConfig
Posted by ha...@apache.org.
Delete deprecated Entity/Policy.getAllConfig
Project: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/commit/4fc46691
Tree: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/tree/4fc46691
Diff: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/diff/4fc46691
Branch: refs/heads/master
Commit: 4fc46691dd2482e345d516e831b3b41d1cf476c5
Parents: 12c8eeb
Author: Aled Sage <al...@gmail.com>
Authored: Tue Jul 28 22:30:39 2015 +0100
Committer: Aled Sage <al...@gmail.com>
Committed: Sat Aug 1 00:13:30 2015 +0100
----------------------------------------------------------------------
api/src/main/java/brooklyn/policy/Enricher.java | 6 ------
api/src/main/java/brooklyn/policy/Policy.java | 6 ------
.../java/brooklyn/policy/basic/AbstractEntityAdjunct.java | 8 --------
3 files changed, 20 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/4fc46691/api/src/main/java/brooklyn/policy/Enricher.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/brooklyn/policy/Enricher.java b/api/src/main/java/brooklyn/policy/Enricher.java
index 22a7ba6..a5b641e 100644
--- a/api/src/main/java/brooklyn/policy/Enricher.java
+++ b/api/src/main/java/brooklyn/policy/Enricher.java
@@ -59,12 +59,6 @@ public interface Enricher extends EntityAdjunct, Rebindable, Configurable {
<T> T setConfig(ConfigKey<T> key, T val);
/**
- * @deprecated since 0.7.0; use {@link #config()}, such as {@code policy.config().getBag()}
- */
- @Deprecated
- Map<ConfigKey<?>, Object> getAllConfig();
-
- /**
* Users are strongly discouraged from calling or overriding this method.
* It is for internal calls only, relating to persisting/rebinding entities.
* This method may change (or be removed) in a future release without notice.
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/4fc46691/api/src/main/java/brooklyn/policy/Policy.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/brooklyn/policy/Policy.java b/api/src/main/java/brooklyn/policy/Policy.java
index c314ec0..f13f299 100644
--- a/api/src/main/java/brooklyn/policy/Policy.java
+++ b/api/src/main/java/brooklyn/policy/Policy.java
@@ -72,12 +72,6 @@ public interface Policy extends EntityAdjunct, Rebindable, Configurable {
<T> T setConfig(ConfigKey<T> key, T val);
/**
- * @deprecated since 0.7.0; use {@link #config()}, such as {@code policy.config().getBag()}
- */
- @Deprecated
- Map<ConfigKey<?>, Object> getAllConfig();
-
- /**
* Users are strongly discouraged from calling or overriding this method.
* It is for internal calls only, relating to persisting/rebinding entities.
* This method may change (or be removed) in a future release without notice.
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/4fc46691/core/src/main/java/brooklyn/policy/basic/AbstractEntityAdjunct.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/brooklyn/policy/basic/AbstractEntityAdjunct.java b/core/src/main/java/brooklyn/policy/basic/AbstractEntityAdjunct.java
index 070ac5f..bdf1d70 100644
--- a/core/src/main/java/brooklyn/policy/basic/AbstractEntityAdjunct.java
+++ b/core/src/main/java/brooklyn/policy/basic/AbstractEntityAdjunct.java
@@ -301,14 +301,6 @@ public abstract class AbstractEntityAdjunct extends AbstractBrooklynObject imple
return config().get(key);
}
- /**
- * @deprecated since 0.7.0; use {@link #config()}, such as {@code entity.config().getBag()}
- */
- @Deprecated
- public Map<ConfigKey<?>, Object> getAllConfig() {
- return configsInternal.getAllConfig();
- }
-
protected <K> K getRequiredConfig(ConfigKey<K> key) {
K result = config().get(key);
if (result==null)
[05/21] incubator-brooklyn git commit: Delete deprecated
HighAvailabilityManager.getManagementPlaneSyncState
Posted by ha...@apache.org.
Delete deprecated HighAvailabilityManager.getManagementPlaneSyncState
Project: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/commit/f49ca1b7
Tree: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/tree/f49ca1b7
Diff: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/diff/f49ca1b7
Branch: refs/heads/master
Commit: f49ca1b7e9dee43760355929337b801a043eebfd
Parents: 29c9718
Author: Aled Sage <al...@gmail.com>
Authored: Tue Jul 28 22:52:23 2015 +0100
Committer: Aled Sage <al...@gmail.com>
Committed: Sat Aug 1 00:13:31 2015 +0100
----------------------------------------------------------------------
.../java/brooklyn/management/ha/HighAvailabilityManager.java | 6 ------
.../brooklyn/management/ha/HighAvailabilityManagerImpl.java | 5 -----
.../management/internal/NonDeploymentManagementContext.java | 4 ----
.../management/ha/HighAvailabilityManagerSplitBrainTest.java | 4 ++--
.../management/ha/HighAvailabilityManagerTestFixture.java | 2 +-
5 files changed, 3 insertions(+), 18 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/f49ca1b7/api/src/main/java/brooklyn/management/ha/HighAvailabilityManager.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/brooklyn/management/ha/HighAvailabilityManager.java b/api/src/main/java/brooklyn/management/ha/HighAvailabilityManager.java
index c530116..a525601 100644
--- a/api/src/main/java/brooklyn/management/ha/HighAvailabilityManager.java
+++ b/api/src/main/java/brooklyn/management/ha/HighAvailabilityManager.java
@@ -113,12 +113,6 @@ public interface HighAvailabilityManager {
ManagementPlaneSyncRecord getLastManagementPlaneSyncRecord();
/**
- * @deprecated since 0.7.0 use {@link #getLastManagementPlaneSyncRecord()} or {@link #loadManagementPlaneSyncRecord(boolean)}
- * to be explicit about the source.
- */
- ManagementPlaneSyncRecord getManagementPlaneSyncState();
-
- /**
* @param useLocalKnowledgeForThisNode - if true, the record for this mgmt node will be replaced with the
* actual current status known in this JVM (may be more recent than what is persisted);
* for most purposes there is little difference but in some cases the local node being updated
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/f49ca1b7/core/src/main/java/brooklyn/management/ha/HighAvailabilityManagerImpl.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/brooklyn/management/ha/HighAvailabilityManagerImpl.java b/core/src/main/java/brooklyn/management/ha/HighAvailabilityManagerImpl.java
index 4c631c7..edb16c7 100644
--- a/core/src/main/java/brooklyn/management/ha/HighAvailabilityManagerImpl.java
+++ b/core/src/main/java/brooklyn/management/ha/HighAvailabilityManagerImpl.java
@@ -531,11 +531,6 @@ public class HighAvailabilityManagerImpl implements HighAvailabilityManager {
return lastSyncRecord;
}
- @Override
- public ManagementPlaneSyncRecord getManagementPlaneSyncState() {
- return loadManagementPlaneSyncRecord(true);
- }
-
@SuppressWarnings("unchecked")
protected void registerPollTask() {
final Runnable job = new Runnable() {
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/f49ca1b7/core/src/main/java/brooklyn/management/internal/NonDeploymentManagementContext.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/brooklyn/management/internal/NonDeploymentManagementContext.java b/core/src/main/java/brooklyn/management/internal/NonDeploymentManagementContext.java
index b437561..329fead 100644
--- a/core/src/main/java/brooklyn/management/internal/NonDeploymentManagementContext.java
+++ b/core/src/main/java/brooklyn/management/internal/NonDeploymentManagementContext.java
@@ -604,10 +604,6 @@ public class NonDeploymentManagementContext implements ManagementContextInternal
throw new IllegalStateException("Non-deployment context "+NonDeploymentManagementContext.this+" is not valid for this operation.");
}
@Override
- public ManagementPlaneSyncRecord getManagementPlaneSyncState() {
- throw new IllegalStateException("Non-deployment context "+NonDeploymentManagementContext.this+" is not valid for this operation.");
- }
- @Override
public ManagementPlaneSyncRecord getLastManagementPlaneSyncRecord() {
throw new IllegalStateException("Non-deployment context "+NonDeploymentManagementContext.this+" is not valid for this operation.");
}
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/f49ca1b7/core/src/test/java/brooklyn/management/ha/HighAvailabilityManagerSplitBrainTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/brooklyn/management/ha/HighAvailabilityManagerSplitBrainTest.java b/core/src/test/java/brooklyn/management/ha/HighAvailabilityManagerSplitBrainTest.java
index 5a521cb..934090c 100644
--- a/core/src/test/java/brooklyn/management/ha/HighAvailabilityManagerSplitBrainTest.java
+++ b/core/src/test/java/brooklyn/management/ha/HighAvailabilityManagerSplitBrainTest.java
@@ -359,7 +359,7 @@ public class HighAvailabilityManagerSplitBrainTest {
log.info("publish "+n1.ownNodeId);
n1.ha.publishAndCheck(false);
- ManagementPlaneSyncRecord memento1b = n1.ha.getManagementPlaneSyncState();
+ ManagementPlaneSyncRecord memento1b = n1.ha.loadManagementPlaneSyncRecord(true);
log.info(n1+" HA now: "+memento1b);
ManagementNodeState expectedStateAfterDemotion = BrooklynFeatureEnablement.isEnabled(BrooklynFeatureEnablement.FEATURE_DEFAULT_STANDBY_IS_HOT_PROPERTY) ?
@@ -373,7 +373,7 @@ public class HighAvailabilityManagerSplitBrainTest {
assertEquals(memento1b.getManagementNodes().get(n2.ownNodeId).getRemoteTimestamp(), time1);
// n2 now sees itself as master, with n1 in standby again
- ManagementPlaneSyncRecord memento2c = n2.ha.getManagementPlaneSyncState();
+ ManagementPlaneSyncRecord memento2c = n2.ha.loadManagementPlaneSyncRecord(true);
log.info(n2+" HA now: "+memento2c);
assertEquals(memento2c.getManagementNodes().get(n1.ownNodeId).getStatus(), expectedStateAfterDemotion);
assertEquals(memento2c.getManagementNodes().get(n2.ownNodeId).getStatus(), ManagementNodeState.MASTER);
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/f49ca1b7/core/src/test/java/brooklyn/management/ha/HighAvailabilityManagerTestFixture.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/brooklyn/management/ha/HighAvailabilityManagerTestFixture.java b/core/src/test/java/brooklyn/management/ha/HighAvailabilityManagerTestFixture.java
index c9026e8..e1ecad7 100644
--- a/core/src/test/java/brooklyn/management/ha/HighAvailabilityManagerTestFixture.java
+++ b/core/src/test/java/brooklyn/management/ha/HighAvailabilityManagerTestFixture.java
@@ -126,7 +126,7 @@ public abstract class HighAvailabilityManagerTestFixture {
.setLocalTicker(ticker)
.setRemoteTicker(ticker);
try {
- ManagementPlaneSyncRecord state = manager2.getManagementPlaneSyncState();
+ ManagementPlaneSyncRecord state = manager2.loadManagementPlaneSyncRecord(true);
assertNotNull(state);
} finally {
manager2.stop();
[03/21] incubator-brooklyn git commit: Delete deprecated
getName/setName
Posted by ha...@apache.org.
Delete deprecated getName/setName
Instead in Enricher/Policy use getDisplayName, and setDisplayName,
so it is consistent with Entity.
Project: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/commit/12c8eebf
Tree: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/tree/12c8eebf
Diff: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/diff/12c8eebf
Branch: refs/heads/master
Commit: 12c8eebf8989a0e1917d64c38301f2d152965b5e
Parents: f5f0126
Author: Aled Sage <al...@gmail.com>
Authored: Tue Jul 28 22:28:23 2015 +0100
Committer: Aled Sage <al...@gmail.com>
Committed: Sat Aug 1 00:13:30 2015 +0100
----------------------------------------------------------------------
api/src/main/java/brooklyn/policy/Enricher.java | 9 ---------
api/src/main/java/brooklyn/policy/EntityAdjunct.java | 6 ------
api/src/main/java/brooklyn/policy/Policy.java | 11 -----------
.../brooklyn/policy/basic/AbstractEntityAdjunct.java | 12 ------------
4 files changed, 38 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/12c8eebf/api/src/main/java/brooklyn/policy/Enricher.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/brooklyn/policy/Enricher.java b/api/src/main/java/brooklyn/policy/Enricher.java
index 244af79..22a7ba6 100644
--- a/api/src/main/java/brooklyn/policy/Enricher.java
+++ b/api/src/main/java/brooklyn/policy/Enricher.java
@@ -42,15 +42,6 @@ public interface Enricher extends EntityAdjunct, Rebindable, Configurable {
String getId();
/**
- * Get the name assigned to this enricher.
- *
- * @deprecated since 0.7; use {@link #getDisplayName()}
- */
- @Deprecated
- @Override
- String getName();
-
- /**
* Information about the type of this entity; analogous to Java's object.getClass.
*/
@Beta
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/12c8eebf/api/src/main/java/brooklyn/policy/EntityAdjunct.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/brooklyn/policy/EntityAdjunct.java b/api/src/main/java/brooklyn/policy/EntityAdjunct.java
index 4405ea2..7f16dbb 100644
--- a/api/src/main/java/brooklyn/policy/EntityAdjunct.java
+++ b/api/src/main/java/brooklyn/policy/EntityAdjunct.java
@@ -34,12 +34,6 @@ public interface EntityAdjunct extends BrooklynObject {
String getId();
/**
- * @deprecated since 0.7; use {@link #getDisplayName()}
- */
- @Deprecated
- String getName();
-
- /**
* Whether the adjunct is destroyed
*/
boolean isDestroyed();
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/12c8eebf/api/src/main/java/brooklyn/policy/Policy.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/brooklyn/policy/Policy.java b/api/src/main/java/brooklyn/policy/Policy.java
index 0713042..c314ec0 100644
--- a/api/src/main/java/brooklyn/policy/Policy.java
+++ b/api/src/main/java/brooklyn/policy/Policy.java
@@ -40,17 +40,6 @@ public interface Policy extends EntityAdjunct, Rebindable, Configurable {
String getId();
/**
- * Get the name assigned to this policy.
- *
- * @return the name assigned to the policy.
- *
- * @deprecated since 0.7; use {@link #getDisplayName()}
- */
- @Deprecated
- @Override
- String getName();
-
- /**
* Information about the type of this entity; analogous to Java's object.getClass.
*/
@Beta
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/12c8eebf/core/src/main/java/brooklyn/policy/basic/AbstractEntityAdjunct.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/brooklyn/policy/basic/AbstractEntityAdjunct.java b/core/src/main/java/brooklyn/policy/basic/AbstractEntityAdjunct.java
index 1b91ce9..070ac5f 100644
--- a/core/src/main/java/brooklyn/policy/basic/AbstractEntityAdjunct.java
+++ b/core/src/main/java/brooklyn/policy/basic/AbstractEntityAdjunct.java
@@ -356,22 +356,10 @@ public abstract class AbstractEntityAdjunct extends AbstractBrooklynObject imple
return getClass().getCanonicalName();
}
- @Override
- @Deprecated
- public String getName() {
- return getDisplayName();
- }
-
public void setDisplayName(String name) {
this.name = name;
}
- /**
- * @deprecated since 0.7.0; see {@link #setDisplayName(String)}
- */
- @Deprecated
- public void setName(String name) { setDisplayName(name); }
-
public void setEntity(EntityLocal entity) {
if (destroyed.get()) throw new IllegalStateException("Cannot set entity on a destroyed entity adjunct");
this.entity = entity;
[20/21] incubator-brooklyn git commit: Delete deprecated code from
SoftwareProcessImpl
Posted by ha...@apache.org.
Delete deprecated code from SoftwareProcessImpl
- SoftwareProcessImpl.doStart/doStop/doRestart
- STOP_MACHINE config (replaced by STOP_MACHINE_MODE)
- MachineLifecycleEffectorTasks.restart()/stop() - now always take
ConfigBag arg.
Project: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/commit/2f336084
Tree: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/tree/2f336084
Diff: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/diff/2f336084
Branch: refs/heads/master
Commit: 2f336084dd4dcc55d2637c77704a7e16af049193
Parents: d9715b4
Author: Aled Sage <al...@gmail.com>
Authored: Wed Jul 29 17:42:17 2015 +0100
Committer: Aled Sage <al...@gmail.com>
Committed: Sat Aug 1 00:16:52 2015 +0100
----------------------------------------------------------------------
.../entity/basic/SameServerEntityImpl.java | 2 +-
.../brooklyn/entity/basic/SoftwareProcess.java | 11 ---
.../entity/basic/SoftwareProcessImpl.java | 90 +++-----------------
.../software/MachineLifecycleEffectorTasks.java | 39 ---------
...ctSoftwareProcessRestartIntegrationTest.java | 2 +-
.../entity/basic/SoftwareProcessEntityTest.java | 4 +-
.../test/entity/TestJavaWebAppEntity.java | 3 +-
7 files changed, 18 insertions(+), 133 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/2f336084/software/base/src/main/java/brooklyn/entity/basic/SameServerEntityImpl.java
----------------------------------------------------------------------
diff --git a/software/base/src/main/java/brooklyn/entity/basic/SameServerEntityImpl.java b/software/base/src/main/java/brooklyn/entity/basic/SameServerEntityImpl.java
index 9b00836..fcd687e 100644
--- a/software/base/src/main/java/brooklyn/entity/basic/SameServerEntityImpl.java
+++ b/software/base/src/main/java/brooklyn/entity/basic/SameServerEntityImpl.java
@@ -99,7 +99,7 @@ public class SameServerEntityImpl extends AbstractEntity implements SameServerEn
* {@link DynamicTasks#queue(String, java.util.concurrent.Callable)}.
*/
protected void doStop() {
- LIFECYCLE_TASKS.stop();
+ LIFECYCLE_TASKS.stop(ConfigBag.EMPTY);
}
/**
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/2f336084/software/base/src/main/java/brooklyn/entity/basic/SoftwareProcess.java
----------------------------------------------------------------------
diff --git a/software/base/src/main/java/brooklyn/entity/basic/SoftwareProcess.java b/software/base/src/main/java/brooklyn/entity/basic/SoftwareProcess.java
index 1570355..5144a2b 100644
--- a/software/base/src/main/java/brooklyn/entity/basic/SoftwareProcess.java
+++ b/software/base/src/main/java/brooklyn/entity/basic/SoftwareProcess.java
@@ -339,17 +339,6 @@ public interface SoftwareProcess extends Entity, Startable {
"ALWAYS will try to stop the machine even if the entity is marked as stopped, " +
"IF_NOT_STOPPED stops the machine only if the entity is not marked as stopped, " +
"NEVER doesn't stop the machine.", StopMode.IF_NOT_STOPPED);
-
- /** @since 0.7.0 semantics of parameters to restart being explored
- * @deprecated since 0.7.0 use {@link #STOP_MACHINE_MODE} instead */
- @Beta
- @Deprecated
- public static final ConfigKey<Boolean> STOP_MACHINE = ConfigKeys.newBooleanConfigKey("stopMachine",
- "Whether to stop the machine provisioned for this entity: 'true', or 'false' are supported, " +
- "with the default being 'true'." +
- " 'true' is equivalent to " + STOP_MACHINE_MODE.getName() + " = " + StopMode.IF_NOT_STOPPED.name() + "." +
- " 'false' is equivalent to " + STOP_MACHINE_MODE.getName() + " = " + StopMode.NEVER.name() + ".", true);
-
}
// NB: the START, STOP, and RESTART effectors themselves are (re)defined by MachineLifecycleEffectorTasks
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/2f336084/software/base/src/main/java/brooklyn/entity/basic/SoftwareProcessImpl.java
----------------------------------------------------------------------
diff --git a/software/base/src/main/java/brooklyn/entity/basic/SoftwareProcessImpl.java b/software/base/src/main/java/brooklyn/entity/basic/SoftwareProcessImpl.java
index 9daed4c..79275b2 100644
--- a/software/base/src/main/java/brooklyn/entity/basic/SoftwareProcessImpl.java
+++ b/software/base/src/main/java/brooklyn/entity/basic/SoftwareProcessImpl.java
@@ -40,7 +40,6 @@ import brooklyn.entity.basic.Lifecycle.Transition;
import brooklyn.entity.basic.ServiceStateLogic.ServiceNotUpLogic;
import brooklyn.entity.drivers.DriverDependentEntity;
import brooklyn.entity.drivers.EntityDriverManager;
-import brooklyn.entity.effector.EffectorBody;
import brooklyn.event.SensorEvent;
import brooklyn.event.SensorEventListener;
import brooklyn.event.feed.function.FunctionFeed;
@@ -50,7 +49,6 @@ import brooklyn.location.MachineLocation;
import brooklyn.location.MachineProvisioningLocation;
import brooklyn.location.PortRange;
import brooklyn.location.basic.LocationConfigKeys;
-import brooklyn.location.basic.Machines;
import brooklyn.location.cloud.CloudLocationConfig;
import brooklyn.management.Task;
import brooklyn.policy.EnricherSpec;
@@ -394,30 +392,6 @@ public abstract class SoftwareProcessImpl extends AbstractEntity implements Soft
Entities.waitForServiceUp(this, Duration.of(duration, units));
}
- /** @deprecated since 0.7.0, this isn't a general test for modifiability, and was hardly ever used (now never used) */
- @Deprecated
- public void checkModifiable() {
- Lifecycle state = getAttribute(SERVICE_STATE_ACTUAL);
- if (getAttribute(SERVICE_STATE_ACTUAL) == Lifecycle.RUNNING) return;
- if (getAttribute(SERVICE_STATE_ACTUAL) == Lifecycle.STARTING) return;
- throw new IllegalStateException("Cannot configure entity "+this+" in state "+state);
- }
-
- /** @deprecated since 0.6.0 use/override method in {@link SoftwareProcessDriverLifecycleEffectorTasks} */
- protected final void startInLocation(Collection<? extends Location> locations) {}
-
- /** @deprecated since 0.6.0 use/override method in {@link SoftwareProcessDriverLifecycleEffectorTasks} */
- protected final void startInLocation(Location location) {}
-
- /** @deprecated since 0.6.0 use/override method in {@link SoftwareProcessDriverLifecycleEffectorTasks} */
- protected final void startInLocation(final MachineProvisioningLocation<?> location) {}
-
- /** @deprecated since 0.6.0 use/override method in {@link SoftwareProcessDriverLifecycleEffectorTasks} */
- protected final void startInLocation(MachineLocation machine) {}
-
- /** @deprecated since 0.6.0 use/override method in {@link SoftwareProcessDriverLifecycleEffectorTasks} */
- protected final void callStartHooks() {}
-
protected Map<String,Object> obtainProvisioningFlags(MachineProvisioningLocation location) {
ConfigBag result = ConfigBag.newInstance(location.getProvisioningFlags(ImmutableList.of(getClass().getName())));
result.putAll(getConfig(PROVISIONING_PROPERTIES));
@@ -476,11 +450,6 @@ public abstract class SoftwareProcessImpl extends AbstractEntity implements Soft
return ports;
}
- /** @deprecated since 0.6.0 use {@link Machines#findSubnetHostname(Entity)} */ @Deprecated
- public String getLocalHostname() {
- return Machines.findSubnetHostname(this).get();
- }
-
protected void initDriver(MachineLocation machine) {
SoftwareProcessDriver newDriver = doInitDriver(machine);
if (newDriver == null) {
@@ -555,20 +524,22 @@ public abstract class SoftwareProcessImpl extends AbstractEntity implements Soft
}
/**
- * If custom behaviour is required by sub-classes, consider overriding {@link #doStart(Collection)})}.
+ * If custom behaviour is required by sub-classes, consider overriding {@link #preStart()} or {@link #postStart()})}.
+ * Also consider adding additional work via tasks, executed using {@link DynamicTasks#queue(String, Callable)}.
*/
@Override
public final void start(final Collection<? extends Location> locations) {
if (DynamicTasks.getTaskQueuingContext() != null) {
- doStart(locations);
+ getLifecycleEffectorTasks().start(locations);
} else {
- Task<?> task = Tasks.builder().name("start (sequential)").body(new Runnable() { public void run() { doStart(locations); } }).build();
+ Task<?> task = Tasks.builder().name("start (sequential)").body(new Runnable() { public void run() { getLifecycleEffectorTasks().start(locations); } }).build();
Entities.submit(this, task).getUnchecked();
}
}
/**
- * If custom behaviour is required by sub-classes, consider overriding {@link #doStop()}.
+ * If custom behaviour is required by sub-classes, consider overriding {@link #preStop()} or {@link #postStop()}.
+ * Also consider adding additional work via tasks, executed using {@link DynamicTasks#queue(String, Callable)}.
*/
@Override
public final void stop() {
@@ -581,64 +552,27 @@ public abstract class SoftwareProcessImpl extends AbstractEntity implements Soft
// or do a SERVICE_STATE check before setting SERVICE_UP to true in a feed (?).
if (DynamicTasks.getTaskQueuingContext() != null) {
- doStop();
+ getLifecycleEffectorTasks().stop(ConfigBag.EMPTY);
} else {
- Task<?> task = Tasks.builder().name("stop").body(new Runnable() { public void run() { doStop(); } }).build();
+ Task<?> task = Tasks.builder().name("stop").body(new Runnable() { public void run() { getLifecycleEffectorTasks().stop(ConfigBag.EMPTY); } }).build();
Entities.submit(this, task).getUnchecked();
}
}
/**
- * If custom behaviour is required by sub-classes, consider overriding {@link #doRestart()}.
+ * If custom behaviour is required by sub-classes, consider overriding {@link #preRestart()} or {@link #postRestart()}.
+ * Also consider adding additional work via tasks, executed using {@link DynamicTasks#queue(String, Callable)}.
*/
@Override
public final void restart() {
if (DynamicTasks.getTaskQueuingContext() != null) {
- doRestart(ConfigBag.EMPTY);
+ getLifecycleEffectorTasks().restart(ConfigBag.EMPTY);
} else {
- Task<?> task = Tasks.builder().name("restart").body(new Runnable() { public void run() { doRestart(ConfigBag.EMPTY); } }).build();
+ Task<?> task = Tasks.builder().name("restart").body(new Runnable() { public void run() { getLifecycleEffectorTasks().restart(ConfigBag.EMPTY); } }).build();
Entities.submit(this, task).getUnchecked();
}
}
- /**
- * To be overridden instead of {@link #start(Collection)}; sub-classes should call {@code super.doStart(locations)} and should
- * add do additional work via tasks, executed using {@link DynamicTasks#queue(String, Callable)}.
- * @deprecated since 0.7.0 override {@link #preStart()} or {@link #postStart()},
- * or define a {@link SoftwareProcessDriverLifecycleEffectorTasks} subclass if more complex behaviour needed
- * (this method is no longer invoked by the {@link EffectorBody} call path,
- * hence deprecating it and marking it final to highlight incompatibilities at compile time)
- */
- @Deprecated
- protected final void doStart(Collection<? extends Location> locations) {
- getLifecycleEffectorTasks().start(locations);
- }
-
- /**
- * To be overridden instead of {@link #stop()}; sub-classes should call {@code super.doStop()} and should
- * add do additional work via tasks, executed using {@link DynamicTasks#queue(String, Callable)}.
- * @deprecated since 0.7.0 override {@link #preStop()} or {@link #postStop()}; see note on {@link #doStart(Collection)} for more information
- */
- @Deprecated
- protected final void doStop() {
- getLifecycleEffectorTasks().stop();
- }
-
- /**
- * To be overridden instead of {@link #restart()}; sub-classes should call {@code super.doRestart(ConfigBag)} and should
- * add do additional work via tasks, executed using {@link DynamicTasks#queue(String, Callable)}.
- * @deprecated since 0.7.0; see note on {@link #doStart(Collection)} for more information
- */
- @Deprecated
- protected final void doRestart(ConfigBag parameters) {
- getLifecycleEffectorTasks().restart(parameters);
- }
-
- @Deprecated /** @deprecated since 0.7.0 see {@link #doRestart(ConfigBag)} */
- protected final void doRestart() {
- doRestart(ConfigBag.EMPTY);
- }
-
protected SoftwareProcessDriverLifecycleEffectorTasks getLifecycleEffectorTasks() {
return getConfig(LIFECYCLE_EFFECTOR_TASKS);
}
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/2f336084/software/base/src/main/java/brooklyn/entity/software/MachineLifecycleEffectorTasks.java
----------------------------------------------------------------------
diff --git a/software/base/src/main/java/brooklyn/entity/software/MachineLifecycleEffectorTasks.java b/software/base/src/main/java/brooklyn/entity/software/MachineLifecycleEffectorTasks.java
index 48bb6a4..6ce7d1c 100644
--- a/software/base/src/main/java/brooklyn/entity/software/MachineLifecycleEffectorTasks.java
+++ b/software/base/src/main/java/brooklyn/entity/software/MachineLifecycleEffectorTasks.java
@@ -543,12 +543,6 @@ public abstract class MachineLifecycleEffectorTasks {
// nothing by default
}
- /** @deprecated since 0.7.0 use {@link #restart(ConfigBag)} */
- @Deprecated
- public void restart() {
- restart(ConfigBag.EMPTY);
- }
-
/**
* whether when 'auto' mode is specified, the machine should be stopped when the restart effector is called
* <p>
@@ -635,12 +629,6 @@ public abstract class MachineLifecycleEffectorTasks {
throw new IllegalArgumentException("Invalid value '"+isRestartChildren+"' for "+RestartSoftwareParameters.RESTART_CHILDREN.getName());
}
- /** @deprecated since 0.7.0 use {@link #stop(ConfigBag)} */
- @Deprecated
- public void stop() {
- stop(ConfigBag.EMPTY);
- }
-
/**
* Default stop implementation for an entity.
* <p>
@@ -778,22 +766,7 @@ public abstract class MachineLifecycleEffectorTasks {
}
public static StopMode getStopMachineMode(ConfigBag parameters) {
- @SuppressWarnings("deprecation")
- final boolean hasStopMachine = parameters.containsKey(StopSoftwareParameters.STOP_MACHINE);
- @SuppressWarnings("deprecation")
- final Boolean isStopMachine = parameters.get(StopSoftwareParameters.STOP_MACHINE);
-
- final boolean hasStopMachineMode = parameters.containsKey(StopSoftwareParameters.STOP_MACHINE_MODE);
final StopMode stopMachineMode = parameters.get(StopSoftwareParameters.STOP_MACHINE_MODE);
-
- if (hasStopMachine && isStopMachine != null) {
- checkCompatibleMachineModes(isStopMachine, hasStopMachineMode, stopMachineMode);
- if (isStopMachine) {
- return StopMode.IF_NOT_STOPPED;
- } else {
- return StopMode.NEVER;
- }
- }
return stopMachineMode;
}
@@ -807,18 +780,6 @@ public abstract class MachineLifecycleEffectorTasks {
stopMode == StopMode.IF_NOT_STOPPED && !isStopped;
}
- @SuppressWarnings("deprecation")
- private static void checkCompatibleMachineModes(Boolean isStopMachine, boolean hasStopMachineMode, StopMode stopMachineMode) {
- if (hasStopMachineMode &&
- (isStopMachine && stopMachineMode != StopMode.IF_NOT_STOPPED ||
- !isStopMachine && stopMachineMode != StopMode.NEVER)) {
- throw new IllegalStateException("Incompatible values for " +
- StopSoftwareParameters.STOP_MACHINE.getName() + " (" + isStopMachine + ") and " +
- StopSoftwareParameters.STOP_MACHINE_MODE.getName() + " (" + stopMachineMode + "). " +
- "Use only one of the parameters.");
- }
- }
-
/**
* Override to check whether stop can be executed.
* Throw if stop should be aborted.
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/2f336084/software/base/src/test/java/brooklyn/entity/basic/AbstractSoftwareProcessRestartIntegrationTest.java
----------------------------------------------------------------------
diff --git a/software/base/src/test/java/brooklyn/entity/basic/AbstractSoftwareProcessRestartIntegrationTest.java b/software/base/src/test/java/brooklyn/entity/basic/AbstractSoftwareProcessRestartIntegrationTest.java
index c2c7291..d70ed76 100644
--- a/software/base/src/test/java/brooklyn/entity/basic/AbstractSoftwareProcessRestartIntegrationTest.java
+++ b/software/base/src/test/java/brooklyn/entity/basic/AbstractSoftwareProcessRestartIntegrationTest.java
@@ -73,7 +73,7 @@ public abstract class AbstractSoftwareProcessRestartIntegrationTest extends Broo
// Stop the process
Entities.invokeEffector(app, entity, SoftwareProcess.STOP, ImmutableMap.of(
- StopSoftwareParameters.STOP_MACHINE.getName(), false))
+ StopSoftwareParameters.STOP_MACHINE_MODE.getName(), StopSoftwareParameters.StopMode.NEVER))
.get();
EntityTestUtils.assertAttributeEqualsEventually(entity, SoftwareProcess.SERVICE_UP, false);
EntityTestUtils.assertAttributeEqualsEventually(entity, SoftwareProcess.SERVICE_STATE_ACTUAL, Lifecycle.STOPPED);
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/2f336084/software/base/src/test/java/brooklyn/entity/basic/SoftwareProcessEntityTest.java
----------------------------------------------------------------------
diff --git a/software/base/src/test/java/brooklyn/entity/basic/SoftwareProcessEntityTest.java b/software/base/src/test/java/brooklyn/entity/basic/SoftwareProcessEntityTest.java
index b770293..4d2e7fd 100644
--- a/software/base/src/test/java/brooklyn/entity/basic/SoftwareProcessEntityTest.java
+++ b/software/base/src/test/java/brooklyn/entity/basic/SoftwareProcessEntityTest.java
@@ -262,7 +262,7 @@ public class SoftwareProcessEntityTest extends BrooklynAppUnitTestSupport {
d.events.clear();
TaskAdaptable<Void> t1 = Entities.submit(entity, Effectors.invocation(entity, Startable.STOP,
- ConfigBag.newInstance().configure(StopSoftwareParameters.STOP_MACHINE, true)));
+ ConfigBag.newInstance().configure(StopSoftwareParameters.STOP_MACHINE_MODE, StopSoftwareParameters.StopMode.IF_NOT_STOPPED)));
t1.asTask().get();
assertEquals(d.events, ImmutableList.of("stop"));
@@ -279,7 +279,7 @@ public class SoftwareProcessEntityTest extends BrooklynAppUnitTestSupport {
d.events.clear();
TaskAdaptable<Void> t1 = Entities.submit(entity, Effectors.invocation(entity, Startable.STOP,
- ConfigBag.newInstance().configure(StopSoftwareParameters.STOP_MACHINE, false)));
+ ConfigBag.newInstance().configure(StopSoftwareParameters.STOP_MACHINE_MODE, StopSoftwareParameters.StopMode.NEVER)));
t1.asTask().get(10, TimeUnit.SECONDS);
assertEquals(d.events, ImmutableList.of("stop"));
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/2f336084/software/webapp/src/test/java/brooklyn/test/entity/TestJavaWebAppEntity.java
----------------------------------------------------------------------
diff --git a/software/webapp/src/test/java/brooklyn/test/entity/TestJavaWebAppEntity.java b/software/webapp/src/test/java/brooklyn/test/entity/TestJavaWebAppEntity.java
index 003d81c..3fa4015 100644
--- a/software/webapp/src/test/java/brooklyn/test/entity/TestJavaWebAppEntity.java
+++ b/software/webapp/src/test/java/brooklyn/test/entity/TestJavaWebAppEntity.java
@@ -32,6 +32,7 @@ import brooklyn.entity.java.VanillaJavaApp;
import brooklyn.entity.proxying.ImplementedBy;
import brooklyn.entity.webapp.WebAppService;
import brooklyn.location.Location;
+import brooklyn.util.config.ConfigBag;
/**
* Mock web application server entity for testing.
@@ -64,7 +65,7 @@ public interface TestJavaWebAppEntity extends VanillaJavaApp, WebAppService {
}
@Override
- public void stop() {
+ public void stop(ConfigBag parameters) {
ServiceStateLogic.setExpectedState(entity(), Lifecycle.STOPPING);
LOG.trace("Stopping {}", this);
entity().setAttribute(Attributes.SERVICE_UP, false);
[11/21] incubator-brooklyn git commit: Delete deprecated memento
persisters
Posted by ha...@apache.org.
Delete deprecated memento persisters
Project: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/commit/358806da
Tree: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/tree/358806da
Diff: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/diff/358806da
Branch: refs/heads/master
Commit: 358806dab5cc19c8e4a6a2dfb9913bda10f5499a
Parents: b53a79a
Author: Aled Sage <al...@gmail.com>
Authored: Tue Jul 28 22:58:50 2015 +0100
Committer: Aled Sage <al...@gmail.com>
Committed: Sat Aug 1 00:13:32 2015 +0100
----------------------------------------------------------------------
.../AbstractBrooklynMementoPersister.java | 129 ----
.../BrooklynMementoPersisterInMemory.java | 211 -------
.../BrooklynMementoPersisterToFile.java | 147 -----
.../BrooklynMementoPersisterToMultiFile.java | 601 -------------------
.../rebind/persister/MementoFileWriter.java | 267 --------
.../rebind/persister/MementoFileWriterSync.java | 159 -----
...mentPlaneSyncRecordPersisterToMultiFile.java | 280 ---------
...BrooklynMementoPersisterToMultiFileTest.java | 68 ---
.../persister/MementoFileWriterSyncTest.java | 128 ----
.../rebind/persister/MementoFileWriterTest.java | 99 ---
10 files changed, 2089 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/358806da/core/src/main/java/brooklyn/entity/rebind/persister/AbstractBrooklynMementoPersister.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/brooklyn/entity/rebind/persister/AbstractBrooklynMementoPersister.java b/core/src/main/java/brooklyn/entity/rebind/persister/AbstractBrooklynMementoPersister.java
deleted file mode 100644
index d3f85df..0000000
--- a/core/src/main/java/brooklyn/entity/rebind/persister/AbstractBrooklynMementoPersister.java
+++ /dev/null
@@ -1,129 +0,0 @@
-/*
- * 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
- * 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 brooklyn.entity.rebind.persister;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import brooklyn.entity.rebind.PersistenceExceptionHandler;
-import brooklyn.entity.rebind.RebindExceptionHandler;
-import brooklyn.entity.rebind.dto.BrooklynMementoManifestImpl;
-import brooklyn.entity.rebind.dto.MutableBrooklynMemento;
-import brooklyn.mementos.BrooklynMemento;
-import brooklyn.mementos.BrooklynMementoManifest;
-import brooklyn.mementos.BrooklynMementoPersister;
-import brooklyn.mementos.BrooklynMementoRawData;
-import brooklyn.mementos.CatalogItemMemento;
-import brooklyn.mementos.EnricherMemento;
-import brooklyn.mementos.EntityMemento;
-import brooklyn.mementos.LocationMemento;
-import brooklyn.mementos.PolicyMemento;
-
-/**
- * @deprecated since 0.7.0 for production use {@link BrooklynMementoPersisterToObjectStore} instead
- */
-@Deprecated
-public abstract class AbstractBrooklynMementoPersister implements BrooklynMementoPersister {
-
- private static final Logger log = LoggerFactory.getLogger(AbstractBrooklynMementoPersister.class);
-
- protected volatile MutableBrooklynMemento memento = new MutableBrooklynMemento();
-
- @Override
- public BrooklynMementoRawData loadMementoRawData(RebindExceptionHandler exceptionHandler) {
- return null;
- }
-
- @Override
- public BrooklynMemento loadMemento(BrooklynMementoRawData mementoData, LookupContext lookupContext, RebindExceptionHandler exceptionHandler) {
- // Trusting people not to cast+modify, because the in-memory persister wouldn't be used in production code
- return memento;
- }
-
- @Override
- public BrooklynMemento loadMemento(LookupContext lookupContext, RebindExceptionHandler exceptionHandler) {
- return loadMemento(null, lookupContext, exceptionHandler);
- }
-
- @Override
- public BrooklynMementoManifest loadMementoManifest(RebindExceptionHandler exceptionHandler) {
- return loadMementoManifest(null, exceptionHandler);
- }
-
- @Override
- public BrooklynMementoManifest loadMementoManifest(BrooklynMementoRawData mementoData, RebindExceptionHandler exceptionHandler) {
- BrooklynMementoManifestImpl.Builder builder = BrooklynMementoManifestImpl.builder();
- for (EntityMemento entity : memento.getEntityMementos().values()) {
- builder.entity(entity.getId(), entity.getType(), entity.getParent(), entity.getCatalogItemId());
- }
- for (LocationMemento entity : memento.getLocationMementos().values()) {
- builder.location(entity.getId(), entity.getType());
- }
- for (PolicyMemento entity : memento.getPolicyMementos().values()) {
- builder.policy(entity.getId(), entity.getType());
- }
- for (EnricherMemento entity : memento.getEnricherMementos().values()) {
- builder.enricher(entity.getId(), entity.getType());
- }
- for (CatalogItemMemento entity : memento.getCatalogItemMementos().values()) {
- builder.catalogItem(entity);
- }
- return builder.build();
- }
-
- @Override public void enableWriteAccess() {}
- @Override public void disableWriteAccess(boolean graceful) {}
- @Override public void stop(boolean graceful) {}
-
- @Override
- public void checkpoint(BrooklynMemento newMemento, PersistenceExceptionHandler exceptionHandler) {
- memento.reset(checkNotNull(newMemento, "memento"));
- }
-
- public void checkpoint(BrooklynMementoRawData newMemento, PersistenceExceptionHandler exceptionHandler) {
- throw new IllegalStateException("Not supported; use "+BrooklynMementoPersisterToObjectStore.class);
- }
-
- @Override
- public void delta(Delta delta, PersistenceExceptionHandler exceptionHanlder) {
- memento.removeEntities(delta.removedEntityIds());
- memento.removeLocations(delta.removedLocationIds());
- memento.removePolicies(delta.removedPolicyIds());
- memento.removeEnrichers(delta.removedEnricherIds());
- memento.removeCatalogItems(delta.removedCatalogItemIds());
- memento.updateEntityMementos(delta.entities());
- memento.updateLocationMementos(delta.locations());
- memento.updatePolicyMementos(delta.policies());
- memento.updateEnricherMementos(delta.enrichers());
- memento.updateCatalogItemMementos(delta.catalogItems());
- }
-
- @Override
- public void queueDelta(Delta delta) {
- log.warn("Legacy persister ignoring queued delta: "+delta);
- }
-
- @Override
- public String getBackingStoreDescription() {
- return toString();
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/358806da/core/src/main/java/brooklyn/entity/rebind/persister/BrooklynMementoPersisterInMemory.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/brooklyn/entity/rebind/persister/BrooklynMementoPersisterInMemory.java b/core/src/main/java/brooklyn/entity/rebind/persister/BrooklynMementoPersisterInMemory.java
deleted file mode 100644
index dbb1e52..0000000
--- a/core/src/main/java/brooklyn/entity/rebind/persister/BrooklynMementoPersisterInMemory.java
+++ /dev/null
@@ -1,211 +0,0 @@
-/*
- * 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
- * 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 brooklyn.entity.rebind.persister;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-
-import java.io.File;
-import java.io.IOException;
-import java.lang.reflect.InvocationHandler;
-import java.lang.reflect.Method;
-import java.util.List;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.TimeoutException;
-
-import brooklyn.basic.BrooklynObject;
-import brooklyn.catalog.CatalogItem;
-import brooklyn.entity.Entity;
-import brooklyn.entity.Feed;
-import brooklyn.entity.basic.EntityInternal;
-import brooklyn.entity.proxying.EntityProxy;
-import brooklyn.entity.rebind.BrooklynObjectType;
-import brooklyn.entity.rebind.PersistenceExceptionHandler;
-import brooklyn.entity.rebind.PersistenceExceptionHandlerImpl;
-import brooklyn.entity.rebind.RebindExceptionHandler;
-import brooklyn.entity.rebind.RebindExceptionHandlerImpl;
-import brooklyn.entity.rebind.RebindManager;
-import brooklyn.location.Location;
-import brooklyn.management.ManagementContext;
-import brooklyn.mementos.BrooklynMemento;
-import brooklyn.mementos.BrooklynMementoManifest;
-import brooklyn.policy.Enricher;
-import brooklyn.policy.Policy;
-import brooklyn.util.collections.MutableList;
-import brooklyn.util.collections.MutableMap;
-import brooklyn.util.exceptions.Exceptions;
-import brooklyn.util.javalang.JavaClassNames;
-import brooklyn.util.javalang.Reflections;
-import brooklyn.util.os.Os;
-import brooklyn.util.time.Duration;
-
-import com.google.common.annotations.VisibleForTesting;
-import com.google.common.base.Optional;
-import com.google.common.base.Throwables;
-
-/**
- * @deprecated since 0.7.0 for production use {@link BrooklynMementoPersisterToObjectStore} instead; class be moved to tests
- * <code>
- * new BrooklynMementoPersisterToObjectStore(new InMemoryObjectStore(), classLoader)
- * </code>
- */
-@Deprecated
-public class BrooklynMementoPersisterInMemory extends AbstractBrooklynMementoPersister {
-
- private final ClassLoader classLoader;
- private final boolean checkPersistable;
-
- public BrooklynMementoPersisterInMemory(ClassLoader classLoader) {
- this(classLoader, true);
- }
-
- public BrooklynMementoPersisterInMemory(ClassLoader classLoader, boolean checkPersistable) {
- this.classLoader = checkNotNull(classLoader, "classLoader");
- this.checkPersistable = checkPersistable;
- }
-
- @VisibleForTesting
- @Override
- public void waitForWritesCompleted(long timeout, TimeUnit unit) throws InterruptedException, TimeoutException {
- }
-
- @VisibleForTesting
- @Override
- public void waitForWritesCompleted(Duration timeout) throws InterruptedException, TimeoutException {
- // TODO Could wait for concurrent checkpoint/delta, but don't need to for tests
- // because first waits for checkpoint/delta to have been called by RebindManagerImpl.
- return;
- }
-
- @Override
- public void checkpoint(BrooklynMemento newMemento, PersistenceExceptionHandler exceptionHandler) {
- super.checkpoint(newMemento, exceptionHandler);
- if (checkPersistable) reserializeMemento();
- }
-
- @Override
- public void delta(Delta delta, PersistenceExceptionHandler exceptionHandler) {
- super.delta(delta, exceptionHandler);
- if (checkPersistable) reserializeMemento();
- }
-
- private void reserializeMemento() {
- // To confirm always serializable
- try {
- File tempDir = Os.newTempDir(JavaClassNames.cleanSimpleClassName(this));
- try {
- // TODO Duplicate code for LookupContext in RebindManager
- BrooklynMementoPersisterToMultiFile persister = new BrooklynMementoPersisterToMultiFile(tempDir , classLoader);
- RebindExceptionHandler rebindExceptionHandler = RebindExceptionHandlerImpl.builder()
- .danglingRefFailureMode(RebindManager.RebindFailureMode.FAIL_AT_END)
- .rebindFailureMode(RebindManager.RebindFailureMode.FAIL_AT_END)
- .build();
- PersistenceExceptionHandler persistenceExceptionHandler = PersistenceExceptionHandlerImpl.builder().build();
- persister.checkpoint(memento, persistenceExceptionHandler);
- final BrooklynMementoManifest manifest = persister.loadMementoManifest(null, rebindExceptionHandler);
- LookupContext dummyLookupContext = new LookupContext() {
- @Override
- public ManagementContext lookupManagementContext() {
- return null;
- }
- @Override public Entity lookupEntity(String id) {
- List<Class<?>> types = MutableList.<Class<?>>builder()
- .add(Entity.class, EntityInternal.class, EntityProxy.class)
- //TODO Doesn't support loading from catalog item osgi bundles
- .add(loadClass(manifest.getEntityIdToManifest().get(id).getType()))
- .build();
- return (Entity) java.lang.reflect.Proxy.newProxyInstance(
- classLoader,
- types.toArray(new Class<?>[types.size()]),
- new InvocationHandler() {
- @Override public Object invoke(Object proxy, Method m, Object[] args) throws Throwable {
- return m.invoke(this, args);
- }
- });
- }
- @Override public Location lookupLocation(String id) {
- Class<?> clazz = loadClass(manifest.getLocationIdToType().get(id));
- return (Location) invokeConstructor(clazz, new Object[0], new Object[] {MutableMap.of()});
- }
- @Override public Policy lookupPolicy(String id) {
- Class<?> clazz = loadClass(manifest.getPolicyIdToType().get(id));
- return (Policy) invokeConstructor(clazz, new Object[0], new Object[] {MutableMap.of()});
- }
- @Override public Enricher lookupEnricher(String id) {
- Class<?> clazz = loadClass(manifest.getEnricherIdToType().get(id));
- return (Enricher) invokeConstructor(clazz, new Object[0], new Object[] {MutableMap.of()});
- }
- @Override public Feed lookupFeed(String id) {
- Class<?> clazz = loadClass(manifest.getFeedIdToType().get(id));
- return (Feed) invokeConstructor(clazz, new Object[0], new Object[] {MutableMap.of()});
- }
- @Override public CatalogItem<?, ?> lookupCatalogItem(String id) {
- Class<?> clazz = loadClass(manifest.getCatalogItemMemento(id).getType());
- return (CatalogItem<?,?>) invokeConstructor(clazz, new Object[0]);
- }
-
- @Override
- public BrooklynObject lookup(BrooklynObjectType type, String id) {
- switch (type) {
- case CATALOG_ITEM: return lookupCatalogItem(id);
- case ENRICHER: return lookupEnricher(id);
- case ENTITY: return lookupEntity(id);
- case FEED: return lookupFeed(id);
- case LOCATION: return lookupLocation(id);
- case POLICY: return lookupPolicy(id);
- case UNKNOWN: return null;
- }
- throw new IllegalStateException("Unexpected type "+type+" / id "+id);
- }
- @Override
- public BrooklynObject peek(BrooklynObjectType type, String id) {
- return lookup(type, id);
- }
-
- private Class<?> loadClass(String name) {
- try {
- return classLoader.loadClass(name);
- } catch (ClassNotFoundException e) {
- throw Exceptions.propagate(e);
- }
- }
- private <T> T invokeConstructor(Class<T> clazz, Object[]... possibleArgs) {
- for (Object[] args : possibleArgs) {
- try {
- Optional<T> v = Reflections.invokeConstructorWithArgs(clazz, args, true);
- if (v.isPresent()) {
- return v.get();
- }
- } catch (Exception e) {
- throw Exceptions.propagate(e);
- }
- }
- throw new IllegalStateException("Cannot instantiate instance of type "+clazz+"; expected constructor signature not found");
- }
- };
-
- // Not actually reconstituting, because need to use a real lookupContext to reconstitute all the entities
- persister.loadMemento(null, dummyLookupContext, rebindExceptionHandler);
- } finally {
- Os.deleteRecursively(tempDir);
- }
- } catch (IOException e) {
- throw Throwables.propagate(e);
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/358806da/core/src/main/java/brooklyn/entity/rebind/persister/BrooklynMementoPersisterToFile.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/brooklyn/entity/rebind/persister/BrooklynMementoPersisterToFile.java b/core/src/main/java/brooklyn/entity/rebind/persister/BrooklynMementoPersisterToFile.java
deleted file mode 100644
index 68dd6eb..0000000
--- a/core/src/main/java/brooklyn/entity/rebind/persister/BrooklynMementoPersisterToFile.java
+++ /dev/null
@@ -1,147 +0,0 @@
-/*
- * 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
- * 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 brooklyn.entity.rebind.persister;
-
-import java.io.File;
-import java.io.IOException;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.TimeoutException;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import brooklyn.entity.rebind.PersistenceExceptionHandler;
-import brooklyn.entity.rebind.RebindExceptionHandler;
-import brooklyn.mementos.BrooklynMemento;
-import brooklyn.util.exceptions.Exceptions;
-import brooklyn.util.time.Duration;
-import brooklyn.util.time.Time;
-
-import com.google.common.annotations.VisibleForTesting;
-import com.google.common.base.Charsets;
-import com.google.common.base.Stopwatch;
-import com.google.common.io.Files;
-
-/**
- * @deprecated since 0.7.0 use BrooklynMementoPersisterToMultiFile instead; the single-file version
- * has not been tested recently or kept up-to-date.
- */
-@Deprecated
-public class BrooklynMementoPersisterToFile extends AbstractBrooklynMementoPersister {
-
- // FIXME This is no longer used (instead we use ToMultiFile).
- // Is this definitely no longer useful? Delete if not, and
- // merge AbstractBrooklynMementoPersister+BrooklynMementoPerisisterInMemory.
-
- private static final Logger LOG = LoggerFactory.getLogger(BrooklynMementoPersisterToFile.class);
-
- private final File file;
- private final MementoSerializer<BrooklynMemento> serializer;
- private final Object mutex = new Object();
-
-
- public BrooklynMementoPersisterToFile(File file, ClassLoader classLoader) {
- this.file = file;
- this.serializer = new XmlMementoSerializer<BrooklynMemento>(classLoader);
- }
-
- @VisibleForTesting
- @Override
- public void waitForWritesCompleted(long timeout, TimeUnit unit) throws InterruptedException, TimeoutException {
- }
-
- @VisibleForTesting
- @Override
- public void waitForWritesCompleted(Duration timeout) throws InterruptedException, TimeoutException {
- // TODO Could wait for concurrent checkpoint/delta, but don't need to for tests
- // because they first wait for checkpoint/delta to have been called by RebindManagerImpl.
- return;
- }
-
- @Override
- public BrooklynMemento loadMemento(LookupContext lookupContext, RebindExceptionHandler exceptionHandler) {
- Stopwatch stopwatch = Stopwatch.createStarted();
-
- String xml = readFile();
- serializer.setLookupContext(lookupContext);
- try {
- BrooklynMemento result = serializer.fromString(xml);
-
- if (LOG.isDebugEnabled()) LOG.debug("Loaded memento; took {}", Time.makeTimeStringRounded(stopwatch));
- return result;
-
- } finally {
- serializer.unsetLookupContext();
- }
- }
-
- private String readFile() {
- try {
- synchronized (mutex) {
- return Files.asCharSource(file, Charsets.UTF_8).read();
- }
- } catch (IOException e) {
- LOG.error("Failed to persist memento", e);
- throw Exceptions.propagate(e);
- }
- }
-
- @Override
- public void checkpoint(BrooklynMemento newMemento, PersistenceExceptionHandler exceptionHandler) {
- Stopwatch stopwatch = Stopwatch.createStarted();
- synchronized (mutex) {
- long timeObtainedMutex = stopwatch.elapsed(TimeUnit.MILLISECONDS);
- super.checkpoint(newMemento, exceptionHandler);
- long timeCheckpointed = stopwatch.elapsed(TimeUnit.MILLISECONDS);
- writeMemento();
- long timeWritten = stopwatch.elapsed(TimeUnit.MILLISECONDS);
-
- if (LOG.isDebugEnabled()) LOG.debug("Checkpointed memento; total={}ms, obtainingMutex={}ms, " +
- "checkpointing={}ms, writing={}ms",
- new Object[] {timeWritten, timeObtainedMutex, (timeCheckpointed-timeObtainedMutex),
- (timeWritten-timeCheckpointed)});
- }
- }
-
- @Override
- public void delta(Delta delta, PersistenceExceptionHandler exceptionHandler) {
- Stopwatch stopwatch = Stopwatch.createStarted();
- synchronized (mutex) {
- long timeObtainedMutex = stopwatch.elapsed(TimeUnit.MILLISECONDS);
- super.delta(delta, exceptionHandler);
- long timeDeltad = stopwatch.elapsed(TimeUnit.MILLISECONDS);
- writeMemento();
- long timeWritten = stopwatch.elapsed(TimeUnit.MILLISECONDS);
-
- if (LOG.isDebugEnabled()) LOG.debug("Checkpointed memento; total={}ms, obtainingMutex={}ms, " +
- "delta'ing={}ms, writing={}",
- new Object[] {timeWritten, timeObtainedMutex, (timeDeltad-timeObtainedMutex),
- (timeWritten-timeDeltad)});
- }
- }
-
- private void writeMemento() {
- assert Thread.holdsLock(mutex);
- try {
- Files.write(serializer.toString(memento), file, Charsets.UTF_8);
- } catch (IOException e) {
- LOG.error("Failed to persist memento", e);
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/358806da/core/src/main/java/brooklyn/entity/rebind/persister/BrooklynMementoPersisterToMultiFile.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/brooklyn/entity/rebind/persister/BrooklynMementoPersisterToMultiFile.java b/core/src/main/java/brooklyn/entity/rebind/persister/BrooklynMementoPersisterToMultiFile.java
deleted file mode 100644
index afb3d61..0000000
--- a/core/src/main/java/brooklyn/entity/rebind/persister/BrooklynMementoPersisterToMultiFile.java
+++ /dev/null
@@ -1,601 +0,0 @@
-/*
- * 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
- * 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 brooklyn.entity.rebind.persister;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-
-import java.io.File;
-import java.io.FileFilter;
-import java.io.IOException;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.ConcurrentMap;
-import java.util.concurrent.Executors;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.TimeoutException;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import brooklyn.entity.rebind.BrooklynObjectType;
-import brooklyn.entity.rebind.PersistenceExceptionHandler;
-import brooklyn.entity.rebind.RebindExceptionHandler;
-import brooklyn.entity.rebind.dto.BrooklynMementoImpl;
-import brooklyn.entity.rebind.dto.BrooklynMementoManifestImpl;
-import brooklyn.mementos.BrooklynMemento;
-import brooklyn.mementos.BrooklynMementoManifest;
-import brooklyn.mementos.BrooklynMementoPersister;
-import brooklyn.mementos.BrooklynMementoRawData;
-import brooklyn.mementos.CatalogItemMemento;
-import brooklyn.mementos.EnricherMemento;
-import brooklyn.mementos.EntityMemento;
-import brooklyn.mementos.LocationMemento;
-import brooklyn.mementos.PolicyMemento;
-import brooklyn.util.exceptions.Exceptions;
-import brooklyn.util.text.Strings;
-import brooklyn.util.time.Duration;
-import brooklyn.util.time.Time;
-import brooklyn.util.xstream.XmlUtil;
-
-import com.google.common.annotations.VisibleForTesting;
-import com.google.common.base.Charsets;
-import com.google.common.base.Stopwatch;
-import com.google.common.io.Files;
-import com.google.common.util.concurrent.ListeningExecutorService;
-import com.google.common.util.concurrent.MoreExecutors;
-
-/**
- * @deprecated since 0.7.0 use {@link BrooklynMementoPersisterToObjectStore} instead;
- * it has a multi-file filesystem backend for equivalent functionality, but is pluggable
- * to support other storage backends
- */
-@Deprecated
-public class BrooklynMementoPersisterToMultiFile implements BrooklynMementoPersister {
-
- private static final Logger LOG = LoggerFactory.getLogger(BrooklynMementoPersisterToMultiFile.class);
-
- private static final int SHUTDOWN_TIMEOUT_MS = 10*1000;
-
- private final File dir;
-
- private final File entitiesDir;
- private final File locationsDir;
- private final File policiesDir;
- private final File enrichersDir;
- private final File catalogItemsDir;
-
- private final ConcurrentMap<String, MementoFileWriter<EntityMemento>> entityWriters = new ConcurrentHashMap<String, MementoFileWriter<EntityMemento>>();
- private final ConcurrentMap<String, MementoFileWriter<LocationMemento>> locationWriters = new ConcurrentHashMap<String, MementoFileWriter<LocationMemento>>();
- private final ConcurrentMap<String, MementoFileWriter<PolicyMemento>> policyWriters = new ConcurrentHashMap<String, MementoFileWriter<PolicyMemento>>();
- private final ConcurrentMap<String, MementoFileWriter<EnricherMemento>> enricherWriters = new ConcurrentHashMap<String, MementoFileWriter<EnricherMemento>>();
- private final ConcurrentMap<String, MementoFileWriter<CatalogItemMemento>> catalogItemWriters = new ConcurrentHashMap<String, MementoFileWriter<CatalogItemMemento>>();
-
- private final MementoSerializer<Object> serializer;
-
- private final ListeningExecutorService executor;
-
- private static final int MAX_SERIALIZATION_ATTEMPTS = 5;
-
- private volatile boolean running = true;
-
-
- public BrooklynMementoPersisterToMultiFile(File dir, ClassLoader classLoader) {
- this.dir = checkNotNull(dir, "dir");
- MementoSerializer<Object> rawSerializer = new XmlMementoSerializer<Object>(classLoader);
- this.serializer = new RetryingMementoSerializer<Object>(rawSerializer, MAX_SERIALIZATION_ATTEMPTS);
-
- checkDirIsAccessible(dir);
-
- entitiesDir = new File(dir, "entities");
- entitiesDir.mkdir();
- checkDirIsAccessible(entitiesDir);
-
- locationsDir = new File(dir, "locations");
- locationsDir.mkdir();
- checkDirIsAccessible(locationsDir);
-
- policiesDir = new File(dir, "policies");
- policiesDir.mkdir();
- checkDirIsAccessible(policiesDir);
-
- enrichersDir = new File(dir, "enrichers");
- enrichersDir.mkdir();
- checkDirIsAccessible(enrichersDir);
-
- catalogItemsDir = new File(dir, "catalog");
- catalogItemsDir.mkdir();
- checkDirIsAccessible(catalogItemsDir);
-
- File planeDir = new File(dir, "plane");
- planeDir.mkdir();
- checkDirIsAccessible(planeDir);
-
- this.executor = MoreExecutors.listeningDecorator(Executors.newCachedThreadPool());
-
- LOG.info("Memento-persister will use directory {}", dir);
- }
-
- @Override public void enableWriteAccess() {
- // no-op -- means subsequent writes will not be enabled
- }
-
- @Override public void disableWriteAccess(boolean graceful) {
- stop(graceful);
- }
-
- @Override
- public void stop(boolean graceful) {
- running = false;
- if (graceful) {
- executor.shutdown();
- try {
- executor.awaitTermination(SHUTDOWN_TIMEOUT_MS, TimeUnit.MILLISECONDS);
- } catch (InterruptedException e) {
- throw Exceptions.propagate(e);
- }
- } else {
- executor.shutdownNow();
- }
- }
-
- @Override
- public BrooklynMementoRawData loadMementoRawData(RebindExceptionHandler exceptionHandler) {
- return null;
- }
-
- @Override
- public BrooklynMementoManifest loadMementoManifest(RebindExceptionHandler exceptionHandler) throws IOException {
- return loadMementoManifest(null, exceptionHandler);
- }
-
- @Override
- public BrooklynMementoManifest loadMementoManifest(BrooklynMementoRawData mementoData, RebindExceptionHandler exceptionHandler) throws IOException {
- if (!running) {
- throw new IllegalStateException("Persister not running; cannot load memento manifest from "+dir);
- }
-
- Stopwatch stopwatch = Stopwatch.createStarted();
-
- FileFilter fileFilter = new FileFilter() {
- @Override public boolean accept(File file) {
- return !file.getName().endsWith(".tmp");
- }
- };
- File[] entityFiles;
- File[] locationFiles;
- File[] policyFiles;
- File[] enricherFiles;
- File[] catalogItemFiles;
- try {
- entityFiles = entitiesDir.listFiles(fileFilter);
- locationFiles = locationsDir.listFiles(fileFilter);
- policyFiles = policiesDir.listFiles(fileFilter);
- enricherFiles = enrichersDir.listFiles(fileFilter);
- catalogItemFiles = catalogItemsDir.listFiles(fileFilter);
- } catch (Exception e) {
- Exceptions.propagateIfFatal(e);
- exceptionHandler.onLoadMementoFailed(BrooklynObjectType.UNKNOWN, "Failed to list files", e);
- throw new IllegalStateException("Failed to list memento files in "+dir, e);
- }
-
- LOG.info("Loading memento manifest from {}; {} entities, {} locations, {} policies, {} enrichers",
- new Object[] {dir, entityFiles.length, locationFiles.length, policyFiles.length, enricherFiles.length});
-
- BrooklynMementoManifestImpl.Builder builder = BrooklynMementoManifestImpl.builder();
-
- try {
- for (File file : entityFiles) {
- try {
- String contents = readFile(file);
- String id = (String) XmlUtil.xpath(contents, "/entity/id");
- String type = (String) XmlUtil.xpath(contents, "/entity/type");
- String parentId = (String) XmlUtil.xpath(contents, "/entity/parent");
- String catalogItemId = (String) XmlUtil.xpath(contents, "/entity/catalogItemId");
- builder.entity(id, type, Strings.emptyToNull(parentId), Strings.emptyToNull(catalogItemId));
- } catch (Exception e) {
- exceptionHandler.onLoadMementoFailed(BrooklynObjectType.ENTITY, "File "+file, e);
- }
- }
- for (File file : locationFiles) {
- try {
- String contents = readFile(file);
- String id = (String) XmlUtil.xpath(contents, "/location/id");
- String type = (String) XmlUtil.xpath(contents, "/location/type");
- builder.location(id, type);
- } catch (Exception e) {
- exceptionHandler.onLoadMementoFailed(BrooklynObjectType.LOCATION, "File "+file, e);
- }
- }
- for (File file : policyFiles) {
- try {
- String contents = readFile(file);
- String id = (String) XmlUtil.xpath(contents, "/policy/id");
- String type = (String) XmlUtil.xpath(contents, "/policy/type");
- builder.policy(id, type);
- } catch (Exception e) {
- exceptionHandler.onLoadMementoFailed(BrooklynObjectType.POLICY, "File "+file, e);
- }
- }
- for (File file : enricherFiles) {
- try {
- String contents = readFile(file);
- String id = (String) XmlUtil.xpath(contents, "/enricher/id");
- String type = (String) XmlUtil.xpath(contents, "/enricher/type");
- builder.enricher(id, type);
- } catch (Exception e) {
- exceptionHandler.onLoadMementoFailed(BrooklynObjectType.ENRICHER, "File "+file, e);
- }
- }
- for (File file : catalogItemFiles) {
- try {
- String contents = readFile(file);
- String id = (String) XmlUtil.xpath(contents, "/catalogItem/id");
- String type = (String) XmlUtil.xpath(contents, "/catalogItem/type");
- builder.enricher(id, type);
- } catch (Exception e) {
- exceptionHandler.onLoadMementoFailed(BrooklynObjectType.CATALOG_ITEM, "File "+file, e);
- }
- }
-
- if (LOG.isDebugEnabled()) LOG.debug("Loaded memento manifest; took {}", Time.makeTimeStringRounded(stopwatch.elapsed(TimeUnit.MILLISECONDS)));
- return builder.build();
-
- } finally {
- serializer.unsetLookupContext();
- }
- }
-
- @Override
- public BrooklynMemento loadMemento(LookupContext lookupContext, RebindExceptionHandler exceptionHandler) throws IOException {
- return loadMemento(null, lookupContext, exceptionHandler);
- }
-
- @Override
- public BrooklynMemento loadMemento(BrooklynMementoRawData mementoData, LookupContext lookupContext, RebindExceptionHandler exceptionHandler) throws IOException {
- if (!running) {
- throw new IllegalStateException("Persister not running; cannot load memento from "+dir);
- }
-
- Stopwatch stopwatch = Stopwatch.createStarted();
-
- FileFilter fileFilter = new FileFilter() {
- @Override public boolean accept(File file) {
- return !file.getName().endsWith(".tmp");
- }
- };
- File[] entityFiles;
- File[] locationFiles;
- File[] policyFiles;
- File[] enricherFiles;
- File[] catalogItemFiles;
- try {
- entityFiles = entitiesDir.listFiles(fileFilter);
- locationFiles = locationsDir.listFiles(fileFilter);
- policyFiles = policiesDir.listFiles(fileFilter);
- enricherFiles = enrichersDir.listFiles(fileFilter);
- catalogItemFiles = catalogItemsDir.listFiles(fileFilter);
- } catch (Exception e) {
- Exceptions.propagateIfFatal(e);
- exceptionHandler.onLoadMementoFailed(BrooklynObjectType.UNKNOWN, "Failed to list files", e);
- throw new IllegalStateException("Failed to list memento files in "+dir, e);
- }
-
- LOG.info("Loading memento from {}; {} entities, {} locations, {} policies, {} enrichers and {} catalog items",
- new Object[] {dir, entityFiles.length, locationFiles.length, policyFiles.length, enricherFiles.length, catalogItemFiles.length});
-
- BrooklynMementoImpl.Builder builder = BrooklynMementoImpl.builder();
-
- serializer.setLookupContext(lookupContext);
- try {
- for (File file : entityFiles) {
- try {
- EntityMemento memento = (EntityMemento) serializer.fromString(readFile(file));
- if (memento == null) {
- LOG.warn("No entity-memento deserialized from file "+file+"; ignoring and continuing");
- } else {
- builder.entity(memento);
- if (memento.isTopLevelApp()) {
- builder.applicationId(memento.getId());
- }
- }
- } catch (Exception e) {
- exceptionHandler.onLoadMementoFailed(BrooklynObjectType.ENTITY, "File "+file, e);
- }
- }
- for (File file : locationFiles) {
- try {
- LocationMemento memento = (LocationMemento) serializer.fromString(readFile(file));
- if (memento == null) {
- LOG.warn("No location-memento deserialized from file "+file+"; ignoring and continuing");
- } else {
- builder.location(memento);
- }
- } catch (Exception e) {
- exceptionHandler.onLoadMementoFailed(BrooklynObjectType.LOCATION, "File "+file, e);
- }
- }
- for (File file : policyFiles) {
- try {
- PolicyMemento memento = (PolicyMemento) serializer.fromString(readFile(file));
- if (memento == null) {
- LOG.warn("No policy-memento deserialized from file "+file+"; ignoring and continuing");
- } else {
- builder.policy(memento);
- }
- } catch (Exception e) {
- exceptionHandler.onLoadMementoFailed(BrooklynObjectType.POLICY, "File "+file, e);
- }
- }
- for (File file : enricherFiles) {
- EnricherMemento memento = (EnricherMemento) serializer.fromString(readFile(file));
- if (memento == null) {
- LOG.warn("No enricher-memento deserialized from file "+file+"; ignoring and continuing");
- } else {
- builder.enricher(memento);
- }
- }
- for (File file : catalogItemFiles) {
- CatalogItemMemento memento = (CatalogItemMemento) serializer.fromString(readFile(file));
- if (memento == null) {
- LOG.warn("No catalog-item-memento deserialized from file "+file+"; ignoring and continuing");
- } else {
- builder.catalogItem(memento);
- }
- }
-
- if (LOG.isDebugEnabled()) LOG.debug("Loaded memento; took {}", Time.makeTimeStringRounded(stopwatch.elapsed(TimeUnit.MILLISECONDS)));
- return builder.build();
-
- } finally {
- serializer.unsetLookupContext();
- }
- }
-
- @Override
- public void checkpoint(BrooklynMemento newMemento, PersistenceExceptionHandler exceptionHandler) {
- if (!running) {
- if (LOG.isDebugEnabled()) LOG.debug("Ignoring checkpointing entire memento, because not running");
- return;
- }
- if (LOG.isDebugEnabled()) LOG.debug("Checkpointing entire memento");
-
- for (EntityMemento m : newMemento.getEntityMementos().values()) {
- persist(m);
- }
- for (LocationMemento m : newMemento.getLocationMementos().values()) {
- persist(m);
- }
- for (PolicyMemento m : newMemento.getPolicyMementos().values()) {
- persist(m);
- }
- for (EnricherMemento m : newMemento.getEnricherMementos().values()) {
- persist(m);
- }
- for (CatalogItemMemento m : newMemento.getCatalogItemMementos().values()) {
- persist(m);
- }
- LOG.warn("Using legacy persister; feeds will not be persisted");
- }
-
- @Override
- public void checkpoint(BrooklynMementoRawData newMemento, PersistenceExceptionHandler exceptionHandler) {
- throw new IllegalStateException("Not supported; use "+BrooklynMementoPersisterToObjectStore.class);
- }
-
- @Override
- public void delta(Delta delta, PersistenceExceptionHandler exceptionHandler) {
- if (!running) {
- if (LOG.isDebugEnabled()) LOG.debug("Ignoring checkpointed delta of memento, because not running");
- return;
- }
- if (LOG.isTraceEnabled()) LOG.trace("Checkpointed delta of memento; updating {} entities, {} locations, {} policies and {} enrichers; " +
- "removing {} entities, {} locations {} policies and {} enrichers",
- new Object[] {delta.entities(), delta.locations(), delta.policies(), delta.enrichers(),
- delta.removedEntityIds(), delta.removedLocationIds(), delta.removedPolicyIds(), delta.removedEnricherIds()});
-
- for (EntityMemento entity : delta.entities()) {
- persist(entity);
- }
- for (LocationMemento location : delta.locations()) {
- persist(location);
- }
- for (PolicyMemento policy : delta.policies()) {
- persist(policy);
- }
- for (EnricherMemento enricher : delta.enrichers()) {
- persist(enricher);
- }
- for (CatalogItemMemento catalogItem : delta.catalogItems()) {
- persist(catalogItem);
- }
- for (String id : delta.removedEntityIds()) {
- deleteEntity(id);
- }
- for (String id : delta.removedLocationIds()) {
- deleteLocation(id);
- }
- for (String id : delta.removedPolicyIds()) {
- deletePolicy(id);
- }
- for (String id : delta.removedEnricherIds()) {
- deleteEnricher(id);
- }
- for (String id : delta.removedCatalogItemIds()) {
- deleteCatalogItem(id);
- }
- }
-
- @Override
- public void queueDelta(Delta delta) {
- LOG.warn("Legacy persister ignoring queued delta: "+delta);
- }
-
- @VisibleForTesting
- public File getDir() {
- return dir;
- }
-
- @Override
- @VisibleForTesting
- public void waitForWritesCompleted(long timeout, TimeUnit unit) throws InterruptedException, TimeoutException {
- waitForWritesCompleted(Duration.of(timeout, unit));
- }
-
- public void waitForWritesCompleted(Duration timeout) throws InterruptedException, TimeoutException {
- for (MementoFileWriter<?> writer : entityWriters.values()) {
- writer.waitForWriteCompleted(timeout);
- }
- for (MementoFileWriter<?> writer : locationWriters.values()) {
- writer.waitForWriteCompleted(timeout);
- }
- for (MementoFileWriter<?> writer : policyWriters.values()) {
- writer.waitForWriteCompleted(timeout);
- }
- for (MementoFileWriter<?> writer : enricherWriters.values()) {
- writer.waitForWriteCompleted(timeout);
- }
- for (MementoFileWriter<?> writer : catalogItemWriters.values()) {
- writer.waitForWriteCompleted(timeout);
- }
- }
-
- // TODO Promote somewhere sensible; share code with BrooklynLauncher.checkPersistenceDirAccessible
- public static void checkDirIsAccessible(File dir) {
- if (!(dir.exists() && dir.isDirectory() && dir.canRead() && dir.canWrite())) {
- throw new IllegalStateException("Invalid directory "+dir+" because "+
- (!dir.exists() ? "does not exist" :
- (!dir.isDirectory() ? "not a directory" :
- (!dir.canRead() ? "not readable" :
- (!dir.canWrite() ? "not writable" : "unknown reason")))));
- }
- }
-
- private String readFile(File file) throws IOException {
- return Files.asCharSource(file, Charsets.UTF_8).read();
- }
-
- private void persist(EntityMemento entity) {
- MementoFileWriter<EntityMemento> writer = entityWriters.get(entity.getId());
- if (writer == null) {
- entityWriters.putIfAbsent(entity.getId(), new MementoFileWriter<EntityMemento>(getFileFor(entity), executor, serializer));
- writer = entityWriters.get(entity.getId());
- }
- writer.write(entity);
- }
-
- private void persist(LocationMemento location) {
- MementoFileWriter<LocationMemento> writer = locationWriters.get(location.getId());
- if (writer == null) {
- locationWriters.putIfAbsent(location.getId(), new MementoFileWriter<LocationMemento>(getFileFor(location), executor, serializer));
- writer = locationWriters.get(location.getId());
- }
- writer.write(location);
- }
-
- private void persist(PolicyMemento policy) {
- MementoFileWriter<PolicyMemento> writer = policyWriters.get(policy.getId());
- if (writer == null) {
- policyWriters.putIfAbsent(policy.getId(), new MementoFileWriter<PolicyMemento>(getFileFor(policy), executor, serializer));
- writer = policyWriters.get(policy.getId());
- }
- writer.write(policy);
- }
-
- private void persist(EnricherMemento enricher) {
- MementoFileWriter<EnricherMemento> writer = enricherWriters.get(enricher.getId());
- if (writer == null) {
- enricherWriters.putIfAbsent(enricher.getId(), new MementoFileWriter<EnricherMemento>(getFileFor(enricher), executor, serializer));
- writer = enricherWriters.get(enricher.getId());
- }
- writer.write(enricher);
- }
-
- private void persist(CatalogItemMemento catalogItem) {
- MementoFileWriter<CatalogItemMemento> writer = catalogItemWriters.get(catalogItem.getId());
- if (writer == null) {
- catalogItemWriters.putIfAbsent(catalogItem.getId(), new MementoFileWriter<CatalogItemMemento>(getFileFor(catalogItem), executor, serializer));
- writer = catalogItemWriters.get(catalogItem.getId());
- }
- writer.write(catalogItem);
- }
-
- private void deleteEntity(String id) {
- MementoFileWriter<EntityMemento> writer = entityWriters.get(id);
- if (writer != null) {
- writer.delete();
- }
- }
-
- private void deleteLocation(String id) {
- MementoFileWriter<LocationMemento> writer = locationWriters.get(id);
- if (writer != null) {
- writer.delete();
- }
- }
-
- private void deletePolicy(String id) {
- MementoFileWriter<PolicyMemento> writer = policyWriters.get(id);
- if (writer != null) {
- writer.delete();
- }
- }
-
- private void deleteEnricher(String id) {
- MementoFileWriter<EnricherMemento> writer = enricherWriters.get(id);
- if (writer != null) {
- writer.delete();
- }
- }
-
- private void deleteCatalogItem(String id) {
- MementoFileWriter<CatalogItemMemento> writer = catalogItemWriters.get(id);
- if (writer != null) {
- writer.delete();
- }
- }
-
- private File getFileFor(EntityMemento entity) {
- return getFileFor(entitiesDir, entity.getId());
- }
-
- private File getFileFor(LocationMemento location) {
- return getFileFor(locationsDir, location.getId());
- }
-
- private File getFileFor(PolicyMemento policy) {
- return getFileFor(policiesDir, policy.getId());
- }
-
- private File getFileFor(EnricherMemento enricher) {
- return getFileFor(enrichersDir, enricher.getId());
- }
-
- private File getFileFor(CatalogItemMemento catalogItem) {
- return getFileFor(catalogItemsDir, catalogItem.getId());
- }
-
- private File getFileFor(File parent, String id) {
- return new File(parent, Strings.makeValidFilename(id));
- }
-
- @Override
- public String getBackingStoreDescription() {
- return toString();
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/358806da/core/src/main/java/brooklyn/entity/rebind/persister/MementoFileWriter.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/brooklyn/entity/rebind/persister/MementoFileWriter.java b/core/src/main/java/brooklyn/entity/rebind/persister/MementoFileWriter.java
deleted file mode 100644
index f6b1a3a..0000000
--- a/core/src/main/java/brooklyn/entity/rebind/persister/MementoFileWriter.java
+++ /dev/null
@@ -1,267 +0,0 @@
-/*
- * 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
- * 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 brooklyn.entity.rebind.persister;
-
-import java.io.File;
-import java.io.IOException;
-import java.util.concurrent.Callable;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.TimeoutException;
-import java.util.concurrent.atomic.AtomicBoolean;
-import java.util.concurrent.atomic.AtomicLong;
-import java.util.concurrent.atomic.AtomicReference;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.google.common.annotations.VisibleForTesting;
-import com.google.common.base.Charsets;
-import com.google.common.base.Objects;
-import com.google.common.base.Stopwatch;
-import com.google.common.io.Files;
-import com.google.common.util.concurrent.ListenableFuture;
-import com.google.common.util.concurrent.ListeningExecutorService;
-import com.google.common.util.concurrent.MoreExecutors;
-
-import brooklyn.util.exceptions.Exceptions;
-import brooklyn.util.time.Duration;
-import brooklyn.util.time.Time;
-
-/**
- * For asynchronously writing to a file.
- *
- * This class is thread-safe. If a write is in progress, one will be scheduled. If a write is already
- * scheduled, we will just rely on the existing one; otherwise we will write now.
- *
- * @author aled
- * @deprecated since 0.7.0; used only by now-deprecated {@link BrooklynMementoPersisterToMultiFile},
- * impl largely moved to {@link FileBasedStoreObjectAccessor}
- */
-@Deprecated
-public class MementoFileWriter<T> {
-
- private static final Logger LOG = LoggerFactory.getLogger(MementoFileWriter.class);
-
- private final File file;
- private final File tmpFile;
- private final ListeningExecutorService executor;
- private final MementoSerializer<? super T> serializer;
- private final AtomicBoolean executing = new AtomicBoolean();
- private final AtomicReference<T> requireWrite = new AtomicReference<T>();
- private final AtomicBoolean requireDelete = new AtomicBoolean();
- private final AtomicBoolean deleted = new AtomicBoolean();
- private final AtomicLong modCount = new AtomicLong();
-
- /**
- * @param file
- * @param executor A sequential executor (e.g. SingleThreadedExecutor, or equivalent)
- * @param serializer
- */
- public MementoFileWriter(File file, ListeningExecutorService executor, MementoSerializer<? super T> serializer) {
- this.file = file;
- this.executor = executor;
- this.serializer = serializer;
- this.tmpFile = new File(file.getParentFile(), file.getName()+".tmp");
- }
-
- public void write(T val) {
- requireWrite.set(val);
- if (requireDelete.get() || deleted.get()) {
- LOG.warn("Not writing {}, because already deleted", file);
- } else if (executing.compareAndSet(false, true)) {
- if (LOG.isTraceEnabled()) LOG.trace("Submitting write task for {}", file);
- writeAsync();
- } else {
- if (LOG.isTraceEnabled()) LOG.trace("Execution already in-progress for {}; recorded write-requirement; returning", file);
- }
- }
-
- public void delete() {
- if (deleted.get() || requireDelete.get()) {
- if (LOG.isDebugEnabled()) LOG.debug("Duplicate call to delete {}; ignoring", file);
- return;
- }
-
- requireWrite.set(null);
- requireDelete.set(true);
- if (executing.compareAndSet(false, true)) {
- if (LOG.isTraceEnabled()) LOG.trace("Submitting delete task for {}", file);
- deleteAsync();
- } else {
- if (LOG.isTraceEnabled()) LOG.trace("Execution already in-progress for {}; recorded delete-requirement; returning", file);
- }
- }
-
- /**
- * This method must only be used for testing. If required in production, then revisit implementation!
- */
- @VisibleForTesting
- public void waitForWriteCompleted(long timeout, TimeUnit unit) throws InterruptedException, TimeoutException {
- waitForWriteCompleted(Duration.of(timeout, unit));
- }
-
- @VisibleForTesting
- public void waitForWriteCompleted(Duration timeout) throws InterruptedException, TimeoutException {
- // Every time we finish writing, we increment a counter. We note the current val, and then
- // wait until we can guarantee that a complete additional write has been done. Not sufficient
- // to wait for `writeCount > origWriteCount` because we might have read the value when it was
- // almost finished a write.
-
- long timeoutMillis = timeout.toMilliseconds();
- long startTime = System.currentTimeMillis();
- long maxEndtime = (timeoutMillis > 0) ? (startTime + timeoutMillis) : (timeoutMillis < 0) ? startTime : Long.MAX_VALUE;
- long origModCount = modCount.get();
- while (true) {
- if (modCount.get() > (origModCount+1)) {
- return;
- } else if (requireWrite.get() != null) {
- // must continue waiting for mods+1
- } else if (executing.get()) {
- // must wait for either this invocation to complete, or mods+1 (because might have already updated)
- } else {
- return;
- }
-
- if (System.currentTimeMillis() > maxEndtime) {
- throw new TimeoutException("Timeout waiting for pending complete of rebind-periodic-delta, after "+Time.makeTimeStringRounded(timeout));
- }
- Thread.sleep(10);
- }
- }
-
- private void deleteAsync() {
- ListenableFuture<Void> future = executor.submit(new Callable<Void>() {
- @Override public Void call() throws IOException {
- try {
- deleteNow();
- return null;
- } catch (Throwable t) {
- if (executor.isShutdown()) {
- LOG.debug("Error deleting "+file+" (but executor shutdown)", t);
- return null; // just return without throwing; no more work to do
- } else {
- LOG.error("Error deleting "+file, t);
- throw Exceptions.propagate(t);
- }
- }
- }});
- addPostExecListener(future);
- }
-
- private void writeAsync() {
- ListenableFuture<Void> future = executor.submit(new Callable<Void>() {
- @Override public Void call() throws IOException {
- try {
- writeNow();
- return null;
- } catch (Throwable t) {
- if (executor.isShutdown()) {
- LOG.debug("Error writing to "+file+" (but executor shutdown)", t);
- return null; // just return without throwing; no more work to do
- } else {
- LOG.error("Error writing to "+file, t);
- throw Exceptions.propagate(t);
- }
- }
- }});
- addPostExecListener(future);
- }
-
- private void addPostExecListener(ListenableFuture<?> future) {
- future.addListener(
- new Runnable() {
- @Override public void run() {
- if (LOG.isTraceEnabled()) LOG.trace("Write complete for {}", file);
- try {
- executing.set(false);
- if (requireDelete.get()) {
- if (executing.compareAndSet(false, true)) {
- if (LOG.isTraceEnabled()) LOG.trace("Submitting delete-task for {} (in post-exec) due to recorded delete-requirement", file);
- deleteAsync();
- } else {
- if (LOG.isTraceEnabled()) LOG.trace("Delete-requirement for {} (in post-exec) handled by other thread; returning", file);
- }
-
- } else if (requireWrite.get() != null) {
- if (executing.compareAndSet(false, true)) {
- if (LOG.isTraceEnabled()) LOG.trace("Submitting write task for {} (in post-exec) due to recorded write-requirement", file);
- writeAsync();
- } else {
- if (LOG.isTraceEnabled()) LOG.trace("Write-requirement for {} (in post-exec) handled by other thread; returning", file);
- }
- } else {
- if (LOG.isTraceEnabled()) LOG.trace("No pending exec-requirements for {}", file);
- }
- } catch (Throwable t) {
- if (executor.isShutdown()) {
- LOG.debug("Error in post-exec for "+file+" (but executor shutdown)", t);
- return; // just return without throwing; no more work to do
- } else {
- LOG.error("Error in post-exec for "+file, t);
- throw Exceptions.propagate(t);
- }
- }
- }
- },
- MoreExecutors.sameThreadExecutor());
- }
-
- private void writeNow() throws IOException {
- T val = requireWrite.getAndSet(null);
-
- /*
- * Need to guarantee "happens before", with any thread that has written
- * fields of these mementos. In particular, saw failures where SshMachineLocation
- * had null address field. Our hypothesis is that another thread wrote the memento,
- * but that no synchronization subsequently happened so we did not see all the values
- * in that memento from this thread.
- *
- * See PeriodicDeltaChangeListener.persistNow for the corresponding synchronization,
- * that guarantees its thread made the writes visible.
- */
- synchronized (new Object()) {}
-
- Stopwatch stopwatch = Stopwatch.createStarted();
-
- // Write to the temp file, then atomically move it to the permanent file location
- Files.write(serializer.toString(val), tmpFile, Charsets.UTF_8);
- Files.move(tmpFile, file);
-
- modCount.incrementAndGet();
-
- if (LOG.isTraceEnabled()) LOG.trace("Wrote {}, took {}; modified file {} times",
- new Object[] {file, Time.makeTimeStringRounded(stopwatch), modCount});
- }
-
- private void deleteNow() throws IOException {
- if (LOG.isTraceEnabled()) LOG.trace("Deleting {} and {}", file, tmpFile);
- deleted.set(true);
- requireDelete.set(false);
-
- file.delete();
- tmpFile.delete();
-
- modCount.incrementAndGet();
- }
-
- @Override
- public String toString() {
- return Objects.toStringHelper(this).add("file", file).toString();
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/358806da/core/src/main/java/brooklyn/entity/rebind/persister/MementoFileWriterSync.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/brooklyn/entity/rebind/persister/MementoFileWriterSync.java b/core/src/main/java/brooklyn/entity/rebind/persister/MementoFileWriterSync.java
deleted file mode 100644
index ea49111..0000000
--- a/core/src/main/java/brooklyn/entity/rebind/persister/MementoFileWriterSync.java
+++ /dev/null
@@ -1,159 +0,0 @@
-/*
- * 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
- * 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 brooklyn.entity.rebind.persister;
-
-import java.io.File;
-import java.io.IOException;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.TimeoutException;
-import java.util.concurrent.atomic.AtomicLong;
-import java.util.concurrent.locks.ReadWriteLock;
-import java.util.concurrent.locks.ReentrantReadWriteLock;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import brooklyn.util.exceptions.Exceptions;
-import brooklyn.util.time.Duration;
-import brooklyn.util.time.Time;
-
-import com.google.common.annotations.VisibleForTesting;
-import com.google.common.base.Charsets;
-import com.google.common.base.Objects;
-import com.google.common.base.Stopwatch;
-import com.google.common.io.Files;
-
-/**
- * For synchronously writing to a file - all calls block.
- *
- * This class is thread-safe. If a write/delete/append is in progress, then subsequent calls will
- * block.
- *
- * @author aled
- * @deprecated since 0.7.0 we use {@link PersistenceObjectStore} instances now, and when we need sync behaviour we just wait
- */
-@Deprecated
-public class MementoFileWriterSync<T> {
-
- private static final Logger LOG = LoggerFactory.getLogger(MementoFileWriterSync.class);
-
- private final ReadWriteLock lock = new ReentrantReadWriteLock();
- private final File file;
- private final File tmpFile;
- private final MementoSerializer<? super T> serializer;
- private final AtomicLong modCount = new AtomicLong();
-
- /**
- * @param file
- * @param serializer
- */
- public MementoFileWriterSync(File file, MementoSerializer<? super T> serializer) {
- this(file, serializer, "tmp");
- }
-
- public MementoFileWriterSync(File file, MementoSerializer<? super T> serializer, String tmpFileSuffix) {
- this.file = file;
- this.serializer = serializer;
- this.tmpFile = new File(file.getParentFile(), file.getName()+"."+tmpFileSuffix);
- }
-
- public boolean exists() {
- return file.exists();
- }
-
- public void write(T val) {
- try {
- lock.writeLock().lockInterruptibly();
- } catch (InterruptedException e) {
- throw Exceptions.propagate(e);
- }
- try {
- Stopwatch stopwatch = Stopwatch.createStarted();
-
- // Write to the temp file, then atomically move it to the permanent file location
- Files.write(serializer.toString(val), tmpFile, Charsets.UTF_8);
- Files.move(tmpFile, file);
- modCount.incrementAndGet();
-
- if (LOG.isTraceEnabled()) LOG.trace("Wrote {}, took {}; modified file {} times",
- new Object[] {file, Time.makeTimeStringRounded(stopwatch), modCount});
- } catch (IOException e) {
- throw Exceptions.propagate(e);
- } finally {
- lock.writeLock().unlock();
- }
- }
-
- public void append(T val) {
- try {
- lock.writeLock().lockInterruptibly();
- } catch (InterruptedException e) {
- throw Exceptions.propagate(e);
- }
- try {
- Stopwatch stopwatch = Stopwatch.createStarted();
-
- // Write to the temp file, then atomically move it to the permanent file location
- Files.append(serializer.toString(val), file, Charsets.UTF_8);
- modCount.incrementAndGet();
-
- if (LOG.isTraceEnabled()) LOG.trace("Wrote {}, took {}; modified file {} times",
- new Object[] {file, Time.makeTimeStringRounded(stopwatch), modCount});
- } catch (IOException e) {
- throw Exceptions.propagate(e);
- } finally {
- lock.writeLock().unlock();
- }
- }
-
- public void delete() {
- try {
- lock.writeLock().lockInterruptibly();
- } catch (InterruptedException e) {
- throw Exceptions.propagate(e);
- }
- try {
- Stopwatch stopwatch = Stopwatch.createStarted();
-
- file.delete();
- tmpFile.delete();
- modCount.incrementAndGet();
-
- if (LOG.isTraceEnabled()) LOG.trace("Deleted {}, took {}; modified file {} times",
- new Object[] {file, Time.makeTimeStringRounded(stopwatch), modCount});
- } finally {
- lock.writeLock().unlock();
- }
- }
-
- @VisibleForTesting
- public void waitForWriteCompleted(Duration timeout) throws InterruptedException, TimeoutException {
- boolean locked = lock.writeLock().tryLock(timeout.toMilliseconds(), TimeUnit.MILLISECONDS);
- if (locked) {
- lock.writeLock().unlock();
- } else {
- throw new TimeoutException("Timeout waiting for lock on "+file);
- }
- }
-
- @Override
- public String toString() {
- return Objects.toStringHelper(this).add("file", file).toString();
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/358806da/core/src/main/java/brooklyn/management/ha/ManagementPlaneSyncRecordPersisterToMultiFile.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/brooklyn/management/ha/ManagementPlaneSyncRecordPersisterToMultiFile.java b/core/src/main/java/brooklyn/management/ha/ManagementPlaneSyncRecordPersisterToMultiFile.java
deleted file mode 100644
index fcade26..0000000
--- a/core/src/main/java/brooklyn/management/ha/ManagementPlaneSyncRecordPersisterToMultiFile.java
+++ /dev/null
@@ -1,280 +0,0 @@
-/*
- * 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
- * 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 brooklyn.management.ha;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-
-import java.io.File;
-import java.io.FileFilter;
-import java.io.IOException;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.ConcurrentMap;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.TimeoutException;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import brooklyn.entity.rebind.persister.BrooklynMementoPersisterToMultiFile;
-import brooklyn.entity.rebind.persister.FileBasedStoreObjectAccessor;
-import brooklyn.entity.rebind.persister.MementoFileWriterSync;
-import brooklyn.entity.rebind.persister.MementoSerializer;
-import brooklyn.entity.rebind.persister.RetryingMementoSerializer;
-import brooklyn.entity.rebind.persister.XmlMementoSerializer;
-import brooklyn.entity.rebind.plane.dto.ManagementPlaneSyncRecordImpl;
-import brooklyn.util.exceptions.Exceptions;
-import brooklyn.util.time.Duration;
-import brooklyn.util.time.Time;
-
-import com.google.common.annotations.Beta;
-import com.google.common.annotations.VisibleForTesting;
-import com.google.common.base.Charsets;
-import com.google.common.base.Stopwatch;
-import com.google.common.io.Files;
-
-/**
- * Structure of files is:
- * <ul>
- * <li>{@code plane/} - top-level directory
- * <ul>
- * <li>{@code master} - contains the id of the management-node that is currently master
- * <li>{@code change.log} - log of changes made
- * <li>{@code nodes/} - sub-directory, containing one file per management-node
- * <ul>
- * <li>{@code a9WiuVKp} - file named after the management-node's id, containing the management node's current state
- * <li>{@code E1eDXQF3}
- * </ul>
- * </ul>
- * </ul>
- *
- * All writes are done synchronously.
- *
- * @since 0.7.0
- *
- * @author aled
- * @deprecated since 0.7.0 use {@link ManagementPlaneSyncRecordPersisterToObjectStore} e.g. with {@link FileBasedStoreObjectAccessor}
- */
-@Beta
-@Deprecated
-public class ManagementPlaneSyncRecordPersisterToMultiFile implements ManagementPlaneSyncRecordPersister {
-
- // TODO Multiple node appending to change.log could cause strange interleaving, or perhaps even data loss?
- // But this file is not critical to functionality.
-
- // TODO Should ManagementPlaneSyncRecordPersister.Delta be different so can tell what is a significant event,
- // and thus log it in change.log - currently only subset of significant things being logged.
-
- private static final Logger LOG = LoggerFactory.getLogger(ManagementPlaneSyncRecordPersisterToMultiFile.class);
-
- private static final Duration SHUTDOWN_TIMEOUT = Duration.TEN_SECONDS;
-
- private final String tmpSuffix;
- private final File dir;
- private final File nodesDir;
-
- // TODO Leak if we go through lots of managers; but tiny!
- private final ConcurrentMap<String, MementoFileWriterSync<ManagementNodeSyncRecord>> nodeWriters = new ConcurrentHashMap<String, MementoFileWriterSync<ManagementNodeSyncRecord>>();
-
- private final MementoFileWriterSync<String> masterWriter;
-
- private final MementoFileWriterSync<String> changeLogWriter;
-
- private final MementoSerializer<Object> serializer;
-
- private static final int MAX_SERIALIZATION_ATTEMPTS = 5;
-
- private volatile boolean running = true;
-
- /**
- * @param dir Directory to write management-plane data
- * @param classLoader ClassLoader to use when deserializing data
- * @param id Unique identifier, e.g. used for temp file suffix in case multpile concurrent writers
- */
- public ManagementPlaneSyncRecordPersisterToMultiFile(File dir, ClassLoader classLoader, String id) {
- this.dir = checkNotNull(dir, "dir");
- MementoSerializer<Object> rawSerializer = new XmlMementoSerializer<Object>(checkNotNull(classLoader, "classLoader"));
- this.serializer = new RetryingMementoSerializer<Object>(rawSerializer, MAX_SERIALIZATION_ATTEMPTS);
- this.tmpSuffix = checkNotNull(id, "id")+".tmp"; // important to end in .tmp for loadMemento's file filter
-
- BrooklynMementoPersisterToMultiFile.checkDirIsAccessible(dir);
-
- nodesDir = new File(dir, "nodes");
- nodesDir.mkdir();
- BrooklynMementoPersisterToMultiFile.checkDirIsAccessible(nodesDir);
-
- masterWriter = new MementoFileWriterSync<String>(getFileForMaster(), serializer, tmpSuffix);
- changeLogWriter = new MementoFileWriterSync<String>(getFileForChangeLog(), MementoSerializer.NOOP, tmpSuffix);
-
- LOG.info("ManagementPlaneMemento-persister will use directory {}", dir);
- }
-
- @Override
- public void stop() {
- running = false;
- try {
- for (MementoFileWriterSync<?> writer : nodeWriters.values()) {
- try {
- writer.waitForWriteCompleted(SHUTDOWN_TIMEOUT);
- } catch (TimeoutException e) {
- LOG.warn("Timeout during shutdown, waiting for write of "+writer+"; continuing");
- }
- }
- try {
- masterWriter.waitForWriteCompleted(SHUTDOWN_TIMEOUT);
- } catch (TimeoutException e) {
- LOG.warn("Timeout during shutdown, waiting for write of "+masterWriter+"; continuing");
- }
- } catch (InterruptedException e) {
- throw Exceptions.propagate(e);
- }
- }
-
- @VisibleForTesting
- public File getDir() {
- return dir;
- }
-
- @Override
- public ManagementPlaneSyncRecord loadSyncRecord() throws IOException {
- if (!running) {
- throw new IllegalStateException("Persister not running; cannot load memento from "+dir);
- }
-
- // Note this is called a lot - every time we check the heartbeats
- if (LOG.isTraceEnabled()) LOG.trace("Loading management-plane memento from {}", dir);
-
- Stopwatch stopwatch = Stopwatch.createStarted();
-
- ManagementPlaneSyncRecordImpl.Builder builder = ManagementPlaneSyncRecordImpl.builder();
-
- // Be careful about order: if the master-file says nodeX then nodeX's file must have an up-to-date timestamp.
- // Therefore read master file first, followed by the other node-files.
- File masterFile = getFileForMaster();
- String masterNodeId = (String) (masterFile.exists() ? serializer.fromString(readFile(masterFile)) : null);
- if (masterNodeId == null) {
- LOG.warn("No entity-memento deserialized from file "+masterFile+"; ignoring and continuing");
- } else {
- builder.masterNodeId(masterNodeId);
- }
-
- // Load node-files
- FileFilter fileFilter = new FileFilter() {
- @Override public boolean accept(File file) {
- return !file.getName().endsWith(".tmp");
- }
- };
- File[] nodeFiles = nodesDir.listFiles(fileFilter);
-
- for (File file : nodeFiles) {
- ManagementNodeSyncRecord memento = (ManagementNodeSyncRecord) serializer.fromString(readFile(file));
- if (memento == null) {
- LOG.warn("No manager-memento deserialized from file "+file+" (possibly just stopped?); ignoring and continuing");
- } else {
- builder.node(memento);
- }
- }
-
- if (LOG.isTraceEnabled()) LOG.trace("Loaded management-plane memento; took {}", Time.makeTimeStringRounded(stopwatch.elapsed(TimeUnit.MILLISECONDS)));
- return builder.build();
- }
-
- @Override
- public void delta(Delta delta) {
- if (!running) {
- if (LOG.isDebugEnabled()) LOG.debug("Persister not running; ignoring checkpointed delta of manager-memento");
- return;
- }
- if (LOG.isTraceEnabled()) LOG.trace("Checkpointed delta of manager-memento; updating {}", delta);
-
- for (ManagementNodeSyncRecord m : delta.getNodes()) {
- persist(m);
- }
- for (String id : delta.getRemovedNodeIds()) {
- deleteNode(id);
- }
- switch (delta.getMasterChange()) {
- case NO_CHANGE:
- break; // no-op
- case SET_MASTER:
- persistMaster(checkNotNull(delta.getNewMasterOrNull()));
- break;
- case CLEAR_MASTER:
- persistMaster(null);
- break; // no-op
- default:
- throw new IllegalStateException("Unknown state for master-change: "+delta.getMasterChange());
- }
- }
-
- private void persistMaster(String nodeId) {
- masterWriter.write(nodeId);
- changeLogWriter.append(Time.makeDateString()+": set master to "+nodeId+"\n");
- }
-
- @Override
- @VisibleForTesting
- public void waitForWritesCompleted(Duration timeout) throws InterruptedException, TimeoutException {
- for (MementoFileWriterSync<?> writer : nodeWriters.values()) {
- writer.waitForWriteCompleted(timeout);
- }
- masterWriter.waitForWriteCompleted(timeout);
- }
-
- private String readFile(File file) throws IOException {
- return Files.asCharSource(file, Charsets.UTF_8).read();
- }
-
- private void persist(ManagementNodeSyncRecord node) {
- MementoFileWriterSync<ManagementNodeSyncRecord> writer = getOrCreateNodeWriter(node.getNodeId());
- boolean fileExists = writer.exists();
- writer.write(node);
- if (!fileExists) {
- changeLogWriter.append(Time.makeDateString()+": created node "+node.getNodeId()+"\n");
- }
- if (node.getStatus() == ManagementNodeState.TERMINATED || node.getStatus() == ManagementNodeState.FAILED) {
- changeLogWriter.append(Time.makeDateString()+": set node "+node.getNodeId()+" status to "+node.getStatus()+"\n");
- }
- }
-
- private void deleteNode(String nodeId) {
- getOrCreateNodeWriter(nodeId).delete();
- changeLogWriter.append(Time.makeDateString()+": deleted node "+nodeId+"\n");
- }
-
- private MementoFileWriterSync<ManagementNodeSyncRecord> getOrCreateNodeWriter(String nodeId) {
- MementoFileWriterSync<ManagementNodeSyncRecord> writer = nodeWriters.get(nodeId);
- if (writer == null) {
- nodeWriters.putIfAbsent(nodeId, new MementoFileWriterSync<ManagementNodeSyncRecord>(getFileForNode(nodeId), serializer, tmpSuffix));
- writer = nodeWriters.get(nodeId);
- }
- return writer;
- }
-
- private File getFileForNode(String nodeId) {
- return new File(nodesDir, nodeId);
- }
-
- private File getFileForMaster() {
- return new File(dir, "master");
- }
-
- private File getFileForChangeLog() {
- return new File(dir, "change.log");
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/358806da/core/src/test/java/brooklyn/entity/rebind/persister/BrooklynMementoPersisterToMultiFileTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/brooklyn/entity/rebind/persister/BrooklynMementoPersisterToMultiFileTest.java b/core/src/test/java/brooklyn/entity/rebind/persister/BrooklynMementoPersisterToMultiFileTest.java
deleted file mode 100644
index 6dc9aa1a..0000000
--- a/core/src/test/java/brooklyn/entity/rebind/persister/BrooklynMementoPersisterToMultiFileTest.java
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- * 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
- * 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 brooklyn.entity.rebind.persister;
-
-import java.io.File;
-
-import org.testng.annotations.AfterMethod;
-import org.testng.annotations.Test;
-
-import brooklyn.entity.rebind.PersistenceExceptionHandlerImpl;
-import brooklyn.entity.rebind.RebindManagerImpl;
-import brooklyn.management.internal.LocalManagementContext;
-import brooklyn.test.entity.LocalManagementContextForTests;
-import brooklyn.util.javalang.JavaClassNames;
-import brooklyn.util.os.Os;
-import brooklyn.util.time.Duration;
-
-/**
- * @author Andrea Turli
- * @deprecated just tests the deprecated {@link BrooklynMementoPersisterToMultiFile}
- */
-public class BrooklynMementoPersisterToMultiFileTest extends BrooklynMementoPersisterTestFixture {
-
- protected File mementoDir;
-
- @Override
- protected LocalManagementContext newPersistingManagementContext() {
- mementoDir = Os.newTempDir(JavaClassNames.cleanSimpleClassName(this));
- Os.deleteOnExitRecursively(mementoDir);
-
- LocalManagementContext mgmt = new LocalManagementContextForTests();
- ((RebindManagerImpl) mgmt.getRebindManager()).setPeriodicPersistPeriod(Duration.millis(100));
- persister = new BrooklynMementoPersisterToMultiFile(mementoDir, BrooklynMementoPersisterToMultiFileTest.class.getClassLoader());
- mgmt.getRebindManager().setPersister(persister, PersistenceExceptionHandlerImpl.builder().build());
- mgmt.getHighAvailabilityManager().disabled();
- mgmt.getRebindManager().startPersistence();
- return mgmt;
- }
-
- @AfterMethod(alwaysRun=true)
- public void tearDown() throws Exception {
- super.tearDown();
- mementoDir = Os.deleteRecursively(mementoDir).asNullOrThrowing();
- }
-
- @Test(groups="Integration")
- public void testLoadAndCheckpointRawMemento() throws Exception {
- // test here is deliberately no-op;
- // checkpoint routines not supported for this (deprecated) persister
- }
-
-}
[08/21] incubator-brooklyn git commit: Delete deprecated Feed.isActive
Posted by ha...@apache.org.
Delete deprecated Feed.isActive
Project: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/commit/29cbd0f6
Tree: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/tree/29cbd0f6
Diff: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/diff/29cbd0f6
Branch: refs/heads/master
Commit: 29cbd0f6a32ee37e6ebe738d50db8e3e68e2bb8a
Parents: 1b3dc15
Author: Aled Sage <al...@gmail.com>
Authored: Tue Jul 28 22:46:28 2015 +0100
Committer: Aled Sage <al...@gmail.com>
Committed: Sat Aug 1 00:13:31 2015 +0100
----------------------------------------------------------------------
api/src/main/java/brooklyn/entity/Feed.java | 6 ------
core/src/main/java/brooklyn/event/feed/AbstractFeed.java | 5 -----
2 files changed, 11 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/29cbd0f6/api/src/main/java/brooklyn/entity/Feed.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/brooklyn/entity/Feed.java b/api/src/main/java/brooklyn/entity/Feed.java
index 029ed78..a708bdc 100644
--- a/api/src/main/java/brooklyn/entity/Feed.java
+++ b/api/src/main/java/brooklyn/entity/Feed.java
@@ -47,12 +47,6 @@ public interface Feed extends EntityAdjunct, Rebindable {
*/
boolean isActivated();
- /**
- * @return true iff the feed is actually running (like {@link #isActivated()}, but including other items like poll jobs not cancelled)
- * @deprecated since 0.7.0 use {@link #isRunning()}
- */ @Deprecated
- boolean isActive();
-
void start();
/** suspends this feed (stops the poller, or indicates that the feed should start in a state where the poller is stopped) */
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/29cbd0f6/core/src/main/java/brooklyn/event/feed/AbstractFeed.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/brooklyn/event/feed/AbstractFeed.java b/core/src/main/java/brooklyn/event/feed/AbstractFeed.java
index d487a9a..58cab2a 100644
--- a/core/src/main/java/brooklyn/event/feed/AbstractFeed.java
+++ b/core/src/main/java/brooklyn/event/feed/AbstractFeed.java
@@ -181,11 +181,6 @@ public abstract class AbstractFeed extends AbstractEntityAdjunct implements Feed
return activated;
}
- @Override
- public boolean isActive() {
- return isRunning();
- }
-
public EntityLocal getEntity() {
return entity;
}
[12/21] incubator-brooklyn git commit: Move deprecated
SimulatedLocation to src/test/java
Posted by ha...@apache.org.
Move deprecated SimulatedLocation to src/test/java
Project: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/commit/b53a79ac
Tree: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/tree/b53a79ac
Diff: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/diff/b53a79ac
Branch: refs/heads/master
Commit: b53a79aca5c3170d288302865e639b1d939c0ce6
Parents: 5c1015f
Author: Aled Sage <al...@gmail.com>
Authored: Tue Jul 28 22:56:38 2015 +0100
Committer: Aled Sage <al...@gmail.com>
Committed: Sat Aug 1 00:13:32 2015 +0100
----------------------------------------------------------------------
.../location/basic/SimulatedLocation.java | 138 -------------------
.../location/basic/SimulatedLocation.java | 136 ++++++++++++++++++
2 files changed, 136 insertions(+), 138 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/b53a79ac/core/src/main/java/brooklyn/location/basic/SimulatedLocation.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/brooklyn/location/basic/SimulatedLocation.java b/core/src/main/java/brooklyn/location/basic/SimulatedLocation.java
deleted file mode 100644
index 05d39ce..0000000
--- a/core/src/main/java/brooklyn/location/basic/SimulatedLocation.java
+++ /dev/null
@@ -1,138 +0,0 @@
-/*
- * 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
- * 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 brooklyn.location.basic;
-
-import java.net.InetAddress;
-import java.util.Collection;
-import java.util.Map;
-import java.util.Set;
-
-import brooklyn.location.HardwareDetails;
-import brooklyn.location.LocationSpec;
-import brooklyn.location.MachineDetails;
-import brooklyn.location.MachineLocation;
-import brooklyn.location.MachineProvisioningLocation;
-import brooklyn.location.OsDetails;
-import brooklyn.location.PortRange;
-import brooklyn.location.PortSupplier;
-import brooklyn.util.collections.MutableMap;
-import brooklyn.util.net.Networking;
-
-import com.google.common.collect.ImmutableSet;
-import com.google.common.collect.Iterables;
-import com.google.common.collect.Sets;
-
-
-/** Location for use in dev/test, defining custom start/stop support, and/or tweaking the ports which are permitted to be available
- * (using setPermittedPorts(Iterable))
- *
- * @deprecated since 0.7.0; will be moved to src/test/java
- */
-public class SimulatedLocation extends AbstractLocation implements MachineProvisioningLocation<MachineLocation>, MachineLocation, PortSupplier {
-
- private static final long serialVersionUID = 1L;
-
- private static final InetAddress address;
- static {
- address = Networking.getLocalHost();
- }
-
- Iterable<Integer> permittedPorts = PortRanges.fromString("1+");
- Set<Integer> usedPorts = Sets.newLinkedHashSet();
-
- public SimulatedLocation() {
- this(MutableMap.<String,Object>of());
- }
- public SimulatedLocation(Map<String,? extends Object> flags) {
- super(flags);
- }
-
- @Override
- public SimulatedLocation newSubLocation(Map<?,?> newFlags) {
- // TODO shouldn't have to copy config bag as it should be inherited (but currently it is not used inherited everywhere; just most places)
- return getManagementContext().getLocationManager().createLocation(LocationSpec.create(getClass())
- .parent(this)
- .configure(config().getLocalBag().getAllConfig()) // FIXME Should this just be inherited?
- .configure(newFlags));
- }
-
- public MachineLocation obtain(Map<?,?> flags) {
- return this;
- }
-
- public void release(MachineLocation machine) {
- }
-
- public Map<String,Object> getProvisioningFlags(Collection<String> tags) {
- return MutableMap.<String,Object>of();
- }
-
- public InetAddress getAddress() {
- return address;
- }
-
- @Override
- public String getHostname() {
- String hostname = address.getHostName();
- return (hostname == null || hostname.equals(address.getHostAddress())) ? null : hostname;
- }
-
- @Override
- public Set<String> getPublicAddresses() {
- return ImmutableSet.of(address.getHostAddress());
- }
-
- @Override
- public Set<String> getPrivateAddresses() {
- return ImmutableSet.of();
- }
-
- public synchronized boolean obtainSpecificPort(int portNumber) {
- if (!Iterables.contains(permittedPorts, portNumber)) return false;
- if (usedPorts.contains(portNumber)) return false;
- usedPorts.add(portNumber);
- return true;
- }
-
- public synchronized int obtainPort(PortRange range) {
- for (int p: range)
- if (obtainSpecificPort(p)) return p;
- return -1;
- }
-
- public synchronized void releasePort(int portNumber) {
- usedPorts.remove(portNumber);
- }
-
- public synchronized void setPermittedPorts(Iterable<Integer> ports) {
- permittedPorts = ports;
- }
-
- @Override
- public OsDetails getOsDetails() {
- return getMachineDetails().getOsDetails();
- }
-
- @Override
- public MachineDetails getMachineDetails() {
- HardwareDetails hardwareDetails = new BasicHardwareDetails(null, null);
- OsDetails osDetails = BasicOsDetails.Factory.ANONYMOUS_LINUX;
- return new BasicMachineDetails(hardwareDetails, osDetails);
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/b53a79ac/core/src/test/java/brooklyn/location/basic/SimulatedLocation.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/brooklyn/location/basic/SimulatedLocation.java b/core/src/test/java/brooklyn/location/basic/SimulatedLocation.java
new file mode 100644
index 0000000..83d5455
--- /dev/null
+++ b/core/src/test/java/brooklyn/location/basic/SimulatedLocation.java
@@ -0,0 +1,136 @@
+/*
+ * 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
+ * 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 brooklyn.location.basic;
+
+import java.net.InetAddress;
+import java.util.Collection;
+import java.util.Map;
+import java.util.Set;
+
+import brooklyn.location.HardwareDetails;
+import brooklyn.location.LocationSpec;
+import brooklyn.location.MachineDetails;
+import brooklyn.location.MachineLocation;
+import brooklyn.location.MachineProvisioningLocation;
+import brooklyn.location.OsDetails;
+import brooklyn.location.PortRange;
+import brooklyn.location.PortSupplier;
+import brooklyn.util.collections.MutableMap;
+import brooklyn.util.net.Networking;
+
+import com.google.common.collect.ImmutableSet;
+import com.google.common.collect.Iterables;
+import com.google.common.collect.Sets;
+
+
+/** Location for use in dev/test, defining custom start/stop support, and/or tweaking the ports which are permitted to be available
+ * (using setPermittedPorts(Iterable))
+ */
+public class SimulatedLocation extends AbstractLocation implements MachineProvisioningLocation<MachineLocation>, MachineLocation, PortSupplier {
+
+ private static final long serialVersionUID = 1L;
+
+ private static final InetAddress address;
+ static {
+ address = Networking.getLocalHost();
+ }
+
+ Iterable<Integer> permittedPorts = PortRanges.fromString("1+");
+ Set<Integer> usedPorts = Sets.newLinkedHashSet();
+
+ public SimulatedLocation() {
+ this(MutableMap.<String,Object>of());
+ }
+ public SimulatedLocation(Map<String,? extends Object> flags) {
+ super(flags);
+ }
+
+ @Override
+ public SimulatedLocation newSubLocation(Map<?,?> newFlags) {
+ // TODO shouldn't have to copy config bag as it should be inherited (but currently it is not used inherited everywhere; just most places)
+ return getManagementContext().getLocationManager().createLocation(LocationSpec.create(getClass())
+ .parent(this)
+ .configure(config().getLocalBag().getAllConfig()) // FIXME Should this just be inherited?
+ .configure(newFlags));
+ }
+
+ public MachineLocation obtain(Map<?,?> flags) {
+ return this;
+ }
+
+ public void release(MachineLocation machine) {
+ }
+
+ public Map<String,Object> getProvisioningFlags(Collection<String> tags) {
+ return MutableMap.<String,Object>of();
+ }
+
+ public InetAddress getAddress() {
+ return address;
+ }
+
+ @Override
+ public String getHostname() {
+ String hostname = address.getHostName();
+ return (hostname == null || hostname.equals(address.getHostAddress())) ? null : hostname;
+ }
+
+ @Override
+ public Set<String> getPublicAddresses() {
+ return ImmutableSet.of(address.getHostAddress());
+ }
+
+ @Override
+ public Set<String> getPrivateAddresses() {
+ return ImmutableSet.of();
+ }
+
+ public synchronized boolean obtainSpecificPort(int portNumber) {
+ if (!Iterables.contains(permittedPorts, portNumber)) return false;
+ if (usedPorts.contains(portNumber)) return false;
+ usedPorts.add(portNumber);
+ return true;
+ }
+
+ public synchronized int obtainPort(PortRange range) {
+ for (int p: range)
+ if (obtainSpecificPort(p)) return p;
+ return -1;
+ }
+
+ public synchronized void releasePort(int portNumber) {
+ usedPorts.remove(portNumber);
+ }
+
+ public synchronized void setPermittedPorts(Iterable<Integer> ports) {
+ permittedPorts = ports;
+ }
+
+ @Override
+ public OsDetails getOsDetails() {
+ return getMachineDetails().getOsDetails();
+ }
+
+ @Override
+ public MachineDetails getMachineDetails() {
+ HardwareDetails hardwareDetails = new BasicHardwareDetails(null, null);
+ OsDetails osDetails = BasicOsDetails.Factory.ANONYMOUS_LINUX;
+ return new BasicMachineDetails(hardwareDetails, osDetails);
+ }
+}
[10/21] incubator-brooklyn git commit: Delete deprecated memento
persisters
Posted by ha...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/358806da/core/src/test/java/brooklyn/entity/rebind/persister/MementoFileWriterSyncTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/brooklyn/entity/rebind/persister/MementoFileWriterSyncTest.java b/core/src/test/java/brooklyn/entity/rebind/persister/MementoFileWriterSyncTest.java
deleted file mode 100644
index 62b9f38..0000000
--- a/core/src/test/java/brooklyn/entity/rebind/persister/MementoFileWriterSyncTest.java
+++ /dev/null
@@ -1,128 +0,0 @@
-/*
- * 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
- * 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 brooklyn.entity.rebind.persister;
-
-import static org.testng.Assert.assertEquals;
-import static org.testng.Assert.assertFalse;
-import static org.testng.Assert.assertTrue;
-
-import java.io.File;
-
-import org.testng.annotations.AfterMethod;
-import org.testng.annotations.BeforeMethod;
-import org.testng.annotations.Test;
-
-import brooklyn.mementos.BrooklynMementoPersister.LookupContext;
-import brooklyn.util.javalang.JavaClassNames;
-import brooklyn.util.os.Os;
-import brooklyn.util.text.Identifiers;
-
-import com.google.common.base.Charsets;
-import com.google.common.io.Files;
-
-public class MementoFileWriterSyncTest {
-
- private File file;
- private File dir;
- private MementoSerializer<String> serializer;
- private MementoFileWriterSync<String> writer;
-
-
- @BeforeMethod(alwaysRun=true)
- public void setUp() throws Exception {
- dir = Os.newTempDir(JavaClassNames.cleanSimpleClassName(this));
- file = Os.newTempFile(getClass(), "txt");
- serializer = new MementoSerializer<String>() {
- @Override public String toString(String memento) {
- return memento;
- }
- @Override public String fromString(String string) {
- return string;
- }
- @Override public void setLookupContext(LookupContext lookupContext) {
- }
- @Override public void unsetLookupContext() {
- }
- };
- writer = new MementoFileWriterSync<String>(file, serializer);
- }
-
- @AfterMethod(alwaysRun=true)
- public void tearDown() throws Exception {
- if (file != null) file.delete();
- dir = Os.deleteRecursively(dir).asNullOrThrowing();
- }
-
- @Test
- public void testWritesFile() throws Exception {
- writer.write("abc");
-
- String fromfile = Files.asCharSource(file, Charsets.UTF_8).read();
- assertEquals(fromfile, "abc");
- }
-
- @Test
- public void testWritesFileEvenIfDoesNotExist() throws Exception {
- File newFile = new File(dir, "mementoFileWriterSyncTest-"+Identifiers.makeRandomId(4)+".txt");
- writer = new MementoFileWriterSync<String>(newFile, serializer);
- writer.write("abc");
-
- String fromfile = Files.asCharSource(newFile, Charsets.UTF_8).read();
- assertEquals(fromfile, "abc");
- }
-
- @Test
- public void testExists() throws Exception {
- File newFile = new File(dir, "mementoFileWriterSyncTest-"+Identifiers.makeRandomId(4)+".txt");
- writer = new MementoFileWriterSync<String>(newFile, serializer);
- assertFalse(writer.exists());
-
- writer.write("abc");
- assertTrue(writer.exists());
- }
-
- @Test
- public void testDeletesFile() throws Exception {
- writer.delete();
- assertFalse(file.exists());
- }
-
- @Test
- public void testAppendsFile() throws Exception {
- writer.append("abc\n");
- writer.append("def\n");
-
- String fromfile = Files.asCharSource(file, Charsets.UTF_8).read();
- assertEquals(fromfile, "abc\ndef\n");
- }
-
- @Test
- public void testWriteBacklogThenDeleteWillLeaveFileDeleted() throws Exception {
- String big = makeBigString(100000);
-
- writer.write(big);
- writer.write(big);
- writer.delete();
- assertFalse(file.exists());
- }
-
- private String makeBigString(int size) {
- return com.google.common.base.Strings.repeat("x", size);
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/358806da/core/src/test/java/brooklyn/entity/rebind/persister/MementoFileWriterTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/brooklyn/entity/rebind/persister/MementoFileWriterTest.java b/core/src/test/java/brooklyn/entity/rebind/persister/MementoFileWriterTest.java
deleted file mode 100644
index 98f65b5..0000000
--- a/core/src/test/java/brooklyn/entity/rebind/persister/MementoFileWriterTest.java
+++ /dev/null
@@ -1,99 +0,0 @@
-/*
- * 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
- * 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 brooklyn.entity.rebind.persister;
-
-import static org.testng.Assert.assertEquals;
-import static org.testng.Assert.assertFalse;
-
-import java.io.File;
-import java.util.concurrent.Executors;
-
-import org.testng.annotations.AfterMethod;
-import org.testng.annotations.BeforeMethod;
-import org.testng.annotations.Test;
-
-import brooklyn.mementos.BrooklynMementoPersister.LookupContext;
-import brooklyn.util.os.Os;
-import brooklyn.util.time.Duration;
-
-import com.google.common.base.Charsets;
-import com.google.common.io.Files;
-import com.google.common.util.concurrent.ListeningExecutorService;
-import com.google.common.util.concurrent.MoreExecutors;
-
-public class MementoFileWriterTest {
-
- private static final Duration TIMEOUT = Duration.TEN_SECONDS;
-
- private File file;
- private ListeningExecutorService executor;
- private MementoSerializer<String> serializer;
- private MementoFileWriter<String> writer;
-
- @BeforeMethod(alwaysRun=true)
- public void setUp() throws Exception {
- file = Os.newTempFile(getClass(), "txt");
- executor = MoreExecutors.listeningDecorator(Executors.newCachedThreadPool());
- serializer = new MementoSerializer<String>() {
- @Override public String toString(String memento) {
- return memento;
- }
- @Override public String fromString(String string) {
- return string;
- }
- @Override public void setLookupContext(LookupContext lookupContext) {
- }
- @Override public void unsetLookupContext() {
- }
- };
- writer = new MementoFileWriter<String>(file, executor, serializer);
- }
-
- @AfterMethod(alwaysRun=true)
- public void tearDown() throws Exception {
- if (executor != null) executor.shutdownNow();
- if (file != null) file.delete();
-
- }
-
- @Test
- public void testWritesFile() throws Exception {
- writer.write("abc");
- writer.waitForWriteCompleted(TIMEOUT);
-
- String fromfile = Files.asCharSource(file, Charsets.UTF_8).read();
- assertEquals(fromfile, "abc");
- }
-
- @Test
- public void testWriteBacklogThenDeleteWillLeaveFileDeleted() throws Exception {
- String big = makeBigString(100000);
-
- writer.write(big);
- writer.write(big);
- writer.delete();
-
- writer.waitForWriteCompleted(TIMEOUT);
- assertFalse(file.exists());
- }
-
- private String makeBigString(int size) {
- return com.google.common.base.Strings.repeat("x", size);
- }
-}
[06/21] incubator-brooklyn git commit: Delete deprecated
ManagementNodeState.UNINITIALISED
Posted by ha...@apache.org.
Delete deprecated ManagementNodeState.UNINITIALISED
Project: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/commit/29c9718c
Tree: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/tree/29c9718c
Diff: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/diff/29c9718c
Branch: refs/heads/master
Commit: 29c9718c46438893b5729fd4ab46d0c762a47ded
Parents: 29cbd0f
Author: Aled Sage <al...@gmail.com>
Authored: Tue Jul 28 22:51:59 2015 +0100
Committer: Aled Sage <al...@gmail.com>
Committed: Sat Aug 1 00:13:31 2015 +0100
----------------------------------------------------------------------
.../main/java/brooklyn/management/ha/ManagementNodeState.java | 2 --
.../java/brooklyn/management/ha/HighAvailabilityManagerImpl.java | 4 ----
2 files changed, 6 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/29c9718c/api/src/main/java/brooklyn/management/ha/ManagementNodeState.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/brooklyn/management/ha/ManagementNodeState.java b/api/src/main/java/brooklyn/management/ha/ManagementNodeState.java
index d7608bd..ac54ef2 100644
--- a/api/src/main/java/brooklyn/management/ha/ManagementNodeState.java
+++ b/api/src/main/java/brooklyn/management/ha/ManagementNodeState.java
@@ -21,8 +21,6 @@ package brooklyn.management.ha;
import brooklyn.util.guava.Maybe;
public enum ManagementNodeState {
- /** @deprecated since 0.7.0 synonym for maintenance (plus, it should have been US English!) */
- UNINITIALISED,
/** Node is either coming online, or is in some kind of recovery/transitioning mode */
INITIALIZING,
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/29c9718c/core/src/main/java/brooklyn/management/ha/HighAvailabilityManagerImpl.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/brooklyn/management/ha/HighAvailabilityManagerImpl.java b/core/src/main/java/brooklyn/management/ha/HighAvailabilityManagerImpl.java
index 96e6bea..4c631c7 100644
--- a/core/src/main/java/brooklyn/management/ha/HighAvailabilityManagerImpl.java
+++ b/core/src/main/java/brooklyn/management/ha/HighAvailabilityManagerImpl.java
@@ -515,7 +515,6 @@ public class HighAvailabilityManagerImpl implements HighAvailabilityManager {
}
}
- @SuppressWarnings("deprecation")
@Override
public ManagementNodeState getNodeState() {
ManagementNodeState myNodeState = getInternalNodeState();
@@ -524,9 +523,6 @@ public class HighAvailabilityManagerImpl implements HighAvailabilityManager {
// (we may fail subsequently of course)
if (myNodeState==ManagementNodeState.MASTER) return myNodeState;
- // for backwards compatibility; remove in 0.8.0
- if (myNodeState==ManagementNodeState.UNINITIALISED) return ManagementNodeState.INITIALIZING;
-
if (!nodeStateTransitionComplete) return ManagementNodeState.INITIALIZING;
return myNodeState;
}
[17/21] incubator-brooklyn git commit: Delete deprecated
AutoScalerPolicy methods
Posted by ha...@apache.org.
Delete deprecated AutoScalerPolicy methods
- These took long, rather than Duration as an arg to configure the
AutoScalerPolicy
Project: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/commit/08516378
Tree: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/tree/08516378
Diff: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/diff/08516378
Branch: refs/heads/master
Commit: 085163786360407ef162a8cdaaad89613152bad8
Parents: d754818
Author: Aled Sage <al...@gmail.com>
Authored: Wed Jul 29 17:22:38 2015 +0100
Committer: Aled Sage <al...@gmail.com>
Committed: Sat Aug 1 00:16:51 2015 +0100
----------------------------------------------------------------------
.../policy/autoscaling/AutoScalerPolicy.java | 49 --------------------
1 file changed, 49 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/08516378/policy/src/main/java/brooklyn/policy/autoscaling/AutoScalerPolicy.java
----------------------------------------------------------------------
diff --git a/policy/src/main/java/brooklyn/policy/autoscaling/AutoScalerPolicy.java b/policy/src/main/java/brooklyn/policy/autoscaling/AutoScalerPolicy.java
index f453aa5..ddac9c4 100644
--- a/policy/src/main/java/brooklyn/policy/autoscaling/AutoScalerPolicy.java
+++ b/policy/src/main/java/brooklyn/policy/autoscaling/AutoScalerPolicy.java
@@ -157,33 +157,12 @@ public class AutoScalerPolicy extends AbstractPolicy {
this.resizeUpIterationMax = val; return this;
}
- /**
- * @deprecated since 0.7; use {@link #minPeriodBetweenExecs(Duration)}
- */
- @Deprecated
- public Builder minPeriodBetweenExecs(long val) {
- return minPeriodBetweenExecs(Duration.of(val, TimeUnit.MILLISECONDS));
- }
public Builder minPeriodBetweenExecs(Duration val) {
this.minPeriodBetweenExecs = val; return this;
}
- /**
- * @deprecated since 0.7; use {@link #resizeUpStabilizationDelay(Duration)}
- */
- @Deprecated
- public Builder resizeUpStabilizationDelay(long val) {
- return resizeUpStabilizationDelay(Duration.of(val, TimeUnit.MILLISECONDS));
- }
public Builder resizeUpStabilizationDelay(Duration val) {
this.resizeUpStabilizationDelay = val; return this;
}
- /**
- * @deprecated since 0.7; use {@link #resizeDownStabilizationDelay(Duration)}
- */
- @Deprecated
- public Builder resizeDownStabilizationDelay(long val) {
- return resizeDownStabilizationDelay(Duration.of(val, TimeUnit.MILLISECONDS));
- }
public Builder resizeDownStabilizationDelay(Duration val) {
this.resizeDownStabilizationDelay = val; return this;
}
@@ -205,13 +184,6 @@ public class AutoScalerPolicy extends AbstractPolicy {
public Builder maxSizeReachedSensor(BasicNotificationSensor<? super MaxPoolSizeReachedEvent> val) {
this.maxSizeReachedSensor = val; return this;
}
- /**
- * @deprecated since 0.7; use {@link #maxReachedNotificationDelay(Duration)}
- */
- @Deprecated
- public Builder maxReachedNotificationDelay(long val) {
- return maxReachedNotificationDelay(Duration.of(val, TimeUnit.MILLISECONDS));
- }
public Builder maxReachedNotificationDelay(Duration val) {
this.maxReachedNotificationDelay = val; return this;
}
@@ -529,37 +501,16 @@ public class AutoScalerPolicy extends AbstractPolicy {
setOrDefault(RESIZE_DOWN_ITERATION_MAX, val);
}
- /**
- * @deprecated since 0.7.0; use {@link #setMinPeriodBetweenExecs(Duration)}
- */
- public void setMinPeriodBetweenExecs(long val) {
- setMinPeriodBetweenExecs(Duration.millis(val));
- }
-
public void setMinPeriodBetweenExecs(Duration val) {
if (LOG.isInfoEnabled()) LOG.info("{} changing minPeriodBetweenExecs from {} to {}", new Object[] {this, getMinPeriodBetweenExecs(), val});
config().set(MIN_PERIOD_BETWEEN_EXECS, val);
}
- /**
- * @deprecated since 0.7.0; use {@link #setResizeDownStabilizationDelay(Duration)}
- */
- public void setResizeUpStabilizationDelay(long val) {
- setResizeUpStabilizationDelay(Duration.millis(val));
- }
-
public void setResizeUpStabilizationDelay(Duration val) {
if (LOG.isInfoEnabled()) LOG.info("{} changing resizeUpStabilizationDelay from {} to {}", new Object[] {this, getResizeUpStabilizationDelay(), val});
config().set(RESIZE_UP_STABILIZATION_DELAY, val);
}
- /**
- * @deprecated since 0.7.0; use {@link #setResizeDownStabilizationDelay(Duration)}
- */
- public void setResizeDownStabilizationDelay(long val) {
- setResizeDownStabilizationDelay(Duration.millis(val));
- }
-
public void setResizeDownStabilizationDelay(Duration val) {
if (LOG.isInfoEnabled()) LOG.info("{} changing resizeDownStabilizationDelay from {} to {}", new Object[] {this, getResizeDownStabilizationDelay(), val});
config().set(RESIZE_DOWN_STABILIZATION_DELAY, val);
[14/21] incubator-brooklyn git commit: Delete deprecated code from
BrooklynMementoPersister
Posted by ha...@apache.org.
Delete deprecated code from BrooklynMementoPersister
Project: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/commit/8d4c82b5
Tree: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/tree/8d4c82b5
Diff: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/diff/8d4c82b5
Branch: refs/heads/master
Commit: 8d4c82b5c426e7ae5bdeaf0d185caf3538e460a7
Parents: 2184e35
Author: Aled Sage <al...@gmail.com>
Authored: Wed Jul 29 17:01:14 2015 +0100
Committer: Aled Sage <al...@gmail.com>
Committed: Sat Aug 1 00:16:50 2015 +0100
----------------------------------------------------------------------
.../mementos/BrooklynMementoPersister.java | 16 ---------
.../BrooklynMementoPersisterToObjectStore.java | 34 --------------------
2 files changed, 50 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/8d4c82b5/api/src/main/java/brooklyn/mementos/BrooklynMementoPersister.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/brooklyn/mementos/BrooklynMementoPersister.java b/api/src/main/java/brooklyn/mementos/BrooklynMementoPersister.java
index ec16e9b..f952670 100644
--- a/api/src/main/java/brooklyn/mementos/BrooklynMementoPersister.java
+++ b/api/src/main/java/brooklyn/mementos/BrooklynMementoPersister.java
@@ -21,7 +21,6 @@ package brooklyn.mementos;
import java.io.IOException;
import java.util.Collection;
import java.util.Set;
-import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
import javax.annotation.Nullable;
@@ -73,9 +72,6 @@ public interface BrooklynMementoPersister {
*/
BrooklynMementoRawData loadMementoRawData(RebindExceptionHandler exceptionHandler);
- /** @deprecated since 0.7.0 use {@link #loadMementoManifest(BrooklynMementoRawData, RebindExceptionHandler)} */
- BrooklynMementoManifest loadMementoManifest(RebindExceptionHandler exceptionHandler) throws IOException;
-
/**
* Loads minimal manifest information (almost entirely *not* deserialized).
* Implementations should load the raw data if {@link BrooklynMementoRawData} is not supplied,
@@ -83,8 +79,6 @@ public interface BrooklynMementoPersister {
*/
BrooklynMementoManifest loadMementoManifest(@Nullable BrooklynMementoRawData mementoData, RebindExceptionHandler exceptionHandler) throws IOException;
- /** @deprecated since 0.7.0 use {@link #loadMemento(RebindExceptionHandler)} */
- BrooklynMemento loadMemento(LookupContext lookupContext, RebindExceptionHandler exceptionHandler) throws IOException;
/**
* Retrieves the memento class, containing deserialized objects (but not the {@link BrooklynObject} class).
* Implementations should load the raw data if {@link BrooklynMementoRawData} is not supplied,
@@ -94,10 +88,6 @@ public interface BrooklynMementoPersister {
*/
BrooklynMemento loadMemento(@Nullable BrooklynMementoRawData mementoData, LookupContext lookupContext, RebindExceptionHandler exceptionHandler) throws IOException;
- /** @deprecated since 0.7.0, use {@link #checkpoint(BrooklynMementoRawData, PersistenceExceptionHandler)}
- * and javadoc on implementations of that */ @Deprecated // pretty sure this is not used outwith deprecated code
- void checkpoint(BrooklynMemento memento, PersistenceExceptionHandler exceptionHandler);
-
/** applies a full checkpoint (write) of all state */
void checkpoint(BrooklynMementoRawData newMemento, PersistenceExceptionHandler exceptionHandler);
/** applies a partial write of state delta */
@@ -114,12 +104,6 @@ public interface BrooklynMementoPersister {
@VisibleForTesting
void waitForWritesCompleted(Duration timeout) throws InterruptedException, TimeoutException;
- /**
- * @deprecated since 0.7.0; use {@link #waitForWritesCompleted(Duration)}
- */
- @VisibleForTesting
- void waitForWritesCompleted(long timeout, TimeUnit unit) throws InterruptedException, TimeoutException;
-
String getBackingStoreDescription();
/** All methods on this interface are unmodifiable by the caller. Sub-interfaces may introduce modifiers. */
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/8d4c82b5/core/src/main/java/brooklyn/entity/rebind/persister/BrooklynMementoPersisterToObjectStore.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/brooklyn/entity/rebind/persister/BrooklynMementoPersisterToObjectStore.java b/core/src/main/java/brooklyn/entity/rebind/persister/BrooklynMementoPersisterToObjectStore.java
index 6e3c24d..7c0cc3c 100644
--- a/core/src/main/java/brooklyn/entity/rebind/persister/BrooklynMementoPersisterToObjectStore.java
+++ b/core/src/main/java/brooklyn/entity/rebind/persister/BrooklynMementoPersisterToObjectStore.java
@@ -322,11 +322,6 @@ public class BrooklynMementoPersisterToObjectStore implements BrooklynMementoPer
}
@Override
- public BrooklynMementoManifest loadMementoManifest(final RebindExceptionHandler exceptionHandler) throws IOException {
- return loadMementoManifest(null, exceptionHandler);
- }
-
- @Override
public BrooklynMementoManifest loadMementoManifest(BrooklynMementoRawData mementoData, final RebindExceptionHandler exceptionHandler) throws IOException {
if (mementoData==null)
mementoData = loadMementoRawData(exceptionHandler);
@@ -391,11 +386,6 @@ public class BrooklynMementoPersisterToObjectStore implements BrooklynMementoPer
return result;
}
-
- @Override
- public BrooklynMemento loadMemento(LookupContext lookupContext, final RebindExceptionHandler exceptionHandler) throws IOException {
- return loadMemento(null, lookupContext, exceptionHandler);
- }
@Override
public BrooklynMemento loadMemento(BrooklynMementoRawData mementoData, final LookupContext lookupContext, final RebindExceptionHandler exceptionHandler) throws IOException {
@@ -547,24 +537,6 @@ public class BrooklynMementoPersisterToObjectStore implements BrooklynMementoPer
}
}
-
- @Override
- public void checkpoint(BrooklynMemento newMemento, PersistenceExceptionHandler exceptionHandler) {
- checkWritesAllowed();
-
- MutableDelta delta = new PersisterDeltaImpl();
- delta.addAll(BrooklynObjectType.ENTITY, newMemento.getEntityMementos().values());
- delta.addAll(BrooklynObjectType.LOCATION, newMemento.getLocationMementos().values());
- delta.addAll(BrooklynObjectType.POLICY, newMemento.getPolicyMementos().values());
- delta.addAll(BrooklynObjectType.ENRICHER, newMemento.getEnricherMementos().values());
- delta.addAll(BrooklynObjectType.FEED, newMemento.getFeedMementos().values());
- delta.addAll(BrooklynObjectType.CATALOG_ITEM, newMemento.getCatalogItemMementos().values());
-
- Stopwatch stopwatch = deltaImpl(delta, exceptionHandler);
-
- if (LOG.isDebugEnabled()) LOG.debug("Checkpointed entire memento in {}", Time.makeTimeStringRounded(stopwatch));
- }
-
@Override
public void delta(Delta delta, PersistenceExceptionHandler exceptionHandler) {
checkWritesAllowed();
@@ -639,12 +611,6 @@ public class BrooklynMementoPersisterToObjectStore implements BrooklynMementoPer
}
@Override
- @VisibleForTesting
- public void waitForWritesCompleted(long timeout, TimeUnit unit) throws InterruptedException, TimeoutException {
- waitForWritesCompleted(Duration.of(timeout, unit));
- }
-
- @Override
public void waitForWritesCompleted(Duration timeout) throws InterruptedException, TimeoutException {
boolean locked = lock.readLock().tryLock(timeout.toMillisecondsRoundingUp(), TimeUnit.MILLISECONDS);
if (locked) {
[07/21] incubator-brooklyn git commit: Change deprecated
AbstractApplication.log to private
Posted by ha...@apache.org.
Change deprecated AbstractApplication.log to private
Project: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/commit/5c1015f0
Tree: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/tree/5c1015f0
Diff: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/diff/5c1015f0
Branch: refs/heads/master
Commit: 5c1015f034759eadbf768ec6f46934d041769f08
Parents: fa9450e
Author: Aled Sage <al...@gmail.com>
Authored: Tue Jul 28 22:55:10 2015 +0100
Committer: Aled Sage <al...@gmail.com>
Committed: Sat Aug 1 00:13:31 2015 +0100
----------------------------------------------------------------------
.../main/java/brooklyn/entity/basic/AbstractApplication.java | 7 ++-----
1 file changed, 2 insertions(+), 5 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/5c1015f0/core/src/main/java/brooklyn/entity/basic/AbstractApplication.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/brooklyn/entity/basic/AbstractApplication.java b/core/src/main/java/brooklyn/entity/basic/AbstractApplication.java
index 10df7a1..d916afc 100644
--- a/core/src/main/java/brooklyn/entity/basic/AbstractApplication.java
+++ b/core/src/main/java/brooklyn/entity/basic/AbstractApplication.java
@@ -42,11 +42,8 @@ import brooklyn.util.time.Time;
* their entities.
*/
public abstract class AbstractApplication extends AbstractEntity implements StartableApplication {
- /**
- * @deprecated since 0.8.0; will be changed to private
- */
- @Deprecated
- public static final Logger log = LoggerFactory.getLogger(AbstractApplication.class);
+
+ private static final Logger log = LoggerFactory.getLogger(AbstractApplication.class);
/**
* The default name to use for this app, if not explicitly overridden by the top-level app.
[09/21] incubator-brooklyn git commit: Delete deprecated EntitySpec.id
Posted by ha...@apache.org.
Delete deprecated EntitySpec.id
Project: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/commit/1b3dc159
Tree: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/tree/1b3dc159
Diff: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/diff/1b3dc159
Branch: refs/heads/master
Commit: 1b3dc15927929a73862686a4c277f643a3312cb0
Parents: 0835846
Author: Aled Sage <al...@gmail.com>
Authored: Tue Jul 28 22:39:58 2015 +0100
Committer: Aled Sage <al...@gmail.com>
Committed: Sat Aug 1 00:13:31 2015 +0100
----------------------------------------------------------------------
.../brooklyn/entity/proxying/EntitySpec.java | 22 --------------------
.../entity/proxying/InternalEntityFactory.java | 15 +++++--------
2 files changed, 5 insertions(+), 32 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/1b3dc159/api/src/main/java/brooklyn/entity/proxying/EntitySpec.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/brooklyn/entity/proxying/EntitySpec.java b/api/src/main/java/brooklyn/entity/proxying/EntitySpec.java
index 4d8a643..0706ddc 100644
--- a/api/src/main/java/brooklyn/entity/proxying/EntitySpec.java
+++ b/api/src/main/java/brooklyn/entity/proxying/EntitySpec.java
@@ -133,8 +133,6 @@ public class EntitySpec<T extends Entity> extends AbstractBrooklynObjectSpec<T,E
return new EntitySpec<T>(type);
}
- private String id;
-
private Class<? extends T> impl;
private Entity parent;
private final Map<String, Object> flags = Maps.newLinkedHashMap();
@@ -166,16 +164,6 @@ public class EntitySpec<T extends Entity> extends AbstractBrooklynObjectSpec<T,E
}
/**
- * @return The id to use when creating the entity, or null if allow brooklyn to generate a unique id.
- /**
- * @deprecated since 0.7.0; instead let the management context pick a random+unique id
- */
- @Deprecated
- public String getId() {
- return id;
- }
-
- /**
* @return The implementation of the entity; if not null. this overrides any defaults or other configuration
*
* @see ImplementedBy on the entity interface classes for how defaults are defined.
@@ -258,16 +246,6 @@ public class EntitySpec<T extends Entity> extends AbstractBrooklynObjectSpec<T,E
return locations;
}
- /**
- * @deprecated since 0.7.0; instead let the management context pick a random+unique id
- */
- @Deprecated
- public EntitySpec<T> id(String val) {
- checkMutable();
- id = val;
- return this;
- }
-
public EntitySpec<T> impl(Class<? extends T> val) {
checkMutable();
checkIsImplementation(checkNotNull(val, "impl"), getType());
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/1b3dc159/core/src/main/java/brooklyn/entity/proxying/InternalEntityFactory.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/brooklyn/entity/proxying/InternalEntityFactory.java b/core/src/main/java/brooklyn/entity/proxying/InternalEntityFactory.java
index 880d07a..c48c059 100644
--- a/core/src/main/java/brooklyn/entity/proxying/InternalEntityFactory.java
+++ b/core/src/main/java/brooklyn/entity/proxying/InternalEntityFactory.java
@@ -38,7 +38,6 @@ import brooklyn.entity.basic.BrooklynTaskTags;
import brooklyn.entity.basic.Entities;
import brooklyn.entity.basic.EntityInternal;
import brooklyn.entity.basic.EntityLocal;
-import brooklyn.management.internal.LocalEntityManager;
import brooklyn.management.internal.ManagementContextInternal;
import brooklyn.policy.Enricher;
import brooklyn.policy.EnricherSpec;
@@ -179,7 +178,6 @@ public class InternalEntityFactory extends InternalFactory {
return entity;
}
- @SuppressWarnings("deprecation")
protected <T extends Entity> T createEntityAndDescendantsUninitialized(EntitySpec<T> spec, Map<String,Entity> entitiesByEntityId, Map<String,EntitySpec<?>> specsByEntityId) {
if (spec.getFlags().containsKey("parent") || spec.getFlags().containsKey("owner")) {
throw new IllegalArgumentException("Spec's flags must not contain parent or owner; use spec.parent() instead for "+spec);
@@ -187,12 +185,6 @@ public class InternalEntityFactory extends InternalFactory {
if (spec.getFlags().containsKey("id")) {
throw new IllegalArgumentException("Spec's flags must not contain id; use spec.id() instead for "+spec);
}
- if (spec.getId() != null) {
- log.warn("Use of deprecated EntitySpec.id ({}); instead let management context pick the random+unique id", spec);
- if (((LocalEntityManager)managementContext.getEntityManager()).isKnownEntityId(spec.getId())) {
- throw new IllegalArgumentException("Entity with id "+spec.getId()+" already exists; cannot create new entity with this explicit id from spec "+spec);
- }
- }
try {
Class<? extends T> clazz = getImplementedBy(spec);
@@ -337,8 +329,7 @@ public class InternalEntityFactory extends InternalFactory {
* although for old-style entities flags from the spec are passed to the constructor.
*/
public <T extends Entity> T constructEntity(Class<? extends T> clazz, EntitySpec<T> spec) {
- @SuppressWarnings("deprecation")
- T entity = constructEntityImpl(clazz, spec.getFlags(), spec.getId());
+ T entity = constructEntityImpl(clazz, spec.getFlags());
if (((AbstractEntity)entity).getProxy() == null) ((AbstractEntity)entity).setProxy(createEntityProxy(spec, entity));
return entity;
}
@@ -371,6 +362,10 @@ public class InternalEntityFactory extends InternalFactory {
}
return entity;
}
+
+ protected <T extends Entity> T constructEntityImpl(Class<? extends T> clazz, Map<String, ?> constructionFlags) {
+ return constructEntityImpl(clazz, constructionFlags, null);
+ }
protected <T extends Entity> T constructEntityImpl(Class<? extends T> clazz, Map<String, ?> constructionFlags, String entityId) {
T entity = super.construct(clazz, constructionFlags);
[21/21] incubator-brooklyn git commit: This closes #787
Posted by ha...@apache.org.
This closes #787
Project: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/commit/ffbd6eff
Tree: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/tree/ffbd6eff
Diff: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/diff/ffbd6eff
Branch: refs/heads/master
Commit: ffbd6eff3eeea053bd13b35a4b04868ab855be4f
Parents: e858863 2f33608
Author: Hadrian Zbarcea <ha...@apache.org>
Authored: Sat Aug 1 11:29:35 2015 -0400
Committer: Hadrian Zbarcea <ha...@apache.org>
Committed: Sat Aug 1 11:29:35 2015 -0400
----------------------------------------------------------------------
.../java/brooklyn/basic/BrooklynObject.java | 7 -
api/src/main/java/brooklyn/entity/Entity.java | 27 -
api/src/main/java/brooklyn/entity/Feed.java | 6 -
.../brooklyn/entity/proxying/EntitySpec.java | 22 -
.../management/TaskQueueingContext.java | 5 -
.../management/ha/HighAvailabilityManager.java | 6 -
.../management/ha/ManagementNodeState.java | 2 -
.../mementos/BrooklynMementoPersister.java | 16 -
api/src/main/java/brooklyn/policy/Enricher.java | 15 -
.../java/brooklyn/policy/EntityAdjunct.java | 6 -
api/src/main/java/brooklyn/policy/Policy.java | 17 -
.../brooklyn/basic/AbstractBrooklynObject.java | 6 -
.../catalog/internal/CatalogItemDo.java | 6 -
.../entity/basic/AbstractApplication.java | 7 +-
.../brooklyn/entity/basic/AbstractEntity.java | 19 -
.../basic/EntityTransientCopyInternal.java | 3 -
.../brooklyn/entity/effector/EffectorBody.java | 10 -
.../entity/proxying/InternalEntityFactory.java | 15 +-
.../AbstractBrooklynMementoPersister.java | 129 ----
.../BrooklynMementoPersisterInMemory.java | 211 -------
.../BrooklynMementoPersisterToFile.java | 147 -----
.../BrooklynMementoPersisterToMultiFile.java | 601 -------------------
.../BrooklynMementoPersisterToObjectStore.java | 34 --
.../rebind/persister/MementoFileWriter.java | 267 --------
.../rebind/persister/MementoFileWriterSync.java | 159 -----
.../java/brooklyn/event/feed/AbstractFeed.java | 5 -
.../access/PortForwardManagerClient.java | 5 -
.../location/basic/SimulatedLocation.java | 138 -----
.../ha/HighAvailabilityManagerImpl.java | 9 -
...mentPlaneSyncRecordPersisterToMultiFile.java | 280 ---------
.../NonDeploymentManagementContext.java | 4 -
.../policy/basic/AbstractEntityAdjunct.java | 20 -
.../util/task/DynamicSequentialTask.java | 7 -
.../brooklyn/entity/basic/EntitiesTest.java | 2 +-
...BrooklynMementoPersisterToMultiFileTest.java | 68 ---
.../rebind/persister/InMemoryObjectStore.java | 2 +-
.../persister/MementoFileWriterSyncTest.java | 128 ----
.../rebind/persister/MementoFileWriterTest.java | 99 ---
...nceStoreObjectAccessorWriterTestFixture.java | 27 +-
.../location/basic/SimulatedLocation.java | 136 +++++
.../HighAvailabilityManagerSplitBrainTest.java | 4 +-
.../ha/HighAvailabilityManagerTestFixture.java | 2 +-
.../JcloudsObjectStoreAccessorWriterTest.java | 12 +
.../policy/autoscaling/AutoScalerPolicy.java | 49 --
.../policy/ha/MemberFailureDetectionPolicy.java | 224 -------
.../ha/MemberFailureDetectionPolicyTest.java | 271 ---------
.../entity/basic/SameServerEntityImpl.java | 2 +-
.../brooklyn/entity/basic/SoftwareProcess.java | 11 -
.../entity/basic/SoftwareProcessImpl.java | 90 +--
.../entity/brooklynnode/BrooklynNode.java | 8 -
.../brooklynnode/BrooklynNodeSshDriver.java | 3 -
.../software/MachineLifecycleEffectorTasks.java | 39 --
...ctSoftwareProcessRestartIntegrationTest.java | 2 +-
.../entity/basic/SoftwareProcessEntityTest.java | 4 +-
.../test/entity/TestJavaWebAppEntity.java | 3 +-
usage/cli/src/main/java/brooklyn/cli/Main.java | 24 +-
.../cli/src/test/java/brooklyn/cli/CliTest.java | 5 +-
.../brooklyn/launcher/BrooklynLauncher.java | 1 -
.../config/BrooklynDevelopmentModes.java | 93 ---
.../launcher/config/BrooklynGlobalConfig.java | 4 -
60 files changed, 206 insertions(+), 3318 deletions(-)
----------------------------------------------------------------------
[15/21] incubator-brooklyn git commit: Deletes deprecated
BrooklynGlobalConfig
Posted by ha...@apache.org.
Deletes deprecated BrooklynGlobalConfig
Project: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/commit/d7548187
Tree: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/tree/d7548187
Diff: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/diff/d7548187
Branch: refs/heads/master
Commit: d75481873e207b229c99462f34f5a66b9f7c5e34
Parents: 54cbccc
Author: Aled Sage <al...@gmail.com>
Authored: Wed Jul 29 17:20:27 2015 +0100
Committer: Aled Sage <al...@gmail.com>
Committed: Sat Aug 1 00:16:51 2015 +0100
----------------------------------------------------------------------
.../config/BrooklynDevelopmentModes.java | 93 --------------------
.../launcher/config/BrooklynGlobalConfig.java | 4 -
2 files changed, 97 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/d7548187/usage/launcher/src/main/java/brooklyn/launcher/config/BrooklynDevelopmentModes.java
----------------------------------------------------------------------
diff --git a/usage/launcher/src/main/java/brooklyn/launcher/config/BrooklynDevelopmentModes.java b/usage/launcher/src/main/java/brooklyn/launcher/config/BrooklynDevelopmentModes.java
deleted file mode 100644
index ea08466..0000000
--- a/usage/launcher/src/main/java/brooklyn/launcher/config/BrooklynDevelopmentModes.java
+++ /dev/null
@@ -1,93 +0,0 @@
-/*
- * 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
- * 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 brooklyn.launcher.config;
-
-import java.io.File;
-import java.util.concurrent.atomic.AtomicBoolean;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import brooklyn.config.ConfigKey;
-import brooklyn.event.basic.BasicConfigKey;
-import brooklyn.util.os.Os;
-
-@Deprecated /** @deprecated since 0.7.0; see BrooklynVersion;
-* and anyway this was not really used, and if it were, it would be needed in core; autodetection is pretty good */
-public class BrooklynDevelopmentModes {
-
- private static final Logger log = LoggerFactory.getLogger(BrooklynDevelopmentModes.class);
-
- public static final ConfigKey<BrooklynDevelopmentMode> BROOKLYN_DEV_MODE = new BasicConfigKey<BrooklynDevelopmentMode>(
- BrooklynDevelopmentMode.class, "brooklyn.developmentMode", "whether to run in development mode " +
- "(default is to autodetect based on classpath)", BrooklynDevelopmentMode.AUTO);
-
- private static AtomicBoolean loggedMode = new AtomicBoolean(false);
-
- public static enum BrooklynDevelopmentMode {
- TRUE(true), FALSE(false), AUTO(null);
-
- private final Boolean enabled;
-
- BrooklynDevelopmentMode(Boolean enabled) {
- this.enabled = enabled;
- }
-
- public boolean isEnabled() {
- boolean enabled = computeEnabled();
- if (!loggedMode.getAndSet(true)) {
- // log on first invocation
- String reason = (this.enabled==null ? "autodetected" : "forced");
- if (enabled) {
- log.info("Brooklyn running in development mode ("+reason+")");
- } else {
- log.debug("Brooklyn not running in development mode ("+reason+")");
- }
- }
- return enabled;
- }
-
- protected boolean computeEnabled() {
- if (enabled!=null) return enabled;
- return getAutodectectedDevelopmentMode();
- }
- }
-
- private static Boolean developmentMode = null;
-
- public static boolean getAutodectectedDevelopmentMode() {
- if (developmentMode!=null) return developmentMode;
- developmentMode = computeAutodectectedDevelopmentMode();
- return developmentMode;
- }
-
- private static final String segment = "/core/target/classes";
-
- private static boolean computeAutodectectedDevelopmentMode() {
- String cp = System.getProperty("java.class.path");
- String platformSegment = Os.nativePath(segment);
- if (cp==null) return false;
- if (cp.endsWith(platformSegment) || cp.contains(platformSegment+File.pathSeparator)) {
- log.debug("Brooklyn developmentMode autodetected (based on presence of '"+segment+"' in classpath)");
- return true;
- }
- return false;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/d7548187/usage/launcher/src/main/java/brooklyn/launcher/config/BrooklynGlobalConfig.java
----------------------------------------------------------------------
diff --git a/usage/launcher/src/main/java/brooklyn/launcher/config/BrooklynGlobalConfig.java b/usage/launcher/src/main/java/brooklyn/launcher/config/BrooklynGlobalConfig.java
index 5f79cf0..408c08a 100644
--- a/usage/launcher/src/main/java/brooklyn/launcher/config/BrooklynGlobalConfig.java
+++ b/usage/launcher/src/main/java/brooklyn/launcher/config/BrooklynGlobalConfig.java
@@ -43,10 +43,6 @@ import brooklyn.util.time.Duration;
*/
public class BrooklynGlobalConfig {
- @Deprecated /** @deprecated since 0.7.0; see BrooklynVersion;
- * and anyway this was not really used, and if it were, it would be needed in core; autodetection is pretty good */
- public static final ConfigKey<brooklyn.launcher.config.BrooklynDevelopmentModes.BrooklynDevelopmentMode> BROOKLYN_DEV_MODE = brooklyn.launcher.config.BrooklynDevelopmentModes.BROOKLYN_DEV_MODE;
-
public static final ConfigKey<Boolean> REQUIRE_HTTPS = BrooklynWebConfig.HTTPS_REQUIRED;
public static final ConfigKey<Duration> GC_PERIOD = BrooklynGarbageCollector.GC_PERIOD;
[13/21] incubator-brooklyn git commit: Adds more tests to
PersistenceStoreObjectAccessorWriterTestFixture
Posted by ha...@apache.org.
Adds more tests to PersistenceStoreObjectAccessorWriterTestFixture
These tests were in MementoFileWriterTest, but missing in newer version.
Also fixes it for InMemoryObjectStore.append
Project: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/commit/2184e350
Tree: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/tree/2184e350
Diff: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/diff/2184e350
Branch: refs/heads/master
Commit: 2184e350938ed8950202cd690c12d64a84155892
Parents: 358806d
Author: Aled Sage <al...@gmail.com>
Authored: Wed Jul 29 16:56:20 2015 +0100
Committer: Aled Sage <al...@gmail.com>
Committed: Sat Aug 1 00:16:50 2015 +0100
----------------------------------------------------------------------
.../rebind/persister/InMemoryObjectStore.java | 2 +-
...nceStoreObjectAccessorWriterTestFixture.java | 27 +++++++++++++++++---
.../JcloudsObjectStoreAccessorWriterTest.java | 12 +++++++++
3 files changed, 37 insertions(+), 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/2184e350/core/src/test/java/brooklyn/entity/rebind/persister/InMemoryObjectStore.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/brooklyn/entity/rebind/persister/InMemoryObjectStore.java b/core/src/test/java/brooklyn/entity/rebind/persister/InMemoryObjectStore.java
index c829369..a5c7cc6 100644
--- a/core/src/test/java/brooklyn/entity/rebind/persister/InMemoryObjectStore.java
+++ b/core/src/test/java/brooklyn/entity/rebind/persister/InMemoryObjectStore.java
@@ -109,7 +109,7 @@ public class InMemoryObjectStore implements PersistenceObjectStore {
if (val2==null) val2 = val;
else val2 = val2 + val;
- map.put(key, val);
+ map.put(key, val2);
mapModTime.put(key, new Date());
}
}
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/2184e350/core/src/test/java/brooklyn/entity/rebind/persister/PersistenceStoreObjectAccessorWriterTestFixture.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/brooklyn/entity/rebind/persister/PersistenceStoreObjectAccessorWriterTestFixture.java b/core/src/test/java/brooklyn/entity/rebind/persister/PersistenceStoreObjectAccessorWriterTestFixture.java
index 6cdb32d..740a2f2 100644
--- a/core/src/test/java/brooklyn/entity/rebind/persister/PersistenceStoreObjectAccessorWriterTestFixture.java
+++ b/core/src/test/java/brooklyn/entity/rebind/persister/PersistenceStoreObjectAccessorWriterTestFixture.java
@@ -20,6 +20,7 @@ package brooklyn.entity.rebind.persister;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertFalse;
+import static org.testng.Assert.assertTrue;
import java.io.IOException;
import java.util.Date;
@@ -30,14 +31,14 @@ import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
+import com.google.common.util.concurrent.ListeningExecutorService;
+import com.google.common.util.concurrent.MoreExecutors;
+
import brooklyn.entity.rebind.persister.PersistenceObjectStore.StoreObjectAccessorWithLock;
import brooklyn.util.text.Identifiers;
import brooklyn.util.time.Duration;
import brooklyn.util.time.Time;
-import com.google.common.util.concurrent.ListeningExecutorService;
-import com.google.common.util.concurrent.MoreExecutors;
-
public abstract class PersistenceStoreObjectAccessorWriterTestFixture {
private static final Duration TIMEOUT = Duration.TEN_SECONDS;
@@ -70,6 +71,26 @@ public abstract class PersistenceStoreObjectAccessorWriterTestFixture {
assertEquals(accessor.get(), "abc");
}
+ @Test
+ public void testExists() throws Exception {
+ accessor.put("abc");
+ accessor.waitForCurrentWrites(TIMEOUT);
+ assertTrue(accessor.exists());
+
+ accessor.delete();
+ accessor.waitForCurrentWrites(TIMEOUT);
+ assertFalse(accessor.exists());
+ }
+
+ @Test
+ public void testAppendsFile() throws Exception {
+ accessor.put("abc\n");
+ accessor.append("def\n");
+ accessor.waitForCurrentWrites(TIMEOUT);
+
+ assertEquals(accessor.get(), "abc\ndef\n");
+ }
+
/** most storage systems support <= 1ms resolution; but some file systems -- esp FAT and OSX HFS+ are much much higher! */
protected Duration getLastModifiedResolution() {
return Duration.millis(1);
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/2184e350/locations/jclouds/src/test/java/brooklyn/entity/rebind/persister/jclouds/JcloudsObjectStoreAccessorWriterTest.java
----------------------------------------------------------------------
diff --git a/locations/jclouds/src/test/java/brooklyn/entity/rebind/persister/jclouds/JcloudsObjectStoreAccessorWriterTest.java b/locations/jclouds/src/test/java/brooklyn/entity/rebind/persister/jclouds/JcloudsObjectStoreAccessorWriterTest.java
index ef62dee..37549a6 100644
--- a/locations/jclouds/src/test/java/brooklyn/entity/rebind/persister/jclouds/JcloudsObjectStoreAccessorWriterTest.java
+++ b/locations/jclouds/src/test/java/brooklyn/entity/rebind/persister/jclouds/JcloudsObjectStoreAccessorWriterTest.java
@@ -167,4 +167,16 @@ public class JcloudsObjectStoreAccessorWriterTest extends PersistenceStoreObject
public void testLastModifiedTime() throws Exception {
super.testLastModifiedTime();
}
+
+ @Test(groups={"Live", "Live-sanity"})
+ @Override
+ public void testExists() throws Exception {
+ super.testExists();
+ }
+
+ @Test(groups={"Live", "Live-sanity"})
+ @Override
+ public void testAppendsFile() throws Exception {
+ super.testAppendsFile();
+ }
}
[16/21] incubator-brooklyn git commit: Deletes deprecated CLI option —noShutdownOnExit
Posted by ha...@apache.org.
Deletes deprecated CLI option —noShutdownOnExit
Project: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/commit/54cbccca
Tree: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/tree/54cbccca
Diff: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/diff/54cbccca
Branch: refs/heads/master
Commit: 54cbccca514ef5d28b07f167958883d302f9202a
Parents: da33c3d
Author: Aled Sage <al...@gmail.com>
Authored: Wed Jul 29 17:19:01 2015 +0100
Committer: Aled Sage <al...@gmail.com>
Committed: Sat Aug 1 00:16:51 2015 +0100
----------------------------------------------------------------------
.../entity/brooklynnode/BrooklynNode.java | 8 --------
.../brooklynnode/BrooklynNodeSshDriver.java | 3 ---
usage/cli/src/main/java/brooklyn/cli/Main.java | 20 +-------------------
.../cli/src/test/java/brooklyn/cli/CliTest.java | 5 ++---
.../brooklyn/launcher/BrooklynLauncher.java | 1 -
5 files changed, 3 insertions(+), 34 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/54cbccca/software/base/src/main/java/brooklyn/entity/brooklynnode/BrooklynNode.java
----------------------------------------------------------------------
diff --git a/software/base/src/main/java/brooklyn/entity/brooklynnode/BrooklynNode.java b/software/base/src/main/java/brooklyn/entity/brooklynnode/BrooklynNode.java
index 669ac61..0f5b97f 100644
--- a/software/base/src/main/java/brooklyn/entity/brooklynnode/BrooklynNode.java
+++ b/software/base/src/main/java/brooklyn/entity/brooklynnode/BrooklynNode.java
@@ -235,14 +235,6 @@ public interface BrooklynNode extends SoftwareProcess, UsesJava {
public static final ConfigKey<Duration> POLL_PERIOD = ConfigKeys.newConfigKey(Duration.class, "brooklynnode.poll_period",
"Frequency to poll for client sensors", Duration.seconds(2));
- @Deprecated
- /** @deprecated since 0.7.0 this flag is being replaced with the stopWhichAppsOnShutdown flag;
- * if truly needed that could be represented here, but in general the hope is to remove all such complexity,
- * so the better way if you really do need this is to use {@link #EXTRA_LAUNCH_PARAMETERS} */
- @SetFromFlag("noShutdownOnExit")
- public static final ConfigKey<Boolean> NO_SHUTDOWN_ON_EXIT = ConfigKeys.newBooleanConfigKey("brooklynnode.noshutdownonexit",
- "Whether to pass the (deprecated) noShutdownOnExit flag to the process", false);
-
public interface DeployBlueprintEffector {
ConfigKey<Map<String,Object>> BLUEPRINT_CAMP_PLAN = new MapConfigKey<Object>(Object.class, "blueprintPlan",
"CAMP plan for the blueprint to be deployed; currently only supports Java map or JSON string (not yet YAML)");
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/54cbccca/software/base/src/main/java/brooklyn/entity/brooklynnode/BrooklynNodeSshDriver.java
----------------------------------------------------------------------
diff --git a/software/base/src/main/java/brooklyn/entity/brooklynnode/BrooklynNodeSshDriver.java b/software/base/src/main/java/brooklyn/entity/brooklynnode/BrooklynNodeSshDriver.java
index 82a98d5..bd1a2d4 100644
--- a/software/base/src/main/java/brooklyn/entity/brooklynnode/BrooklynNodeSshDriver.java
+++ b/software/base/src/main/java/brooklyn/entity/brooklynnode/BrooklynNodeSshDriver.java
@@ -318,9 +318,6 @@ public class BrooklynNodeSshDriver extends JavaSoftwareProcessSshDriver implemen
if (getEntity().getAttribute(BrooklynNode.NO_WEB_CONSOLE_AUTHENTICATION)) {
cmd += " --noConsoleSecurity";
}
- if (getEntity().getConfig(BrooklynNode.NO_SHUTDOWN_ON_EXIT)) {
- cmd += " --noShutdownOnExit ";
- }
if (Strings.isNonBlank(getEntity().getConfig(BrooklynNode.EXTRA_LAUNCH_PARAMETERS))) {
cmd += " "+getEntity().getConfig(BrooklynNode.EXTRA_LAUNCH_PARAMETERS);
}
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/54cbccca/usage/cli/src/main/java/brooklyn/cli/Main.java
----------------------------------------------------------------------
diff --git a/usage/cli/src/main/java/brooklyn/cli/Main.java b/usage/cli/src/main/java/brooklyn/cli/Main.java
index 0fe5531..3fa7cf4 100644
--- a/usage/cli/src/main/java/brooklyn/cli/Main.java
+++ b/usage/cli/src/main/java/brooklyn/cli/Main.java
@@ -321,12 +321,6 @@ public class Main extends AbstractMain {
+ "Can be used in combination with --persist auto --persistenceDir <custom folder location> to attach to the running app at a later time.")
public boolean exitAndLeaveAppsRunningAfterStarting = false;
- /** @deprecated since 0.7.0 see {@link #stopWhichAppsOnShutdown} */
- @Deprecated
- @Option(name = { "-ns", "--noShutdownOnExit" },
- description = "Deprecated synonym for `--stopOnShutdown none`")
- public boolean noShutdownOnExit = false;
-
final static String PERSIST_OPTION = "--persist";
protected final static String PERSIST_OPTION_DISABLED = "disabled";
protected final static String PERSIST_OPTION_AUTO = "auto";
@@ -561,18 +555,7 @@ public class Main extends AbstractMain {
protected StopWhichAppsOnShutdown computeStopWhichAppsOnShutdown() {
boolean isDefault = STOP_THESE_IF_NOT_PERSISTED.equals(stopWhichAppsOnShutdown);
- if (noShutdownOnExit) {
- if (isDefault) {
- // the default; assume it was not explicitly specified so no error
- stopWhichAppsOnShutdown = STOP_NONE;
- // but warn of deprecation
- log.warn("Deprecated paramater `--noShutdownOnExit` detected; this will likely be removed in a future version; "
- + "replace with `"+STOP_WHICH_APPS_ON_SHUTDOWN+" "+stopWhichAppsOnShutdown+"`");
- return StopWhichAppsOnShutdown.NONE;
- } else {
- throw new FatalConfigurationRuntimeException("Cannot specify both `--noShutdownOnExit` and `"+STOP_WHICH_APPS_ON_SHUTDOWN+"`");
- }
- } else if (exitAndLeaveAppsRunningAfterStarting && isDefault) {
+ if (exitAndLeaveAppsRunningAfterStarting && isDefault) {
return StopWhichAppsOnShutdown.NONE;
} else {
return Enums.valueOfIgnoreCase(StopWhichAppsOnShutdown.class, stopWhichAppsOnShutdown).get();
@@ -823,7 +806,6 @@ public class Main extends AbstractMain {
.add("catalogReset", catalogReset)
.add("catalogForce", catalogForce)
.add("stopWhichAppsOnShutdown", stopWhichAppsOnShutdown)
- .add("noShutdownOnExit", noShutdownOnExit)
.add("stopOnKeyPress", stopOnKeyPress)
.add("localBrooklynProperties", localBrooklynProperties)
.add("persist", persist)
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/54cbccca/usage/cli/src/test/java/brooklyn/cli/CliTest.java
----------------------------------------------------------------------
diff --git a/usage/cli/src/test/java/brooklyn/cli/CliTest.java b/usage/cli/src/test/java/brooklyn/cli/CliTest.java
index 13b27c1..9bf173c 100644
--- a/usage/cli/src/test/java/brooklyn/cli/CliTest.java
+++ b/usage/cli/src/test/java/brooklyn/cli/CliTest.java
@@ -241,7 +241,7 @@ public class CliTest {
"--location", "localhost",
"--port", "1234",
"--bindAddress", "myhostname",
- "--noConsole", "--noConsoleSecurity", "--noShutdownOnExit", "--stopOnKeyPress",
+ "--noConsole", "--noConsoleSecurity", "--stopOnKeyPress",
"--localBrooklynProperties", "/path/to/myprops",
LaunchCommand.PERSIST_OPTION, LaunchCommand.PERSIST_OPTION_REBIND,
"--persistenceDir", "/path/to/mypersist",
@@ -255,7 +255,6 @@ public class CliTest {
assertTrue(details.contains("bindAddress=myhostname"), details);
assertTrue(details.contains("noConsole=true"), details);
assertTrue(details.contains("noConsoleSecurity=true"), details);
- assertTrue(details.contains("noShutdownOnExit=true"), details);
assertTrue(details.contains("stopOnKeyPress=true"), details);
assertTrue(details.contains("localBrooklynProperties=/path/to/myprops"), details);
assertTrue(details.contains("persist=rebind"), details);
@@ -274,7 +273,7 @@ public class CliTest {
assertTrue(details.contains("port=null"), details);
assertTrue(details.contains("noConsole=false"), details);
assertTrue(details.contains("noConsoleSecurity=false"), details);
- assertTrue(details.contains("noShutdownOnExit=false"), details);
+ assertTrue(details.contains("stopWhichAppsOnShutdown=theseIfNotPersisted"), details);
assertTrue(details.contains("stopOnKeyPress=false"), details);
assertTrue(details.contains("localBrooklynProperties=null"), details);
assertTrue(details.contains("persist=disabled"), details);
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/54cbccca/usage/launcher/src/main/java/brooklyn/launcher/BrooklynLauncher.java
----------------------------------------------------------------------
diff --git a/usage/launcher/src/main/java/brooklyn/launcher/BrooklynLauncher.java b/usage/launcher/src/main/java/brooklyn/launcher/BrooklynLauncher.java
index a6db5f7..76ded17 100644
--- a/usage/launcher/src/main/java/brooklyn/launcher/BrooklynLauncher.java
+++ b/usage/launcher/src/main/java/brooklyn/launcher/BrooklynLauncher.java
@@ -946,7 +946,6 @@ public class BrooklynLauncher {
.configure(BrooklynNode.WEB_CONSOLE_PUBLIC_ADDRESS, publicAddress)
.configure(BrooklynNode.CLASSPATH, Splitter.on(":").splitToList(classpath))
.configure(BrooklynNode.NO_WEB_CONSOLE_AUTHENTICATION, Boolean.TRUE.equals(skipSecurityFilter))
- .configure(BrooklynNode.NO_SHUTDOWN_ON_EXIT, stopWhichAppsOnShutdown == StopWhichAppsOnShutdown.NONE)
.displayName("Brooklyn Console"));
}
};
[04/21] incubator-brooklyn git commit: Delete deprecated
TaskQueuingContext.last
Posted by ha...@apache.org.
Delete deprecated TaskQueuingContext.last
Project: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/commit/fa9450ed
Tree: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/tree/fa9450ed
Diff: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/diff/fa9450ed
Branch: refs/heads/master
Commit: fa9450ed4bbc4bff919fa68dec0b1d7995830c2d
Parents: f49ca1b
Author: Aled Sage <al...@gmail.com>
Authored: Tue Jul 28 22:53:49 2015 +0100
Committer: Aled Sage <al...@gmail.com>
Committed: Sat Aug 1 00:13:31 2015 +0100
----------------------------------------------------------------------
.../java/brooklyn/management/TaskQueueingContext.java | 5 -----
.../main/java/brooklyn/entity/effector/EffectorBody.java | 10 ----------
.../java/brooklyn/util/task/DynamicSequentialTask.java | 7 -------
3 files changed, 22 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/fa9450ed/api/src/main/java/brooklyn/management/TaskQueueingContext.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/brooklyn/management/TaskQueueingContext.java b/api/src/main/java/brooklyn/management/TaskQueueingContext.java
index db96fcd..65faea4 100644
--- a/api/src/main/java/brooklyn/management/TaskQueueingContext.java
+++ b/api/src/main/java/brooklyn/management/TaskQueueingContext.java
@@ -43,11 +43,6 @@ public interface TaskQueueingContext {
/** returns a list of queued tasks (immutable copy) */
public List<Task<?>> getQueue();
- /** returns the last task in the queue, or null if none
- * @deprecated since 0.7.0 this method is misleading if the caller attempts to block on the task and the queue aborts */
- @Deprecated
- public Task<?> last();
-
/** Drains the task queue for this context to complete, ie waits for this context to complete (or terminate early)
* @param optionalTimeout null to run forever
* @param includePrimaryThread whether the parent (this context) should also be joined on;
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/fa9450ed/core/src/main/java/brooklyn/entity/effector/EffectorBody.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/brooklyn/entity/effector/EffectorBody.java b/core/src/main/java/brooklyn/entity/effector/EffectorBody.java
index ca62e48..72d4a58 100644
--- a/core/src/main/java/brooklyn/entity/effector/EffectorBody.java
+++ b/core/src/main/java/brooklyn/entity/effector/EffectorBody.java
@@ -82,16 +82,6 @@ public abstract class EffectorBody<T> {
return DynamicTasks.queue(task.newTask());
}
- /** Returns the last task queued in this context, or null if none.
- * Does not block, and there is no guarantee the task is submitted
- * or even that it will be submitted (if the queue aborts early).
- * @deprecated since 0.7.0 not needed, and misleading given {@link #last(Class)},
- * and the prospect that the task will never complete if there are errors */
- @Deprecated
- protected Task<?> last() {
- return DynamicTasks.getTaskQueuingContext().last();
- }
-
/** see {@link DynamicTasks#waitForLast()} */
protected Task<?> waitForLast() {
return DynamicTasks.waitForLast();
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/fa9450ed/core/src/main/java/brooklyn/util/task/DynamicSequentialTask.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/brooklyn/util/task/DynamicSequentialTask.java b/core/src/main/java/brooklyn/util/task/DynamicSequentialTask.java
index 7756388..b4ae488 100644
--- a/core/src/main/java/brooklyn/util/task/DynamicSequentialTask.java
+++ b/core/src/main/java/brooklyn/util/task/DynamicSequentialTask.java
@@ -461,13 +461,6 @@ public class DynamicSequentialTask<T> extends BasicTask<T> implements HasTaskChi
throw Exceptions.propagate(throwable);
}
- @Override @Deprecated
- public Task<?> last() {
- List<Task<?>> l = getQueue();
- if (l.isEmpty()) return null;
- return l.get(l.size()-1);
- }
-
@Override
public void drain(Duration optionalTimeout, boolean includePrimary, boolean throwFirstError) {
try {
[18/21] incubator-brooklyn git commit: Change deprecated Main.log to
be private
Posted by ha...@apache.org.
Change deprecated Main.log to be private
Project: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/commit/da33c3df
Tree: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/tree/da33c3df
Diff: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/diff/da33c3df
Branch: refs/heads/master
Commit: da33c3df8ed3d465a3e6b3b14a11c75129caa87b
Parents: 8d4c82b
Author: Aled Sage <al...@gmail.com>
Authored: Wed Jul 29 17:02:59 2015 +0100
Committer: Aled Sage <al...@gmail.com>
Committed: Sat Aug 1 00:16:51 2015 +0100
----------------------------------------------------------------------
usage/cli/src/main/java/brooklyn/cli/Main.java | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/da33c3df/usage/cli/src/main/java/brooklyn/cli/Main.java
----------------------------------------------------------------------
diff --git a/usage/cli/src/main/java/brooklyn/cli/Main.java b/usage/cli/src/main/java/brooklyn/cli/Main.java
index 2379bdd..0fe5531 100644
--- a/usage/cli/src/main/java/brooklyn/cli/Main.java
+++ b/usage/cli/src/main/java/brooklyn/cli/Main.java
@@ -115,9 +115,7 @@ import io.airlift.command.Option;
*/
public class Main extends AbstractMain {
- /** @deprecated since 0.7.0 will become private static, subclasses should define their own logger */
- @Deprecated
- public static final Logger log = LoggerFactory.getLogger(Main.class);
+ private static final Logger log = LoggerFactory.getLogger(Main.class);
public static void main(String... args) {
log.debug("Launching Brooklyn via CLI, with "+Arrays.toString(args));
[19/21] incubator-brooklyn git commit: Delete deprecated
MemberFailureDetectionPolicy
Posted by ha...@apache.org.
Delete deprecated MemberFailureDetectionPolicy
Project: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/commit/d9715b42
Tree: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/tree/d9715b42
Diff: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/diff/d9715b42
Branch: refs/heads/master
Commit: d9715b4269cdd2452607edf26ddb706acfda32ef
Parents: 0851637
Author: Aled Sage <al...@gmail.com>
Authored: Wed Jul 29 17:24:03 2015 +0100
Committer: Aled Sage <al...@gmail.com>
Committed: Sat Aug 1 00:16:52 2015 +0100
----------------------------------------------------------------------
.../policy/ha/MemberFailureDetectionPolicy.java | 224 ---------------
.../ha/MemberFailureDetectionPolicyTest.java | 271 -------------------
2 files changed, 495 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/d9715b42/policy/src/main/java/brooklyn/policy/ha/MemberFailureDetectionPolicy.java
----------------------------------------------------------------------
diff --git a/policy/src/main/java/brooklyn/policy/ha/MemberFailureDetectionPolicy.java b/policy/src/main/java/brooklyn/policy/ha/MemberFailureDetectionPolicy.java
deleted file mode 100644
index 5a6fa0a..0000000
--- a/policy/src/main/java/brooklyn/policy/ha/MemberFailureDetectionPolicy.java
+++ /dev/null
@@ -1,224 +0,0 @@
-/*
- * 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
- * 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 brooklyn.policy.ha;
-
-import java.util.Map;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import brooklyn.config.ConfigKey;
-import brooklyn.entity.Entity;
-import brooklyn.entity.Group;
-import brooklyn.entity.basic.Attributes;
-import brooklyn.entity.basic.ConfigKeys;
-import brooklyn.entity.basic.EntityLocal;
-import brooklyn.entity.basic.Lifecycle;
-import brooklyn.entity.trait.Changeable;
-import brooklyn.entity.trait.Startable;
-import brooklyn.event.SensorEvent;
-import brooklyn.event.SensorEventListener;
-import brooklyn.policy.basic.AbstractPolicy;
-import brooklyn.util.collections.MutableMap;
-import brooklyn.util.flags.SetFromFlag;
-import brooklyn.util.time.Time;
-
-import com.google.common.base.Objects;
-import com.google.common.base.Predicate;
-import com.google.common.base.Predicates;
-import com.google.common.collect.Maps;
-import com.google.common.reflect.TypeToken;
-
-/**
- * Detects when members of a group have failed/recovered, and emits ENTITY_FAILED or
- * ENTITY_RECOVERED accordingly.
- *
- * This policy should be associated with a group to monitor its members:
- * <pre>
- * {@code
- * group.addPolicy(new MemberFailureDetectionPolicy(...));
- * }
- * </pre>
- *
- * Basic "failure" is defined as the service being "running" but isUp having flipped from
- * true to false.
- *
- * These criteria can be further configured using "onlyReportIfPreviouslyUp" and
- * "useServiceStateRunning".
- *
- * @author aled
- *
- * @deprecated since 0.7.0; use {@link ServiceFailureDetector} associated with each member instead.
- */
-public class MemberFailureDetectionPolicy extends AbstractPolicy {
-
- // TODO Remove duplication between this and ServiceFailureDetection.
- // This could be re-written to use the latter. Or we could even deprecate
- // this in favour of the latter.
- //
- // Tricky to use ServiceFailureDetector: obvious thing would be to create a ServiceFailureDetector
- // on memberAdded, and let do the hard work. But policy.setEntity(...) wants an EntityLocal
- // whereas the member here could be remote.
-
- private static final Logger LOG = LoggerFactory.getLogger(MemberFailureDetectionPolicy.class);
-
- @SetFromFlag("onlyReportIfPreviouslyUp")
- public static final ConfigKey<Boolean> ONLY_REPORT_IF_PREVIOUSLY_UP = ConfigKeys.newBooleanConfigKey("onlyReportIfPreviouslyUp", "", true);
-
- @SetFromFlag("useServiceStateRunning")
- public static final ConfigKey<Boolean> USE_SERVICE_STATE_RUNNING = ConfigKeys.newBooleanConfigKey("useServiceStateRunning", "", true);
-
- @SuppressWarnings("serial")
- @SetFromFlag("memberFilter")
- public static final ConfigKey<Predicate<? super Entity>> MEMBER_FILTER = ConfigKeys.newConfigKey(new TypeToken<Predicate<? super Entity>>() {}, "memberFilter", "", Predicates.<Entity>alwaysTrue());
-
- private final Map<Entity, Long> memberFailures = Maps.newLinkedHashMap();
- private final Map<Entity, Long> memberLastUps = Maps.newLinkedHashMap();
- private final Map<Entity, Boolean> memberIsUps = Maps.newLinkedHashMap();
- private final Map<Entity, Lifecycle> memberStates = Maps.newLinkedHashMap();
-
- public MemberFailureDetectionPolicy() {
- this(MutableMap.<String,Object>of());
- }
-
- public MemberFailureDetectionPolicy(Map<String,?> flags) {
- super(flags);
- }
-
- protected boolean acceptsMember(Entity member) {
- return getConfig(MEMBER_FILTER).apply(member);
- }
-
- @Override
- public void setEntity(EntityLocal entity) {
- super.setEntity(entity);
-
- if (getConfig(USE_SERVICE_STATE_RUNNING)) {
- subscribeToMembers((Group)entity, Attributes.SERVICE_STATE_ACTUAL, new SensorEventListener<Lifecycle>() {
- @Override public void onEvent(SensorEvent<Lifecycle> event) {
- if (!acceptsMember(event.getSource())) return;
- onMemberStatus(event.getSource(), event.getValue());
- }
- });
- }
-
- subscribeToMembers((Group)entity, Startable.SERVICE_UP, new SensorEventListener<Boolean>() {
- @Override public void onEvent(SensorEvent<Boolean> event) {
- if (!acceptsMember(event.getSource())) return;
- onMemberIsUp(event.getSource(), event.getValue());
- }
- });
-
- subscribe(entity, Changeable.MEMBER_REMOVED, new SensorEventListener<Entity>() {
- @Override public void onEvent(SensorEvent<Entity> event) {
- onMemberRemoved(event.getValue());
- }
- });
-
- subscribe(entity, Changeable.MEMBER_ADDED, new SensorEventListener<Entity>() {
- @Override public void onEvent(SensorEvent<Entity> event) {
- if (!acceptsMember(event.getSource())) return;
- onMemberAdded(event.getValue());
- }
- });
-
- for (Entity member : ((Group)entity).getMembers()) {
- if (!acceptsMember(member)) continue;
- onMemberAdded(member);
- }
- }
-
- private synchronized void onMemberIsUp(Entity member, Boolean isUp) {
- if (isUp != null) {
- Boolean old = memberIsUps.put(member, isUp);
- if (isUp) {
- memberLastUps.put(member, System.currentTimeMillis());
- }
- if (!Objects.equal(old, isUp)) {
- checkMemberHealth(member);
- }
- }
- }
-
- private synchronized void onMemberStatus(Entity member, Lifecycle status) {
- if (status != null) {
- Lifecycle old = memberStates.put(member, status);
- if (!Objects.equal(old, status)) {
- checkMemberHealth(member);
- }
- }
- }
-
- private synchronized void onMemberAdded(Entity member) {
- if (getConfig(USE_SERVICE_STATE_RUNNING)) {
- Lifecycle status = member.getAttribute(Attributes.SERVICE_STATE_ACTUAL);
- onMemberStatus(member, status);
- }
-
- Boolean isUp = member.getAttribute(Startable.SERVICE_UP);
- onMemberIsUp(member, isUp);
- }
-
- private synchronized void onMemberRemoved(Entity member) {
- memberStates.remove(member);
- memberIsUps.remove(member);
- memberLastUps.remove(member);
- memberFailures.remove(member);
- }
-
- private synchronized void checkMemberHealth(Entity member) {
- Long lastUpTime = memberLastUps.get(member);
- Boolean isUp = memberIsUps.get(member);
- Lifecycle status = memberStates.get(member);
- boolean failed =
- (getConfig(USE_SERVICE_STATE_RUNNING) && status == Lifecycle.ON_FIRE) ||
- (Boolean.FALSE.equals(isUp) &&
- (getConfig(USE_SERVICE_STATE_RUNNING) ? status == Lifecycle.RUNNING : true) &&
- (getConfig(ONLY_REPORT_IF_PREVIOUSLY_UP) ? lastUpTime != null : true));
- boolean recovered =
- (getConfig(USE_SERVICE_STATE_RUNNING) ? status == Lifecycle.RUNNING : true) &&
- Boolean.TRUE.equals(isUp);
-
- String description = String.format("location=%s; isUp=%s; status=%s; lastReportedUp=%s; timeNow=%s",
- member.getLocations(),
- (isUp != null ? isUp : "<unreported>"),
- (status != null ? status : "<unreported>"),
- (lastUpTime != null ? Time.makeDateString(lastUpTime) : "<never>"),
- Time.makeDateString(System.currentTimeMillis()));
-
- if (memberFailures.containsKey(member)) {
- if (recovered) {
- LOG.info("{} health-check for {}, component recovered (from failure at {}): {}",
- new Object[] {this, member, Time.makeDateString(memberFailures.get(member)), description});
- entity.emit(HASensors.ENTITY_RECOVERED, new HASensors.FailureDescriptor(member, description));
- memberFailures.remove(member);
- } else if (failed) {
- if (LOG.isTraceEnabled()) LOG.trace("{} health-check for {}, confirmed still failed: {}", new Object[] {this, member, description});
- } else {
- if (LOG.isTraceEnabled()) LOG.trace("{} health-check for {}, in unconfirmed sate (previously failed): {}", new Object[] {this, member, description});
- }
- } else if (failed) {
- LOG.info("{} health-check for {}, component failed: {}", new Object[] {this, member, description});
- memberFailures.put(member, System.currentTimeMillis());
- entity.emit(HASensors.ENTITY_FAILED, new HASensors.FailureDescriptor(member, description));
- } else {
- if (LOG.isTraceEnabled()) LOG.trace("{} health-check for {}, either healthy or insufficient data: {}", new Object[] {this, member, description});
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/d9715b42/policy/src/test/java/brooklyn/policy/ha/MemberFailureDetectionPolicyTest.java
----------------------------------------------------------------------
diff --git a/policy/src/test/java/brooklyn/policy/ha/MemberFailureDetectionPolicyTest.java b/policy/src/test/java/brooklyn/policy/ha/MemberFailureDetectionPolicyTest.java
deleted file mode 100644
index 0587804..0000000
--- a/policy/src/test/java/brooklyn/policy/ha/MemberFailureDetectionPolicyTest.java
+++ /dev/null
@@ -1,271 +0,0 @@
-/*
- * 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
- * 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 brooklyn.policy.ha;
-
-import static org.testng.Assert.assertEquals;
-import static org.testng.Assert.assertTrue;
-import static org.testng.Assert.fail;
-
-import java.util.List;
-import java.util.concurrent.CopyOnWriteArrayList;
-
-import org.testng.annotations.AfterMethod;
-import org.testng.annotations.BeforeMethod;
-import org.testng.annotations.Test;
-
-import brooklyn.entity.Entity;
-import brooklyn.entity.basic.ApplicationBuilder;
-import brooklyn.entity.basic.BasicGroup;
-import brooklyn.entity.basic.Entities;
-import brooklyn.entity.basic.Lifecycle;
-import brooklyn.entity.proxying.EntitySpec;
-import brooklyn.event.Sensor;
-import brooklyn.event.SensorEvent;
-import brooklyn.event.SensorEventListener;
-import brooklyn.policy.ha.HASensors.FailureDescriptor;
-import brooklyn.test.TestUtils;
-import brooklyn.test.entity.TestApplication;
-import brooklyn.test.entity.TestEntity;
-import brooklyn.util.collections.MutableMap;
-
-import com.google.common.base.Predicate;
-import com.google.common.base.Predicates;
-
-public class MemberFailureDetectionPolicyTest {
-
- private static final int TIMEOUT_MS = 10*1000;
-
- private MemberFailureDetectionPolicy policy;
- private TestApplication app;
- private BasicGroup group;
- private List<SensorEvent<FailureDescriptor>> events;
-
- @BeforeMethod(alwaysRun=true)
- public void setUp() throws Exception {
- events = new CopyOnWriteArrayList<SensorEvent<FailureDescriptor>>();
- app = ApplicationBuilder.newManagedApp(TestApplication.class);
- group = app.createAndManageChild(EntitySpec.create(BasicGroup.class)
- .configure("childrenAsMembers", true));
-
- app.getManagementContext().getSubscriptionManager().subscribe(
- null,
- HASensors.ENTITY_FAILED,
- new SensorEventListener<FailureDescriptor>() {
- @Override public void onEvent(SensorEvent<FailureDescriptor> event) {
- events.add(event);
- }
- });
- app.getManagementContext().getSubscriptionManager().subscribe(
- null,
- HASensors.ENTITY_RECOVERED,
- new SensorEventListener<FailureDescriptor>() {
- @Override public void onEvent(SensorEvent<FailureDescriptor> event) {
- events.add(event);
- }
- });
- }
-
- @AfterMethod(alwaysRun=true)
- public void tearDown() throws Exception {
- if (app != null) Entities.destroyAll(app.getManagementContext());
- }
-
- private TestEntity createAndManageChildOf(Entity parent) {
- TestEntity e = app.getManagementContext().getEntityManager().createEntity(EntitySpec.create(TestEntity.class));
- e.setParent(parent);
- Entities.manage(e);
- return e;
- }
-
- @Test(groups="Integration") // Has a 1 second wait
- public void testNotNotifiedOfFailuresForHealthyMembers() throws Exception {
- // Create members before and after the policy is registered, to test both scenarios
- TestEntity e1 = createAndManageChildOf(group);
- e1.setAttribute(TestEntity.SERVICE_STATE, Lifecycle.RUNNING);
- e1.setAttribute(TestEntity.SERVICE_UP, true);
-
- policy = new MemberFailureDetectionPolicy(MutableMap.<String,Object>of());
- group.addPolicy(policy);
-
- TestEntity e2 = createAndManageChildOf(group);
- e2.setAttribute(TestEntity.SERVICE_STATE, Lifecycle.RUNNING);
- e2.setAttribute(TestEntity.SERVICE_UP, true);
-
- TestUtils.assertSucceedsContinually(new Runnable() {
- public void run() {
- assertTrue(events.isEmpty(), "events="+events);
- }});
- }
-
- @Test
- public void testNotifiedOfFailedMember() throws Exception {
- policy = new MemberFailureDetectionPolicy(MutableMap.<String,Object>of());
- group.addPolicy(policy);
-
- TestEntity e1 = createAndManageChildOf(group);
-
- e1.setAttribute(TestEntity.SERVICE_STATE, Lifecycle.RUNNING);
- e1.setAttribute(TestEntity.SERVICE_UP, true);
- e1.setAttribute(TestEntity.SERVICE_UP, false);
-
- assertHasEventEventually(HASensors.ENTITY_FAILED, Predicates.<Object>equalTo(e1), null);
- assertEquals(events.size(), 1, "events="+events);
- }
-
- @Test
- public void testNotifiedOfFailedMemberOnStateOnFire() throws Exception {
- policy = new MemberFailureDetectionPolicy(MutableMap.<String,Object>of());
- group.addPolicy(policy);
-
- TestEntity e1 = createAndManageChildOf(group);
-
- e1.setAttribute(TestEntity.SERVICE_STATE, Lifecycle.ON_FIRE);
-
- assertHasEventEventually(HASensors.ENTITY_FAILED, Predicates.<Object>equalTo(e1), null);
- assertEquals(events.size(), 1, "events="+events);
- }
-
- @Test
- public void testNotifiedOfRecoveredMember() throws Exception {
- policy = new MemberFailureDetectionPolicy(MutableMap.<String,Object>of());
- group.addPolicy(policy);
-
- TestEntity e1 = createAndManageChildOf(group);
-
- // Make the entity fail
- e1.setAttribute(TestEntity.SERVICE_STATE, Lifecycle.RUNNING);
- e1.setAttribute(TestEntity.SERVICE_UP, true);
- e1.setAttribute(TestEntity.SERVICE_UP, false);
-
- assertHasEventEventually(HASensors.ENTITY_FAILED, Predicates.<Object>equalTo(e1), null);
-
- // And make the entity recover
- e1.setAttribute(TestEntity.SERVICE_UP, true);
- assertHasEventEventually(HASensors.ENTITY_RECOVERED, Predicates.<Object>equalTo(e1), null);
- assertEquals(events.size(), 2, "events="+events);
- }
-
- @Test(groups="Integration") // Has a 1 second wait
- public void testOnlyReportsFailureIfPreviouslyUp() throws Exception {
- policy = new MemberFailureDetectionPolicy(MutableMap.<String,Object>of());
- group.addPolicy(policy);
-
- TestEntity e1 = createAndManageChildOf(group);
-
- // Make the entity fail
- e1.setAttribute(TestEntity.SERVICE_STATE, Lifecycle.RUNNING);
- e1.setAttribute(TestEntity.SERVICE_UP, false);
-
- TestUtils.assertSucceedsContinually(new Runnable() {
- public void run() {
- assertTrue(events.isEmpty(), "events="+events);
- }});
- }
-
- @Test(groups="Integration") // Has a 1 second wait
- public void testOnlyReportsFailureIfRunning() throws Exception {
- policy = new MemberFailureDetectionPolicy(MutableMap.<String,Object>of());
- group.addPolicy(policy);
-
- TestEntity e1 = createAndManageChildOf(group);
-
- // Make the entity fail
- e1.setAttribute(TestEntity.SERVICE_STATE, Lifecycle.STARTING);
- e1.setAttribute(TestEntity.SERVICE_UP, true);
- e1.setAttribute(TestEntity.SERVICE_UP, false);
-
- TestUtils.assertSucceedsContinually(new Runnable() {
- public void run() {
- assertTrue(events.isEmpty(), "events="+events);
- }});
- }
-
- @Test
- public void testReportsFailureWhenNotPreviouslyUp() throws Exception {
- policy = new MemberFailureDetectionPolicy(MutableMap.of("onlyReportIfPreviouslyUp", false));
- group.addPolicy(policy);
-
- TestEntity e1 = createAndManageChildOf(group);
-
- // Make the entity fail
- e1.setAttribute(TestEntity.SERVICE_STATE, Lifecycle.RUNNING);
- e1.setAttribute(TestEntity.SERVICE_UP, false);
-
- assertHasEventEventually(HASensors.ENTITY_FAILED, Predicates.<Object>equalTo(e1), null);
- }
-
- @Test
- public void testReportsFailureWhenNoServiceState() throws Exception {
- policy = new MemberFailureDetectionPolicy(MutableMap.of("useServiceStateRunning", false));
- group.addPolicy(policy);
-
- TestEntity e1 = createAndManageChildOf(group);
-
- // Make the entity fail
- e1.setAttribute(TestEntity.SERVICE_UP, true);
- e1.setAttribute(TestEntity.SERVICE_UP, false);
-
- assertHasEventEventually(HASensors.ENTITY_FAILED, Predicates.<Object>equalTo(e1), null);
- }
-
- @Test
- public void testReportsFailureWhenAlreadyDownOnBecomingMember() throws Exception {
- policy = new MemberFailureDetectionPolicy(MutableMap.of("onlyReportIfPreviouslyUp", false));
- group.addPolicy(policy);
-
- TestEntity e1 = createAndManageChildOf(group);
- e1.setAttribute(TestEntity.SERVICE_STATE, Lifecycle.RUNNING);
- e1.setAttribute(TestEntity.SERVICE_UP, false);
-
- group.addMember(e1);
-
- assertHasEventEventually(HASensors.ENTITY_FAILED, Predicates.<Object>equalTo(e1), null);
- }
-
- @Test
- public void testReportsFailureWhenAlreadyOnFireOnBecomingMember() throws Exception {
- policy = new MemberFailureDetectionPolicy(MutableMap.of("onlyReportIfPreviouslyUp", false));
- group.addPolicy(policy);
-
- TestEntity e1 = app.createAndManageChild(EntitySpec.create(TestEntity.class));
- e1.setAttribute(TestEntity.SERVICE_STATE, Lifecycle.ON_FIRE);
-
- group.addMember(e1);
-
- assertHasEventEventually(HASensors.ENTITY_FAILED, Predicates.<Object>equalTo(e1), null);
- }
-
- private void assertHasEvent(Sensor<?> sensor, Predicate<Object> componentPredicate, Predicate<? super CharSequence> descriptionPredicate) {
- for (SensorEvent<FailureDescriptor> event : events) {
- if (event.getSensor().equals(sensor) &&
- (componentPredicate == null || componentPredicate.apply(event.getValue().getComponent())) &&
- (descriptionPredicate == null || descriptionPredicate.apply(event.getValue().getDescription()))) {
- return;
- }
- }
- fail("No matching "+sensor+" event found; events="+events);
- }
-
- private void assertHasEventEventually(final Sensor<?> sensor, final Predicate<Object> componentPredicate, final Predicate<? super CharSequence> descriptionPredicate) {
- TestUtils.executeUntilSucceeds(MutableMap.of("timeout", TIMEOUT_MS), new Runnable() {
- @Override public void run() {
- assertHasEvent(sensor, componentPredicate, descriptionPredicate);
- }});
- }
-}