org.apache.ignite.internal

## Interface GridKernalGateway

All Known Implementing Classes:
  GridKernalGatewayImpl

    @GridToStringExclude
    public interface GridKernalGateway

This interface guards access to implementations of public methods that access kernal functionality from the following main API interfaces:

- `ClusterGroup`

Note that this kernal gateway should not be used to guard against method from the following non-rich interfaces since their implementations are already managed by their respective implementing classes:

- `Ignite`
- `ClusterNode`

Kernal gateway is also responsible for notifying various futures about the change in kernal state so that issued futures could properly interrupt themselves when kernal becomes unavailable while future is held externally by the user.

### Method Summary

Methods
`GridKernalState` `getState()` Gets current kernal state.
`GridFutureAdapter<?>` `onDisconnected()` Disconnected callback.
`void` `onReconnected()` Reconnected callback.
`void` `readLock()` Should be called on entering every kernal related call originated directly or indirectly via public API.
`void` `readLockAnyway()` Same as `readLock()` but doesn't throw IllegalStateException if grid stop.
`void` `readUnlock()` Should be called on leaving every kernal related call originated directly or indirectly via public API.
`void` `setState(GridKernalState state)` Sets kernal state.
`boolean` `tryWriteLock(long timeout)`
`String` `userStackTrace()` Gets user stack trace through the first call of grid public API.
`void` `writeLock()` This method waits for all current calls to exit and blocks any further `readLock()` calls until `writeUnlock()` method is called.
`void` `writeUnlock()` This method unblocks `writeLock()`.

### Method Detail

#### readLock

    void readLock()
                  throws IllegalStateException

Should be called on entering every kernal related call originated directly or indirectly via public API.

This method essentially acquires a read lock and multiple threads can enter the call without blocking.

Throws:
  `IllegalStateException` - Thrown in case when no kernal calls are allowed.
See Also:
  `readUnlock()`

#### readLockAnyway

    void readLockAnyway()

Same as `readLock()` but doesn't throw IllegalStateException if grid stop.

#### setState

    void setState(GridKernalState state)

Sets kernal state. Various kernal states drive the logic inside of the gateway.

Parameters:
  `state` - Kernal state to set.

#### getState

    GridKernalState getState()

Gets current kernal state.

Returns:
  Kernal state.

#### readUnlock

    void readUnlock()

Should be called on leaving every kernal related call originated directly or indirectly via public API.

This method essentially releases the internal read-lock acquired previously by `readLock()` method.

See Also:
  `readLock()`

#### writeLock

    void writeLock()

This method waits for all current calls to exit and blocks any further `readLock()` calls until `writeUnlock()` method is called.

This method essentially acquires the internal write lock.

#### writeUnlock

    void writeUnlock()

This method unblocks `writeLock()`.

This method essentially releases internal write lock previously acquired by `writeLock()` method.

#### userStackTrace

    String userStackTrace()

Gets user stack trace through the first call of grid public API.

Returns:
  User stack trace.

#### tryWriteLock

    boolean tryWriteLock(long timeout)
                         throws InterruptedException

Parameters:
  `timeout` - Timeout.
Returns:
  `True` if write lock has been acquired.
Throws:
  `InterruptedException` - If interrupted.

#### onDisconnected

    @Nullable
    GridFutureAdapter<?> onDisconnected()

Disconnected callback.

Returns:
  Reconnect future.

#### onReconnected

    void onReconnected()

Reconnected callback.

2015 Copyright © Apache Software Foundation

Follow @ApacheIgnite

Ignite Fabric | : ver. 1.4.0
Release Date | : September 24 2015