Merge pull request #112 from andrerod/dev
More ServiceRuntime incremental work
This commit is contained in:
Коммит
d04ce22311
|
@ -23,7 +23,7 @@ exports = module.exports = FileInputChannel;
|
|||
function FileInputChannel() { }
|
||||
|
||||
FileInputChannel.prototype.readInputChannel = function (name, parseXml, callback) {
|
||||
this.readData(name, function (error, data) {
|
||||
this._readData(name, function (error, data) {
|
||||
if (!error) {
|
||||
if (parseXml) {
|
||||
var parser = new xml2js.Parser();
|
||||
|
@ -42,7 +42,6 @@ FileInputChannel.prototype.readInputChannel = function (name, parseXml, callback
|
|||
});
|
||||
};
|
||||
|
||||
FileInputChannel.prototype.readData = function(name, callback) {
|
||||
var data = fs.readFileSync(name);
|
||||
callback(undefined, data);
|
||||
FileInputChannel.prototype._readData = function (name, callback) {
|
||||
fs.readFile(name, callback);
|
||||
};
|
|
@ -20,10 +20,12 @@ var xml2js = require('xml2js');
|
|||
// Expose 'NamedPipeInputChannel'.
|
||||
exports = module.exports = NamedPipeInputChannel;
|
||||
|
||||
function NamedPipeInputChannel() { }
|
||||
function NamedPipeInputChannel() {
|
||||
this.closeOnRead = true;
|
||||
}
|
||||
|
||||
NamedPipeInputChannel.prototype.readInputChannel = function (name, parseXml, callback) {
|
||||
this.readData(name, function (error, data) {
|
||||
this._readData(name, function (error, data) {
|
||||
if (!error) {
|
||||
var parts = data.toString().split('\r\n');
|
||||
|
||||
|
@ -46,24 +48,30 @@ NamedPipeInputChannel.prototype.readInputChannel = function (name, parseXml, cal
|
|||
}
|
||||
}
|
||||
|
||||
if (error) {
|
||||
error.fileName = name;
|
||||
}
|
||||
|
||||
callback(error, xml);
|
||||
} else {
|
||||
error.fileName = name;
|
||||
callback(error);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
NamedPipeInputChannel.prototype.readData = function(name, callback) {
|
||||
NamedPipeInputChannel.prototype._readData = function (name, callback) {
|
||||
var self = this;
|
||||
var client = net.connect(name);
|
||||
var data = '';
|
||||
client.on('data', function(chunk) {
|
||||
data += chunk;
|
||||
client.end();
|
||||
client.on('data', function (data) {
|
||||
if (self.closeOnRead) {
|
||||
client.end();
|
||||
}
|
||||
|
||||
callback(undefined, data);
|
||||
});
|
||||
|
||||
client.on('error', function(error) {
|
||||
client.on('error', function (error) {
|
||||
callback(error);
|
||||
});
|
||||
};
|
|
@ -14,7 +14,7 @@
|
|||
*/
|
||||
|
||||
// Module dependencies.
|
||||
var net = require("net");
|
||||
var net = require('net');
|
||||
|
||||
// Expose 'NamedPipeOutputChannel'.
|
||||
exports = module.exports = NamedPipeOutputChannel;
|
||||
|
|
|
@ -37,17 +37,28 @@ function Protocol1RuntimeClient(goalStateClient, currentStateClient, endpoint) {
|
|||
util.inherits(Protocol1RuntimeClient, EventEmitter);
|
||||
|
||||
Protocol1RuntimeClient.prototype.getCurrentGoalState = function (callback) {
|
||||
return this.goalStateClient.getCurrentGoalState(callback);
|
||||
this._addListeners();
|
||||
|
||||
this.goalStateClient.getCurrentGoalState(callback);
|
||||
};
|
||||
|
||||
Protocol1RuntimeClient.prototype.getRoleEnvironmentData = function (callback) {
|
||||
this.goalStateClient.on(ServiceRuntimeConstants.CHANGED, function (currentGoalState) {
|
||||
self.emit(ServiceRuntimeConstants.CHANGED, currentGoalState);
|
||||
});
|
||||
this._addListeners();
|
||||
|
||||
return this.goalStateClient.getRoleEnvironmentData(callback);
|
||||
this.goalStateClient.getRoleEnvironmentData(callback);
|
||||
};
|
||||
|
||||
Protocol1RuntimeClient.prototype.setCurrentState = function (state, callback) {
|
||||
this._addListeners();
|
||||
|
||||
this.currentStateClient.setCurrentState(state, callback);
|
||||
};
|
||||
|
||||
Protocol1RuntimeClient.prototype._addListeners = function () {
|
||||
var self = this;
|
||||
if (this.goalStateClient.listeners(ServiceRuntimeConstants.CHANGED).length === 0) {
|
||||
this.goalStateClient.on(ServiceRuntimeConstants.CHANGED, function (currentGoalState) {
|
||||
self.emit(ServiceRuntimeConstants.CHANGED, currentGoalState);
|
||||
});
|
||||
}
|
||||
};
|
|
@ -24,5 +24,5 @@ function Protocol1RuntimeCurrentStateClient(currentStateSerializer, outputChanne
|
|||
|
||||
Protocol1RuntimeCurrentStateClient.prototype.setCurrentState = function (state, callback) {
|
||||
var serializedState = this.currentStateSerializer.serialize(state);
|
||||
this.outputChannel.writeOutputChannel(serializedState, callback);
|
||||
this.outputChannel.writeOutputChannel(this.endpoint, serializedState, callback);
|
||||
};
|
|
@ -17,6 +17,7 @@
|
|||
var EventEmitter = require('events').EventEmitter;
|
||||
var util = require('util');
|
||||
|
||||
var azureutil = require('../util/util');
|
||||
var Constants = require('../util/constants');
|
||||
var ServiceRuntimeConstants = Constants.ServiceRuntimeConstants;
|
||||
|
||||
|
@ -41,7 +42,7 @@ util.inherits(Protocol1RuntimeGoalStateClient, EventEmitter);
|
|||
|
||||
Protocol1RuntimeGoalStateClient.prototype.getCurrentGoalState = function (callback) {
|
||||
var self = this;
|
||||
this.ensureGoalStateRetrieved(function (error) {
|
||||
this._ensureGoalStateRetrieved(function (error) {
|
||||
if (!error) {
|
||||
callback(error, self.currentGoalState);
|
||||
} else {
|
||||
|
@ -52,12 +53,16 @@ Protocol1RuntimeGoalStateClient.prototype.getCurrentGoalState = function (callba
|
|||
|
||||
Protocol1RuntimeGoalStateClient.prototype.getRoleEnvironmentData = function (callback) {
|
||||
var self = this;
|
||||
this.ensureGoalStateRetrieved(function (error) {
|
||||
this._ensureGoalStateRetrieved(function (error) {
|
||||
if (!error) {
|
||||
if (!self.currentEnvironmentData) {
|
||||
self.fileInputChannel.readInputChannel(self.currentGoalState.roleEnvironmentPath, true, function (readError, data) {
|
||||
self.currentEnvironmentData = self.roleEnvironmentDataDeserializer.deserialize(data);
|
||||
callback(readError, self.currentEnvironmentData);
|
||||
if (!readError) {
|
||||
self.currentEnvironmentData = self.roleEnvironmentDataDeserializer.deserialize(data);
|
||||
callback(readError, self.currentEnvironmentData);
|
||||
} else {
|
||||
callback(readError);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
callback(undefined, self.currentEnvironmentData);
|
||||
|
@ -68,18 +73,43 @@ Protocol1RuntimeGoalStateClient.prototype.getRoleEnvironmentData = function (cal
|
|||
});
|
||||
};
|
||||
|
||||
Protocol1RuntimeGoalStateClient.prototype.ensureGoalStateRetrieved = function (callback) {
|
||||
var self = this;
|
||||
if (!self.currentGoalState) {
|
||||
self.namedPipeInputChannel.readInputChannel(self.endpoint, true, function (error, data) {
|
||||
if (error) {
|
||||
callback(error);
|
||||
} else {
|
||||
self.currentGoalState = self.goalStateDeserializer.deserialize(data);
|
||||
callback();
|
||||
}
|
||||
});
|
||||
Protocol1RuntimeGoalStateClient.prototype._ensureGoalStateRetrieved = function (callback) {
|
||||
if (!this.currentGoalState) {
|
||||
this._ensurePolling(callback);
|
||||
} else {
|
||||
callback();
|
||||
}
|
||||
};
|
||||
|
||||
Protocol1RuntimeGoalStateClient.prototype._ensurePolling = function (callback) {
|
||||
var currentCallback = callback;
|
||||
var self = this;
|
||||
|
||||
self.namedPipeInputChannel.closeOnRead = false;
|
||||
self.namedPipeInputChannel.readInputChannel(self.endpoint, true, function (error, data) {
|
||||
if (error) {
|
||||
if (currentCallback) {
|
||||
currentCallback(error);
|
||||
}
|
||||
} else if (data) {
|
||||
self.currentGoalState = self.goalStateDeserializer.deserialize(data);
|
||||
|
||||
// reset environment data to force refresh
|
||||
if (self.currentEnvironmentData) {
|
||||
self.currentEnvironmentData = null;
|
||||
}
|
||||
|
||||
self.currentStateClient.endpoint = self.currentGoalState.currentStateEndpoint;
|
||||
|
||||
// if callback available invoke it to return immediately
|
||||
if (currentCallback) {
|
||||
currentCallback();
|
||||
currentCallback = null;
|
||||
} else {
|
||||
// no call back means this is looping for the second time and so there's
|
||||
// a re-read that triggers a changed event
|
||||
self.emit(ServiceRuntimeConstants.CHANGED, self.currentGoalState);
|
||||
}
|
||||
}
|
||||
});
|
||||
};
|
|
@ -17,6 +17,7 @@
|
|||
var events = require('events');
|
||||
var uuid = require('node-uuid');
|
||||
|
||||
var azureutil = require('../util/util');
|
||||
var RuntimeKernel = require('./runtimekernel');
|
||||
var Constants = require('../util/constants');
|
||||
var ServiceRuntimeConstants = Constants.ServiceRuntimeConstants;
|
||||
|
@ -31,8 +32,8 @@ RoleEnvironment.VersionEndpointFixedPath = '\\\\.\\pipe\\WindowsAzureRuntime';
|
|||
exports = module.exports = RoleEnvironment;
|
||||
|
||||
exports.clientId = uuid();
|
||||
exports.runtimeClient = null;
|
||||
|
||||
var runtimeClient = null;
|
||||
var currentGoalState = null;
|
||||
var currentEnvironmentData = null;
|
||||
var lastState = null;
|
||||
|
@ -41,66 +42,6 @@ var eventEmitter = new events.EventEmitter();
|
|||
|
||||
function RoleEnvironment() { }
|
||||
|
||||
RoleEnvironment._initialize = function (callback) {
|
||||
var getCurrentGoalState = function (error, rtClient) {
|
||||
if (error) {
|
||||
callback(error);
|
||||
} else {
|
||||
runtimeClient = rtClient;
|
||||
currentGoalState = runtimeClient.getCurrentGoalState(getCurrentEnvironmentData);
|
||||
}
|
||||
};
|
||||
|
||||
var getCurrentEnvironmentData = function (error, goalState) {
|
||||
if (error) {
|
||||
callback(error);
|
||||
} else {
|
||||
currentGoalState = goalState;
|
||||
runtimeClient.getRoleEnvironmentData(function (getRoleEnvironmentDataError, environmentData) {
|
||||
if (getRoleEnvironmentDataError) {
|
||||
callback(getRoleEnvironmentDataError);
|
||||
} else {
|
||||
currentEnvironmentData = environmentData;
|
||||
|
||||
runtimeClient.on(ServiceRuntimeConstants.CHANGED, function (newGoalState) {
|
||||
switch (newGoalState.expectedState) {
|
||||
case ServiceRuntimeConstants.STARTED:
|
||||
if (newGoalState.incarnation > currentGoalState.incarnation) {
|
||||
self._processGoalStateChange(newGoalState); // NOTE: do we need a callback here ?
|
||||
}
|
||||
break;
|
||||
case ServiceRuntimeConstants.STOPPED:
|
||||
/*
|
||||
raiseStoppingEvent();
|
||||
|
||||
CurrentState stoppedState = new AcquireCurrentState(clientId,
|
||||
newGoalState.getIncarnation(), CurrentStatus.STOPPED, maxDateTime);
|
||||
|
||||
runtimeClient.setCurrentState(stoppedState);*/
|
||||
break;
|
||||
}
|
||||
});
|
||||
|
||||
callback();
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
if (!runtimeClient) {
|
||||
var endpoint = process.env[RoleEnvironment.EnvironmentVariables.VersionEndpointEnvironmentName];
|
||||
|
||||
if (!endpoint) {
|
||||
endpoint = RoleEnvironment.VersionEndpointFixedPath;
|
||||
}
|
||||
|
||||
var kernel = RuntimeKernel.getKernel();
|
||||
kernel.getRuntimeVersionManager().getRuntimeClient(endpoint, getCurrentGoalState);
|
||||
} else {
|
||||
getCurrentGoalState(undefined, runtimeClient);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns a RoleInstance object that represents the role instance
|
||||
* in which this code is currently executing.
|
||||
|
@ -109,12 +50,11 @@ RoleEnvironment._initialize = function (callback) {
|
|||
*/
|
||||
RoleEnvironment.getCurrentRoleInstance = function (callback) {
|
||||
RoleEnvironment._initialize(function (error) {
|
||||
var currentInstance = undefined;
|
||||
if (!error) {
|
||||
currentInstance = currentEnvironmentData.currentInstance;
|
||||
if (error) {
|
||||
callback(error);
|
||||
} else {
|
||||
callback(undefined, currentEnvironmentData.currentInstance);
|
||||
}
|
||||
|
||||
callback(error, currentInstance);
|
||||
});
|
||||
};
|
||||
|
||||
|
@ -126,12 +66,11 @@ RoleEnvironment.getCurrentRoleInstance = function (callback) {
|
|||
*/
|
||||
RoleEnvironment.getDeploymentId = function (callback) {
|
||||
RoleEnvironment._initialize(function (error) {
|
||||
var id = undefined;
|
||||
if (!error) {
|
||||
id = currentEnvironmentData.id;
|
||||
if (error) {
|
||||
callback(error);
|
||||
} else {
|
||||
callback(undefined, currentEnvironmentData.id);
|
||||
}
|
||||
|
||||
callback(error, id);
|
||||
});
|
||||
};
|
||||
|
||||
|
@ -144,7 +83,7 @@ RoleEnvironment.getDeploymentId = function (callback) {
|
|||
RoleEnvironment.isAvailable = function (callback) {
|
||||
try {
|
||||
RoleEnvironment._initialize(function (initializeError) {
|
||||
callback(initializeError, runtimeClient != null);
|
||||
callback(initializeError, !azureutil.objectIsNull(exports.runtimeClient));
|
||||
});
|
||||
} catch (error) {
|
||||
callback(error, false);
|
||||
|
@ -156,14 +95,13 @@ RoleEnvironment.isAvailable = function (callback) {
|
|||
*
|
||||
* @param {function(error, isEmulated)} callback The callback function.
|
||||
*/
|
||||
RoleEnvironment.isEmulated = function(callback) {
|
||||
RoleEnvironment.isEmulated = function (callback) {
|
||||
RoleEnvironment._initialize(function (error) {
|
||||
var isEmulated = undefined;
|
||||
if (!error) {
|
||||
isEmulated = currentEnvironmentData.isEmulated;
|
||||
if (error) {
|
||||
callback(error);
|
||||
} else {
|
||||
callback(undefined, currentEnvironmentData.id);
|
||||
}
|
||||
|
||||
callback(error, isEmulated);
|
||||
});
|
||||
};
|
||||
|
||||
|
@ -175,12 +113,11 @@ RoleEnvironment.isEmulated = function(callback) {
|
|||
*/
|
||||
RoleEnvironment.getRoles = function (callback) {
|
||||
RoleEnvironment._initialize(function (error) {
|
||||
var roles = undefined;
|
||||
if (!error) {
|
||||
roles = currentEnvironmentData.roles;
|
||||
if (error) {
|
||||
callback(error);
|
||||
} else {
|
||||
callback(undefined, currentEnvironmentData.roles);
|
||||
}
|
||||
|
||||
callback(error, roles);
|
||||
});
|
||||
};
|
||||
|
||||
|
@ -193,12 +130,11 @@ RoleEnvironment.getRoles = function (callback) {
|
|||
*/
|
||||
RoleEnvironment.getConfigurationSettings = function (callback) {
|
||||
RoleEnvironment._initialize(function (error) {
|
||||
var configurationSettings = undefined;
|
||||
if (!error) {
|
||||
configurationSettings = currentEnvironmentData.configurationSettings;
|
||||
if (error) {
|
||||
callback(error);
|
||||
} else {
|
||||
callback(undefined, currentEnvironmentData.configurationSettings);
|
||||
}
|
||||
|
||||
callback(error, configurationSettings);
|
||||
});
|
||||
};
|
||||
|
||||
|
@ -209,12 +145,11 @@ RoleEnvironment.getConfigurationSettings = function (callback) {
|
|||
*/
|
||||
RoleEnvironment.getLocalResources = function (callback) {
|
||||
RoleEnvironment._initialize(function (error) {
|
||||
var localResources = undefined;
|
||||
if (!error) {
|
||||
localResources = currentEnvironmentData.localResources;
|
||||
if (error) {
|
||||
callback(error);
|
||||
} else {
|
||||
callback(undefined, currentEnvironmentData.localResources);
|
||||
}
|
||||
|
||||
callback(error, localResources);
|
||||
});
|
||||
};
|
||||
|
||||
|
@ -238,7 +173,7 @@ RoleEnvironment.requestRecycle = function (callback) {
|
|||
expiration: maxDateTime
|
||||
};
|
||||
|
||||
runtimeClient.setCurrentState(newState, callback);
|
||||
exports.runtimeClient.setCurrentState(newState, callback);
|
||||
} else {
|
||||
callback(error);
|
||||
}
|
||||
|
@ -279,7 +214,7 @@ RoleEnvironment.setStatus = function (roleInstanceStatus, expirationUtc, callbac
|
|||
|
||||
lastState = newState;
|
||||
|
||||
runtimeClient.setCurrentState(newState, callback);
|
||||
exports.runtimeClient.setCurrentState(newState, callback);
|
||||
} else {
|
||||
callback(error);
|
||||
}
|
||||
|
@ -299,33 +234,108 @@ RoleEnvironment.clearStatus = function (callback) {
|
|||
|
||||
lastState = newState;
|
||||
|
||||
runtimeClient.setCurrentState(newState, callback);
|
||||
exports.runtimeClient.setCurrentState(newState, callback);
|
||||
} else {
|
||||
callback(error);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
// TODO: find a better way to hook eventing up
|
||||
RoleEnvironment.on = function (event, callback) {
|
||||
eventEmitter.on(event, callback);
|
||||
};
|
||||
|
||||
RoleEnvironment._initialize = function (callback) {
|
||||
var getCurrentGoalState = function (finalCallback) {
|
||||
exports.runtimeClient.getCurrentGoalState(function (error, goalState) {
|
||||
if (error) {
|
||||
callback(error);
|
||||
} else {
|
||||
currentGoalState = goalState;
|
||||
getCurrentEnvironmentData(goalState, finalCallback);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
var getCurrentEnvironmentData = function (goalState, finalCallback) {
|
||||
exports.runtimeClient.getRoleEnvironmentData(function (getRoleEnvironmentDataError, environmentData) {
|
||||
if (getRoleEnvironmentDataError) {
|
||||
callback(getRoleEnvironmentDataError);
|
||||
} else {
|
||||
currentEnvironmentData = environmentData;
|
||||
|
||||
finalCallback();
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
if (!exports.runtimeClient) {
|
||||
var endpoint = process.env[RoleEnvironment.EnvironmentVariables.VersionEndpointEnvironmentName];
|
||||
|
||||
if (!endpoint) {
|
||||
endpoint = RoleEnvironment.VersionEndpointFixedPath;
|
||||
}
|
||||
|
||||
var kernel = RuntimeKernel.getKernel();
|
||||
kernel.getRuntimeVersionManager().getRuntimeClient(endpoint, function (error, rtClient) {
|
||||
if (error) {
|
||||
callback(error);
|
||||
} else {
|
||||
exports.runtimeClient = rtClient;
|
||||
|
||||
getCurrentGoalState(function (error) {
|
||||
if (error) {
|
||||
callback(error);
|
||||
} else {
|
||||
if (exports.runtimeClient.listeners(ServiceRuntimeConstants.CHANGED).length === 0) {
|
||||
exports.runtimeClient.on(ServiceRuntimeConstants.CHANGED, function (newGoalState) {
|
||||
switch (newGoalState.expectedState) {
|
||||
case ServiceRuntimeConstants.RoleStatus.STARTED:
|
||||
if (newGoalState.incarnation > currentGoalState.incarnation) {
|
||||
RoleEnvironment._processGoalStateChange(newGoalState, function () { });
|
||||
}
|
||||
|
||||
break;
|
||||
case ServiceRuntimeConstants.RoleStatus.STOPPED:
|
||||
RoleEnvironment._raiseStoppingEvent();
|
||||
|
||||
var stoppedState = {
|
||||
clientId: exports.clientId,
|
||||
incarnation: newGoalState.incarnation,
|
||||
status: ServiceRuntimeConstants.RoleStatus.STOPPED,
|
||||
expiration: maxDateTime
|
||||
};
|
||||
|
||||
exports.runtimeClient.setCurrentState(stoppedState, function () { });
|
||||
break;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
callback();
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
} else {
|
||||
getCurrentGoalState(callback);
|
||||
}
|
||||
};
|
||||
|
||||
RoleEnvironment._processGoalStateChange = function (newGoalState, callback) {
|
||||
var self = this;
|
||||
var last = lastState;
|
||||
|
||||
RoleEnvironment._calculateChanges(function (error, changes) {
|
||||
if (!error) {
|
||||
if (changes.length === 0) {
|
||||
self._acceptLatestIncarnation(newGoalState, last);
|
||||
RoleEnvironment._acceptLatestIncarnation(newGoalState, last);
|
||||
} else {
|
||||
eventEmitter.emit(ServiceRuntimeConstants.CHANGING, changes);
|
||||
|
||||
// TODO: check for canceled ?
|
||||
|
||||
RoleEnvironment._acceptLatestIncarnation(newGoalState, last);
|
||||
|
||||
runtimeClient.getRoleEnvironmentData(function (getRoleEnvironmentDataError, environmentData) {
|
||||
exports.runtimeClient.getRoleEnvironmentData(function (getRoleEnvironmentDataError, environmentData) {
|
||||
if (getRoleEnvironmentDataError) {
|
||||
callback(getRoleEnvironmentDataError);
|
||||
} else {
|
||||
|
@ -343,7 +353,22 @@ RoleEnvironment._processGoalStateChange = function (newGoalState, callback) {
|
|||
};
|
||||
|
||||
RoleEnvironment._acceptLatestIncarnation = function (newGoalState, last) {
|
||||
// TODO: implement
|
||||
var setGoalState = function () {
|
||||
currentGoalState = newGoalState;
|
||||
};
|
||||
|
||||
if (last !== null && last.status !== null) {
|
||||
var acceptState = {
|
||||
clientId: exports.clientId,
|
||||
incarnation: newGoalState.incarnation,
|
||||
status: last.status,
|
||||
expiration: last.expiration
|
||||
};
|
||||
|
||||
exports.runtimeClient.setCurrentState(acceptState, setGoalState);
|
||||
} else {
|
||||
setGoalState();
|
||||
}
|
||||
};
|
||||
|
||||
RoleEnvironment._calculateChanges = function (callback) {
|
||||
|
@ -352,7 +377,7 @@ RoleEnvironment._calculateChanges = function (callback) {
|
|||
var current = currentEnvironmentData;
|
||||
var newData;
|
||||
|
||||
runtimeClient.getRoleEnvironmentData(function (getRoleEnvironmentDataError, environmentData) {
|
||||
exports.runtimeClient.getRoleEnvironmentData(function (getRoleEnvironmentDataError, environmentData) {
|
||||
if (!getRoleEnvironmentDataError) {
|
||||
newData = environmentData;
|
||||
|
||||
|
@ -396,17 +421,17 @@ RoleEnvironment._calculateChanges = function (callback) {
|
|||
currentInstance = currentRole[instance];
|
||||
newInstance = newRole[instance];
|
||||
|
||||
if (currentInstance['faultDomain'] === newInstance['faultDomain'] &&
|
||||
currentInstance['updateDomain'] === currentInstance['updateDomain']) {
|
||||
if (currentInstance.faultDomain === newInstance.faultDomain &&
|
||||
currentInstance.updateDomain === newInstance.updateDomain) {
|
||||
|
||||
for (endpoint in currentInstance['endpoints']) {
|
||||
if (newInstance['endpoints'][endpoint]) {
|
||||
currentEndpoint = currentInstance['endpoints'][endpoint];
|
||||
newEndpoint = newInstance['endpoints'][endpoint];
|
||||
for (endpoint in currentInstance.endpoints) {
|
||||
if (newInstance.endpoints[endpoint]) {
|
||||
currentEndpoint = currentInstance.endpoints[endpoint];
|
||||
newEndpoint = newInstance.endpoints[endpoint];
|
||||
|
||||
if (currentEndpoint['protocol'] !== newEndpoint['protocol'] ||
|
||||
currentEndpoint['address'] !== newEndpoint['address'] ||
|
||||
currentEndpoint['port'] !== newEndpoint['port']) {
|
||||
if (currentEndpoint.protocol !== newEndpoint.protocol ||
|
||||
currentEndpoint.address !== newEndpoint.address ||
|
||||
currentEndpoint.port !== newEndpoint.port) {
|
||||
changedRoleSet.push(role);
|
||||
}
|
||||
} else {
|
||||
|
@ -435,17 +460,17 @@ RoleEnvironment._calculateChanges = function (callback) {
|
|||
currentInstance = currentRole[instance];
|
||||
newInstance = newRole[instance];
|
||||
|
||||
if (currentInstance['faultDomain'] === newInstance['faultDomain'] &&
|
||||
currentInstance['updateDomain'] === currentInstance['updateDomain']) {
|
||||
if (currentInstance.faultDomain === newInstance.faultDomain &&
|
||||
currentInstance.updateDomain === currentInstance.updateDomain) {
|
||||
|
||||
for (endpoint in newInstance['endpoints']) {
|
||||
if (currentInstance['endpoints'][endpoint]) {
|
||||
currentEndpoint = currentInstance['endpoints'][endpoint];
|
||||
newEndpoint = newInstance['endpoints'][endpoint];
|
||||
for (endpoint in newInstance.endpoints) {
|
||||
if (currentInstance.endpoints[endpoint]) {
|
||||
currentEndpoint = currentInstance.endpoints[endpoint];
|
||||
newEndpoint = newInstance.endpoints[endpoint];
|
||||
|
||||
if (currentEndpoint['protocol'] !== newEndpoint['protocol'] ||
|
||||
currentEndpoint['address'] !== newEndpoint['address'] ||
|
||||
currentEndpoint['port'] !== newEndpoint['port']) {
|
||||
if (currentEndpoint.protocol !== newEndpoint.protocol ||
|
||||
currentEndpoint.address !== newEndpoint.address ||
|
||||
currentEndpoint.port !== newEndpoint.port) {
|
||||
changedRoleSet.push(role);
|
||||
}
|
||||
} else {
|
||||
|
@ -473,4 +498,8 @@ RoleEnvironment._calculateChanges = function (callback) {
|
|||
callback(getRoleEnvironmentDataError);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
RoleEnvironment._raiseStoppingEvent = function () {
|
||||
eventEmitter.emit(ServiceRuntimeConstants.STOPPING);
|
||||
};
|
|
@ -1,21 +0,0 @@
|
|||
/**
|
||||
* Copyright 2011 Microsoft Corporation
|
||||
*
|
||||
* Licensed 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.
|
||||
*/
|
||||
|
||||
// Module dependencies.
|
||||
|
||||
// Expose 'RoleInstance'.
|
||||
exports = module.exports = RoleInstance;
|
||||
|
||||
function RoleInstance() { }
|
|
@ -14,6 +14,7 @@
|
|||
*/
|
||||
|
||||
// Module dependencies.
|
||||
var ISO8061Date = require('../util/iso8061date');
|
||||
var js2xml = require('../util/js2xml');
|
||||
var Constants = require('../util/constants');
|
||||
var ServiceRuntimeConstants = Constants.ServiceRuntimeConstants;
|
||||
|
@ -34,9 +35,11 @@ XmlCurrentStateSerializer.prototype.serialize = function (currentState) {
|
|||
if (currentState.status) {
|
||||
currentStateXml[ServiceRuntimeConstants.CURRENT_STATE][ServiceRuntimeConstants.STATUS_LEASE][ServiceRuntimeConstants.ACQUIRE] = {};
|
||||
|
||||
currentStateXml[ServiceRuntimeConstants.CURRENT_STATE][ServiceRuntimeConstants.STATUS_LEASE][ServiceRuntimeConstants.ACQUIRE][ServiceRuntimeConstants.EXPIRATION] = currentState.expiration;
|
||||
var expirationDate = ISO8061Date.format(currentState.expiration);
|
||||
currentStateXml[ServiceRuntimeConstants.CURRENT_STATE][ServiceRuntimeConstants.STATUS_LEASE][ServiceRuntimeConstants.ACQUIRE][ServiceRuntimeConstants.INCARNATION] = currentState.incarnation;
|
||||
currentStateXml[ServiceRuntimeConstants.CURRENT_STATE][ServiceRuntimeConstants.STATUS_LEASE][ServiceRuntimeConstants.ACQUIRE][ServiceRuntimeConstants.STATUS] = currentState.status;
|
||||
currentStateXml[ServiceRuntimeConstants.CURRENT_STATE][ServiceRuntimeConstants.STATUS_LEASE][ServiceRuntimeConstants.ACQUIRE][ServiceRuntimeConstants.STATUS_DETAIL] = currentState.status;
|
||||
currentStateXml[ServiceRuntimeConstants.CURRENT_STATE][ServiceRuntimeConstants.STATUS_LEASE][ServiceRuntimeConstants.ACQUIRE][ServiceRuntimeConstants.EXPIRATION] = expirationDate;
|
||||
} else {
|
||||
currentStateXml[ServiceRuntimeConstants.CURRENT_STATE][ServiceRuntimeConstants.STATUS_LEASE][ServiceRuntimeConstants.RELEASE] = {};
|
||||
}
|
||||
|
|
|
@ -56,7 +56,7 @@ XmlRoleEnvironmentDataDeserializer.prototype._translateConfigurationSettings = f
|
|||
|
||||
for (var configurationSetting in configurationSettings) {
|
||||
var currentConfigurationSetting = configurationSettings[configurationSetting];
|
||||
configurationSettingsMap[currentConfigurationSetting[Constants.ATOM_METADATA_MARKER]['name']] = currentConfigurationSetting[Constants.ATOM_METADATA_MARKER]['value'];
|
||||
configurationSettingsMap[currentConfigurationSetting[Constants.ATOM_METADATA_MARKER].name] = currentConfigurationSetting[Constants.ATOM_METADATA_MARKER].value;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -77,8 +77,8 @@ XmlRoleEnvironmentDataDeserializer.prototype._translateLocalResources = function
|
|||
|
||||
for (var localResource in localResources) {
|
||||
var currentLocalResource = localResources[localResource];
|
||||
var currentLocalResourceName = currentLocalResource[Constants.ATOM_METADATA_MARKER]['name'];
|
||||
delete currentLocalResource[Constants.ATOM_METADATA_MARKER]['name'];
|
||||
var currentLocalResourceName = currentLocalResource[Constants.ATOM_METADATA_MARKER].name;
|
||||
delete currentLocalResource[Constants.ATOM_METADATA_MARKER].name;
|
||||
|
||||
localResourcesMap[currentLocalResourceName] = currentLocalResource[Constants.ATOM_METADATA_MARKER];
|
||||
}
|
||||
|
@ -90,37 +90,18 @@ XmlRoleEnvironmentDataDeserializer.prototype._translateLocalResources = function
|
|||
XmlRoleEnvironmentDataDeserializer.prototype._translateCurrentInstance = function (xml) {
|
||||
var currentInstance = {};
|
||||
|
||||
currentInstance.id = xml[ServiceRuntimeConstants.CURRENT_INSTANCE][Constants.ATOM_METADATA_MARKER]['id'];
|
||||
currentInstance.roleName = xml[ServiceRuntimeConstants.CURRENT_INSTANCE][Constants.ATOM_METADATA_MARKER]['roleName'];
|
||||
currentInstance.faultDomain = xml[ServiceRuntimeConstants.CURRENT_INSTANCE][Constants.ATOM_METADATA_MARKER]['faultDomain'];
|
||||
currentInstance.updateDomain = xml[ServiceRuntimeConstants.CURRENT_INSTANCE][Constants.ATOM_METADATA_MARKER]['updateDomain'];
|
||||
currentInstance.endpoints = this._translateRoleInstanceEndpoints(xml);
|
||||
currentInstance.id = xml[ServiceRuntimeConstants.CURRENT_INSTANCE][Constants.ATOM_METADATA_MARKER].id;
|
||||
currentInstance.roleName = xml[ServiceRuntimeConstants.CURRENT_INSTANCE][Constants.ATOM_METADATA_MARKER].roleName;
|
||||
currentInstance.faultDomain = xml[ServiceRuntimeConstants.CURRENT_INSTANCE][Constants.ATOM_METADATA_MARKER].faultDomain;
|
||||
currentInstance.updateDomain = xml[ServiceRuntimeConstants.CURRENT_INSTANCE][Constants.ATOM_METADATA_MARKER].updateDomain;
|
||||
|
||||
return currentInstance;
|
||||
};
|
||||
|
||||
XmlRoleEnvironmentDataDeserializer.prototype._translateRoleInstanceEndpoints = function(xml) {
|
||||
var endpointsMap = { };
|
||||
|
||||
if (xml[ServiceRuntimeConstants.CURRENT_INSTANCE] &&
|
||||
xml[ServiceRuntimeConstants.CURRENT_INSTANCE][ServiceRuntimeConstants.ENDPOINTS] &&
|
||||
xml[ServiceRuntimeConstants.CURRENT_INSTANCE][ServiceRuntimeConstants.ENDPOINTS][ServiceRuntimeConstants.ENDPOINT]) {
|
||||
|
||||
var endpoints = xml[ServiceRuntimeConstants.CURRENT_INSTANCE][ServiceRuntimeConstants.ENDPOINTS][ServiceRuntimeConstants.ENDPOINT];
|
||||
if (!Array.isArray(endpoints)) {
|
||||
endpoints = [endpoints];
|
||||
}
|
||||
|
||||
for (var endpoint in endpoints) {
|
||||
var currentEndpoint = endpoints[endpoint];
|
||||
var currentEndpointName = currentEndpoint[Constants.ATOM_METADATA_MARKER]['name'];
|
||||
|
||||
delete currentEndpoint[Constants.ATOM_METADATA_MARKER]['name'];
|
||||
endpointsMap[currentEndpointName] = currentEndpoint[Constants.ATOM_METADATA_MARKER];
|
||||
}
|
||||
if (xml[ServiceRuntimeConstants.CURRENT_INSTANCE][ServiceRuntimeConstants.ENDPOINTS]) {
|
||||
currentInstance.endpoints = this._translateRoleInstanceEndpoints(xml[ServiceRuntimeConstants.CURRENT_INSTANCE][ServiceRuntimeConstants.ENDPOINTS]);
|
||||
} else {
|
||||
currentInstance.endpoints = {};
|
||||
}
|
||||
|
||||
return endpointsMap;
|
||||
return currentInstance;
|
||||
};
|
||||
|
||||
XmlRoleEnvironmentDataDeserializer.prototype._translateRoles = function (xml, currentInstance, currentRole) {
|
||||
|
@ -137,7 +118,7 @@ XmlRoleEnvironmentDataDeserializer.prototype._translateRoles = function (xml, cu
|
|||
|
||||
for (var role in roles) {
|
||||
var currentIterationRole = roles[role];
|
||||
var currentIterationRoleName = currentIterationRole[Constants.ATOM_METADATA_MARKER]['name'];
|
||||
var currentIterationRoleName = currentIterationRole[Constants.ATOM_METADATA_MARKER].name;
|
||||
roleInstances = this._translateRoleInstances(currentIterationRole);
|
||||
|
||||
if (currentIterationRoleName === currentRole) {
|
||||
|
@ -172,8 +153,8 @@ XmlRoleEnvironmentDataDeserializer.prototype._translateRoleInstances = function
|
|||
|
||||
for (var instance in instances) {
|
||||
var currentIterationInstance = instances[instance];
|
||||
var currentIterationInstanceId = currentIterationInstance[Constants.ATOM_METADATA_MARKER]['id'];
|
||||
delete currentIterationInstance[Constants.ATOM_METADATA_MARKER]['id'];
|
||||
var currentIterationInstanceId = currentIterationInstance[Constants.ATOM_METADATA_MARKER].id;
|
||||
delete currentIterationInstance[Constants.ATOM_METADATA_MARKER].id;
|
||||
|
||||
currentIterationInstance[Constants.ATOM_METADATA_MARKER].endpoints = this._translateRoleInstanceEndpoints(currentIterationInstance[ServiceRuntimeConstants.ENDPOINTS]);
|
||||
|
||||
|
@ -197,8 +178,8 @@ XmlRoleEnvironmentDataDeserializer.prototype._translateRoleInstanceEndpoints = f
|
|||
|
||||
for (var endpoint in endpoints) {
|
||||
var currentEndpoint = endpoints[endpoint];
|
||||
var currentEndpointName = currentEndpoint[Constants.ATOM_METADATA_MARKER]['name'];
|
||||
delete currentEndpoint[Constants.ATOM_METADATA_MARKER]['name'];
|
||||
var currentEndpointName = currentEndpoint[Constants.ATOM_METADATA_MARKER].name;
|
||||
delete currentEndpoint[Constants.ATOM_METADATA_MARKER].name;
|
||||
|
||||
endpointsMap[currentEndpointName] = currentEndpoint[Constants.ATOM_METADATA_MARKER];
|
||||
}
|
||||
|
|
|
@ -98,12 +98,6 @@ ServiceBusServiceClient.prototype._buildRequestOptions = function (webResource,
|
|||
webResource.addOptionalHeader(HeaderConstants.ACCEPT_CHARSET_HEADER, 'UTF-8');
|
||||
webResource.addOptionalHeader(HeaderConstants.HOST_HEADER, this.getHostname() + ':' + this.port);
|
||||
|
||||
if (options) {
|
||||
if (options.timeoutIntervalInS) {
|
||||
webResource.addOptionalQueryParam(QueryStringConstants.TIMEOUT, options.timeoutIntervalInS);
|
||||
}
|
||||
}
|
||||
|
||||
// Sets the request url in the web resource.
|
||||
this._setRequestUrl(webResource);
|
||||
|
||||
|
|
|
@ -112,19 +112,10 @@ ServiceBusService.prototype.receiveSubscriptionMessage = function (topicPath, su
|
|||
* Deletes a message.
|
||||
*
|
||||
* @param {object|string} message The message object or a string with the message location.
|
||||
* @param {object|function} [optionsOrCallback] The request options or callback function.
|
||||
* @param {int} [optionsOrCallback.timeoutIntervalInS] The timeout interval, in seconds, to use for the request.
|
||||
* @param {function(error, response)} callback The callback function.
|
||||
* @return {undefined}
|
||||
*/
|
||||
ServiceBusService.prototype.deleteMessage = function (message, optionsOrCallback, callback) {
|
||||
var options = null;
|
||||
if (typeof optionsOrCallback === 'function' && !callback) {
|
||||
callback = optionsOrCallback;
|
||||
} else {
|
||||
options = optionsOrCallback;
|
||||
}
|
||||
|
||||
ServiceBusService.prototype.deleteMessage = function (message, callback) {
|
||||
validateCallback(callback);
|
||||
|
||||
if (azureutil.objectIsString(message)) {
|
||||
|
@ -147,26 +138,17 @@ ServiceBusService.prototype.deleteMessage = function (message, optionsOrCallback
|
|||
next(responseObject, finalCallback);
|
||||
};
|
||||
|
||||
this.performRequest(webResource, null, options, processResponseCallback);
|
||||
this.performRequest(webResource, null, null, processResponseCallback);
|
||||
};
|
||||
|
||||
/**
|
||||
* Unlocks a message.
|
||||
*
|
||||
* @param {object|string} message The message object or a string with the message location.
|
||||
* @param {object|function} [optionsOrCallback] The request options or callback function.
|
||||
* @param {int} [optionsOrCallback.timeoutIntervalInS] The timeout interval, in seconds, to use for the request.
|
||||
* @param {function(error, response)} callback The callback function.
|
||||
* @return {undefined}
|
||||
*/
|
||||
ServiceBusService.prototype.unlockMessage = function (message, optionsOrCallback, callback) {
|
||||
var options = null;
|
||||
if (typeof optionsOrCallback === 'function' && !callback) {
|
||||
callback = optionsOrCallback;
|
||||
} else {
|
||||
options = optionsOrCallback;
|
||||
}
|
||||
|
||||
ServiceBusService.prototype.unlockMessage = function (message, callback) {
|
||||
validateCallback(callback);
|
||||
|
||||
if (azureutil.objectIsString(message)) {
|
||||
|
@ -189,7 +171,7 @@ ServiceBusService.prototype.unlockMessage = function (message, optionsOrCallback
|
|||
next(responseObject, finalCallback);
|
||||
};
|
||||
|
||||
this.performRequest(webResource, null, options, processResponseCallback);
|
||||
this.performRequest(webResource, null, null, processResponseCallback);
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -208,21 +190,12 @@ ServiceBusService.prototype.unlockMessage = function (message, optionsOrCallback
|
|||
* @param {string} [message.brokerProperties.To] The message's to.
|
||||
* @param {string} [message.brokerProperties.ScheduledEnqueueTimeUtc] The message's scheduled enqueue time in UTC.
|
||||
* @param {string} [message.brokerProperties.ReplyToSessionId] The message's reply to session identifier.
|
||||
* @param {object|function} [optionsOrCallback] The request options or callback function.
|
||||
* @param {int} [optionsOrCallback.timeoutIntervalInS] The timeout interval, in seconds, to use for the request.
|
||||
* @param {function(error, response)} callback The callback function.
|
||||
* @return {undefined}
|
||||
*/
|
||||
ServiceBusService.prototype.sendQueueMessage = function (queuePath, message, optionsOrCallback, callback) {
|
||||
var options = null;
|
||||
if (typeof optionsOrCallback === 'function' && !callback) {
|
||||
callback = optionsOrCallback;
|
||||
} else {
|
||||
options = optionsOrCallback;
|
||||
}
|
||||
|
||||
ServiceBusService.prototype.sendQueueMessage = function (queuePath, message, callback) {
|
||||
validateQueueName(queuePath);
|
||||
this._sendMessage(queuePath, message, options, callback);
|
||||
this._sendMessage(queuePath, message, callback);
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -241,21 +214,12 @@ ServiceBusService.prototype.sendQueueMessage = function (queuePath, message, opt
|
|||
* @param {string} [message.brokerProperties.To] The message's to.
|
||||
* @param {string} [message.brokerProperties.ScheduledEnqueueTimeUtc] The message's scheduled enqueue time in UTC.
|
||||
* @param {string} [message.brokerProperties.ReplyToSessionId] The message's reply to session identifier.
|
||||
* @param {object|function} [optionsOrCallback] The request options or callback function.
|
||||
* @param {int} [optionsOrCallback.timeoutIntervalInS] The timeout interval, in seconds, to use for the request.
|
||||
* @param {function(error, receivequeuemessageresult, response)} callback The callback function.
|
||||
* @param {function(error, receivetopicmessageresult, response)} callback The callback function.
|
||||
* @return {undefined}
|
||||
*/
|
||||
ServiceBusService.prototype.sendTopicMessage = function (topicPath, message, optionsOrCallback, callback) {
|
||||
var options = null;
|
||||
if (typeof optionsOrCallback === 'function' && !callback) {
|
||||
callback = optionsOrCallback;
|
||||
} else {
|
||||
options = optionsOrCallback;
|
||||
}
|
||||
|
||||
ServiceBusService.prototype.sendTopicMessage = function (topicPath, message, callback) {
|
||||
validateTopicName(topicPath);
|
||||
this._sendMessage(topicPath, message, options, callback);
|
||||
this._sendMessage(topicPath, message, callback);
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -274,19 +238,10 @@ ServiceBusService.prototype.sendTopicMessage = function (topicPath, message, opt
|
|||
* @param {string} [message.brokerProperties.To] The message's to.
|
||||
* @param {string} [message.brokerProperties.ScheduledEnqueueTimeUtc] The message's scheduled enqueue time in UTC.
|
||||
* @param {string} [message.brokerProperties.ReplyToSessionId] The message's reply to session identifier.
|
||||
* @param {object|function} [optionsOrCallback] The request options or callback function.
|
||||
* @param {int} [optionsOrCallback.timeoutIntervalInS] The timeout interval, in seconds, to use for the request.
|
||||
* @param {function(error, response)} callback The callback function.
|
||||
* @return {undefined}
|
||||
*/
|
||||
ServiceBusService.prototype._sendMessage = function (path, message, optionsOrCallback, callback) {
|
||||
var options = null;
|
||||
if (typeof optionsOrCallback === 'function' && !callback) {
|
||||
callback = optionsOrCallback;
|
||||
} else {
|
||||
options = optionsOrCallback;
|
||||
}
|
||||
|
||||
ServiceBusService.prototype._sendMessage = function (path, message, callback) {
|
||||
validateCallback(callback);
|
||||
|
||||
if (azureutil.objectIsString(message)) {
|
||||
|
@ -304,7 +259,7 @@ ServiceBusService.prototype._sendMessage = function (path, message, optionsOrCal
|
|||
next(responseObject, finalCallback);
|
||||
};
|
||||
|
||||
this.performRequest(webResource, message.body, options, processResponseCallback);
|
||||
this.performRequest(webResource, message.body, null, processResponseCallback);
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -338,6 +293,10 @@ ServiceBusService.prototype._receiveMessage = function (path, optionsOrCallback,
|
|||
.withRawResponse();
|
||||
}
|
||||
|
||||
if (options && options.timeoutIntervalInS) {
|
||||
webResource.addOptionalQueryParam(QueryStringConstants.TIMEOUT, options.timeoutIntervalInS);
|
||||
}
|
||||
|
||||
var processResponseCallback = function (responseObject, next) {
|
||||
if (responseObject.response &&
|
||||
responseObject.response.statusCode === HttpConstants.HttpResponseCodes.NO_CONTENT_CODE) {
|
||||
|
@ -368,7 +327,6 @@ ServiceBusService.prototype._receiveMessage = function (path, optionsOrCallback,
|
|||
* @param {bool} [optionsOrCallback.RequiresDuplicateDetection] Settable only at queue creation time.
|
||||
* @param {bool} [optionsOrCallback.DeadLetteringOnMessageExpiration] This field controls how the Service Bus handles a message whose TTL has expired. If it is enabled and a message expires, the Service Bus moves the message from the queue into the queue’s dead-letter sub-queue. If disabled, message will be permanently deleted from the queue. Settable only at queue creation time.
|
||||
* @param {bool} [optionsOrCallback.DuplicateDetectionHistoryTimeWindow] Specifies the time span during which the Service Bus detects message duplication.
|
||||
* @param {int} [optionsOrCallback.timeoutIntervalInS] The timeout interval, in seconds, to use for the request.
|
||||
* @param {function(error, createqueueresult, response)} callback The callback function.
|
||||
* @return {undefined}
|
||||
*/
|
||||
|
@ -416,7 +374,6 @@ ServiceBusService.prototype.createQueue = function (queuePath, optionsOrCallback
|
|||
* @param {bool} [optionsOrCallback.RequiresDuplicateDetection] Settable only at queue creation time.
|
||||
* @param {bool} [optionsOrCallback.DeadLetteringOnMessageExpiration] This field controls how the Service Bus handles a message whose TTL has expired. If it is enabled and a message expires, the Service Bus moves the message from the queue into the queue’s dead-letter sub-queue. If disabled, message will be permanently deleted from the queue. Settable only at queue creation time.
|
||||
* @param {bool} [optionsOrCallback.DuplicateDetectionHistoryTimeWindow] Specifies the time span during which the Service Bus detects message duplication.
|
||||
* @param {int} [optionsOrCallback.timeoutIntervalInS] The timeout interval, in seconds, to use for the request.
|
||||
* @param {function(error, createqueueresult, response)} callback The callback function.
|
||||
* @return {undefined}
|
||||
*/
|
||||
|
@ -462,19 +419,10 @@ ServiceBusService.prototype.createQueueIfNotExists = function (queuePath, option
|
|||
* Deletes a queue.
|
||||
*
|
||||
* @param {string} queuePath A string object that represents the name of the queue to delete.
|
||||
* @param {object|function} [optionsOrCallback] The request options or callback function.
|
||||
* @param {int} [optionsOrCallback.timeoutIntervalInS] The timeout interval, in seconds, to use for the request.
|
||||
* @param {function(error, response)} callback The callback function.
|
||||
* @return {undefined}
|
||||
*/
|
||||
ServiceBusService.prototype.deleteQueue = function (queuePath, optionsOrCallback, callback) {
|
||||
var options = null;
|
||||
if (typeof optionsOrCallback === 'function' && !callback) {
|
||||
callback = optionsOrCallback;
|
||||
} else {
|
||||
options = optionsOrCallback;
|
||||
}
|
||||
|
||||
ServiceBusService.prototype.deleteQueue = function (queuePath, callback) {
|
||||
validateQueueName(queuePath);
|
||||
validateCallback(callback);
|
||||
|
||||
|
@ -489,26 +437,17 @@ ServiceBusService.prototype.deleteQueue = function (queuePath, optionsOrCallback
|
|||
next(responseObject, finalCallback);
|
||||
};
|
||||
|
||||
this.performRequest(webResource, null, options, processResponseCallback);
|
||||
this.performRequest(webResource, null, null, processResponseCallback);
|
||||
};
|
||||
|
||||
/**
|
||||
* Retrieves a queue.
|
||||
*
|
||||
* @param {string} queuePath A string object that represents the name of the queue to retrieve.
|
||||
* @param {object|function} [optionsOrCallback] The request options or callback function.
|
||||
* @param {int} [optionsOrCallback.timeoutIntervalInS] The timeout interval, in seconds, to use for the request.
|
||||
* @param {function(error, getqueueresult, response)} callback The callback function.
|
||||
* @return {undefined}
|
||||
*/
|
||||
ServiceBusService.prototype.getQueue = function (queuePath, optionsOrCallback, callback) {
|
||||
var options = null;
|
||||
if (typeof optionsOrCallback === 'function' && !callback) {
|
||||
callback = optionsOrCallback;
|
||||
} else {
|
||||
options = optionsOrCallback;
|
||||
}
|
||||
|
||||
ServiceBusService.prototype.getQueue = function (queuePath, callback) {
|
||||
validateQueueName(queuePath);
|
||||
validateCallback(callback);
|
||||
|
||||
|
@ -534,7 +473,7 @@ ServiceBusService.prototype.getQueue = function (queuePath, optionsOrCallback, c
|
|||
next(responseObject, finalCallback);
|
||||
};
|
||||
|
||||
this.performRequest(webResource, null, options, processResponseCallback);
|
||||
this.performRequest(webResource, null, null, processResponseCallback);
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -543,7 +482,6 @@ ServiceBusService.prototype.getQueue = function (queuePath, optionsOrCallback, c
|
|||
* @param {object|function} [optionsOrCallback] The request options or callback function.
|
||||
* @param {int} [optionsOrCallback.top] The top clause for listing queues.
|
||||
* @param {int} [optionsOrCallback.skip] The skip clause for listing queues.
|
||||
* @param {int} [optionsOrCallback.timeoutIntervalInS] The timeout interval, in seconds, to use for the request.
|
||||
* @param {function(error, listqueuesresult, response)} callback The callback function.
|
||||
* @return {undefined}
|
||||
*/
|
||||
|
@ -606,7 +544,6 @@ ServiceBusService.prototype.listQueues = function (optionsOrCallback, callback)
|
|||
* @param {PTnHnMnS} [optionsOrCallback.DuplicateDetectionHistoryTimeWindow] Specifies the time span during which the Service Bus will detect message duplication.
|
||||
* @param {bool} [optionsOrCallback.EnableBatchedOperations] Specifies if batched operations should be allowed.
|
||||
* @param {int} [optionsOrCallback.SizeInBytes] Specifies the topic size in bytes.
|
||||
* @param {int} [optionsOrCallback.timeoutIntervalInS] The timeout interval, in seconds, to use for the request.
|
||||
* @param {function(error, createtopicresult, response)} callback The callback function.
|
||||
* @return {undefined}
|
||||
*/
|
||||
|
@ -656,7 +593,6 @@ ServiceBusService.prototype.createTopic = function (topic, optionsOrCallback, ca
|
|||
* @param {int} [optionsOrCallback.MaxCorrelationFiltersPerTopic] Specifies the maximum number of correlation filter expressions (in total) that can be added to the subscriptions associated with the topic.
|
||||
* @param {bool} [optionsOrCallback.EnableDeadLetteringOnMessageExpiration] Settable only at topic creation time.
|
||||
* @param {bool} [optionsOrCallback.EnableDeadLetteringOnFilterEvaluationExceptions] Settable only at topic creation time.
|
||||
* @param {int} [optionsOrCallback.timeoutIntervalInS] The timeout interval, in seconds, to use for the request.
|
||||
* @param {function(error, createtopicresult, response)} callback The callback function.
|
||||
* @return {undefined}
|
||||
*/
|
||||
|
@ -702,19 +638,10 @@ ServiceBusService.prototype.createTopicIfNotExists = function (topic, optionsOrC
|
|||
* Deletes a topic.
|
||||
*
|
||||
* @param {string} topicPath A <code>String</code> object that represents the name of the queue to delete.
|
||||
* @param {object|function} [optionsOrCallback] The request options or callback function.
|
||||
* @param {int} [optionsOrCallback.timeoutIntervalInS] The timeout interval, in seconds, to use for the request.
|
||||
* @param {function(error, response)} callback The callback function.
|
||||
* @return {undefined}
|
||||
*/
|
||||
ServiceBusService.prototype.deleteTopic = function (topicPath, optionsOrCallback, callback) {
|
||||
var options = null;
|
||||
if (typeof optionsOrCallback === 'function' && !callback) {
|
||||
callback = optionsOrCallback;
|
||||
} else {
|
||||
options = optionsOrCallback;
|
||||
}
|
||||
|
||||
ServiceBusService.prototype.deleteTopic = function (topicPath, callback) {
|
||||
validateTopicName(topicPath);
|
||||
validateCallback(callback);
|
||||
|
||||
|
@ -729,26 +656,17 @@ ServiceBusService.prototype.deleteTopic = function (topicPath, optionsOrCallback
|
|||
next(responseObject, finalCallback);
|
||||
};
|
||||
|
||||
this.performRequest(webResource, null, options, processResponseCallback);
|
||||
this.performRequest(webResource, null, null, processResponseCallback);
|
||||
};
|
||||
|
||||
/**
|
||||
* Retrieves a topic.
|
||||
*
|
||||
* @param {string} topicPath A <code>String</code> object that represents the name of the topic to retrieve.
|
||||
* @param {object|function} [optionsOrCallback] The request options or callback function.
|
||||
* @param {int} [optionsOrCallback.timeoutIntervalInS] The timeout interval, in seconds, to use for the request.
|
||||
* @param {function(error, gettopicresult, response)} callback The callback function.
|
||||
* @return {undefined}
|
||||
*/
|
||||
ServiceBusService.prototype.getTopic = function (topicPath, optionsOrCallback, callback) {
|
||||
var options = null;
|
||||
if (typeof optionsOrCallback === 'function' && !callback) {
|
||||
callback = optionsOrCallback;
|
||||
} else {
|
||||
options = optionsOrCallback;
|
||||
}
|
||||
|
||||
ServiceBusService.prototype.getTopic = function (topicPath, callback) {
|
||||
validateTopicName(topicPath);
|
||||
validateCallback(callback);
|
||||
|
||||
|
@ -774,14 +692,15 @@ ServiceBusService.prototype.getTopic = function (topicPath, optionsOrCallback, c
|
|||
next(responseObject, finalCallback);
|
||||
};
|
||||
|
||||
this.performRequest(webResource, null, options, processResponseCallback);
|
||||
this.performRequest(webResource, null, null, processResponseCallback);
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns a list of topics.
|
||||
*
|
||||
* @param {object|function} [optionsOrCallback] The request options or callback function.
|
||||
* @param {int} [optionsOrCallback.timeoutIntervalInS] The timeout interval, in seconds, to use for the request.
|
||||
* @param {int} [optionsOrCallback.top] The number of topics to fetch.
|
||||
* @param {int} [optionsOrCallback.skip] The number of topics to skip.
|
||||
* @param {function(error, listtopicsresult, response)} callback The callback function.
|
||||
* @return {undefined}
|
||||
*/
|
||||
|
@ -844,7 +763,6 @@ ServiceBusService.prototype.listTopics = function (optionsOrCallback, callback)
|
|||
* @param {PTnHnMnS} [optionsOrCallback.DefaultMessageTimeToLive] Determines how long a message lives in the subscription. Based on whether dead-lettering is enabled, a message whose TTL has expired will either be moved to the subscription’s associated DeadLtterQueue or permanently deleted.
|
||||
* @param {bool} [optionsOrCallback.EnableDeadLetteringOnMessageExpiration] This field controls how the Service Bus handles a message whose TTL has expired. If it is enabled and a message expires, the Service Bus moves the message from the queue into the subscription’s dead-letter sub-queue. If disabled, message will be permanently deleted from the subscription’s main queue. Settable only at subscription creation time.
|
||||
* @param {bool} [optionsOrCallback.EnableDeadLetteringOnFilterEvaluationExceptions] Determines how the Service Bus handles a message that causes an exception during a subscription’s filter evaluation. If the value is set to true, the message that caused the exception will be moved to the subscription’s dead-letter queue. Otherwise, it will be discarded. By default this parameter is set to true, allowing the user a chance to investigate the cause of the exception. It can occur from a malformed message or some incorrect assumptions being made in the filter about the form of the message. Settable only at topic creation time.
|
||||
* @param {int} [optionsOrCallback.timeoutIntervalInS] The timeout interval, in seconds, to use for the request.
|
||||
* @param {function(error, createsubscriptionresult, response)} callback The callback function.
|
||||
* @return {undefined}
|
||||
*/
|
||||
|
@ -887,19 +805,10 @@ ServiceBusService.prototype.createSubscription = function (topicPath, subscripti
|
|||
*
|
||||
* @param {string} topicPath A string object that represents the name of the topic for the subscription.
|
||||
* @param {string} subscriptionPath A string object that represents the name of the subscription to delete.
|
||||
* @param {object|function} [optionsOrCallback] The request options or callback function.
|
||||
* @param {int} [optionsOrCallback.timeoutIntervalInS] The timeout interval, in seconds, to use for the request.
|
||||
* @param {function(error, response)} callback The callback function.
|
||||
* @return {undefined}
|
||||
*/
|
||||
ServiceBusService.prototype.deleteSubscription = function (topicPath, subscriptionPath, optionsOrCallback, callback) {
|
||||
var options = null;
|
||||
if (typeof optionsOrCallback === 'function' && !callback) {
|
||||
callback = optionsOrCallback;
|
||||
} else {
|
||||
options = optionsOrCallback;
|
||||
}
|
||||
|
||||
ServiceBusService.prototype.deleteSubscription = function (topicPath, subscriptionPath, callback) {
|
||||
validateTopicName(topicPath);
|
||||
validateSubscriptionName(subscriptionPath);
|
||||
validateCallback(callback);
|
||||
|
@ -916,7 +825,7 @@ ServiceBusService.prototype.deleteSubscription = function (topicPath, subscripti
|
|||
next(responseObject, finalCallback);
|
||||
};
|
||||
|
||||
this.performRequest(webResource, null, options, processResponseCallback);
|
||||
this.performRequest(webResource, null, null, processResponseCallback);
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -924,19 +833,10 @@ ServiceBusService.prototype.deleteSubscription = function (topicPath, subscripti
|
|||
*
|
||||
* @param {string} topicPath A string object that represents the name of the topic for the subscription.
|
||||
* @param {string} subscriptionPath A string object that represents the name of the subscription to retrieve.
|
||||
* @param {object|function} [optionsOrCallback] The request options or callback function.
|
||||
* @param {int} [optionsOrCallback.timeoutIntervalInS] The timeout interval, in seconds, to use for the request.
|
||||
* @param {function(error, getsubscriptionresult, response)} callback The callback function.
|
||||
* @return {undefined}
|
||||
*/
|
||||
ServiceBusService.prototype.getSubscription = function (topicPath, subscriptionPath, optionsOrCallback, callback) {
|
||||
var options = null;
|
||||
if (typeof optionsOrCallback === 'function' && !callback) {
|
||||
callback = optionsOrCallback;
|
||||
} else {
|
||||
options = optionsOrCallback;
|
||||
}
|
||||
|
||||
ServiceBusService.prototype.getSubscription = function (topicPath, subscriptionPath, callback) {
|
||||
validateTopicName(topicPath);
|
||||
validateSubscriptionName(subscriptionPath);
|
||||
validateCallback(callback);
|
||||
|
@ -965,7 +865,7 @@ ServiceBusService.prototype.getSubscription = function (topicPath, subscriptionP
|
|||
next(responseObject, finalCallback);
|
||||
};
|
||||
|
||||
this.performRequest(webResource, null, options, processResponseCallback);
|
||||
this.performRequest(webResource, null, null, processResponseCallback);
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -973,7 +873,8 @@ ServiceBusService.prototype.getSubscription = function (topicPath, subscriptionP
|
|||
*
|
||||
* @param {string} topicPath A string object that represents the name of the topic for the subscriptions to retrieve.
|
||||
* @param {object|function} [optionsOrCallback] The request options or callback function.
|
||||
* @param {int} [optionsOrCallback.timeoutIntervalInS] The timeout interval, in seconds, to use for the request.
|
||||
* @param {int} [optionsOrCallback.top] The number of topics to fetch.
|
||||
* @param {int} [optionsOrCallback.skip] The number of topics to skip.
|
||||
* @param {function(error, listsubscriptionsresult, response)} callback The callback function.
|
||||
* @return {undefined}
|
||||
*/
|
||||
|
@ -1030,7 +931,7 @@ ServiceBusService.prototype.listSubscriptions = function (topicPath, optionsOrCa
|
|||
next(responseObject, finalCallback);
|
||||
};
|
||||
|
||||
this.performRequest(webResource, null, options, processResponseCallback);
|
||||
this.performRequest(webResource, null, null, processResponseCallback);
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -1045,7 +946,6 @@ ServiceBusService.prototype.listSubscriptions = function (topicPath, optionsOrCa
|
|||
* @param {string} [optionsOrCallback.sqlExpressionFilter] Defines the expression that the rule evaluates. The expression string is interpreted as a SQL92 expression which must evaluate to True or False. Only one between a correlation and a sql expression can be defined.
|
||||
* @param {string} [optionsOrCallback.correlationIdFilter] Defines the expression that the rule evaluates. Only the messages whose CorrelationId match the CorrelationId set in the filter expression are allowed. Only one between a correlation and a sql expression can be defined.
|
||||
* @param {string} [optionsOrCallback.sqlRuleAction] Defines the expression that the rule evaluates. If the rule is of type SQL, the expression string is interpreted as a SQL92 expression which must evaluate to True or False. If the rule is of type CorrelationFilterExpression then only the messages whose CorrelationId match the CorrelationId set in the filter expression are allowed.
|
||||
* @param {int} [optionsOrCallback.timeoutIntervalInS] The timeout interval, in seconds, to use for the request.
|
||||
* @param {function(error, createruleresult, response)} callback The callback function.
|
||||
* @return {undefined}
|
||||
*/
|
||||
|
@ -1090,19 +990,10 @@ ServiceBusService.prototype.createRule = function (topicPath, subscriptionPath,
|
|||
* @param {string} topicPath A string object that represents the name of the topic for the subscription.
|
||||
* @param {string} subscriptionPath A string object that represents the name of the subscription for which the rule will be deleted.
|
||||
* @param {string} rulePath A string object that represents the name of the rule to delete.
|
||||
* @param {object|function} [optionsOrCallback] The request options or callback function.
|
||||
* @param {int} [optionsOrCallback.timeoutIntervalInS] The timeout interval, in seconds, to use for the request.
|
||||
* @param {function(error, response)} callback The callback function.
|
||||
* @return {undefined}
|
||||
*/
|
||||
ServiceBusService.prototype.deleteRule = function (topicPath, subscriptionPath, rulePath, optionsOrCallback, callback) {
|
||||
var options = null;
|
||||
if (typeof optionsOrCallback === 'function' && !callback) {
|
||||
callback = optionsOrCallback;
|
||||
} else {
|
||||
options = optionsOrCallback;
|
||||
}
|
||||
|
||||
ServiceBusService.prototype.deleteRule = function (topicPath, subscriptionPath, rulePath, callback) {
|
||||
validateTopicName(topicPath);
|
||||
validateSubscriptionName(subscriptionPath);
|
||||
validateRuleName(rulePath);
|
||||
|
@ -1120,7 +1011,7 @@ ServiceBusService.prototype.deleteRule = function (topicPath, subscriptionPath,
|
|||
next(responseObject, finalCallback);
|
||||
};
|
||||
|
||||
this.performRequest(webResource, null, options, processResponseCallback);
|
||||
this.performRequest(webResource, null, null, processResponseCallback);
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -1129,19 +1020,10 @@ ServiceBusService.prototype.deleteRule = function (topicPath, subscriptionPath,
|
|||
* @param {string} topicPath A string object that represents the name of the topic for the subscription.
|
||||
* @param {string} subscriptionPath A string object that represents the name of the subscription for which the rule will be retrieved.
|
||||
* @param {string} rulePath A string object that represents the name of the rule to retrieve.
|
||||
* @param {object|function} [optionsOrCallback] The request options or callback function.
|
||||
* @param {int} [optionsOrCallback.timeoutIntervalInS] The timeout interval, in seconds, to use for the request.
|
||||
* @param {function(error, getruleresult, response)} callback The callback function.
|
||||
* @return {undefined}
|
||||
*/
|
||||
ServiceBusService.prototype.getRule = function (topicPath, subscriptionPath, rulePath, optionsOrCallback, callback) {
|
||||
var options = null;
|
||||
if (typeof optionsOrCallback === 'function' && !callback) {
|
||||
callback = optionsOrCallback;
|
||||
} else {
|
||||
options = optionsOrCallback;
|
||||
}
|
||||
|
||||
ServiceBusService.prototype.getRule = function (topicPath, subscriptionPath, rulePath, callback) {
|
||||
validateTopicName(topicPath);
|
||||
validateSubscriptionName(subscriptionPath);
|
||||
validateRuleName(rulePath);
|
||||
|
@ -1170,7 +1052,7 @@ ServiceBusService.prototype.getRule = function (topicPath, subscriptionPath, rul
|
|||
next(responseObject, finalCallback);
|
||||
};
|
||||
|
||||
this.performRequest(webResource, null, options, processResponseCallback);
|
||||
this.performRequest(webResource, null, null, processResponseCallback);
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -1179,7 +1061,8 @@ ServiceBusService.prototype.getRule = function (topicPath, subscriptionPath, rul
|
|||
* @param {string} topicPath A string object that represents the name of the topic for the subscription.
|
||||
* @param {string} subscriptionPath A string object that represents the name of the subscription whose rules are being retrieved.
|
||||
* @param {object|function} [optionsOrCallback] The request options or callback function.
|
||||
* @param {int} [optionsOrCallback.timeoutIntervalInS] The timeout interval, in seconds, to use for the request.
|
||||
* @param {int} [optionsOrCallback.top] The number of topics to fetch.
|
||||
* @param {int} [optionsOrCallback.skip] The number of topics to skip.
|
||||
* @param {function(error, listrulesresult, response)} callback The callback function.
|
||||
* @return {undefined}
|
||||
*/
|
||||
|
@ -1239,7 +1122,7 @@ ServiceBusService.prototype.listRules = function (topicPath, subscriptionPath, o
|
|||
next(responseObject, finalCallback);
|
||||
};
|
||||
|
||||
this.performRequest(webResource, null, options, processResponseCallback);
|
||||
this.performRequest(webResource, null, null, processResponseCallback);
|
||||
};
|
||||
|
||||
function setRequestHeaders(webResource, message) {
|
||||
|
|
|
@ -1202,6 +1202,22 @@ var Constants = {
|
|||
* @type {string}
|
||||
*/
|
||||
ServiceRuntimeConstants: {
|
||||
/**
|
||||
* The fault domain property.
|
||||
*
|
||||
* @const
|
||||
* @type {string}
|
||||
*/
|
||||
FAULT_DOMAIN: 'faultDomain',
|
||||
|
||||
/**
|
||||
* The update domain property.
|
||||
*
|
||||
* @const
|
||||
* @type {string}
|
||||
*/
|
||||
UPDATE_DOMAIN: 'updateDomain',
|
||||
|
||||
/**
|
||||
* The runtime server endpoint element.
|
||||
*
|
||||
|
@ -1354,6 +1370,14 @@ var Constants = {
|
|||
*/
|
||||
CHANGING: 'changing',
|
||||
|
||||
/**
|
||||
* The role environment stopping event.
|
||||
*
|
||||
* @const
|
||||
* @type {string}
|
||||
*/
|
||||
STOPPING: 'stopping',
|
||||
|
||||
/**
|
||||
* The ready event.
|
||||
*
|
||||
|
@ -1418,6 +1442,14 @@ var Constants = {
|
|||
*/
|
||||
STATUS: 'Status',
|
||||
|
||||
/**
|
||||
* The status detail element.
|
||||
*
|
||||
* @const
|
||||
* @type {string}
|
||||
*/
|
||||
STATUS_DETAIL: 'StatusDetail',
|
||||
|
||||
/**
|
||||
* The expiration element.
|
||||
*
|
||||
|
@ -1463,7 +1495,7 @@ var Constants = {
|
|||
* @const
|
||||
* @type {string}
|
||||
*/
|
||||
READY: 'ready',
|
||||
READY: 'Ready',
|
||||
|
||||
/**
|
||||
* The busy status.
|
||||
|
@ -1471,7 +1503,7 @@ var Constants = {
|
|||
* @const
|
||||
* @type {string}
|
||||
*/
|
||||
BUSY: 'busy'
|
||||
BUSY: 'Busy'
|
||||
},
|
||||
|
||||
/**
|
||||
|
@ -1487,7 +1519,7 @@ var Constants = {
|
|||
* @const
|
||||
* @type {string}
|
||||
*/
|
||||
STARTED: 'started',
|
||||
STARTED: 'Started',
|
||||
|
||||
/**
|
||||
* The stopped event.
|
||||
|
@ -1495,7 +1527,7 @@ var Constants = {
|
|||
* @const
|
||||
* @type {string}
|
||||
*/
|
||||
STOPPED: 'stopped',
|
||||
STOPPED: 'Stopped',
|
||||
|
||||
/**
|
||||
* The busy event.
|
||||
|
@ -1503,7 +1535,7 @@ var Constants = {
|
|||
* @const
|
||||
* @type {string}
|
||||
*/
|
||||
BUSY: 'busy',
|
||||
BUSY: 'Busy',
|
||||
|
||||
/**
|
||||
* The recycle event.
|
||||
|
@ -1511,7 +1543,7 @@ var Constants = {
|
|||
* @const
|
||||
* @type {string}
|
||||
*/
|
||||
RECYCLE: 'recycle'
|
||||
RECYCLE: 'Recycle'
|
||||
}
|
||||
},
|
||||
|
||||
|
|
|
@ -101,7 +101,7 @@ function _writeAtomEntryValue (parentElement, name, value) {
|
|||
}
|
||||
|
||||
return parentElement;
|
||||
};
|
||||
}
|
||||
|
||||
/*
|
||||
* Checks whether the specified value is a Date object.
|
||||
|
@ -110,7 +110,7 @@ function _writeAtomEntryValue (parentElement, name, value) {
|
|||
*/
|
||||
function _isDate (value) {
|
||||
return Object.prototype.toString.call(value) === "[object Date]";
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Formats a value by invoking .toString() on it.
|
||||
|
|
|
@ -38,6 +38,10 @@ exports.encodeUri = function (uri) {
|
|||
* @return {number} The number of keys in the object.
|
||||
*/
|
||||
exports.objectKeysLength = function (value) {
|
||||
if (!value) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return _.keys(value).length;
|
||||
};
|
||||
|
||||
|
|
|
@ -141,9 +141,6 @@
|
|||
<Content Include="..\..\lib\serviceruntime\roleenvironment.js">
|
||||
<Link>lib\serviceruntime\roleenvironment.js</Link>
|
||||
</Content>
|
||||
<Content Include="..\..\lib\serviceruntime\roleinstance.js">
|
||||
<Link>lib\serviceruntime\roleinstance.js</Link>
|
||||
</Content>
|
||||
<Content Include="..\..\lib\serviceruntime\runtimekernel.js">
|
||||
<Link>lib\serviceruntime\runtimekernel.js</Link>
|
||||
</Content>
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
*/
|
||||
|
||||
var assert = require('assert');
|
||||
var net = require('net');
|
||||
|
||||
var RuntimeKernel = require('../../lib/serviceruntime/runtimekernel');
|
||||
var NamedPipeInputChannel = require('../../lib/serviceruntime/namedpipeinputchannel');
|
||||
|
@ -25,15 +26,49 @@ var ServiceRuntimeConstants = Constants.ServiceRuntimeConstants;
|
|||
|
||||
var azure = require('../../lib/azure');
|
||||
|
||||
var originalFileInputChannelReadData;
|
||||
var originalNamedPipeInputChannelReadData;
|
||||
var originalNamedPipeOutputChannelWriteOutputChannel;
|
||||
var originalVersionEndpointFixedPath;
|
||||
var originalRuntimeClient;
|
||||
var originalEndpoint;
|
||||
|
||||
suite('roleenvironment-tests', function () {
|
||||
setup(function (done) {
|
||||
var runtimeKernel = RuntimeKernel.getKernel();
|
||||
|
||||
originalFileInputChannelReadData = runtimeKernel.fileInputChannel._readData;
|
||||
originalNamedPipeInputChannelReadData = runtimeKernel.namedPipeInputChannel._readData;
|
||||
originalNamedPipeOutputChannelWriteOutputChannel = runtimeKernel.namedPipeOutputChannel.writeOutputChannel;
|
||||
originalVersionEndpointFixedPath = azure.RoleEnvironment.VersionEndpointFixedPath;
|
||||
originalRuntimeClient = azure.RoleEnvironment.runtimeClient;
|
||||
originalEndpoint = runtimeKernel.protocol1RuntimeGoalStateClient.endpoint;
|
||||
|
||||
done();
|
||||
});
|
||||
|
||||
teardown(function (done) {
|
||||
var runtimeKernel = RuntimeKernel.getKernel();
|
||||
|
||||
runtimeKernel.namedPipeInputChannel._readData = originalNamedPipeInputChannelReadData;
|
||||
runtimeKernel.fileInputChannel._readData = originalFileInputChannelReadData;
|
||||
runtimeKernel.protocol1RuntimeGoalStateClient.currentGoalState = null;
|
||||
runtimeKernel.protocol1RuntimeGoalStateClient.currentEnvironmentData = null;
|
||||
runtimeKernel.protocol1RuntimeGoalStateClient.endpoint = originalEndpoint;
|
||||
|
||||
azure.RoleEnvironment.VersionEndpointFixedPath = originalVersionEndpointFixedPath;
|
||||
azure.RoleEnvironment.runtimeClient = originalRuntimeClient;
|
||||
|
||||
done();
|
||||
});
|
||||
|
||||
test('IsAvailable', function (done) {
|
||||
azure.RoleEnvironment.isAvailable(function (error1, isAvailable1) {
|
||||
assert.notEqual(error1, null);
|
||||
assert.equal(isAvailable1, false);
|
||||
|
||||
var runtimeKernel = RuntimeKernel.getKernel();
|
||||
var originalNamedPipeInputChannelReadData = runtimeKernel.namedPipeInputChannel.readData;
|
||||
runtimeKernel.namedPipeInputChannel.readData = function (name, callback) {
|
||||
runtimeKernel.namedPipeInputChannel._readData = function (name, callback) {
|
||||
if (name === '\\\\.\\pipe\\WindowsAzureRuntime') {
|
||||
callback(undefined,
|
||||
"<?xml version=\"1.0\" encoding=\"utf-8\"?>" +
|
||||
|
@ -59,8 +94,7 @@ suite('roleenvironment-tests', function () {
|
|||
}
|
||||
};
|
||||
|
||||
var originalFileInputChannelReadData = runtimeKernel.fileInputChannel.readData;
|
||||
runtimeKernel.fileInputChannel.readData = function (name, callback) {
|
||||
runtimeKernel.fileInputChannel._readData = function (name, callback) {
|
||||
if (name === 'C:\\file.xml') {
|
||||
callback(undefined,
|
||||
"<?xml version=\"1.0\" encoding=\"utf-8\"?>" +
|
||||
|
@ -87,11 +121,6 @@ suite('roleenvironment-tests', function () {
|
|||
assert.equal(error2, null);
|
||||
assert.equal(isAvailable2, true);
|
||||
|
||||
runtimeKernel.namedPipeInputChannel.readData = originalNamedPipeInputChannelReadData;
|
||||
runtimeKernel.fileInputChannel.readData = originalFileInputChannelReadData;
|
||||
runtimeKernel.protocol1RuntimeGoalStateClient.currentGoalState = null;
|
||||
runtimeKernel.protocol1RuntimeGoalStateClient.currentEnvironmentData = null;
|
||||
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
@ -99,17 +128,16 @@ suite('roleenvironment-tests', function () {
|
|||
|
||||
test('GetLocalResourcesNoGoalStateNamedPipe', function (done) {
|
||||
assert.throws(
|
||||
azure.RoleEnvironment.getLocalResources(function () { }),
|
||||
Error
|
||||
);
|
||||
azure.RoleEnvironment.getLocalResources(function () { }),
|
||||
Error
|
||||
);
|
||||
|
||||
done();
|
||||
});
|
||||
|
||||
test('GetDeploymentId', function (done) {
|
||||
var runtimeKernel = RuntimeKernel.getKernel();
|
||||
var originalNamedPipeInputChannelReadData = runtimeKernel.namedPipeInputChannel.readData;
|
||||
runtimeKernel.namedPipeInputChannel.readData = function (name, callback) {
|
||||
runtimeKernel.namedPipeInputChannel._readData = function (name, callback) {
|
||||
if (name === '\\\\.\\pipe\\WindowsAzureRuntime') {
|
||||
callback(undefined,
|
||||
"<?xml version=\"1.0\" encoding=\"utf-8\"?>" +
|
||||
|
@ -135,8 +163,8 @@ suite('roleenvironment-tests', function () {
|
|||
}
|
||||
};
|
||||
|
||||
var originalFileInputChannelReadData = runtimeKernel.fileInputChannel.readData;
|
||||
runtimeKernel.fileInputChannel.readData = function (name, callback) {
|
||||
var originalFileInputChannelReadData = runtimeKernel.fileInputChannel._readData;
|
||||
runtimeKernel.fileInputChannel._readData = function (name, callback) {
|
||||
if (name === 'C:\\file.xml') {
|
||||
callback(undefined,
|
||||
"<?xml version=\"1.0\" encoding=\"utf-8\"?>" +
|
||||
|
@ -163,19 +191,13 @@ suite('roleenvironment-tests', function () {
|
|||
assert.equal(error, null);
|
||||
assert.equal(id, 'mydeploymentid');
|
||||
|
||||
runtimeKernel.namedPipeInputChannel.readData = originalNamedPipeInputChannelReadData;
|
||||
runtimeKernel.fileInputChannel.readData = originalFileInputChannelReadData;
|
||||
runtimeKernel.protocol1RuntimeGoalStateClient.currentGoalState = null;
|
||||
runtimeKernel.protocol1RuntimeGoalStateClient.currentEnvironmentData = null;
|
||||
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
test('GetLocalResources', function (done) {
|
||||
var runtimeKernel = RuntimeKernel.getKernel();
|
||||
var originalNamedPipeInputChannelReadData = runtimeKernel.namedPipeInputChannel.readData;
|
||||
runtimeKernel.namedPipeInputChannel.readData = function (name, callback) {
|
||||
runtimeKernel.namedPipeInputChannel._readData = function (name, callback) {
|
||||
if (name === '\\\\.\\pipe\\WindowsAzureRuntime') {
|
||||
callback(undefined,
|
||||
"<?xml version=\"1.0\" encoding=\"utf-8\"?>" +
|
||||
|
@ -201,8 +223,7 @@ suite('roleenvironment-tests', function () {
|
|||
}
|
||||
};
|
||||
|
||||
var originalFileInputChannelReadData = runtimeKernel.fileInputChannel.readData;
|
||||
runtimeKernel.fileInputChannel.readData = function (name, callback) {
|
||||
runtimeKernel.fileInputChannel._readData = function (name, callback) {
|
||||
if (name === 'C:\\file.xml') {
|
||||
callback(undefined,
|
||||
"<?xml version=\"1.0\" encoding=\"utf-8\"?>" +
|
||||
|
@ -232,19 +253,13 @@ suite('roleenvironment-tests', function () {
|
|||
assert.notEqual(localResources['DiagnosticStore']['path'], null);
|
||||
assert.notEqual(localResources['DiagnosticStore']['sizeInMB'], null);
|
||||
|
||||
runtimeKernel.namedPipeInputChannel.readData = originalNamedPipeInputChannelReadData;
|
||||
runtimeKernel.fileInputChannel.readData = originalFileInputChannelReadData;
|
||||
runtimeKernel.protocol1RuntimeGoalStateClient.currentGoalState = null;
|
||||
runtimeKernel.protocol1RuntimeGoalStateClient.currentEnvironmentData = null;
|
||||
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
test('GetRoles', function (done) {
|
||||
var runtimeKernel = RuntimeKernel.getKernel();
|
||||
var originalNamedPipeInputChannelReadData = runtimeKernel.namedPipeInputChannel.readData;
|
||||
runtimeKernel.namedPipeInputChannel.readData = function (name, callback) {
|
||||
runtimeKernel.namedPipeInputChannel._readData = function (name, callback) {
|
||||
if (name === '\\\\.\\pipe\\WindowsAzureRuntime') {
|
||||
callback(undefined,
|
||||
"<?xml version=\"1.0\" encoding=\"utf-8\"?>" +
|
||||
|
@ -270,8 +285,7 @@ suite('roleenvironment-tests', function () {
|
|||
}
|
||||
};
|
||||
|
||||
var originalFileInputChannelReadData = runtimeKernel.fileInputChannel.readData;
|
||||
runtimeKernel.fileInputChannel.readData = function (name, callback) {
|
||||
runtimeKernel.fileInputChannel._readData = function (name, callback) {
|
||||
if (name === 'C:\\file.xml') {
|
||||
callback(undefined,
|
||||
"<?xml version=\"1.0\" encoding=\"utf-8\"?>" +
|
||||
|
@ -328,19 +342,13 @@ suite('roleenvironment-tests', function () {
|
|||
assert.notEqual(roles['role2']['deployment16(191).test.role2_IN_0'], null);
|
||||
assert.notEqual(roles['role2']['deployment16(191).test.role2_IN_1'], null);
|
||||
|
||||
runtimeKernel.namedPipeInputChannel.readData = originalNamedPipeInputChannelReadData;
|
||||
runtimeKernel.fileInputChannel.readData = originalFileInputChannelReadData;
|
||||
runtimeKernel.protocol1RuntimeGoalStateClient.currentGoalState = null;
|
||||
runtimeKernel.protocol1RuntimeGoalStateClient.currentEnvironmentData = null;
|
||||
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
test('CalculateChanges', function (done) {
|
||||
var runtimeKernel = RuntimeKernel.getKernel();
|
||||
var originalNamedPipeInputChannelReadData = runtimeKernel.namedPipeInputChannel.readData;
|
||||
runtimeKernel.namedPipeInputChannel.readData = function (name, callback) {
|
||||
runtimeKernel.namedPipeInputChannel._readData = function (name, callback) {
|
||||
if (name === '\\\\.\\pipe\\WindowsAzureRuntime') {
|
||||
callback(undefined,
|
||||
"<?xml version=\"1.0\" encoding=\"utf-8\"?>" +
|
||||
|
@ -366,8 +374,7 @@ suite('roleenvironment-tests', function () {
|
|||
}
|
||||
};
|
||||
|
||||
var originalFileInputChannelReadData = runtimeKernel.fileInputChannel.readData;
|
||||
runtimeKernel.fileInputChannel.readData = function (name, callback) {
|
||||
runtimeKernel.fileInputChannel._readData = function (name, callback) {
|
||||
if (name === 'C:\\file.xml') {
|
||||
callback(undefined,
|
||||
"<?xml version=\"1.0\" encoding=\"utf-8\"?>" +
|
||||
|
@ -424,11 +431,6 @@ suite('roleenvironment-tests', function () {
|
|||
assert.notEqual(changes, null);
|
||||
assert.equal(changes.length, 0);
|
||||
|
||||
runtimeKernel.namedPipeInputChannel.readData = originalNamedPipeInputChannelReadData;
|
||||
runtimeKernel.fileInputChannel.readData = originalFileInputChannelReadData;
|
||||
runtimeKernel.protocol1RuntimeGoalStateClient.currentGoalState = null;
|
||||
runtimeKernel.protocol1RuntimeGoalStateClient.currentEnvironmentData = null;
|
||||
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
@ -436,56 +438,53 @@ suite('roleenvironment-tests', function () {
|
|||
|
||||
test('testRequestRecycle', function (done) {
|
||||
var runtimeKernel = RuntimeKernel.getKernel();
|
||||
var originalNamedPipeInputChannelReadData = runtimeKernel.namedPipeInputChannel.readData;
|
||||
runtimeKernel.namedPipeInputChannel.readData = function (name, callback) {
|
||||
runtimeKernel.namedPipeInputChannel._readData = function (name, callback) {
|
||||
if (name === '\\\\.\\pipe\\WindowsAzureRuntime') {
|
||||
callback(undefined,
|
||||
"<?xml version=\"1.0\" encoding=\"utf-8\"?>" +
|
||||
"<RuntimeServerDiscovery xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"" +
|
||||
"xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\">" +
|
||||
"<RuntimeServerEndpoints>" +
|
||||
"<RuntimeServerEndpoint version=\"2011-03-08\" path=\"SomePath.GoalState\" />" +
|
||||
"</RuntimeServerEndpoints>" +
|
||||
"</RuntimeServerDiscovery>");
|
||||
"<?xml version=\"1.0\" encoding=\"utf-8\"?>" +
|
||||
"<RuntimeServerDiscovery xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"" +
|
||||
"xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\">" +
|
||||
"<RuntimeServerEndpoints>" +
|
||||
"<RuntimeServerEndpoint version=\"2011-03-08\" path=\"SomePath.GoalState\" />" +
|
||||
"</RuntimeServerEndpoints>" +
|
||||
"</RuntimeServerDiscovery>");
|
||||
} else if (name === 'SomePath.GoalState') {
|
||||
callback(undefined,
|
||||
"<?xml version=\"1.0\" encoding=\"utf-8\"?>" +
|
||||
"<GoalState xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"" +
|
||||
"xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\">" +
|
||||
"<Incarnation>1</Incarnation>" +
|
||||
"<ExpectedState>Started</ExpectedState>" +
|
||||
"<RoleEnvironmentPath>C:\\file.xml</RoleEnvironmentPath>" +
|
||||
"<CurrentStateEndpoint>\\.\pipe\WindowsAzureRuntime.CurrentState</CurrentStateEndpoint>" +
|
||||
"<Deadline>9999-12-31T23:59:59.9999999</Deadline>" +
|
||||
"</GoalState>");
|
||||
"<?xml version=\"1.0\" encoding=\"utf-8\"?>" +
|
||||
"<GoalState xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"" +
|
||||
"xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\">" +
|
||||
"<Incarnation>1</Incarnation>" +
|
||||
"<ExpectedState>Started</ExpectedState>" +
|
||||
"<RoleEnvironmentPath>C:\\file.xml</RoleEnvironmentPath>" +
|
||||
"<CurrentStateEndpoint>\\.\pipe\WindowsAzureRuntime.CurrentState</CurrentStateEndpoint>" +
|
||||
"<Deadline>9999-12-31T23:59:59.9999999</Deadline>" +
|
||||
"</GoalState>");
|
||||
} else {
|
||||
callback('wrong file');
|
||||
}
|
||||
};
|
||||
|
||||
var originalFileInputChannelReadData = runtimeKernel.fileInputChannel.readData;
|
||||
runtimeKernel.fileInputChannel.readData = function (name, callback) {
|
||||
runtimeKernel.fileInputChannel._readData = function (name, callback) {
|
||||
if (name === 'C:\\file.xml') {
|
||||
callback(undefined,
|
||||
"<?xml version=\"1.0\" encoding=\"utf-8\"?>" +
|
||||
"<RoleEnvironment xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"" +
|
||||
"xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\">" +
|
||||
"<Deployment id=\"deploymentId\" emulated=\"false\" />" +
|
||||
"<CurrentInstance id=\"test\" roleName=\"test\" faultDomain=\"0\" updateDomain=\"0\">" +
|
||||
"<ConfigurationSettings />" +
|
||||
"<LocalResources />" +
|
||||
"<Endpoints />" +
|
||||
"</CurrentInstance>" +
|
||||
"<Roles />" +
|
||||
"</RoleEnvironment>");
|
||||
"<?xml version=\"1.0\" encoding=\"utf-8\"?>" +
|
||||
"<RoleEnvironment xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"" +
|
||||
"xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\">" +
|
||||
"<Deployment id=\"deploymentId\" emulated=\"false\" />" +
|
||||
"<CurrentInstance id=\"test\" roleName=\"test\" faultDomain=\"0\" updateDomain=\"0\">" +
|
||||
"<ConfigurationSettings />" +
|
||||
"<LocalResources />" +
|
||||
"<Endpoints />" +
|
||||
"</CurrentInstance>" +
|
||||
"<Roles />" +
|
||||
"</RoleEnvironment>");
|
||||
} else {
|
||||
callback('wrong file');
|
||||
}
|
||||
};
|
||||
|
||||
var originalNamedPipeOutputChannelWriteOutputChannel = runtimeKernel.namedPipeOutputChannel.writeOutputChannel;
|
||||
var writtenData;
|
||||
runtimeKernel.namedPipeOutputChannel.writeOutputChannel = function (data, callback) {
|
||||
runtimeKernel.namedPipeOutputChannel.writeOutputChannel = function (name, data, callback) {
|
||||
writtenData = data;
|
||||
callback();
|
||||
};
|
||||
|
@ -493,70 +492,188 @@ suite('roleenvironment-tests', function () {
|
|||
azure.RoleEnvironment.requestRecycle(function (error) {
|
||||
assert.equal(error, null);
|
||||
|
||||
assert.equal(writtenData, '<?xml version="1.0" encoding="utf-8" standalone="yes"?><CurrentState><StatusLease ClientId="' + azure.RoleEnvironment.clientId + '"><Acquire><Expiration>Fri Dec 31 9999 15:59:59 GMT-0800 (Pacific Standard Time)</Expiration><Incarnation>1</Incarnation><Status>recycle</Status></Acquire></StatusLease></CurrentState>');
|
||||
|
||||
runtimeKernel.namedPipeInputChannel.readData = originalNamedPipeInputChannelReadData;
|
||||
runtimeKernel.fileInputChannel.readData = originalFileInputChannelReadData;
|
||||
runtimeKernel.protocol1RuntimeGoalStateClient.currentGoalState = null;
|
||||
runtimeKernel.protocol1RuntimeGoalStateClient.currentEnvironmentData = null;
|
||||
runtimeKernel.namedPipeOutputChannel.writeOutputChannel = originalNamedPipeOutputChannelWriteOutputChannel;
|
||||
assert.equal(writtenData, '<?xml version="1.0" encoding="utf-8" standalone="yes"?><CurrentState><StatusLease ClientId="' + azure.RoleEnvironment.clientId + '"><Acquire><Incarnation>1</Incarnation><Status>' + ServiceRuntimeConstants.RoleStatus.RECYCLE + '</Status><StatusDetail>' + ServiceRuntimeConstants.RoleStatus.RECYCLE + '</StatusDetail><Expiration>9999-12-31T23:59:59.999Z</Expiration></Acquire></StatusLease></CurrentState>');
|
||||
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
test('testChangedNotifications', function (done) {
|
||||
var versionsXml = "<?xml version=\"1.0\" encoding=\"utf-8\"?>" +
|
||||
"<RuntimeServerDiscovery xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"" +
|
||||
"xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\">" +
|
||||
"<RuntimeServerEndpoints>" +
|
||||
"<RuntimeServerEndpoint version=\"2011-03-08\" path=\"\\\\.\\pipe\\goalState\" />" +
|
||||
"</RuntimeServerEndpoints>" +
|
||||
"</RuntimeServerDiscovery>";
|
||||
|
||||
var goalStateXml = "<?xml version=\"1.0\" encoding=\"utf-8\"?>" +
|
||||
"<GoalState xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"" +
|
||||
"xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\">" +
|
||||
"<Incarnation>1</Incarnation>" +
|
||||
"<ExpectedState>Started</ExpectedState>" +
|
||||
"<RoleEnvironmentPath>C:\\file.xml</RoleEnvironmentPath>" +
|
||||
"<CurrentStateEndpoint>\\.\pipe\WindowsAzureRuntime.CurrentState</CurrentStateEndpoint>" +
|
||||
"<Deadline>9999-12-31T23:59:59.9999999</Deadline>" +
|
||||
"</GoalState>";
|
||||
|
||||
var environmentData = "<?xml version=\"1.0\" encoding=\"utf-8\"?>" +
|
||||
"<RoleEnvironment xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"" +
|
||||
"xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\">" +
|
||||
"<Deployment id=\"deploymentId\" emulated=\"false\" />" +
|
||||
"<CurrentInstance id=\"test\" roleName=\"test\" faultDomain=\"0\" updateDomain=\"0\">" +
|
||||
"<ConfigurationSettings />" +
|
||||
"<LocalResources />" +
|
||||
"<Endpoints />" +
|
||||
"</CurrentInstance>" +
|
||||
"<Roles />" +
|
||||
"</RoleEnvironment>";
|
||||
|
||||
// Create versions pipe
|
||||
var serverVersions = net.createServer(function (stream) {
|
||||
stream.setEncoding('utf8');
|
||||
stream.on('connect', function () {
|
||||
stream.write(versionsXml);
|
||||
});
|
||||
|
||||
stream.on('end', function () {
|
||||
stream.end();
|
||||
});
|
||||
});
|
||||
|
||||
serverVersions.listen('\\\\.\\pipe\\versions');
|
||||
|
||||
// Create goal state pipe
|
||||
var serverGoalStateInterval;
|
||||
var serverGoalState = net.createServer(function (stream) {
|
||||
stream.setEncoding('utf8');
|
||||
stream.on('connect', function () {
|
||||
// Write goal state every second
|
||||
serverGoalStateInterval = setInterval(function () {
|
||||
stream.write(goalStateXml);
|
||||
}, 1000);
|
||||
});
|
||||
|
||||
stream.on('end', function () {
|
||||
stream.end();
|
||||
});
|
||||
});
|
||||
|
||||
serverGoalState.listen('\\\\.\\pipe\\goalState');
|
||||
|
||||
var runtimeKernel = RuntimeKernel.getKernel();
|
||||
runtimeKernel.fileInputChannel._readData = function (name, callback) {
|
||||
if (name === 'C:\\file.xml') {
|
||||
callback(undefined, environmentData);
|
||||
} else {
|
||||
callback('wrong file');
|
||||
}
|
||||
};
|
||||
|
||||
azure.RoleEnvironment.VersionEndpointFixedPath = '\\\\.\\pipe\\versions';
|
||||
azure.RoleEnvironment.runtimeClient = null;
|
||||
|
||||
var changingInvoked = false;
|
||||
|
||||
azure.RoleEnvironment.on(ServiceRuntimeConstants.CHANGING, function () {
|
||||
changingInvoked = true;
|
||||
});
|
||||
|
||||
azure.RoleEnvironment.on(ServiceRuntimeConstants.CHANGED, function (changes) {
|
||||
assert.equal(changingInvoked, true);
|
||||
|
||||
assert.notEqual(changes, null);
|
||||
assert.equal(changes.length, 1);
|
||||
assert.equal(changes[0].type, 'TopologyChange');
|
||||
assert.equal(changes[0].name, 'test');
|
||||
|
||||
serverVersions.close();
|
||||
serverGoalState.close();
|
||||
|
||||
clearInterval(serverGoalStateInterval);
|
||||
|
||||
done();
|
||||
});
|
||||
|
||||
// Make sure incarnation 1 is read
|
||||
azure.RoleEnvironment.getConfigurationSettings(function (error, configurationSettings) {
|
||||
// Update to incarnation 2
|
||||
goalStateXml = "<?xml version=\"1.0\" encoding=\"utf-8\"?>" +
|
||||
"<GoalState xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"" +
|
||||
"xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\">" +
|
||||
"<Incarnation>2</Incarnation>" +
|
||||
"<ExpectedState>Started</ExpectedState>" +
|
||||
"<RoleEnvironmentPath>C:\\file.xml</RoleEnvironmentPath>" +
|
||||
"<CurrentStateEndpoint>\\.\pipe\WindowsAzureRuntime.CurrentState</CurrentStateEndpoint>" +
|
||||
"<Deadline>9999-12-31T23:59:59.9999999</Deadline>" +
|
||||
"</GoalState>";
|
||||
|
||||
environmentData = "<?xml version=\"1.0\" encoding=\"utf-8\"?>" +
|
||||
"<RoleEnvironment xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"" +
|
||||
"xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\">" +
|
||||
"<Deployment id=\"deploymentId\" emulated=\"false\" />" +
|
||||
"<CurrentInstance id=\"test\" roleName=\"test\" faultDomain=\"0\" updateDomain=\"1\">" +
|
||||
"<ConfigurationSettings />" +
|
||||
"<LocalResources />" +
|
||||
"<Endpoints />" +
|
||||
"</CurrentInstance>" +
|
||||
"<Roles />" +
|
||||
"</RoleEnvironment>";
|
||||
|
||||
assert.equal(error, null);
|
||||
});
|
||||
});
|
||||
|
||||
test('testClearStatus', function (done) {
|
||||
var runtimeKernel = RuntimeKernel.getKernel();
|
||||
var originalNamedPipeInputChannelReadData = runtimeKernel.namedPipeInputChannel.readData;
|
||||
runtimeKernel.namedPipeInputChannel.readData = function (name, callback) {
|
||||
runtimeKernel.namedPipeInputChannel._readData = function (name, callback) {
|
||||
if (name === '\\\\.\\pipe\\WindowsAzureRuntime') {
|
||||
callback(undefined,
|
||||
"<?xml version=\"1.0\" encoding=\"utf-8\"?>" +
|
||||
"<RuntimeServerDiscovery xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"" +
|
||||
"xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\">" +
|
||||
"<RuntimeServerEndpoints>" +
|
||||
"<RuntimeServerEndpoint version=\"2011-03-08\" path=\"SomePath.GoalState\" />" +
|
||||
"</RuntimeServerEndpoints>" +
|
||||
"</RuntimeServerDiscovery>");
|
||||
"<?xml version=\"1.0\" encoding=\"utf-8\"?>" +
|
||||
"<RuntimeServerDiscovery xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"" +
|
||||
"xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\">" +
|
||||
"<RuntimeServerEndpoints>" +
|
||||
"<RuntimeServerEndpoint version=\"2011-03-08\" path=\"SomePath.GoalState\" />" +
|
||||
"</RuntimeServerEndpoints>" +
|
||||
"</RuntimeServerDiscovery>");
|
||||
} else if (name === 'SomePath.GoalState') {
|
||||
callback(undefined,
|
||||
"<?xml version=\"1.0\" encoding=\"utf-8\"?>" +
|
||||
"<GoalState xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"" +
|
||||
"xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\">" +
|
||||
"<Incarnation>1</Incarnation>" +
|
||||
"<ExpectedState>Started</ExpectedState>" +
|
||||
"<RoleEnvironmentPath>C:\\file.xml</RoleEnvironmentPath>" +
|
||||
"<CurrentStateEndpoint>\\.\pipe\WindowsAzureRuntime.CurrentState</CurrentStateEndpoint>" +
|
||||
"<Deadline>9999-12-31T23:59:59.9999999</Deadline>" +
|
||||
"</GoalState>");
|
||||
"<?xml version=\"1.0\" encoding=\"utf-8\"?>" +
|
||||
"<GoalState xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"" +
|
||||
"xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\">" +
|
||||
"<Incarnation>1</Incarnation>" +
|
||||
"<ExpectedState>Started</ExpectedState>" +
|
||||
"<RoleEnvironmentPath>C:\\file.xml</RoleEnvironmentPath>" +
|
||||
"<CurrentStateEndpoint>\\.\pipe\WindowsAzureRuntime.CurrentState</CurrentStateEndpoint>" +
|
||||
"<Deadline>9999-12-31T23:59:59.9999999</Deadline>" +
|
||||
"</GoalState>");
|
||||
} else {
|
||||
callback('wrong file');
|
||||
callback('wrong pipe');
|
||||
}
|
||||
};
|
||||
|
||||
var originalFileInputChannelReadData = runtimeKernel.fileInputChannel.readData;
|
||||
runtimeKernel.fileInputChannel.readData = function (name, callback) {
|
||||
runtimeKernel.fileInputChannel._readData = function (name, callback) {
|
||||
if (name === 'C:\\file.xml') {
|
||||
callback(undefined,
|
||||
"<?xml version=\"1.0\" encoding=\"utf-8\"?>" +
|
||||
"<RoleEnvironment xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"" +
|
||||
"xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\">" +
|
||||
"<Deployment id=\"deploymentId\" emulated=\"false\" />" +
|
||||
"<CurrentInstance id=\"test\" roleName=\"test\" faultDomain=\"0\" updateDomain=\"0\">" +
|
||||
"<ConfigurationSettings />" +
|
||||
"<LocalResources />" +
|
||||
"<Endpoints />" +
|
||||
"</CurrentInstance>" +
|
||||
"<Roles />" +
|
||||
"</RoleEnvironment>");
|
||||
"<?xml version=\"1.0\" encoding=\"utf-8\"?>" +
|
||||
"<RoleEnvironment xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"" +
|
||||
"xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\">" +
|
||||
"<Deployment id=\"deploymentId\" emulated=\"false\" />" +
|
||||
"<CurrentInstance id=\"test\" roleName=\"test\" faultDomain=\"0\" updateDomain=\"0\">" +
|
||||
"<ConfigurationSettings />" +
|
||||
"<LocalResources />" +
|
||||
"<Endpoints />" +
|
||||
"</CurrentInstance>" +
|
||||
"<Roles />" +
|
||||
"</RoleEnvironment>");
|
||||
} else {
|
||||
console.log('hahah: ' + name);
|
||||
callback('wrong file');
|
||||
}
|
||||
};
|
||||
|
||||
var originalNamedPipeOutputChannelWriteOutputChannel = runtimeKernel.namedPipeOutputChannel.writeOutputChannel;
|
||||
var writtenData;
|
||||
runtimeKernel.namedPipeOutputChannel.writeOutputChannel = function (data, callback) {
|
||||
runtimeKernel.namedPipeOutputChannel.writeOutputChannel = function (name, data, callback) {
|
||||
writtenData = data;
|
||||
callback();
|
||||
};
|
||||
|
@ -566,87 +683,72 @@ suite('roleenvironment-tests', function () {
|
|||
|
||||
assert.equal(writtenData, '<?xml version="1.0" encoding="utf-8" standalone="yes"?><CurrentState><StatusLease ClientId="' + azure.RoleEnvironment.clientId + '"><Release/></StatusLease></CurrentState>');
|
||||
|
||||
runtimeKernel.namedPipeInputChannel.readData = originalNamedPipeInputChannelReadData;
|
||||
runtimeKernel.fileInputChannel.readData = originalFileInputChannelReadData;
|
||||
runtimeKernel.protocol1RuntimeGoalStateClient.currentGoalState = null;
|
||||
runtimeKernel.protocol1RuntimeGoalStateClient.currentEnvironmentData = null;
|
||||
runtimeKernel.namedPipeOutputChannel.writeOutputChannel = originalNamedPipeOutputChannelWriteOutputChannel;
|
||||
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
test('testSetStatus', function (done) {
|
||||
var runtimeKernel = RuntimeKernel.getKernel();
|
||||
var originalNamedPipeInputChannelReadData = runtimeKernel.namedPipeInputChannel.readData;
|
||||
runtimeKernel.namedPipeInputChannel.readData = function (name, callback) {
|
||||
runtimeKernel.namedPipeInputChannel._readData = function (name, callback) {
|
||||
if (name === '\\\\.\\pipe\\WindowsAzureRuntime') {
|
||||
callback(undefined,
|
||||
"<?xml version=\"1.0\" encoding=\"utf-8\"?>" +
|
||||
"<RuntimeServerDiscovery xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"" +
|
||||
"xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\">" +
|
||||
"<RuntimeServerEndpoints>" +
|
||||
"<RuntimeServerEndpoint version=\"2011-03-08\" path=\"SomePath.GoalState\" />" +
|
||||
"</RuntimeServerEndpoints>" +
|
||||
"</RuntimeServerDiscovery>");
|
||||
"<?xml version=\"1.0\" encoding=\"utf-8\"?>" +
|
||||
"<RuntimeServerDiscovery xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"" +
|
||||
"xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\">" +
|
||||
"<RuntimeServerEndpoints>" +
|
||||
"<RuntimeServerEndpoint version=\"2011-03-08\" path=\"SomePath.GoalState\" />" +
|
||||
"</RuntimeServerEndpoints>" +
|
||||
"</RuntimeServerDiscovery>");
|
||||
} else if (name === 'SomePath.GoalState') {
|
||||
callback(undefined,
|
||||
"<?xml version=\"1.0\" encoding=\"utf-8\"?>" +
|
||||
"<GoalState xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"" +
|
||||
"xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\">" +
|
||||
"<Incarnation>1</Incarnation>" +
|
||||
"<ExpectedState>Started</ExpectedState>" +
|
||||
"<RoleEnvironmentPath>C:\\file.xml</RoleEnvironmentPath>" +
|
||||
"<CurrentStateEndpoint>\\.\pipe\WindowsAzureRuntime.CurrentState</CurrentStateEndpoint>" +
|
||||
"<Deadline>9999-12-31T23:59:59.9999999</Deadline>" +
|
||||
"</GoalState>");
|
||||
"<?xml version=\"1.0\" encoding=\"utf-8\"?>" +
|
||||
"<GoalState xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"" +
|
||||
"xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\">" +
|
||||
"<Incarnation>1</Incarnation>" +
|
||||
"<ExpectedState>Started</ExpectedState>" +
|
||||
"<RoleEnvironmentPath>C:\\file.xml</RoleEnvironmentPath>" +
|
||||
"<CurrentStateEndpoint>\\.\pipe\WindowsAzureRuntime.CurrentState</CurrentStateEndpoint>" +
|
||||
"<Deadline>9999-12-31T23:59:59.9999999</Deadline>" +
|
||||
"</GoalState>");
|
||||
} else {
|
||||
callback('wrong file');
|
||||
}
|
||||
};
|
||||
|
||||
var originalFileInputChannelReadData = runtimeKernel.fileInputChannel.readData;
|
||||
runtimeKernel.fileInputChannel.readData = function (name, callback) {
|
||||
runtimeKernel.fileInputChannel._readData = function (name, callback) {
|
||||
if (name === 'C:\\file.xml') {
|
||||
callback(undefined,
|
||||
"<?xml version=\"1.0\" encoding=\"utf-8\"?>" +
|
||||
"<RoleEnvironment xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"" +
|
||||
"xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\">" +
|
||||
"<Deployment id=\"deploymentId\" emulated=\"false\" />" +
|
||||
"<CurrentInstance id=\"test\" roleName=\"test\" faultDomain=\"0\" updateDomain=\"0\">" +
|
||||
"<ConfigurationSettings />" +
|
||||
"<LocalResources />" +
|
||||
"<Endpoints />" +
|
||||
"</CurrentInstance>" +
|
||||
"<Roles />" +
|
||||
"</RoleEnvironment>");
|
||||
"<?xml version=\"1.0\" encoding=\"utf-8\"?>" +
|
||||
"<RoleEnvironment xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"" +
|
||||
"xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\">" +
|
||||
"<Deployment id=\"deploymentId\" emulated=\"false\" />" +
|
||||
"<CurrentInstance id=\"test\" roleName=\"test\" faultDomain=\"0\" updateDomain=\"0\">" +
|
||||
"<ConfigurationSettings />" +
|
||||
"<LocalResources />" +
|
||||
"<Endpoints />" +
|
||||
"</CurrentInstance>" +
|
||||
"<Roles />" +
|
||||
"</RoleEnvironment>");
|
||||
} else {
|
||||
callback('wrong file');
|
||||
}
|
||||
};
|
||||
|
||||
var originalNamedPipeOutputChannelWriteOutputChannel = runtimeKernel.namedPipeOutputChannel.writeOutputChannel;
|
||||
var writtenData;
|
||||
runtimeKernel.namedPipeOutputChannel.writeOutputChannel = function (data, callback) {
|
||||
runtimeKernel.namedPipeOutputChannel.writeOutputChannel = function (name, data, callback) {
|
||||
writtenData = data;
|
||||
callback();
|
||||
};
|
||||
|
||||
azure.RoleEnvironment.setStatus(ServiceRuntimeConstants.RoleInstanceStatus.READY, new Date(2012, 1, 1, 12, 10, 10, 0), function (error1) {
|
||||
azure.RoleEnvironment.setStatus(ServiceRuntimeConstants.RoleInstanceStatus.READY, new Date(2012, 1, 1, 10, 10, 10, 0), function (error1) {
|
||||
assert.equal(error1, null);
|
||||
|
||||
assert.equal(writtenData, '<?xml version="1.0" encoding="utf-8" standalone="yes"?><CurrentState><StatusLease ClientId="' + azure.RoleEnvironment.clientId + '"><Acquire><Expiration>Wed Feb 01 2012 12:10:10 GMT-0800 (Pacific Standard Time)</Expiration><Incarnation>1</Incarnation><Status>started</Status></Acquire></StatusLease></CurrentState>');
|
||||
assert.equal(writtenData, '<?xml version="1.0" encoding="utf-8" standalone="yes"?><CurrentState><StatusLease ClientId="' + azure.RoleEnvironment.clientId + '"><Acquire><Incarnation>1</Incarnation><Status>Started</Status><StatusDetail>Started</StatusDetail><Expiration>2012-02-01T18:10:10.000Z</Expiration></Acquire></StatusLease></CurrentState>');
|
||||
|
||||
azure.RoleEnvironment.setStatus(ServiceRuntimeConstants.RoleInstanceStatus.BUSY, new Date(2012, 1, 1, 10, 10, 10, 0), function (error2) {
|
||||
assert.equal(error2, null);
|
||||
|
||||
assert.equal(writtenData, '<?xml version="1.0" encoding="utf-8" standalone="yes"?><CurrentState><StatusLease ClientId="' + azure.RoleEnvironment.clientId + '"><Acquire><Expiration>Wed Feb 01 2012 10:10:10 GMT-0800 (Pacific Standard Time)</Expiration><Incarnation>1</Incarnation><Status>busy</Status></Acquire></StatusLease></CurrentState>');
|
||||
|
||||
runtimeKernel.namedPipeInputChannel.readData = originalNamedPipeInputChannelReadData;
|
||||
runtimeKernel.fileInputChannel.readData = originalFileInputChannelReadData;
|
||||
runtimeKernel.protocol1RuntimeGoalStateClient.currentGoalState = null;
|
||||
runtimeKernel.protocol1RuntimeGoalStateClient.currentEnvironmentData = null;
|
||||
runtimeKernel.namedPipeOutputChannel.writeOutputChannel = originalNamedPipeOutputChannelWriteOutputChannel;
|
||||
assert.equal(writtenData, '<?xml version="1.0" encoding="utf-8" standalone="yes"?><CurrentState><StatusLease ClientId="' + azure.RoleEnvironment.clientId + '"><Acquire><Incarnation>1</Incarnation><Status>Busy</Status><StatusDetail>Busy</StatusDetail><Expiration>2012-02-01T18:10:10.000Z</Expiration></Acquire></StatusLease></CurrentState>');
|
||||
|
||||
done();
|
||||
});
|
||||
|
|
|
@ -23,7 +23,7 @@ var RuntimeVersionManager = require('../../lib/serviceruntime/runtimeversionmana
|
|||
suite('runtimeversionmanager-tests', function () {
|
||||
test('GetRuntimeClient', function (done) {
|
||||
var inputChannel = new NamedPipeInputChannel();
|
||||
inputChannel.readData = function (name, callback) {
|
||||
inputChannel._readData = function (name, callback) {
|
||||
callback(undefined,
|
||||
"<?xml version=\"1.0\" encoding=\"utf-8\"?>" +
|
||||
"<RuntimeServerDiscovery xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"" +
|
||||
|
|
|
@ -21,7 +21,7 @@ var RuntimeVersionProtocolClient = require('../../lib/serviceruntime/runtimevers
|
|||
suite('runtimeversionprotocolclient-tests', function () {
|
||||
test('GetVersionMapSingle', function (done) {
|
||||
var inputChannel = new NamedPipeInputChannel();
|
||||
inputChannel.readData = function (name, callback) {
|
||||
inputChannel._readData = function (name, callback) {
|
||||
callback(undefined,
|
||||
"<?xml version=\"1.0\" encoding=\"utf-8\"?>" +
|
||||
"<RuntimeServerDiscovery xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"" +
|
||||
|
@ -44,7 +44,7 @@ suite('runtimeversionprotocolclient-tests', function () {
|
|||
|
||||
test('GetVersionMapArray', function (done) {
|
||||
var inputChannel = new NamedPipeInputChannel();
|
||||
inputChannel.readData = function (name, callback) {
|
||||
inputChannel._readData = function (name, callback) {
|
||||
callback(undefined,
|
||||
"<?xml version=\"1.0\" encoding=\"utf-8\"?>" +
|
||||
"<RuntimeServerDiscovery xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"" +
|
||||
|
|
|
@ -1576,23 +1576,32 @@ suite('servicebusservice-tests', function () {
|
|||
});
|
||||
|
||||
test('TimeoutWorks', function (done) {
|
||||
var topicName = testutil.generateId(topicNamesPrefix, topicNames);
|
||||
var queueName = testutil.generateId(queueNamesPrefix, queueNames);
|
||||
var customTimeoutInternalInS = 5;
|
||||
|
||||
var buildRequestOptionsFunction = serviceBusService._buildRequestOptions.bind(serviceBusService);
|
||||
serviceBusService._buildRequestOptions = function (webResource, options, callback) {
|
||||
buildRequestOptionsFunction(webResource, options, function (error, requestOptions) {
|
||||
assert.equal(webResource._queryString[QueryStringConstants.TIMEOUT], customTimeoutInternalInS);
|
||||
serviceBusService.createQueue(queueName, function (createQueueError) {
|
||||
assert.equal(createQueueError, null);
|
||||
|
||||
callback(error, requestOptions);
|
||||
serviceBusService.sendQueueMessage(queueName, 'hi there', function (sendMessageError) {
|
||||
assert.equal(sendMessageError, null);
|
||||
|
||||
var buildRequestOptionsFunction = serviceBusService._buildRequestOptions.bind(serviceBusService);
|
||||
serviceBusService._buildRequestOptions = function (webResource, options, callback) {
|
||||
buildRequestOptionsFunction(webResource, options, function (error, requestOptions) {
|
||||
assert.equal(webResource._queryString[QueryStringConstants.TIMEOUT]['value'], customTimeoutInternalInS);
|
||||
|
||||
callback(error, requestOptions);
|
||||
});
|
||||
};
|
||||
|
||||
serviceBusService.receiveQueueMessage(queueName, { timeoutIntervalInS: customTimeoutInternalInS }, function (receiveMessageError) {
|
||||
assert.equal(receiveMessageError, null);
|
||||
|
||||
serviceBusService._buildRequestOptions = buildRequestOptionsFunction;
|
||||
|
||||
done();
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
serviceBusService.createTopic(topicName, { timeoutIntervalInS: customTimeoutInternalInS }, function (createError) {
|
||||
assert.equal(createError, null);
|
||||
|
||||
serviceBusService._buildRequestOptions = buildRequestOptionsFunction;
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
Загрузка…
Ссылка в новой задаче