From c683c5a16706434b101f5fe04bb51af1350e01c7 Mon Sep 17 00:00:00 2001 From: HÃ¥kon Hallingstad Date: Wed, 20 Sep 2017 14:29:30 +0200 Subject: Move SuperModel API to config-model-api --- .../yahoo/config/model/api/ApplicationInfo.java | 26 ++++++++++++++++++++++ .../yahoo/config/model/api/SuperModelListener.java | 20 +++++++++++++++++ .../yahoo/config/model/api/SuperModelProvider.java | 13 +++++++++++ 3 files changed, 59 insertions(+) create mode 100644 config-model-api/src/main/java/com/yahoo/config/model/api/ApplicationInfo.java create mode 100644 config-model-api/src/main/java/com/yahoo/config/model/api/SuperModelListener.java create mode 100644 config-model-api/src/main/java/com/yahoo/config/model/api/SuperModelProvider.java (limited to 'config-model-api/src') diff --git a/config-model-api/src/main/java/com/yahoo/config/model/api/ApplicationInfo.java b/config-model-api/src/main/java/com/yahoo/config/model/api/ApplicationInfo.java new file mode 100644 index 00000000000..c6a72ebb3ff --- /dev/null +++ b/config-model-api/src/main/java/com/yahoo/config/model/api/ApplicationInfo.java @@ -0,0 +1,26 @@ +// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +package com.yahoo.config.model.api; + +import com.yahoo.config.provision.ApplicationId; + +public class ApplicationInfo { + private final ApplicationId applicationId; + private final long generation; + private final Model model; // NOT immutable + + public ApplicationInfo(ApplicationId applicationId, long generation, Model model) { + this.applicationId = applicationId; + this.generation = generation; + this.model = model; + } + + public ApplicationId getApplicationId() { + return applicationId; + } + public long getGeneration() { + return generation; + } + public Model getModel() { + return model; + } +} diff --git a/config-model-api/src/main/java/com/yahoo/config/model/api/SuperModelListener.java b/config-model-api/src/main/java/com/yahoo/config/model/api/SuperModelListener.java new file mode 100644 index 00000000000..16580c9e9f6 --- /dev/null +++ b/config-model-api/src/main/java/com/yahoo/config/model/api/SuperModelListener.java @@ -0,0 +1,20 @@ +// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +package com.yahoo.config.model.api; + +import com.yahoo.config.provision.ApplicationId; + +/** + * Interface for those wanting to be notified about changes to the SuperModel. + */ +public interface SuperModelListener { + /** + * Application has been activated: Either deployed the first time, + * internally redeployed, or externally triggered redeploy. + */ + void applicationActivated(ApplicationInfo application); + + /** + * Application has been removed. + */ + void applicationRemoved(ApplicationId id); +} diff --git a/config-model-api/src/main/java/com/yahoo/config/model/api/SuperModelProvider.java b/config-model-api/src/main/java/com/yahoo/config/model/api/SuperModelProvider.java new file mode 100644 index 00000000000..42437b20b83 --- /dev/null +++ b/config-model-api/src/main/java/com/yahoo/config/model/api/SuperModelProvider.java @@ -0,0 +1,13 @@ +// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +package com.yahoo.config.model.api; + +import java.util.List; + +public interface SuperModelProvider { + /** + * Returns all applications in the SuperModel. All changes to the SuperModel + * following that snapshot will be published to the listener. Warning: The listener + * methods may have been invoked before (or concurrently with) this method returning. + */ + List snapshot(SuperModelListener listener); +} -- cgit v1.2.3