Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GPII-3594: Replace lifecycle manager dynamic session components with standard subcomponents. #727

Merged
merged 6 commits into from Jan 16, 2019
Merged
1 .nycrc
@@ -64,7 +64,6 @@
"!**/gpii/node_modules/lifecycleActions/index.js",
"!**/gpii/node_modules/lifecycleActions/src/LifecycleActions.js",
"!**/gpii/node_modules/lifecycleManager/index.js",
"!**/gpii/node_modules/lifecycleManager/src/DynamicComponentIndexer.js",
"!**/gpii/node_modules/lifecycleManager/src/LifecycleManager.js",
"!**/gpii/node_modules/lifecycleManager/src/LifecycleManagerSession.js",
"!**/gpii/node_modules/lifecycleManager/src/PrivateMatchMaker.js",
@@ -161,17 +161,17 @@ gpii.contextManager.stopTemporalEnvironmentReporter = function (that) {
**/
gpii.contextManager.contextChanged = function (that, lifecycleManager, forceContextName) {
// find logged in users
var activeGpiiKeys = lifecycleManager.getActiveSessionGpiiKeys();
var activeSession = lifecycleManager.getSession();
var activeGpiiKey = activeSession.options.gpiiKey;

// if no one is logged in, or, a system reserved key is logged in, do nothing
if (activeGpiiKeys.length === 0 || gpii.isReservedGpiiKey(activeGpiiKeys[0])) {
if (!activeGpiiKey || gpii.isReservedGpiiKey(activeGpiiKey)) {
return;
}
var activeSession = lifecycleManager.getSession(activeGpiiKeys);
var fullPayload = fluid.extend(true, {}, activeSession.model);
var oldActiveContext = fullPayload.activeContextName;

fluid.log("contextManager starts to apply a context change from the old context \"", oldActiveContext, "\" to the new context \"", forceContextName, "\" for the GPII key - ", activeGpiiKeys[0]);
fluid.log("contextManager starts to apply a context change from the old context \"", oldActiveContext, "\" to the new context \"", forceContextName, "\" for the GPII key - ", activeGpiiKey);

// find and update context:
that.updateActiveContextName(fullPayload, forceContextName);
@@ -71,6 +71,11 @@ fluid.defaults("gpii.metrics.lifecycle", {
}
},
listeners: {
"{lifecycleManager}.events.onCreate": {
namespace: "trackContextChange",
listener: "gpii.metrics.trackContextChange",
args: ["{that}", "{lifecycleManager}"]
},
"{lifecycleManager}.events.onSessionStart": [
{
namespace: "eventLog",
@@ -84,9 +89,6 @@ fluid.defaults("gpii.metrics.lifecycle", {
session: "@expand:{lifecycleManager}.getSession({arguments}.1)"
}
]
}, {
funcName: "gpii.metrics.sessionStarted",
args: ["{that}", "{lifecycleManager}", "{arguments}.1"]
}, {
func: "{that}.events.onStartMetrics"
}],
@@ -118,6 +120,29 @@ fluid.defaults("gpii.metrics.lifecycle", {
}
});

/**
* Attached as the lifecycleManager.onCreate event.
*
* Adds a model change listener to the user session's model to listen for changes to the preferences.
*
* @param {Component} that - The gpii.metrics instance.
* @param {Component} lifecycleManager - The lifecycleManager instance.
*/
gpii.metrics.trackContextChange = function (that, lifecycleManager) {
var userSession = lifecycleManager.getSession();
userSession.applier.modelChanged.addListener({
path: "preferences.contexts",
excludeSource: "SESSIONCLEANUP"
}, function (newValue, oldValue) {
var current = newValue && newValue[userSession.model.activeContextName];
current = current && current.preferences;
var previous = oldValue && oldValue[userSession.model.activeContextName];
previous = previous && previous.preferences;

gpii.metrics.preferenceChanged(that, current, previous);
});
};

/**
* Log the solutions as they're applied.
*
@@ -142,27 +167,6 @@ gpii.metrics.snapshotUpdate = function (that, sessionID, originalSettings) {
});
};

/**
* Handles the lifecycle.onSessionStarted event.
*
* Adds a listener to the new session's model to listen for changes to the preferences.
*
* @param {Component} that - The gpii.metrics instance.
* @param {Component} lifecycleManager - The lifecycleManager instance.
* @param {String} gpiiKey - The gpii key of the session.
*/
gpii.metrics.sessionStarted = function (that, lifecycleManager, gpiiKey) {
var session = lifecycleManager.getSession(gpiiKey);
session.applier.modelChanged.addListener("preferences.contexts", function (newValue, oldValue) {
var current = newValue && newValue[session.model.activeContextName];
current = current && current.preferences;
var previous = oldValue && oldValue[session.model.activeContextName];
previous = previous && previous.preferences;

gpii.metrics.preferenceChanged(that, current, previous);
});
};

/**
* Called when a preference has changed. (a change in the preferences field of the session's model.)
*
@@ -121,6 +121,10 @@ fluid.defaults("gpii.flowManager.local", {
privateMatchMaker: "{gpii.flowManager.local}.privateMatchMaker"
},
target: "{that lifecycleManager}.options.components"
},
"lifecycleManager.pspChannel.sessionBinder": {
record: "gpii.pspChannel.sessionBinder",
target: "{that lifecycleManager session}.options.gradeNames"
}
},
components: {
@@ -78,11 +78,6 @@ fluid.defaults("gpii.pspChannel", {
members: {
outputBlocked: null
},
distributeOptions: {
// Not {lifecycleManager session} because of FLUID-6193
target: "{flowManager lifecycleManager session}.options.gradeNames",
record: "gpii.pspChannel.sessionBinder"
},
listeners: {
"{lifecycleManager}.events.onSessionStop": {
namespace: "pspChannel",
@@ -133,10 +128,9 @@ gpii.pspChannel.filterSolution = function (solution) {
// Explicit save when the save button is clicked
gpii.pspChannel.savePreferences = function (flowManager, lifecycleManager, preferencesAppliedLocalEvent) {
// Grab current active lifecycle manager session
var session = lifecycleManager.getSession(lifecycleManager.getActiveSessionGpiiKeys());

var gpiiKey = session.options.gpiiKey;
var preferences = session.model.preferences;
var userSession = lifecycleManager.getSession();
var gpiiKey = userSession.options.gpiiKey;
var preferences = userSession.model.preferences;
fluid.log("PSPChannel: explicit save for gpiiKey (", gpiiKey, "), with preferences: ", preferences);
flowManager.savePreferences(gpiiKey, preferences);

@@ -218,7 +212,7 @@ gpii.pspChannel.sessionToPSP = function (model, transformSpec) {

gpii.pspChannel.modelChangeListener = function (handler, pspChannel, value, oldValue, path, transaction) {
fluid.log("PSPChannel's PSP-facing modelChangeListener, sources are ", fluid.keys(transaction.sources));
if (!transaction.sources.PSP) {
if (!transaction.sources.PSP && !transaction.sources.SESSIONCLEANUP) {
fluid.log("Model change source is not PSP - candidate for update message");
if (pspChannel.outputBlocked) {
// Ensure that we queue just a single outgoing message for when the channel unblocks
@@ -42,17 +42,16 @@

gpii.flowManager.sessionAware.withSession = function (that, lifecycleManager, onSuccess, failMessage, onError) {
onError = onError || that.events.onError.fire;
var gpiiKeys = lifecycleManager.getActiveSessionGpiiKeys();
if (gpiiKeys.length === 0) {
var userSession = lifecycleManager.getSession();
if (!userSession.options.gpiiKey) {
failMessage = failMessage || "Error handling request which required active session, but none was active";
onError({
isError: true,
statusCode: 401,
message: failMessage
});
} else {
var session = lifecycleManager.getSession(gpiiKeys);
onSuccess(session, gpiiKeys);
onSuccess(userSession, userSession.options.gpiiKey);
}
};

@@ -10,7 +10,6 @@ fluid.require("%flowManager/src/SystemUtils.js");
// * Cloud Based Flow Manager: to perform matchmaking in the cloud without the present of lifecycleManager;
// * lifecycleManager: to handle user logon requests.
fluid.require("%flowManager/src/MatchMaking.js");
require("./src/DynamicComponentIndexer.js");
require("./src/Resolvers.js");
require("./src/LifecycleManagerSession.js");
require("./src/PrivateMatchMaker.js");

This file was deleted.

ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.