--- a/web/lib/Zend/Service/WindowsAzure/Diagnostics/Manager.php Thu Mar 21 17:31:31 2013 +0100
+++ b/web/lib/Zend/Service/WindowsAzure/Diagnostics/Manager.php Thu Mar 21 19:50:53 2013 +0100
@@ -15,22 +15,12 @@
* @category Zend
* @package Zend_Service_WindowsAzure
* @subpackage Diagnostics
- * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
+ * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/
/**
- * @see Zend_Service_WindowsAzure_Storage_Blob
- */
-require_once 'Zend/Service/WindowsAzure/Storage/Blob.php';
-
-/**
- * @see Zend_Service_WindowsAzure_Diagnostics_Exception
- */
-require_once 'Zend/Service/WindowsAzure/Diagnostics/Exception.php';
-
-/**
* @see Zend_Service_WindowsAzure_Diagnostics_ConfigurationInstance
*/
require_once 'Zend/Service/WindowsAzure/Diagnostics/ConfigurationInstance.php';
@@ -39,7 +29,7 @@
* @category Zend
* @package Zend_Service_WindowsAzure
* @subpackage Diagnostics
- * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
+ * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Service_WindowsAzure_Diagnostics_Manager
@@ -101,7 +91,8 @@
*/
public function configurationForRoleInstanceExists($roleInstance = null)
{
- if ($roleInstance === null) {
+ if (is_null($roleInstance)) {
+ require_once 'Zend/Service/WindowsAzure/Diagnostics/Exception.php';
throw new Zend_Service_WindowsAzure_Diagnostics_Exception('Role instance should be specified. Try reading $_SERVER[\'RdRoleId\'] for this information if the application is hosted on Windows Azure Fabric or Development Fabric.');
}
@@ -117,10 +108,11 @@
public function configurationForCurrentRoleInstanceExists()
{
if (!isset($_SERVER['RdRoleId'])) {
+ require_once 'Zend/Service/WindowsAzure/Diagnostics/Exception.php';
throw new Zend_Service_WindowsAzure_Diagnostics_Exception('Server variable \'RdRoleId\' is unknown. Please verify the application is running in Development Fabric or Windows Azure Fabric.');
}
- return $this->_blobStorageClient->blobExists($this->_controlContainer, $_SERVER['RdRoleId']);
+ return $this->_blobStorageClient->blobExists($this->_controlContainer, $this->_getCurrentRoleInstanceId());
}
/**
@@ -132,9 +124,41 @@
public function getConfigurationForCurrentRoleInstance()
{
if (!isset($_SERVER['RdRoleId'])) {
+ require_once 'Zend/Service/WindowsAzure/Diagnostics/Exception.php';
+ throw new Zend_Service_WindowsAzure_Diagnostics_Exception('Server variable \'RdRoleId\' is unknown. Please verify the application is running in Development Fabric or Windows Azure Fabric.');
+ }
+ return $this->getConfigurationForRoleInstance($this->_getCurrentRoleInstanceId());
+ }
+
+ /**
+ * Get the current role instance ID. Only works on Development Fabric or Windows Azure Fabric.
+ *
+ * @return string
+ * @throws Zend_Service_WindowsAzure_Diagnostics_Exception
+ */
+ protected function _getCurrentRoleInstanceId()
+ {
+ if (!isset($_SERVER['RdRoleId'])) {
+ require_once 'Zend/Service/WindowsAzure/Diagnostics/Exception.php';
throw new Zend_Service_WindowsAzure_Diagnostics_Exception('Server variable \'RdRoleId\' is unknown. Please verify the application is running in Development Fabric or Windows Azure Fabric.');
}
- return $this->getConfigurationForRoleInstance($_SERVER['RdRoleId']);
+
+ if (strpos($_SERVER['RdRoleId'], 'deployment(') === false) {
+ return $_SERVER['RdRoleId'];
+ } else {
+ $roleIdParts = explode('.', $_SERVER['RdRoleId']);
+ return $roleIdParts[0] . '/' . $roleIdParts[2] . '/' . $_SERVER['RdRoleId'];
+ }
+
+ if (!isset($_SERVER['RoleDeploymentID']) && !isset($_SERVER['RoleInstanceID']) && !isset($_SERVER['RoleName'])) {
+ throw new Exception('Server variables \'RoleDeploymentID\', \'RoleInstanceID\' and \'RoleName\' are unknown. Please verify the application is running in Development Fabric or Windows Azure Fabric.');
+ }
+
+ if (strpos($_SERVER['RdRoleId'], 'deployment(') === false) {
+ return $_SERVER['RdRoleId'];
+ } else {
+ return $_SERVER['RoleDeploymentID'] . '/' . $_SERVER['RoleInstanceID'] . '/' . $_SERVER['RoleName'];
+ }
}
/**
@@ -146,9 +170,11 @@
public function setConfigurationForCurrentRoleInstance(Zend_Service_WindowsAzure_Diagnostics_ConfigurationInstance $configuration)
{
if (!isset($_SERVER['RdRoleId'])) {
+ require_once 'Zend/Service/WindowsAzure/Diagnostics/Exception.php';
throw new Zend_Service_WindowsAzure_Diagnostics_Exception('Server variable \'RdRoleId\' is unknown. Please verify the application is running in Development Fabric or Windows Azure Fabric.');
}
- $this->setConfigurationForRoleInstance($_SERVER['RdRoleId'], $configuration);
+
+ $this->setConfigurationForRoleInstance($this->_getCurrentRoleInstanceId(), $configuration);
}
/**
@@ -160,10 +186,13 @@
*/
public function getConfigurationForRoleInstance($roleInstance = null)
{
- if ($roleInstance === null) {
+ if (is_null($roleInstance)) {
+ require_once 'Zend/Service/WindowsAzure/Diagnostics/Exception.php';
throw new Zend_Service_WindowsAzure_Diagnostics_Exception('Role instance should be specified. Try reading $_SERVER[\'RdRoleId\'] for this information if the application is hosted on Windows Azure Fabric or Development Fabric.');
}
+
+
if ($this->_blobStorageClient->blobExists($this->_controlContainer, $roleInstance)) {
$configurationInstance = new Zend_Service_WindowsAzure_Diagnostics_ConfigurationInstance();
$configurationInstance->loadXml( $this->_blobStorageClient->getBlobData($this->_controlContainer, $roleInstance) );
@@ -182,7 +211,8 @@
*/
public function setConfigurationForRoleInstance($roleInstance = null, Zend_Service_WindowsAzure_Diagnostics_ConfigurationInstance $configuration)
{
- if ($roleInstance === null) {
+ if (is_null($roleInstance)) {
+ require_once 'Zend/Service/WindowsAzure/Diagnostics/Exception.php';
throw new Zend_Service_WindowsAzure_Diagnostics_Exception('Role instance should be specified. Try reading $_SERVER[\'RdRoleId\'] for this information if the application is hosted on Windows Azure Fabric or Development Fabric.');
}