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/13 20:59:54 UTC
[7/9] incubator-brooklyn git commit: [BROOKLYN-162] Rename
./api/management; use the no split package convention
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/2e2de8e4/api/src/main/java/org/apache/brooklyn/api/management/Task.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/org/apache/brooklyn/api/management/Task.java b/api/src/main/java/org/apache/brooklyn/api/management/Task.java
new file mode 100644
index 0000000..37df354
--- /dev/null
+++ b/api/src/main/java/org/apache/brooklyn/api/management/Task.java
@@ -0,0 +1,128 @@
+/*
+ * 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 org.apache.brooklyn.api.management;
+
+import java.util.Set;
+import java.util.concurrent.Callable;
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.Future;
+import java.util.concurrent.FutureTask;
+import java.util.concurrent.TimeoutException;
+
+import com.google.common.util.concurrent.ListenableFuture;
+
+import brooklyn.util.time.Duration;
+
+/**
+ * Represents a unit of work for execution.
+ *
+ * When used with an {@link ExecutionManager} or {@link ExecutionContext} it will record submission time,
+ * execution start time, end time, and any result. A task can be submitted to the ExecutionManager or
+ * ExecutionContext, in which case it will be returned, or it may be created by submission
+ * of a {@link Runnable} or {@link Callable} and thereafter it can be treated just like a {@link Future}.
+ */
+public interface Task<T> extends ListenableFuture<T>, TaskAdaptable<T> {
+
+ public String getId();
+
+ public Set<Object> getTags();
+ /** if {@link #isSubmitted()} returns the time when the task was submitted; or -1 otherwise */
+ public long getSubmitTimeUtc();
+ /** if {@link #isBegun()} returns the time when the task was starts;
+ * guaranteed to be >= {@link #getSubmitTimeUtc()} > 0 if started, or -1 otherwise */
+ public long getStartTimeUtc();
+ /** if {@link #isDone()} (for any reason) returns the time when the task ended;
+ * guaranteed to be >= {@link #getStartTimeUtc()} > 0 if ended, or -1 otherwise */
+ public long getEndTimeUtc();
+ public String getDisplayName();
+ public String getDescription();
+
+ /** task which submitted this task, if was submitted by a task */
+ public Task<?> getSubmittedByTask();
+
+ /** The thread where the task is running, if it is running. */
+ public Thread getThread();
+
+ /**
+ * Whether task has been submitted
+ *
+ * Submitted tasks are normally expected to start running then complete,
+ * but unsubmitted tasks are sometimes passed around for someone else to submit them.
+ */
+ public boolean isSubmitted();
+
+ /**
+ * Whether task has started running.
+ *
+ * Will remain true after normal completion or non-cancellation error.
+ * will be true on cancel iff the thread did actually start.
+ */
+ public boolean isBegun();
+
+ /**
+ * Whether the task threw an error, including cancellation (implies {@link #isDone()})
+ */
+ public boolean isError();
+
+ /**
+ * Causes calling thread to block until the task is started.
+ */
+ public void blockUntilStarted();
+
+ /**
+ * Causes calling thread to block until the task is ended.
+ * <p>
+ * Either normally or by cancellation or error, but without throwing error on cancellation or error.
+ * (Errors are logged at debug.)
+ */
+ public void blockUntilEnded();
+
+ /**
+ * As {@link #blockUntilEnded()}, but returning after the given timeout;
+ * true if the task has ended and false otherwise
+ */
+ public boolean blockUntilEnded(Duration timeout);
+
+ public String getStatusSummary();
+
+ /**
+ * Returns detailed status, suitable for a hover.
+ *
+ * Plain-text format, with new-lines (and sometimes extra info) if multiline enabled.
+ */
+ public String getStatusDetail(boolean multiline);
+
+ /** As {@link #get(long, java.util.concurrent.TimeUnit)} */
+ public T get(Duration duration) throws InterruptedException, ExecutionException, TimeoutException;
+
+ /** As {@link #get()}, but propagating checked exceptions as unchecked for convenience. */
+ public T getUnchecked();
+
+ /** As {@link #get()}, but propagating checked exceptions as unchecked for convenience
+ * (including a {@link TimeoutException} if the duration expires) */
+ public T getUnchecked(Duration duration);
+
+ /** As {@link Future#cancel(boolean)}. Note that {@link #isDone()} and {@link #blockUntilEnded(Duration)} return immediately
+ * once a task is cancelled, consistent with the underlying {@link FutureTask} behaviour.
+ * TODO Fine-grained control over underlying jobs, e.g. to ensure anything represented by this task is actually completed,
+ * is not (yet) publicly exposed. See the convenience method blockUntilInternalTasksEnded in the Tasks set of helpers
+ * for more discussion. */
+ public boolean cancel(boolean mayInterruptIfRunning);
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/2e2de8e4/api/src/main/java/org/apache/brooklyn/api/management/TaskAdaptable.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/org/apache/brooklyn/api/management/TaskAdaptable.java b/api/src/main/java/org/apache/brooklyn/api/management/TaskAdaptable.java
new file mode 100644
index 0000000..714c42a
--- /dev/null
+++ b/api/src/main/java/org/apache/brooklyn/api/management/TaskAdaptable.java
@@ -0,0 +1,24 @@
+/*
+ * 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 org.apache.brooklyn.api.management;
+
+/** marker interface for something which can be adapted to a task */
+public interface TaskAdaptable<T> {
+ Task<T> asTask();
+}
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/2e2de8e4/api/src/main/java/org/apache/brooklyn/api/management/TaskFactory.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/org/apache/brooklyn/api/management/TaskFactory.java b/api/src/main/java/org/apache/brooklyn/api/management/TaskFactory.java
new file mode 100644
index 0000000..d463101
--- /dev/null
+++ b/api/src/main/java/org/apache/brooklyn/api/management/TaskFactory.java
@@ -0,0 +1,25 @@
+/*
+ * 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 org.apache.brooklyn.api.management;
+
+
+/** Interface for something which can generate tasks (or task wrappers) */
+public interface TaskFactory<T extends TaskAdaptable<?>> {
+ T newTask();
+}
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/2e2de8e4/api/src/main/java/org/apache/brooklyn/api/management/TaskQueueingContext.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/org/apache/brooklyn/api/management/TaskQueueingContext.java b/api/src/main/java/org/apache/brooklyn/api/management/TaskQueueingContext.java
new file mode 100644
index 0000000..14304a3
--- /dev/null
+++ b/api/src/main/java/org/apache/brooklyn/api/management/TaskQueueingContext.java
@@ -0,0 +1,62 @@
+/*
+ * 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 org.apache.brooklyn.api.management;
+
+import java.util.List;
+
+import brooklyn.util.time.Duration;
+
+import com.google.common.annotations.Beta;
+
+/**
+ * Marks a place where tasks can be added, e.g. a task which allows children to be added (including after it is activated);
+ * if the implementer of this is also a task, then it may be picked up by hierarchical methods (e.g. in DynamicTasks).
+ *
+ * @since 0.6.0
+ */
+@Beta
+public interface TaskQueueingContext {
+
+ /** queues the task for submission as part of this queueing context
+ * <p>
+ * implementations should mark it as queued but not yet submitted.
+ * note the task may have already been submitted, and is being queued here for informational purposes,
+ * in which case the implementation should not run it. */
+ public void queue(Task<?> t);
+
+ /** returns a list of queued tasks (immutable copy) */
+ public List<Task<?>> getQueue();
+
+ /** 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;
+ * should only be true if invoking this from another task, as otherwise it will be waiting for itself!
+ * @param throwFirstError whether to throw the first exception encountered
+ * <p>
+ * Also note that this waits on tasks so that blocking details on the caller are meaningful.
+ */
+ public void drain(Duration optionalTimeout, boolean includePrimaryThread, boolean throwFirstError);
+
+ /** Returns the task which is this queueing context */
+ public Task<?> asTask();
+
+ /** causes subsequent children failures not to fail the parent */
+ public void swallowChildrenFailures();
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/2e2de8e4/api/src/main/java/org/apache/brooklyn/api/management/TaskWrapper.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/org/apache/brooklyn/api/management/TaskWrapper.java b/api/src/main/java/org/apache/brooklyn/api/management/TaskWrapper.java
new file mode 100644
index 0000000..d932305
--- /dev/null
+++ b/api/src/main/java/org/apache/brooklyn/api/management/TaskWrapper.java
@@ -0,0 +1,28 @@
+/*
+ * 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 org.apache.brooklyn.api.management;
+
+/**
+ * Interface for something which is not a task, but which is closely linked to one, ie. it has a task.
+ *
+ * @since 0.6.0
+ */
+public interface TaskWrapper<T> extends TaskAdaptable<T> {
+ Task<T> getTask();
+}
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/2e2de8e4/api/src/main/java/org/apache/brooklyn/api/management/classloading/BrooklynClassLoadingContext.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/org/apache/brooklyn/api/management/classloading/BrooklynClassLoadingContext.java b/api/src/main/java/org/apache/brooklyn/api/management/classloading/BrooklynClassLoadingContext.java
new file mode 100644
index 0000000..159ac96
--- /dev/null
+++ b/api/src/main/java/org/apache/brooklyn/api/management/classloading/BrooklynClassLoadingContext.java
@@ -0,0 +1,51 @@
+/*
+ * 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 org.apache.brooklyn.api.management.classloading;
+
+import java.net.URL;
+
+import javax.annotation.Nullable;
+
+import org.apache.brooklyn.api.management.ManagementContext;
+
+import brooklyn.util.guava.Maybe;
+
+/**
+ * Provides functionality for loading classes based on the current context
+ * (e.g. catalog item, entity, etc).
+ */
+public interface BrooklynClassLoadingContext {
+
+ public ManagementContext getManagementContext();
+ public Class<?> loadClass(String className);
+ public <T> Class<? extends T> loadClass(String className, @Nullable Class<T> supertype);
+
+ public Maybe<Class<?>> tryLoadClass(String className);
+ public <T> Maybe<Class<? extends T>> tryLoadClass(String className, @Nullable Class<T> supertype);
+
+ /** As {@link ClassLoader#getResource(String)} */
+ public URL getResource(String name);
+
+ /**
+ * As {@link ClassLoader#getResources(String)} but returning an {@link Iterable} rather than
+ * an {@link java.util.Enumeration}.
+ */
+ public Iterable<URL> getResources(String name);
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/2e2de8e4/api/src/main/java/org/apache/brooklyn/api/management/entitlement/EntitlementClass.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/org/apache/brooklyn/api/management/entitlement/EntitlementClass.java b/api/src/main/java/org/apache/brooklyn/api/management/entitlement/EntitlementClass.java
new file mode 100644
index 0000000..90e73df
--- /dev/null
+++ b/api/src/main/java/org/apache/brooklyn/api/management/entitlement/EntitlementClass.java
@@ -0,0 +1,27 @@
+/*
+ * 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 org.apache.brooklyn.api.management.entitlement;
+
+import com.google.common.reflect.TypeToken;
+
+/** @see EntitlementManager */
+public interface EntitlementClass<T> {
+ String entitlementClassIdentifier();
+ TypeToken<T> entitlementClassArgumentType();
+}
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/2e2de8e4/api/src/main/java/org/apache/brooklyn/api/management/entitlement/EntitlementContext.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/org/apache/brooklyn/api/management/entitlement/EntitlementContext.java b/api/src/main/java/org/apache/brooklyn/api/management/entitlement/EntitlementContext.java
new file mode 100644
index 0000000..f0177d3
--- /dev/null
+++ b/api/src/main/java/org/apache/brooklyn/api/management/entitlement/EntitlementContext.java
@@ -0,0 +1,24 @@
+/*
+ * 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 org.apache.brooklyn.api.management.entitlement;
+
+/** @see EntitlementManager */
+public interface EntitlementContext {
+ String user();
+}
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/2e2de8e4/api/src/main/java/org/apache/brooklyn/api/management/entitlement/EntitlementManager.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/org/apache/brooklyn/api/management/entitlement/EntitlementManager.java b/api/src/main/java/org/apache/brooklyn/api/management/entitlement/EntitlementManager.java
new file mode 100644
index 0000000..b46f53d
--- /dev/null
+++ b/api/src/main/java/org/apache/brooklyn/api/management/entitlement/EntitlementManager.java
@@ -0,0 +1,45 @@
+/*
+ * 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 org.apache.brooklyn.api.management.entitlement;
+
+import javax.annotation.Nonnull;
+import javax.annotation.Nullable;
+
+import com.google.common.annotations.Beta;
+
+/**
+ * Entitlement lookup relies on:
+ * <li>an "entitlement context", consisting of at minimum a string identifier of the user/actor for which entitlement is being requested
+ * <li>an "entitlement class", representing the category of activity for which entitlement is being requested
+ * <li>an "entitlement class argument", representing the specifics of the activity for which entitlement is being requested
+ * <p>
+ * Instances of this class typically have a 1-arg constructor taking a BrooklynProperties object
+ * (configuration injected by the Brooklyn framework)
+ * or a 0-arg constructor (if no external configuration is needed).
+ * <p>
+ * An EntitlementManagerAdapter class is available to do dispatch to common methods.
+ * <p>
+ * Instantiation is done e.g. by Entitlements.newManager.
+ * @since 0.7.0 */
+@Beta
+public interface EntitlementManager {
+
+ public <T> boolean isEntitled(@Nullable EntitlementContext context, @Nonnull EntitlementClass<T> entitlementClass, @Nullable T entitlementClassArgument);
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/2e2de8e4/api/src/main/java/org/apache/brooklyn/api/management/ha/HighAvailabilityManager.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/org/apache/brooklyn/api/management/ha/HighAvailabilityManager.java b/api/src/main/java/org/apache/brooklyn/api/management/ha/HighAvailabilityManager.java
new file mode 100644
index 0000000..d643e26
--- /dev/null
+++ b/api/src/main/java/org/apache/brooklyn/api/management/ha/HighAvailabilityManager.java
@@ -0,0 +1,129 @@
+/*
+ * 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 org.apache.brooklyn.api.management.ha;
+
+import java.util.Map;
+
+import com.google.common.annotations.Beta;
+import com.google.common.annotations.VisibleForTesting;
+
+/**
+ * Monitors other management nodes (via the {@link ManagementPlaneSyncRecordPersister}) to detect
+ * if the current master has failed or stopped. If so, then deterministically chooses a new master.
+ * If that master is self, then promotes.
+
+ * Users are not expected to implement this class, or to call methods on it directly.
+ *
+ * Expected lifecycle of methods calls on this is:
+ * <ol>
+ * <li>{@link #setPersister(ManagementPlaneSyncRecordPersister)}
+ * <li>Exactly one of {@link #disabled()} or {@link #start(HighAvailabilityMode)}
+ * <li>{@link #stop()}
+ * </ol>
+ *
+ * @since 0.7.0
+ */
+@Beta
+public interface HighAvailabilityManager {
+
+ ManagementNodeState getNodeState();
+
+ /** The time in milliseconds when the state was last changed. -1 if no state transition has occurred yet.*/
+ long getLastStateChange();
+
+ /**
+ * @param persister
+ * @return self
+ */
+ HighAvailabilityManager setPersister(ManagementPlaneSyncRecordPersister persister);
+
+ /**
+ * Indicates that HA is disabled: this node will act as the only management node in this management plane,
+ * and will not persist HA meta-information (meaning other nodes cannot join).
+ * <p>
+ * Subsequently can expect {@link #getNodeState()} to be {@link ManagementNodeState#MASTER}
+ * and {@link #loadManagementPlaneSyncRecord(boolean)} to show just this one node --
+ * as if it were running HA with just one node --
+ * but {@link #isRunning()} will return false.
+ * <p>
+ * Currently this method is intended to be called early in the lifecycle,
+ * instead of {@link #start(HighAvailabilityMode)}. It may be an error if
+ * this is called after this HA Manager is started.
+ */
+ @Beta
+ void disabled();
+
+ /** Whether HA mode is operational */
+ boolean isRunning();
+
+ /**
+ * Starts the monitoring of other nodes (and thus potential promotion of this node from standby to master).
+ * <p>
+ * When this method returns, the status of this node will be set,
+ * either {@link ManagementNodeState#MASTER} if appropriate
+ * or {@link ManagementNodeState#STANDBY} / {@link ManagementNodeState#HOT_STANDBY} / {@link ManagementNodeState#HOT_BACKUP}.
+ *
+ * @param startMode mode to start with
+ * @throws IllegalStateException if current state of the management-plane doesn't match that desired by {@code startMode}
+ */
+ void start(HighAvailabilityMode startMode);
+
+ /**
+ * Stops this node, then publishes own status (via {@link ManagementPlaneSyncRecordPersister} of {@link ManagementNodeState#TERMINATED}.
+ */
+ void stop();
+
+ /** changes the mode that this HA server is running in
+ * <p>
+ * note it will be an error to {@link #changeMode(HighAvailabilityMode)} to {@link ManagementNodeState#MASTER}
+ * when there is already a master; to promote a node explicitly set its priority higher than
+ * the others and invoke {@link #changeMode(HighAvailabilityMode)} to a standby mode on the existing master */
+ void changeMode(HighAvailabilityMode mode);
+
+ /** sets the priority, and publishes it synchronously so it is canonical */
+ void setPriority(long priority);
+
+ long getPriority();
+
+ /** deletes non-master node records; active nodes (including this) will republish,
+ * so this provides a simple way to clean out the cache of dead brooklyn nodes */
+ @Beta
+ void publishClearNonMaster();
+
+ /**
+ * Returns a snapshot of the management-plane's current / most-recently-known status,
+ * as last read from {@link #loadManagementPlaneSyncRecord(boolean)}, or null if none read.
+ */
+ ManagementPlaneSyncRecord getLastManagementPlaneSyncRecord();
+
+ /**
+ * @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
+ * may be explicitly wanted or not wanted
+ */
+ ManagementPlaneSyncRecord loadManagementPlaneSyncRecord(boolean useLocalKnowledgeForThisNode);
+
+ @VisibleForTesting
+ ManagementPlaneSyncRecordPersister getPersister();
+
+ /** Returns a collection of metrics */
+ Map<String,Object> getMetrics();
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/2e2de8e4/api/src/main/java/org/apache/brooklyn/api/management/ha/HighAvailabilityMode.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/org/apache/brooklyn/api/management/ha/HighAvailabilityMode.java b/api/src/main/java/org/apache/brooklyn/api/management/ha/HighAvailabilityMode.java
new file mode 100644
index 0000000..7d91576
--- /dev/null
+++ b/api/src/main/java/org/apache/brooklyn/api/management/ha/HighAvailabilityMode.java
@@ -0,0 +1,67 @@
+/*
+ * 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 org.apache.brooklyn.api.management.ha;
+
+/** Specifies the HA mode that a mgmt node should run in */
+public enum HighAvailabilityMode {
+ /**
+ * Means HA mode should not be operational.
+ * <p>
+ * When specified for the initial HA mode, this simply turns off HA.
+ * <p>
+ * However if being used to {@link HighAvailabilityManager#changeMode(HighAvailabilityMode)},
+ * this will cause the node to transition to a {@link ManagementNodeState#FAILED} state.
+ * Switching to a "master-but-not-part-of-HA" state is not currently supported, as this would be
+ * problematic if another node (which was part of HA) then tries to become master,
+ * and the more common use of this at runtime is to disable a node from being part of the HA plane.
+ */
+ DISABLED,
+
+ /**
+ * Means auto-detect whether to be master or standby; if there is already a master then start as standby,
+ * otherwise start as master.
+ */
+ AUTO,
+
+ /**
+ * Means node must be lukewarm standby; if there is not already a master then fail fast on startup.
+ * See {@link ManagementNodeState#STANDBY}.
+ */
+ STANDBY,
+
+ /**
+ * Means node must be hot standby; if there is not already a master then fail fast on startup.
+ * See {@link ManagementNodeState#HOT_STANDBY}.
+ */
+ HOT_STANDBY,
+
+ /**
+ * Means node must be hot backup; do not attempt to become master (but it <i>can</i> start without a master).
+ * See {@link ManagementNodeState#HOT_BACKUP}.
+ */
+ HOT_BACKUP,
+
+ /**
+ * Means node must be master; if there is already a master then fail fast on startup.
+ * See {@link ManagementNodeState#MASTER}.
+ */
+ // TODO when multi-master supported we will of course not fail fast on startup when there is already a master;
+ // instead the responsibility for master entities will be divided among masters
+ MASTER;
+}
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/2e2de8e4/api/src/main/java/org/apache/brooklyn/api/management/ha/ManagementNodeState.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/org/apache/brooklyn/api/management/ha/ManagementNodeState.java b/api/src/main/java/org/apache/brooklyn/api/management/ha/ManagementNodeState.java
new file mode 100644
index 0000000..039d0db
--- /dev/null
+++ b/api/src/main/java/org/apache/brooklyn/api/management/ha/ManagementNodeState.java
@@ -0,0 +1,72 @@
+/*
+ * 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 org.apache.brooklyn.api.management.ha;
+
+import brooklyn.util.guava.Maybe;
+
+public enum ManagementNodeState {
+ /** Node is either coming online, or is in some kind of recovery/transitioning mode */
+ INITIALIZING,
+
+ /** Node is in "lukewarm standby" mode, where it is available to be promoted to master,
+ * but does not have entities loaded and will require some effort to be promoted */
+ STANDBY,
+ /** Node is acting as read-only proxy available to be promoted to master on existing master failure */
+ HOT_STANDBY,
+ /** Node is acting as a read-only proxy but not making itself available for promotion to master */
+ HOT_BACKUP,
+ /** Node is running as primary/master, able to manage entities and create new ones */
+ // the semantics are intended to support multi-master here; we could have multiple master nodes,
+ // but we need to look up who is master for any given entity
+ MASTER,
+
+ /** Node has failed and requires maintenance attention */
+ FAILED,
+ /** Node has gone away; maintenance not possible */
+ TERMINATED;
+
+ /** Converts a {@link HighAvailabilityMode} to a {@link ManagementNodeState}, if possible */
+ public static Maybe<ManagementNodeState> of(HighAvailabilityMode startMode) {
+ switch (startMode) {
+ case AUTO:
+ case DISABLED:
+ return Maybe.absent("Requested "+HighAvailabilityMode.class+" mode "+startMode+" cannot be converted to "+ManagementNodeState.class);
+ case HOT_BACKUP:
+ return Maybe.of(HOT_BACKUP);
+ case HOT_STANDBY:
+ return Maybe.of(HOT_STANDBY);
+ case MASTER:
+ return Maybe.of(MASTER);
+ case STANDBY:
+ return Maybe.of(STANDBY);
+ }
+ // above should be exhaustive
+ return Maybe.absent("Requested "+HighAvailabilityMode.class+" mode "+startMode+" was not expected");
+ }
+
+ /** true for hot non-master modes, where we are proxying the data from the persistent store */
+ public static boolean isHotProxy(ManagementNodeState state) {
+ return state==HOT_BACKUP || state==HOT_STANDBY;
+ }
+
+ /** true for non-master modes which can be promoted to master */
+ public static boolean isStandby(ManagementNodeState state) {
+ return state==ManagementNodeState.STANDBY || state==ManagementNodeState.HOT_STANDBY;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/2e2de8e4/api/src/main/java/org/apache/brooklyn/api/management/ha/ManagementNodeSyncRecord.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/org/apache/brooklyn/api/management/ha/ManagementNodeSyncRecord.java b/api/src/main/java/org/apache/brooklyn/api/management/ha/ManagementNodeSyncRecord.java
new file mode 100644
index 0000000..cadb741
--- /dev/null
+++ b/api/src/main/java/org/apache/brooklyn/api/management/ha/ManagementNodeSyncRecord.java
@@ -0,0 +1,62 @@
+/*
+ * 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 org.apache.brooklyn.api.management.ha;
+
+import java.net.URI;
+
+import com.google.common.annotations.Beta;
+
+/**
+ * Represents the state of a management-node.
+ *
+ * @see {@link ManagementPlaneSyncRecord#getManagementNodes()}
+ *
+ * @since 0.7.0
+ *
+ * @author aled
+ */
+@Beta
+public interface ManagementNodeSyncRecord {
+
+ // TODO Not setting URI currently; ManagementContext doesn't know its URI; only have one if web-console was enabled.
+
+ // TODO Add getPlaneId(); but first need to set it in a sensible way
+
+ String getBrooklynVersion();
+
+ String getNodeId();
+
+ URI getUri();
+
+ ManagementNodeState getStatus();
+
+ Long getPriority();
+
+ /** timestamp set by the originating management machine */
+ long getLocalTimestamp();
+
+ /** timestamp set by shared persistent store, if available
+ * <p>
+ * this will not be set on records originating at this machine, nor will it be persisted,
+ * but it will be populated for records being read */
+ Long getRemoteTimestamp();
+
+ String toVerboseString();
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/2e2de8e4/api/src/main/java/org/apache/brooklyn/api/management/ha/ManagementPlaneSyncRecord.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/org/apache/brooklyn/api/management/ha/ManagementPlaneSyncRecord.java b/api/src/main/java/org/apache/brooklyn/api/management/ha/ManagementPlaneSyncRecord.java
new file mode 100644
index 0000000..1537185
--- /dev/null
+++ b/api/src/main/java/org/apache/brooklyn/api/management/ha/ManagementPlaneSyncRecord.java
@@ -0,0 +1,51 @@
+/*
+ * 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 org.apache.brooklyn.api.management.ha;
+
+import java.util.Map;
+
+import org.apache.brooklyn.mementos.BrooklynMemento;
+import org.apache.brooklyn.mementos.BrooklynMementoPersister;
+
+import com.google.common.annotations.Beta;
+
+/**
+ * Meta-data about the management plane - the management nodes and who is currently master.
+ * Does not contain any data about the entities under management.
+ * <p>
+ * This is very similar to how {@link BrooklynMemento} is used by {@link BrooklynMementoPersister},
+ * but it is not a memento in the sense it does not reconstitute the entire management plane
+ * (so is not called Memento although it can be used by the same memento-serializers).
+ *
+ * @since 0.7.0
+ *
+ * @author aled
+ */
+@Beta
+public interface ManagementPlaneSyncRecord {
+
+ // TODO Add getPlaneId(); but first need to set it sensibly on each management node
+
+ String getMasterNodeId();
+
+ /** returns map of {@link ManagementNodeSyncRecord} instances keyed by the nodes' IDs */
+ Map<String, ManagementNodeSyncRecord> getManagementNodes();
+
+ String toVerboseString();
+}
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/2e2de8e4/api/src/main/java/org/apache/brooklyn/api/management/ha/ManagementPlaneSyncRecordPersister.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/org/apache/brooklyn/api/management/ha/ManagementPlaneSyncRecordPersister.java b/api/src/main/java/org/apache/brooklyn/api/management/ha/ManagementPlaneSyncRecordPersister.java
new file mode 100644
index 0000000..1220865
--- /dev/null
+++ b/api/src/main/java/org/apache/brooklyn/api/management/ha/ManagementPlaneSyncRecordPersister.java
@@ -0,0 +1,69 @@
+/*
+ * 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 org.apache.brooklyn.api.management.ha;
+
+import java.io.IOException;
+import java.util.Collection;
+import java.util.concurrent.TimeoutException;
+
+import org.apache.brooklyn.mementos.BrooklynMementoPersister;
+
+import brooklyn.util.time.Duration;
+
+import com.google.common.annotations.Beta;
+import com.google.common.annotations.VisibleForTesting;
+
+/**
+ * Controls the persisting and reading back of mementos relating to the management plane.
+ * This state does not relate to the entities being managed.
+ *
+ * @see {@link HighAvailabilityManager#setPersister(ManagementPlaneSyncRecordPersister)} for its use in management-node failover
+ *
+ * @since 0.7.0
+ */
+@Beta
+public interface ManagementPlaneSyncRecordPersister {
+
+ /**
+ * Analogue to {@link BrooklynMementoPersister#loadMemento(org.apache.brooklyn.mementos.BrooklynMementoPersister.LookupContext)}
+ * <p>
+ * Note that this method is *not* thread safe.
+ */
+ ManagementPlaneSyncRecord loadSyncRecord() throws IOException;
+
+ void delta(Delta delta);
+
+ void stop();
+
+ @VisibleForTesting
+ void waitForWritesCompleted(Duration timeout) throws InterruptedException, TimeoutException;
+
+ public interface Delta {
+ public enum MasterChange {
+ NO_CHANGE,
+ SET_MASTER,
+ CLEAR_MASTER
+ }
+ Collection<ManagementNodeSyncRecord> getNodes();
+ Collection<String> getRemovedNodeIds();
+ MasterChange getMasterChange();
+ String getNewMasterOrNull();
+ String getExpectedMasterToClear();
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/2e2de8e4/api/src/main/java/org/apache/brooklyn/api/management/ha/MementoCopyMode.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/org/apache/brooklyn/api/management/ha/MementoCopyMode.java b/api/src/main/java/org/apache/brooklyn/api/management/ha/MementoCopyMode.java
new file mode 100644
index 0000000..fcdf412
--- /dev/null
+++ b/api/src/main/java/org/apache/brooklyn/api/management/ha/MementoCopyMode.java
@@ -0,0 +1,29 @@
+/*
+ * 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 org.apache.brooklyn.api.management.ha;
+
+public enum MementoCopyMode {
+ /** Use items currently managed at this node */
+ LOCAL,
+ /** Use items as stored in the remote persistence store */
+ REMOTE,
+ /** Auto-detect whether to use {@link #LOCAL} or {@link #REMOTE} depending on the
+ * HA mode of this management node (usually {@link #LOCAL} for master and {@link #REMOTE} otherwise)*/
+ AUTO
+}
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/2e2de8e4/api/src/main/java/org/apache/brooklyn/management/AccessController.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/org/apache/brooklyn/management/AccessController.java b/api/src/main/java/org/apache/brooklyn/management/AccessController.java
deleted file mode 100644
index 78eea31..0000000
--- a/api/src/main/java/org/apache/brooklyn/management/AccessController.java
+++ /dev/null
@@ -1,66 +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 org.apache.brooklyn.management;
-
-import org.apache.brooklyn.api.entity.Entity;
-
-import brooklyn.location.Location;
-
-import com.google.common.annotations.Beta;
-
-@Beta
-public interface AccessController {
-
- // TODO Expect this class' methods to change, e.g. including the user doing the
- // provisioning or the provisioning parameters such as jurisdiction
-
- public static class Response {
- private static final Response ALLOWED = new Response(true, "");
-
- public static Response allowed() {
- return ALLOWED;
- }
-
- public static Response disallowed(String msg) {
- return new Response(false, msg);
- }
-
- private final boolean allowed;
- private final String msg;
-
- private Response(boolean allowed, String msg) {
- this.allowed = allowed;
- this.msg = msg;
- }
-
- public boolean isAllowed() {
- return allowed;
- }
-
- public String getMsg() {
- return msg;
- }
- }
-
- public Response canProvisionLocation(Location provisioner);
-
- public Response canManageLocation(Location loc);
-
- public Response canManageEntity(Entity entity);
-}
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/2e2de8e4/api/src/main/java/org/apache/brooklyn/management/EntityManager.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/org/apache/brooklyn/management/EntityManager.java b/api/src/main/java/org/apache/brooklyn/management/EntityManager.java
deleted file mode 100644
index 030fe90..0000000
--- a/api/src/main/java/org/apache/brooklyn/management/EntityManager.java
+++ /dev/null
@@ -1,126 +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 org.apache.brooklyn.management;
-
-import java.util.Collection;
-import java.util.Map;
-
-import javax.annotation.Nullable;
-
-import org.apache.brooklyn.api.entity.Application;
-import org.apache.brooklyn.api.entity.Entity;
-import org.apache.brooklyn.api.entity.proxying.EntitySpec;
-import org.apache.brooklyn.api.entity.proxying.EntityTypeRegistry;
-import org.apache.brooklyn.policy.Enricher;
-import org.apache.brooklyn.policy.EnricherSpec;
-import org.apache.brooklyn.policy.Policy;
-import org.apache.brooklyn.policy.PolicySpec;
-
-import com.google.common.base.Predicate;
-
-/**
- * For managing and querying entities.
- */
-public interface EntityManager {
-
- /**
- * Returns the type registry, used to identify the entity implementation when instantiating an
- * entity of a given type.
- *
- * @see EntityManager.createEntity(EntitySpec)
- */
- EntityTypeRegistry getEntityTypeRegistry();
-
- /**
- * Creates a new (unmanaged) entity.
- *
- * @param spec
- * @return A proxy to the created entity (rather than the actual entity itself).
- */
- <T extends Entity> T createEntity(EntitySpec<T> spec);
-
- /**
- * Convenience (particularly for groovy code) to create an entity.
- * Equivalent to {@code createEntity(EntitySpec.create(type).configure(config))}
- *
- * @see createEntity(EntitySpec)
- */
- <T extends Entity> T createEntity(Map<?,?> config, Class<T> type);
-
- /**
- * Creates a new policy (not managed; not associated with any entity).
- *
- * @param spec
- */
- <T extends Policy> T createPolicy(PolicySpec<T> spec);
-
- /**
- * Creates a new enricher (not managed; not associated with any entity).
- *
- * @param spec
- */
- <T extends Enricher> T createEnricher(EnricherSpec<T> spec);
-
- /**
- * All entities under control of this management plane
- */
- Collection<Entity> getEntities();
-
- /**
- * All entities managed as part of the given application
- */
- Collection<Entity> getEntitiesInApplication(Application application);
-
- /**
- * All entities under control of this management plane that match the given filter
- */
- Collection<Entity> findEntities(Predicate<? super Entity> filter);
-
- /**
- * All entities managed as part of the given application that match the given filter
- */
- Collection<Entity> findEntitiesInApplication(Application application, Predicate<? super Entity> filter);
-
- /**
- * Returns the entity with the given identifier (may be a full instance, or a proxy to one which is remote),
- * or null.
- */
- @Nullable Entity getEntity(String id);
-
- /** whether the entity is under management by this management context */
- boolean isManaged(Entity entity);
-
- /**
- * Begins management for the given entity and its children, recursively.
- *
- * depending on the implementation of the management context,
- * this might push it out to one or more remote management nodes.
- * Manage an entity.
- */
- // TODO manage and unmanage without arguments should be changed to take an explicit ManagementTransitionMode
- // (but that class is not currently in the API project)
- void manage(Entity e);
-
- /**
- * Causes the given entity and its children, recursively, to be removed from the management plane
- * (for instance because the entity is no longer relevant)
- */
- void unmanage(Entity e);
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/2e2de8e4/api/src/main/java/org/apache/brooklyn/management/ExecutionContext.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/org/apache/brooklyn/management/ExecutionContext.java b/api/src/main/java/org/apache/brooklyn/management/ExecutionContext.java
deleted file mode 100644
index 147689f..0000000
--- a/api/src/main/java/org/apache/brooklyn/management/ExecutionContext.java
+++ /dev/null
@@ -1,67 +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 org.apache.brooklyn.management;
-
-import java.util.Map;
-import java.util.Set;
-import java.util.concurrent.Callable;
-import java.util.concurrent.Executor;
-
-import org.apache.brooklyn.api.entity.Entity;
-
-/**
- * This is a Brooklyn extension to the Java {@link Executor}.
- *
- * The "context" could, for example, be an {@link Entity} so that tasks executed
- * can be annotated as executing in that context.
- */
-public interface ExecutionContext extends Executor {
-
- /**
- * Get the tasks executed through this context (returning an immutable set).
- */
- Set<Task<?>> getTasks();
-
- /**
- * See {@link ExecutionManager#submit(Map, TaskAdaptable)} for properties that can be passed in.
- */
- Task<?> submit(Map<?,?> properties, Runnable runnable);
-
- /**
- * See {@link ExecutionManager#submit(Map, TaskAdaptable)} for properties that can be passed in.
- */
- <T> Task<T> submit(Map<?,?> properties, Callable<T> callable);
-
- /** {@link ExecutionManager#submit(Runnable) */
- Task<?> submit(Runnable runnable);
-
- /** {@link ExecutionManager#submit(Callable) */
- <T> Task<T> submit(Callable<T> callable);
-
- /** See {@link ExecutionManager#submit(Map, TaskAdaptable)}. */
- <T> Task<T> submit(TaskAdaptable<T> task);
-
- /**
- * See {@link ExecutionManager#submit(Map, TaskAdaptable)} for properties that can be passed in.
- */
- <T> Task<T> submit(Map<?,?> properties, TaskAdaptable<T> task);
-
- boolean isShutdown();
-
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/2e2de8e4/api/src/main/java/org/apache/brooklyn/management/ExecutionManager.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/org/apache/brooklyn/management/ExecutionManager.java b/api/src/main/java/org/apache/brooklyn/management/ExecutionManager.java
deleted file mode 100644
index 5c70b61..0000000
--- a/api/src/main/java/org/apache/brooklyn/management/ExecutionManager.java
+++ /dev/null
@@ -1,117 +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 org.apache.brooklyn.management;
-
-import java.util.Collection;
-import java.util.Map;
-import java.util.Set;
-import java.util.concurrent.Callable;
-import java.util.concurrent.ExecutorService;
-
-import org.apache.brooklyn.api.entity.Entity;
-
-/**
- * This class manages the execution of a number of jobs with tags.
- *
- * It is like an executor service (and it ends up delegating to one) but adds additional support
- * where jobs can be:
- * <ul>
- * <li>Tracked with tags/buckets
- * <li>Be {@link Runnable}s, {@link Callable}s, or {@link groovy.lang.Closure}s
- * <li>Remembered after completion
- * <li>Treated as {@link Task} instances (see below)
- * <li>Given powerful synchronization capabilities
- * </ul>
- * <p>
- * The advantage of treating them as {@link Task} instances include:
- * <ul>
- * <li>Richer status information
- * <li>Started-by, contained-by relationships automatically remembered
- * <li>Runtime metadata (start, stop, etc)
- * <li>Grid and multi-machine support)
- * </ul>
- * <p>
- * For usage instructions see {@link #submit(Map, TaskAdaptable)}, and for examples see the various
- * {@code ExecutionTest} and {@code TaskTest} instances.
- * <p>
- * It has been developed for multi-location provisioning and management to track work being
- * done by each {@link Entity}.
- * <p>
- * Note the use of the environment variable {@code THREAD_POOL_SIZE} which is used to size
- * the {@link ExecutorService} thread pool. The default is calculated as twice the number
- * of CPUs in the system plus two, giving 10 for a four core system, 18 for an eight CPU
- * server and so on.
- */
-public interface ExecutionManager {
- public boolean isShutdown();
-
- /** returns the task with the given ID, or null if none */
- public Task<?> getTask(String id);
-
- /** returns all tasks with the given tag (immutable) */
- public Set<Task<?>> getTasksWithTag(Object tag);
-
- /** returns all tasks that have any of the given tags (immutable) */
- public Set<Task<?>> getTasksWithAnyTag(Iterable<?> tags);
-
- /** returns all tasks that have all of the given tags (immutable) */
- public Set<Task<?>> getTasksWithAllTags(Iterable<?> tags);
-
- /** returns all tags known to this manager (immutable) */
- public Set<Object> getTaskTags();
-
-// /** returns all tasks known to this manager (immutable) */
-// public Set<Task<?>> getAllTasks();
-
- /** see {@link #submit(Map, TaskAdaptable)} */
- public Task<?> submit(Runnable r);
-
- /** see {@link #submit(Map, TaskAdaptable)} */
- public <T> Task<T> submit(Callable<T> c);
-
- /** see {@link #submit(Map, TaskAdaptable)} */
- public <T> Task<T> submit(TaskAdaptable<T> task);
-
- /** see {@link #submit(Map, TaskAdaptable)} */
- public Task<?> submit(Map<?, ?> flags, Runnable r);
-
- /** see {@link #submit(Map, TaskAdaptable)} */
- public <T> Task<T> submit(Map<?, ?> flags, Callable<T> c);
-
- /**
- * Submits the given {@link Task} for execution in the context associated with this manager.
- *
- * The following optional flags supported (in the optional map first arg):
- * <ul>
- * <li><em>tag</em> - A single object to be used as a tag for looking up the task
- * <li><em>tags</em> - A {@link Collection} of object tags each of which the task should be associated,
- * used for associating with contexts, mutex execution, and other purposes
- * <li><em>synchId</em> - A string, or {@link Collection} of strings, representing a category on which an object should own a synch lock
- * <li><em>synchObj</em> - A string, or {@link Collection} of strings, representing a category on which an object should own a synch lock
- * <li><em>newTaskStartCallback</em> - A {@link groovy.lang.Closure} that will be invoked just before the task starts if it starts as a result of this call
- * <li><em>newTaskEndCallback</em> - A {@link groovy.lang.Closure} that will be invoked when the task completes if it starts as a result of this call
- * </ul>
- * Callbacks run in the task's thread, and if the callback is a {@link groovy.lang.Closure} it is passed the task for convenience. The closure can be any of the
- * following types; either a {@link groovy.lang.Closure}, {@link Runnable} or {@link Callable}.
- * <p>
- * If a Map is supplied it must be modifiable (currently; may allow immutable maps in future).
- */
- public <T> Task<T> submit(Map<?, ?> flags, TaskAdaptable<T> task);
-
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/2e2de8e4/api/src/main/java/org/apache/brooklyn/management/HasTaskChildren.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/org/apache/brooklyn/management/HasTaskChildren.java b/api/src/main/java/org/apache/brooklyn/management/HasTaskChildren.java
deleted file mode 100644
index d8d5c57..0000000
--- a/api/src/main/java/org/apache/brooklyn/management/HasTaskChildren.java
+++ /dev/null
@@ -1,39 +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 org.apache.brooklyn.management;
-
-import com.google.common.annotations.Beta;
-
-/**
- * Interface marks tasks which have explicit children,
- * typically where the task defines the ordering of running those children tasks
- * <p>
- * The {@link Task#getSubmittedByTask()} on the child will typically return the parent,
- * but note there are other means of submitting tasks (e.g. background, in the same {@link ExecutionContext}),
- * where the submitter has no API reference to the submitted tasks.
- * <p>
- * In general the children mechanism is preferred as it is easier to navigate
- * (otherwise you have to scan the {@link ExecutionContext} to find tasks submitted by a task).
- */
-@Beta // in 0.6.0
-public interface HasTaskChildren {
-
- public Iterable<Task<?>> getChildren();
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/2e2de8e4/api/src/main/java/org/apache/brooklyn/management/LocationManager.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/org/apache/brooklyn/management/LocationManager.java b/api/src/main/java/org/apache/brooklyn/management/LocationManager.java
deleted file mode 100644
index c10249c..0000000
--- a/api/src/main/java/org/apache/brooklyn/management/LocationManager.java
+++ /dev/null
@@ -1,87 +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 org.apache.brooklyn.management;
-
-import java.util.Collection;
-import java.util.Map;
-
-import brooklyn.location.Location;
-import brooklyn.location.LocationSpec;
-
-/**
- * For managing and querying entities.
- */
-public interface LocationManager {
-
- /**
- * Creates a new location, which is tracked by the management context.
- *
- * @param spec
- */
- <T extends Location> T createLocation(LocationSpec<T> spec);
-
- /**
- * Convenience (particularly for groovy code) to create a location.
- * Equivalent to {@code createLocation(LocationSpec.create(type).configure(config))}
- *
- * @see #createLocation(LocationSpec)
- */
- <T extends Location> T createLocation(Map<?,?> config, Class<T> type);
-
- /**
- * All locations under control of this management plane.
- *
- * This returns a snapshot of the current locations; it will not reflect future changes in the locations.
- * If no locations are found, the collection will be empty (i.e. null is never returned).
- */
- Collection<Location> getLocations();
-
- /**
- * Returns the location under management (e.g. in use) with the given identifier
- * (e.g. random string; and different to the LocationDefinition id).
- * May return a full instance, or a proxy to one which is remote.
- * If no location found with that id, returns null.
- */
- Location getLocation(String id);
-
- /** whether the location is under management by this management context */
- boolean isManaged(Location loc);
-
- /**
- * Begins management for the given location and its children, recursively.
- *
- * depending on the implementation of the management context,
- * this might push it out to one or more remote management nodes.
- * Manage a location.
- *
- * @since 0.6.0 (added only for backwards compatibility, where locations are being created directly).
- * @deprecated in 0.6.0; use {@link #createLocation(LocationSpec)} instead.
- */
- Location manage(Location loc);
-
- /**
- * Causes the given location and its children, recursively, to be removed from the management plane
- * (for instance because the location is no longer relevant).
- *
- * If the given location is not managed (e.g. it has already been unmanaged) then this is a no-op
- * (though it may be logged so duplicate calls are best avoided).
- */
- void unmanage(Location loc);
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/2e2de8e4/api/src/main/java/org/apache/brooklyn/management/ManagementContext.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/org/apache/brooklyn/management/ManagementContext.java b/api/src/main/java/org/apache/brooklyn/management/ManagementContext.java
deleted file mode 100644
index 9f9fb55..0000000
--- a/api/src/main/java/org/apache/brooklyn/management/ManagementContext.java
+++ /dev/null
@@ -1,255 +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 org.apache.brooklyn.management;
-
-import java.io.Serializable;
-import java.net.URI;
-import java.util.Collection;
-
-import org.apache.brooklyn.api.basic.BrooklynObject;
-import org.apache.brooklyn.api.catalog.BrooklynCatalog;
-import org.apache.brooklyn.api.entity.Application;
-import org.apache.brooklyn.api.entity.Entity;
-import org.apache.brooklyn.api.entity.drivers.DriverDependentEntity;
-import org.apache.brooklyn.api.entity.drivers.EntityDriverManager;
-import org.apache.brooklyn.api.entity.drivers.downloads.DownloadResolverManager;
-import org.apache.brooklyn.api.entity.rebind.RebindManager;
-import org.apache.brooklyn.management.entitlement.EntitlementManager;
-import org.apache.brooklyn.management.ha.HighAvailabilityManager;
-
-import brooklyn.config.StringConfigMap;
-import brooklyn.location.LocationRegistry;
-import brooklyn.util.guava.Maybe;
-
-import com.google.common.annotations.Beta;
-
-/**
- * This is the entry point for accessing and interacting with a realm of applications and their entities in Brooklyn.
- *
- * For example, policies and the management console(s) (web-app, etc) can use this to interact with entities;
- * policies, web-app, and entities share the realm for subscribing to events, executing tasks, and generally co-existing.
- * <p>
- * It may refer to several applications, and it refers to all the entities descended from those applications.
- */
-public interface ManagementContext {
-
- // TODO Consider separating out into a ConfigManager for methods like:
- // - getConfig()
- // - reloadBrooklynProperties();
- // - addPropertiesReloadListener
- // - removePropertiesReloadListener
- // - interface PropertiesReloadListener
-
- /**
- * UID for the Brooklyn management plane which this {@link ManagementContext} node is a part of.
- * <p>
- * Each Brooklyn entity is actively managed by a unique management plane
- * whose ID which should not normally change for the duration of that entity,
- * even though the nodes in that plane might, and the plane may go down and come back up.
- * In other words the value of {@link Application#getManagementContext()#getManagementPlaneId()}
- * will generally be constant (in contrast to {@link #getManagementNodeId()}).
- * <p>
- * This value should not be null unless the management context is a non-functional
- * (non-deployment) instance. */
- String getManagementPlaneId();
-
- /**
- * UID for this {@link ManagementContext} node (as part of a single management plane).
- * <p>
- * No two instances of {@link ManagementContext} should ever have the same node UID.
- * The value of {@link Application#getManagementContext()#getManagementNodeId()} may
- * change many times (in contrast to {@link #getManagementPlaneId()}).
- * <p>
- * This value should not be null unless the management context is a non-functional
- * (non-deployment) instance. */
- String getManagementNodeId();
-
- /**
- * The URI that this management node's REST API is available at, or absent if the node's
- * API is unavailable.
- */
- Maybe<URI> getManagementNodeUri();
-
- /**
- * All applications under control of this management plane
- */
- Collection<Application> getApplications();
-
- /**
- * Returns the {@link EntityManager} instance for managing/querying entities.
- */
- EntityManager getEntityManager();
-
- /**
- * Returns the {@link ExecutionManager} instance for entities and users in this management realm
- * to submit tasks and to observe what tasks are occurring
- */
- ExecutionManager getExecutionManager();
-
- /**
- * Returns an {@link ExecutionContext} within the {@link ExecutionManager} for tasks
- * associated to the Brooklyn node's operation (not any entities).
- **/
- ExecutionContext getServerExecutionContext();
-
- /**
- * Returns the {@link EntityDriverManager} entities can use to create drivers. This
- * manager can also be used to programmatically customize which driver type to use
- * for entities in different locations.
- *
- * The default strategy for choosing a driver is to use a naming convention:
- * {@link DriverDependentEntity#getDriverInterface()} returns the interface that the
- * driver must implement; its name should end in "Driver". For example, this suffix is
- * replaced with "SshDriver" for SshMachineLocation, for example.
- */
- EntityDriverManager getEntityDriverManager();
-
- /**
- * Returns the {@link DownloadResolverManager} for resolving things like which URL to download an installer from.
- *
- * The default {@link DownloadResolverManager} will retrieve {@code entity.getAttribute(Attributes.DOWNLOAD_URL)},
- * and substitute things like "${version}" etc.
- *
- * However, additional resolvers can be registered to customize this behaviour (e.g. to always go to an
- * enterprise's repository).
- */
- DownloadResolverManager getEntityDownloadsManager();
-
- /**
- * Returns the {@link SubscriptionManager} instance for entities and users of this management realm
- * to subscribe to sensor events (and, in the case of entities, to emit sensor events)
- */
- SubscriptionManager getSubscriptionManager();
-
- //TODO (Alex) I'm not sure the following two getXxxContext methods are needed on the interface;
- //I expect they will only be called once, in AbstractEntity, and fully capable
- //there of generating the respective contexts from the managers
- //(Litmus test will be whether there is anything in FederatedManagementContext
- //which requires a custom FederatedExecutionContext -- or whether BasicEC
- //works with FederatedExecutionManager)
- /**
- * Returns an {@link ExecutionContext} instance representing tasks
- * (from the {@link ExecutionManager}) associated with this entity, and capable
- * of conveniently running such tasks which will be associated with that entity
- */
- ExecutionContext getExecutionContext(Entity entity);
-
- /**
- * Returns a {@link SubscriptionContext} instance representing subscriptions
- * (from the {@link SubscriptionManager}) associated with this entity, and capable
- * of conveniently subscribing on behalf of that entity
- */
- SubscriptionContext getSubscriptionContext(Entity entity);
-
- @Beta // method may move to an internal interface; brooklyn users should not need to call this directly
- RebindManager getRebindManager();
-
- /**
- * @since 0.7.0
- */
- @Beta // method may move to an internal interface; brooklyn users should not need to call this directly
- HighAvailabilityManager getHighAvailabilityManager();
-
- /**
- * Returns the ConfigMap (e.g. BrooklynProperties) applicable to this management context.
- * Defaults to reading ~/.brooklyn/brooklyn.properties but configurable in the management context.
- */
- StringConfigMap getConfig();
-
- /**
- * Whether the management context has been initialized and not yet terminated.
- * This does not mean startup is entirely completed. See also {@link #isStartupComplete()}.
- */
- // TODO should we replace this with isNotYetTerminated() ??
- // and perhaps introduce isFullyRunning() which does (isStartupComplete() && isRunning()),
- // and/or move to a MgmtContextStatus subclass where errors can also be stored?
- public boolean isRunning();
-
- /**
- * Whether all startup tasks have completed. Previous to this point the management context is still usable
- * (and hence {@link #isRunning()} returns true immediately after construction)
- * but some subsystems (e.g. persistence, OSGi, webapps, entities started at startup)
- * may not be available until this returns true.
- * <p>
- * Also see {@link #isStartupComplete()}.
- */
- @Beta // see comment on isRunning() as items might move to a status handler
- public boolean isStartupComplete();
-
- /** Record of configured locations and location resolvers */
- LocationRegistry getLocationRegistry();
-
- /** Record of configured Brooklyn entities (and templates and policies) which can be loaded */
- BrooklynCatalog getCatalog();
-
- /** Returns the class loader to be used to load items.
- * Temporary routine while catalog supports classloader-based and OSGi-based classloading. */
- @Beta
- ClassLoader getCatalogClassLoader();
-
- LocationManager getLocationManager();
-
- /**
- * For controlling access to operations - can be queried to find if an operation is allowed.
- * Callers should *not* cache the result of this method, but should instead always call
- * again to get the {@link AccessController}.
- */
- AccessController getAccessController();
-
- /**
- * Reloads locations from {@code brooklyn.properties}. Any changes will apply only to newly created applications
- */
- void reloadBrooklynProperties();
-
- /**
- * Listener for {@code brooklyn.properties} reload events.
- *
- * @see {@link #raddPropertiesReloadListenerPropertiesReloadListener)}
- * @see {@link #removePropertiesReloadListener(PropertiesReloadListener)}
- */
- interface PropertiesReloadListener extends Serializable {
-
- /** Called when {@code brooklyn.properties} is reloaded. */
- void reloaded();
-
- }
-
- /**
- * Registers a listener to be notified when brooklyn.properties is reloaded
- */
- void addPropertiesReloadListener(PropertiesReloadListener listener);
-
- /**
- * Deregisters a listener from brooklyn.properties reload notifications
- */
- void removePropertiesReloadListener(PropertiesReloadListener listener);
-
- /**
- * Active entitlements checker instance.
- */
- EntitlementManager getEntitlementManager();
-
- /** As {@link #lookup(String, Class)} but not constraining the return type */
- public BrooklynObject lookup(String id);
-
- /** Finds an entity with the given ID known at this management context */
- // TODO in future support policies etc
- public <T extends BrooklynObject> T lookup(String id, Class<T> type);
-
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/2e2de8e4/api/src/main/java/org/apache/brooklyn/management/SubscriptionContext.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/org/apache/brooklyn/management/SubscriptionContext.java b/api/src/main/java/org/apache/brooklyn/management/SubscriptionContext.java
deleted file mode 100644
index 2260c2c..0000000
--- a/api/src/main/java/org/apache/brooklyn/management/SubscriptionContext.java
+++ /dev/null
@@ -1,66 +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 org.apache.brooklyn.management;
-
-import java.util.Map;
-import java.util.Set;
-
-import org.apache.brooklyn.api.entity.Entity;
-import org.apache.brooklyn.api.entity.Group;
-import org.apache.brooklyn.api.event.Sensor;
-import org.apache.brooklyn.api.event.SensorEvent;
-import org.apache.brooklyn.api.event.SensorEventListener;
-
-/**
- * This is the context through which an {@link Entity} can manage its subscriptions.
- */
-public interface SubscriptionContext {
- /**
- * As {@link SubscriptionManager#subscribe(Map, Entity, Sensor, SensorEventListener)} with default subscription parameters for this context
- */
- <T> SubscriptionHandle subscribe(Map<String, Object> flags, Entity producer, Sensor<T> sensor, SensorEventListener<? super T> listener);
-
- /** @see #subscribe(Map, Entity, Sensor, SensorEventListener) */
- <T> SubscriptionHandle subscribe(Entity producer, Sensor<T> sensor, SensorEventListener<? super T> listener);
-
- /** @see #subscribe(Map, Entity, Sensor, SensorEventListener) */
- <T> SubscriptionHandle subscribeToChildren(Map<String, Object> flags, Entity parent, Sensor<T> sensor, SensorEventListener<? super T> listener);
-
- /** @see #subscribe(Map, Entity, Sensor, SensorEventListener) */
- <T> SubscriptionHandle subscribeToChildren(Entity parent, Sensor<T> sensor, SensorEventListener<? super T> listener);
-
- /** @see #subscribe(Map, Entity, Sensor, SensorEventListener) */
- <T> SubscriptionHandle subscribeToMembers(Map<String, Object> flags, Group parent, Sensor<T> sensor, SensorEventListener<? super T> listener);
-
- /** @see #subscribe(Map, Entity, Sensor, SensorEventListener) */
- <T> SubscriptionHandle subscribeToMembers(Group parent, Sensor<T> sensor, SensorEventListener<? super T> listener);
-
- /** @see SubscriptionManager#unsubscribe(SubscriptionHandle) */
- boolean unsubscribe(SubscriptionHandle subscriptionId);
-
- /** causes all subscriptions to be deregistered
- * @return number of subscriptions removed */
- int unsubscribeAll();
-
- /** @see SubscriptionManager#publish(SensorEvent) */
- <T> void publish(SensorEvent<T> event);
-
- /** Return the subscriptions associated with this context */
- Set<SubscriptionHandle> getSubscriptions();
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/2e2de8e4/api/src/main/java/org/apache/brooklyn/management/SubscriptionHandle.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/org/apache/brooklyn/management/SubscriptionHandle.java b/api/src/main/java/org/apache/brooklyn/management/SubscriptionHandle.java
deleted file mode 100644
index e601579..0000000
--- a/api/src/main/java/org/apache/brooklyn/management/SubscriptionHandle.java
+++ /dev/null
@@ -1,27 +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 org.apache.brooklyn.management;
-
-/**
- * A "receipt" returned by {@link SubscriptionContext} and {@link SubscriptionManager}'s {@code subscribe()}
- * methods. It can be used to unsubscribe - see {@link SubscriptionContext#unsubscribe(SubscriptionHandle)}
- * and {@link SubscriptionManager#unsubscribe(SubscriptionHandle)}.
- */
-public interface SubscriptionHandle {
-}