org.apache.ignite.internal.util.ipc.shmem

## Class IpcSharedMemoryServerEndpoint

- java.lang.Object
- - org.apache.ignite.internal.util.ipc.shmem.IpcSharedMemoryServerEndpoint

All Implemented Interfaces:
  Closeable, AutoCloseable, IpcServerEndpoint

    public class IpcSharedMemoryServerEndpoint
    extends Object
    implements IpcServerEndpoint

Server shared memory IPC endpoint.

### Field Summary

Fields
`static int` `DFLT_IPC_PORT` Default endpoint port number.
`static int` `DFLT_SPACE_SIZE` Default shared memory space in bytes.
`static String` `DFLT_TOKEN_DIR_PATH` Default token directory.
`static String` `OUT_OF_RESOURCES_MSG` IPC error message.
`static String` `TOKEN_FILE_NAME` Shared memory token file name prefix.

### Constructor Summary

Constructors
Constructor and Description
`IpcSharedMemoryServerEndpoint()` Use this constructor when dependencies could be injected with `GridResourceProcessor.injectGeneric(Object)`.
`IpcSharedMemoryServerEndpoint(IgniteLogger log, UUID locNodeId, String gridName)` Constructor to set dependencies explicitly.

### Method Summary

Methods
`IpcEndpoint` `accept()` Accepts client IPC connection.
`void` `close()` Closes server IPC.
`String` `getHost()` Gets host endpoint is bound to.
`int` `getPort()` Gets port endpoint is bound to.
`int` `getSize()` Gets size of shared memory spaces that are created by the endpoint.
`String` `getTokenDirectoryPath()` Gets token directory path.
`boolean` `isManagement()` Indicates if this endpoint is a management endpoint.
`void` `omitOutOfResourcesWarning(boolean omitOutOfResourcesWarn)`
`void` `setPort(int port)` Sets port endpoint will be bound to.
`void` `setSize(int size)` Sets size of shared memory spaces that are created by the endpoint.
`void` `setTokenDirectoryPath(String tokDirPath)` Sets token directory path.
`void` `setupConfiguration(Map<String,String> endpointCfg)` Sets configuration properties from the map.
`void` `start()` Starts configured endpoint implementation.
`String` `toString()`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

### Field Detail

#### OUT_OF_RESOURCES_MSG

    public static final String OUT_OF_RESOURCES_MSG

IPC error message.

See Also:
  Constant Field Values

#### DFLT_IPC_PORT

    public static final int DFLT_IPC_PORT

Default endpoint port number.

See Also:
  Constant Field Values

#### DFLT_SPACE_SIZE

    public static final int DFLT_SPACE_SIZE

Default shared memory space in bytes.

See Also:
  Constant Field Values

#### DFLT_TOKEN_DIR_PATH

    public static final String DFLT_TOKEN_DIR_PATH

Default token directory. Note that this path is relative to `IGNITE_HOME/work` folder if `IGNITE_HOME` system or environment variable specified, otherwise it is relative to `work` folder under system `java.io.tmpdir` folder.

See Also:
  `IgniteConfiguration.getWorkDirectory()`, Constant Field Values

#### TOKEN_FILE_NAME

    public static final String TOKEN_FILE_NAME

Shared memory token file name prefix. Token files are created and stored in the following manner: [tokDirPath]/[nodeId]-[current PID]/gg-shmem-space-[auto_idx]-[other_party_pid]-[size]

See Also:
  Constant Field Values

### Constructor Detail

#### IpcSharedMemoryServerEndpoint

    public IpcSharedMemoryServerEndpoint()

Use this constructor when dependencies could be injected with `GridResourceProcessor.injectGeneric(Object)`.

#### IpcSharedMemoryServerEndpoint

    public IpcSharedMemoryServerEndpoint(IgniteLogger log,
                                 UUID locNodeId,
                                 String gridName)

Constructor to set dependencies explicitly.

Parameters:
  `log` - Log.
  `locNodeId` - Node id.
  `gridName` - Grid name.

### Method Detail

#### omitOutOfResourcesWarning

    public void omitOutOfResourcesWarning(boolean omitOutOfResourcesWarn)

Parameters:
  `omitOutOfResourcesWarn` - If `true`, out of resources warning will not be printed by server.

#### start

    public void start()
               throws IgniteCheckedException

Starts configured endpoint implementation.

Specified by:
  `start` in interface `IpcServerEndpoint`
Throws:
  `IgniteCheckedException` - If failed to start server endpoint.

#### accept

    public IpcEndpoint accept()
                       throws IgniteCheckedException

Accepts client IPC connection. After client connection is accepted, it can be used for IPC. This method will block until client connects to IPC server endpoint.

Specified by:
  `accept` in interface `IpcServerEndpoint`
Returns:
  Accepted client connection.
Throws:
  `IgniteCheckedException` - If accept failed and the endpoint is not usable anymore.

#### getPort

    public int getPort()

Gets port endpoint is bound to. Endpoints who does not bind to any port should return -1.

Specified by:
  `getPort` in interface `IpcServerEndpoint`
Returns:
  Port number.

#### getHost

    @Nullable
    public String getHost()

Gets host endpoint is bound to. Endpoints who does not bind to any port should return `null`.

Specified by:
  `getHost` in interface `IpcServerEndpoint`
Returns:
  Host.

#### isManagement

    public boolean isManagement()

Indicates if this endpoint is a management endpoint.

Specified by:
  `isManagement` in interface `IpcServerEndpoint`
Returns:
  `false` as shared memory endpoints can not be used for management.

#### setPort

    public void setPort(int port)

Sets port endpoint will be bound to.

Parameters:
  `port` - Port number.

#### getTokenDirectoryPath

    public String getTokenDirectoryPath()

Gets token directory path.

Returns:
  Token directory path.

#### setTokenDirectoryPath

    public void setTokenDirectoryPath(String tokDirPath)

Sets token directory path.

Parameters:
  `tokDirPath` - Token directory path.

#### getSize

    public int getSize()

Gets size of shared memory spaces that are created by the endpoint.

Returns:
  Size of shared memory space.

#### setSize

    public void setSize(int size)

Sets size of shared memory spaces that are created by the endpoint.

Parameters:
  `size` - Size of shared memory space.

#### close

    public void close()

Closes server IPC. After IPC is closed, no further operations can be performed on this object.

Specified by:
  `close` in interface `Closeable`
Specified by:
  `close` in interface `AutoCloseable`
Specified by:
  `close` in interface `IpcServerEndpoint`

#### toString

    public String toString()

Overrides:
  `toString` in class `Object`

#### setupConfiguration

    public void setupConfiguration(Map<String,String> endpointCfg)
                            throws IgniteCheckedException

Sets configuration properties from the map.

Parameters:
  `endpointCfg` - Map of properties.
Throws:
  `IgniteCheckedException` - If invalid property name or value.

2015 Copyright © Apache Software Foundation

Follow @ApacheIgnite

Ignite Fabric | : ver. 1.5.0.final
Release Date | : December 29 2015