public final class RoleEnvironment extends Object
| Modifier and Type | Method and Description |
|---|---|
static void |
addRoleEnvironmentChangedListener(RoleEnvironmentChangedListener listener)
Adds an event listener for the
Changed event, which occurs
after a configuration change has been applied to a role instance. |
static void |
addRoleEnvironmentChangingListener(RoleEnvironmentChangingListener listener)
Adds an event listener for the
Changing event, which occurs
before a change to the service configuration is applied to the running
instances of the role. |
static void |
addRoleEnvironmentStoppingListener(RoleEnvironmentStoppingListener listener)
Adds an event listener for the
Stopping event, which occurs
wheen the role is stopping. |
static void |
clearStatus()
Clears the status of the role instance.
|
static Map<String,String> |
getConfigurationSettings()
Retrieves the settings in the service configuration file.
|
static RoleInstance |
getCurrentRoleInstance()
Returns a
RoleInstance object that represents the role instance
in which this code is currently executing. |
static String |
getDeploymentId()
Returns the deployment ID that uniquely identifies the deployment in
which this role instance is running.
|
static Map<String,LocalResource> |
getLocalResources()
Retrieves the set of named local storage resources.
|
static Map<String,Role> |
getRoles()
Returns the set of
Role objects defined for your service. |
static boolean |
isAvailable()
Indicates whether the role instance is running in the Windows Azure
environment.
|
static boolean |
isEmulated()
Indicates whether the role instance is running in the development fabric.
|
static void |
removeRoleEnvironmentChangedListener(RoleEnvironmentChangedListener listener)
Removes an event listener for the
Changed event. |
static void |
removeRoleEnvironmentChangingListener(RoleEnvironmentChangingListener listener)
Removes an event listener for the
Changing event. |
static void |
removeRoleEnvironmentStoppingListener(RoleEnvironmentStoppingListener listener)
Removes an event listener for the
Stopping event. |
static void |
requestRecycle()
Requests that the current role instance be stopped and restarted.
|
static void |
setStatus(RoleInstanceStatus status,
Date expiration_utc)
Sets the status of the role instance.
|
public static RoleInstance getCurrentRoleInstance()
RoleInstance object that represents the role instance
in which this code is currently executing.RoleInstance object that represents the role
instance in which this code is currently executing.public static String getDeploymentId()
String object that represents the deployment ID.public static boolean isAvailable()
true if this instance is running in the development
fabric or in the Windows Azure environment in the cloud;
otherwise, false.public static boolean isEmulated()
true if this instance is running in the development
fabric; otherwise, false.public static Map<String,Role> getRoles()
Role objects defined for your service.
Roles are defined in the service definition file.
java.util.Map object containing the set of Role objects that represent the roles
defined for your
service.public static Map<String,String> getConfigurationSettings()
A role's configuration settings are defined in the service definition file. Values for configuration settings are set in the service configuration file.
java.util.Map object containing the String objects that represent the
configuration
settings.public static Map<String,LocalResource> getLocalResources()
java.util.Map object containing the String objects that represent the local
storage
resources.public static void requestRecycle()
Before the role instance is recycled, the Windows Azure load balancer takes the role instance out of rotation.
This ensures that no new requests are routed to the instance while it is restarting.
A call to RequestRecycle initiates the normal shutdown cycle. Windows Azure raises the
Stopping event and calls the OnStop method so that you can run the necessary code to
prepare the instance to be recycled.
public static void setStatus(RoleInstanceStatus status, Date expiration_utc)
An instance may indicate that it is in one of two states: Ready or Busy. If an instance's state is Ready, it is prepared to receive requests from the load balancer. If the instance's state is Busy, it will not receive requests from the load balancer.
status - A RoleInstanceStatus value that indicates whether the
instance is ready or busy.expiration_utc - A java.util.Date value that specifies the
expiration date and time of the status.public static void clearStatus()
An instance may indicate that it has completed communicating status by calling this method.
public static void addRoleEnvironmentChangedListener(RoleEnvironmentChangedListener listener)
Changed event, which occurs
after a configuration change has been applied to a role instance.
A Changed event is encapsulated in a RoleEnvironmentChangedEvent object.
listener - A RoleEnvironmentChangedListener object that
represents the event listener to add.removeRoleEnvironmentChangedListener(com.microsoft.windowsazure.serviceruntime.RoleEnvironmentChangedListener)public static void removeRoleEnvironmentChangedListener(RoleEnvironmentChangedListener listener)
Changed event.listener - A RoleEnvironmentChangedListener object that
represents the event listener to remove.addRoleEnvironmentChangedListener(com.microsoft.windowsazure.serviceruntime.RoleEnvironmentChangedListener)public static void addRoleEnvironmentChangingListener(RoleEnvironmentChangingListener listener)
Changing event, which occurs
before a change to the service configuration is applied to the running
instances of the role.
Service configuration changes are applied on-the-fly to running role instances. Configuration changes include changes to the service configuration changes and changes to the number of instances in the service.
This event occurs after the new configuration file has been submitted to Windows Azure but before the changes have been applied to each running role instance. This event can be cancelled for a given instance to prevent the configuration change.
Note that cancelling this event causes the instance to be automatically recycled. When the instance is recycled, the configuration change is applied when it restarts.
A Changing event is encapsulated in a RoleEnvironmentChangingEvent object.
listener - A RoleEnvironmentChangingListener object that
represents the event listener to add.removeRoleEnvironmentChangingListener(com.microsoft.windowsazure.serviceruntime.RoleEnvironmentChangingListener)public static void removeRoleEnvironmentChangingListener(RoleEnvironmentChangingListener listener)
Changing event.listener - A RoleEnvironmentChangingListener object that
represents the event listener to remove.addRoleEnvironmentChangingListener(com.microsoft.windowsazure.serviceruntime.RoleEnvironmentChangingListener)public static void addRoleEnvironmentStoppingListener(RoleEnvironmentStoppingListener listener)
Stopping event, which occurs
wheen the role is stopping.listener - A RoleEnvironmentStoppingListener object that
represents the event listener to add.removeRoleEnvironmentStoppingListener(com.microsoft.windowsazure.serviceruntime.RoleEnvironmentStoppingListener)public static void removeRoleEnvironmentStoppingListener(RoleEnvironmentStoppingListener listener)
Stopping event.listener - A RoleEnvironmentStoppingListener object that
represents the event listener to remove.addRoleEnvironmentStoppingListener(com.microsoft.windowsazure.serviceruntime.RoleEnvironmentStoppingListener)/**
* Copyright 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.
*/