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