001//
002// NAME
003//    EngineServices.java
004//
005// COPYRIGHT
006//    Copyright 2007-2014 Cloud Software Group, Inc. ALL RIGHTS RESERVED.
007//    Cloud Software Group, Inc. Confidential Information
008//
009// HISTORY
010//    $Revision: 1.1.2.84 $ $Date: 2014/02/06 20:35:16 $
011//
012// WARNINGS
013//    THIS FILE IS GENERATED, DO NOT EDIT
014//
015
016package com.kabira.platform.swbuiltin;
017
018import java.util.*;
019import com.kabira.platform.annotation.*;
020
021
022/**
023<p>
024       Engine services
025<p>
026       Provides access to engine level services.
027                A transaction is required to access methods
028                in this class.
029
030
031*/
032
033public final class EngineServices extends java.lang.Object
034{
035        private static final String _RuntimeType = "swbuiltin::EngineServices";
036        /**
037        <p>
038       Throttle state
039
040        */
041        public enum ThrottleState
042        {
043                /**
044                
045                                Memory utilization below throttle level.  
046                                System not congested.
047                        
048                */
049                Clear,
050                /**
051                
052                                Memory utilization above throttle level.
053                                System is becoming congested.  Throttle
054                                operation will block for a period of time
055                                to allow congestion to clear.
056                        
057                */
058                Throttled,
059                /**
060                
061                                Memory utilization critical.  Application 
062                                should stop accepting incoming work and 
063                                attempt to free shared memory by processing
064                                in-flight work.  In general if a system
065                                ever hits Stall, shared memory size should
066                                be increased since this system is 
067                                misconfigured for the current load.
068                        
069                */
070                Stall;
071        
072                private static ThrottleState from_ordinal(int ordinal)
073                {
074                        return ThrottleState.class.getEnumConstants()[ordinal];
075                }
076        }
077
078        private EngineServices() { }
079
080
081        /**
082        <p>
083       Determine if engine is shutting down
084@return                true if engine is exiting,
085                false otherwise
086
087@deprecated         This method is deprecated, please use
088        either a ShutdownHook
089        (see java.lang.Runtime.addShutdownHook()
090        or a component notifier
091        (see com.kabira.platform.component).
092
093
094        */
095
096        @Deprecated
097        public static final native boolean isStopping();
098
099
100        /**
101        <p>
102       Schedule the current engine to exit
103@param returnCode        Return value for engine
104@deprecated         This method is deprecated, please use
105        System.stop(0);
106
107
108        */
109
110        @Deprecated
111        public static final native void stop(
112                        final int returnCode);
113
114
115        /**
116        <p>
117       Get the name of this engine.
118@return                The name of this engine.
119@deprecated         This method is deprecated, please use
120        the system property:
121        <p>
122System.getProperty("com.kabira.platform.jvm.name");
123
124
125        */
126
127        @Deprecated
128        public static final native String getEngineName();
129
130
131        /**
132        <p>
133       Node name for shared memory
134@return                The node name of the shared memory
135<p>
136        Get the node name associated with the
137        shared memory that this engine is running
138        against.
139
140@deprecated         This method is deprecated, please use
141        the system property:
142        <p>
143System.getProperty("com.kabira.platform.node.name");
144
145
146        */
147
148        @Deprecated
149        public static final native String getNodeName();
150
151
152        /**
153        <p>
154       Access engine instance
155@return                The engine instance
156<p>
157        Get the engine instance for the engine.
158        All engines on a node have a unique
159        engine instance number.
160
161@deprecated 
162
163        */
164
165        @Deprecated
166        public static final native int getEngineInstance();
167
168
169        /**
170        <p>
171       Throttle incoming work if necessary
172@return                Current throttle state
173<p>
174        If the percentage of shared memory in use
175        exceeds the configured throttle threshold 
176        (50% by default), the throttle operation will
177        block a little to slow down incoming work. 
178        Throttled is returned from the operation
179        when in this state.  When shared memory 
180        utilization becomes critical (80% by default)
181        Stall is returned from the throttle operation
182        after blocking for a longer period of time.
183        The application should stop accepting
184        incoming work at this point and attempt
185        to complete processing already accepted
186        work to clear shared memory space.
187
188
189        */
190
191        public static final native com.kabira.platform.swbuiltin.EngineServices.ThrottleState throttle();
192
193
194        /**
195        <p>
196       Check the state of throttling
197@return                Current throttle state
198<p>
199       Get the current throttle state.
200
201        */
202
203        public static final native com.kabira.platform.swbuiltin.EngineServices.ThrottleState getThrottleState();
204
205}