org.apache.mina.core.service.SimpleIoProcessorPool Java Examples

The following examples show how to use org.apache.mina.core.service.SimpleIoProcessorPool. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: Activator.java    From neoscada with Eclipse Public License 1.0 6 votes vote down vote up
@Override
public void start ( final BundleContext context ) throws Exception
{
    Activator.instance = this;

    if ( !Boolean.getBoolean ( "org.eclipse.scada.core.client.ngp.disableSharedProcessor" ) )
    {
        this.processor = new SimpleIoProcessorPool<> ( NioProcessor.class );
    }
    this.factory = new DriverFactoryImpl ( this.processor );

    final Dictionary<String, String> properties = new Hashtable<String, String> ();
    properties.put ( org.eclipse.scada.core.client.DriverFactory.INTERFACE_NAME, "ae" );
    properties.put ( org.eclipse.scada.core.client.DriverFactory.DRIVER_NAME, "ngp" );
    properties.put ( Constants.SERVICE_DESCRIPTION, "Eclipse SCADA AE NGP Adapter" );
    properties.put ( Constants.SERVICE_VENDOR, "Eclipse SCADA Project" );
    this.handle = context.registerService ( org.eclipse.scada.core.client.DriverFactory.class, this.factory, properties );
}
 
Example #2
Source File: SlaveHost.java    From neoscada with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Create a new slave host and bind to a single TCP port
 *
 * @param options
 *            optional protocol options
 * @param port
 *            the TCP port to bind to
 */
public SlaveHost ( final ProtocolOptions options, final int port ) throws IOException
{
    this.options = makeOptions ( options );

    this.connector = null;

    this.processor = new SimpleIoProcessorPool<> ( NioProcessor.class );
    final SocketAcceptor nioAcceptor = new NioSocketAcceptor ( this.processor );
    this.acceptor = nioAcceptor;

    nioAcceptor.setReuseAddress ( true );
    nioAcceptor.setBacklog ( 5 );

    this.disposeAcceptor = true;

    setupAcceptor ( null );

    this.acceptor.bind ( new InetSocketAddress ( port ) );
}
 
Example #3
Source File: Activator.java    From neoscada with Eclipse Public License 1.0 6 votes vote down vote up
@Override
public void start ( final BundleContext context ) throws Exception
{
    Activator.instance = this;

    if ( !Boolean.getBoolean ( "org.eclipse.scada.core.client.ngp.disableSharedProcessor" ) )
    {
        this.processor = new SimpleIoProcessorPool<> ( NioProcessor.class );
    }
    this.factory = new DriverFactoryImpl ( this.processor );

    final Dictionary<String, String> properties = new Hashtable<String, String> ();
    properties.put ( org.eclipse.scada.core.client.DriverFactory.INTERFACE_NAME, "da" );
    properties.put ( org.eclipse.scada.core.client.DriverFactory.DRIVER_NAME, "ngp" );
    properties.put ( Constants.SERVICE_DESCRIPTION, "Eclipse SCADA DA NGP Adapter" );
    properties.put ( Constants.SERVICE_VENDOR, "Eclipse SCADA Project" );
    this.handle = context.registerService ( org.eclipse.scada.core.client.DriverFactory.class, this.factory, properties );
}
 
Example #4
Source File: Activator.java    From neoscada with Eclipse Public License 1.0 6 votes vote down vote up
@Override
public void start ( final BundleContext context ) throws Exception
{
    Activator.instance = this;

    if ( !Boolean.getBoolean ( "org.eclipse.scada.core.client.ngp.disableSharedProcessor" ) )
    {
        this.processor = new SimpleIoProcessorPool<> ( NioProcessor.class );
    }
    this.factory = new DriverFactoryImpl ( this.processor );

    final Dictionary<String, String> properties = new Hashtable<String, String> ();
    properties.put ( org.eclipse.scada.core.client.DriverFactory.INTERFACE_NAME, "hd" );
    properties.put ( org.eclipse.scada.core.client.DriverFactory.DRIVER_NAME, "ngp" );
    properties.put ( Constants.SERVICE_DESCRIPTION, "Eclipse SCADA HD NGP Adapter" );
    properties.put ( Constants.SERVICE_VENDOR, "Eclipse SCADA Project" );
    this.handle = context.registerService ( org.eclipse.scada.core.client.DriverFactory.class, this.factory, properties );
}
 
Example #5
Source File: Activator.java    From neoscada with Eclipse Public License 1.0 6 votes vote down vote up
@Override
public void start ( final BundleContext context ) throws Exception
{
    Activator.instance = this;

    if ( !Boolean.getBoolean ( "org.eclipse.scada.core.client.ngp.disableSharedProcessor" ) )
    {
        this.processor = new SimpleIoProcessorPool<> ( NioProcessor.class );
    }
    this.factory = new DriverFactoryImpl ( this.processor );

    final Dictionary<String, String> properties = new Hashtable<String, String> ();
    properties.put ( org.eclipse.scada.core.client.DriverFactory.INTERFACE_NAME, "ca" );
    properties.put ( org.eclipse.scada.core.client.DriverFactory.DRIVER_NAME, "ngp" );
    properties.put ( Constants.SERVICE_DESCRIPTION, "Eclipse SCADA CA NGP Adapter" );
    properties.put ( Constants.SERVICE_VENDOR, "Eclipse SCADA Project" );
    this.handle = context.registerService ( org.eclipse.scada.core.client.DriverFactory.class, this.factory, properties );

}
 
Example #6
Source File: WrapperNioSocketAcceptor.java    From sailfish-core with Apache License 2.0 5 votes vote down vote up
public WrapperNioSocketAcceptor(ITaskExecutor taskExecutor) {
       this.taskExecutor = taskExecutor;
       if (taskExecutor != null) {
           Executor executor = taskExecutor.getThreadPool();
		this.ioProcessor = new SimpleIoProcessorPool<NioSession>(NioProcessor.class, executor);
		this.nioSocketAcceptor = new NioSocketAcceptor(executor, ioProcessor);
	} else {
		this.ioProcessor = null;
		this.nioSocketAcceptor = new NioSocketAcceptor();
	}
}
 
Example #7
Source File: ExporterFactoryImpl.java    From neoscada with Eclipse Public License 1.0 5 votes vote down vote up
public ExporterFactoryImpl ()
{
    super ( FrameworkUtil.getBundle ( ExporterFactoryImpl.class ).getBundleContext () );

    this.executor = new ScheduledExportedExecutorService ( FrameworkUtil.getBundle ( ExporterFactoryImpl.class ).getSymbolicName (), 1 );

    this.processor = new SimpleIoProcessorPool<> ( NioProcessor.class );

    this.hiveSource = new ServiceListenerHiveSource ( FrameworkUtil.getBundle ( ExporterFactoryImpl.class ).getBundleContext (), this.executor );
    this.hiveSource.open ();

    this.itemPool = new ObjectPoolImpl<> ();
    this.itemPoolHandler = ObjectPoolHelper.registerObjectPool ( FrameworkUtil.getBundle ( ExporterFactoryImpl.class ).getBundleContext (), this.itemPool, DataItem.class );
}
 
Example #8
Source File: SlaveHost.java    From neoscada with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Create a new slave host and bind to a list of socket addresses
 *
 * @param options
 *            optional protocol options
 * @param socketAddresses
 *            a list of socket addresses to bind to.
 *            <em>Note:<em> these socket addresses must be addresses of
 *            local interfaces, not remote addresses.
 */
public SlaveHost ( final ProtocolOptions options, final SlaveHostCustomizer slaveHostCustomizer, final SocketAddress... socketAddresses ) throws IOException
{
    this.options = makeOptions ( options );

    this.connector = null;

    this.processor = new SimpleIoProcessorPool<> ( NioProcessor.class );
    this.acceptor = new NioSocketAcceptor ( this.processor );
    this.disposeAcceptor = true;

    setupAcceptor ( slaveHostCustomizer );

    this.acceptor.bind ( socketAddresses );
}
 
Example #9
Source File: WrapperNioSocketConnector.java    From sailfish-core with Apache License 2.0 5 votes vote down vote up
public WrapperNioSocketConnector(ITaskExecutor taskExecutor) {
       this.taskExecutor = taskExecutor;
	if (taskExecutor != null) {
           Executor executor = taskExecutor.getThreadPool();
		this.ioProcessor = new SimpleIoProcessorPool<NioSession>(NioProcessor.class, executor);
		this.nioSocketConnector = new NioSocketConnector(executor, ioProcessor);
	} else {
		this.ioProcessor = null;
		this.nioSocketConnector = new NioSocketConnector();
	}
}
 
Example #10
Source File: StaticModbusExport.java    From neoscada with Eclipse Public License 1.0 4 votes vote down vote up
/**
 * Build a new modbus export instance based on the current builder state
 * <br/>
 * <em>Note:</em> The call is responsible for disposing the created
 * instance using {@link ModbusExport#dispose()}.
 *
 * @return a newly created modbus instance
 */
public ModbusExport build ()
{
    final ScheduledExecutorService executor;
    if ( this.threadFactory == null )
    {
        executor = ScheduledExportedExecutorService.newSingleThreadExportedScheduledExecutor ( "StaticModubusExporter/" + COUNTER.incrementAndGet () );
    }
    else
    {
        executor = new ScheduledExportedExecutorService ( "StaticModubusExporter/" + COUNTER.incrementAndGet (), 1, this.threadFactory );
    }

    boolean disposeProcessor;
    final IoProcessor<NioSession> processor;
    if ( this.processor == null )
    {
        processor = new SimpleIoProcessorPool<> ( NioProcessor.class );
        disposeProcessor = true;
    }
    else
    {
        processor = this.processor;
        disposeProcessor = false;
    }

    final StaticModbusExport result = new StaticModbusExport ( executor, processor, this.hiveSource, null, disposeProcessor );

    try
    {
        result.setProperties ( this.hiveProperies );

        result.setReadTimeout ( this.readTimeout );
        result.setSlaveId ( this.slaveId );
        result.setPort ( this.port );

        // we must call this after "setProperties", since this method creates the block
        result.setBlockConfiguration ( this.definitions );

        return result;
    }
    catch ( final Throwable e )
    {
        result.dispose ();
        throw new RuntimeException ( "Failed to start exporter", e );
    }
}
 
Example #11
Source File: AbstractPollingIoAcceptor.java    From neoscada with Eclipse Public License 1.0 2 votes vote down vote up
/**
 * Constructor for {@link AbstractPollingIoAcceptor}. You need to provide a default
 * session configuration, a class of {@link IoProcessor} which will be instantiated in a
 * {@link SimpleIoProcessorPool} for using multiple thread for better scaling in multiprocessor
 * systems.
 * 
 * @see SimpleIoProcessorPool
 * 
 * @param sessionConfig
 *            the default configuration for the managed {@link IoSession}
 * @param processorClass a {@link Class} of {@link IoProcessor} for the associated {@link IoSession}
 *            type.
 * @param processorCount the amount of processor to instantiate for the pool
 */
protected AbstractPollingIoAcceptor(IoSessionConfig sessionConfig, Class<? extends IoProcessor<S>> processorClass,
        int processorCount) {
    this(sessionConfig, null, new SimpleIoProcessorPool<S>(processorClass, processorCount), true);
}
 
Example #12
Source File: AbstractPollingIoAcceptor.java    From neoscada with Eclipse Public License 1.0 2 votes vote down vote up
/**
 * Constructor for {@link AbstractPollingIoAcceptor}. You need to provide a default
 * session configuration, a class of {@link IoProcessor} which will be instantiated in a
 * {@link SimpleIoProcessorPool} for better scaling in multiprocessor systems. The default
 * pool size will be used.
 * 
 * @see SimpleIoProcessorPool
 * 
 * @param sessionConfig
 *            the default configuration for the managed {@link IoSession}
 * @param processorClass a {@link Class} of {@link IoProcessor} for the associated {@link IoSession}
 *            type.
 */
protected AbstractPollingIoAcceptor(IoSessionConfig sessionConfig, Class<? extends IoProcessor<S>> processorClass) {
    this(sessionConfig, null, new SimpleIoProcessorPool<S>(processorClass), true);
}
 
Example #13
Source File: AbstractPollingIoConnector.java    From neoscada with Eclipse Public License 1.0 2 votes vote down vote up
/**
 * Constructor for {@link AbstractPollingIoConnector}. You need to provide a default
 * session configuration, a class of {@link IoProcessor} which will be instantiated in a
 * {@link SimpleIoProcessorPool} for using multiple thread for better scaling in multiprocessor
 * systems.
 * 
 * @see SimpleIoProcessorPool
 * 
 * @param sessionConfig
 *            the default configuration for the managed {@link IoSession}
 * @param processorClass a {@link Class} of {@link IoProcessor} for the associated {@link IoSession}
 *            type.
 * @param processorCount the amount of processor to instantiate for the pool
 */
protected AbstractPollingIoConnector(IoSessionConfig sessionConfig, Class<? extends IoProcessor<T>> processorClass,
        int processorCount) {
    this(sessionConfig, null, new SimpleIoProcessorPool<T>(processorClass, processorCount), true);
}
 
Example #14
Source File: AbstractPollingIoConnector.java    From neoscada with Eclipse Public License 1.0 2 votes vote down vote up
/**
 * Constructor for {@link AbstractPollingIoConnector}. You need to provide a default
 * session configuration, a class of {@link IoProcessor} which will be instantiated in a
 * {@link SimpleIoProcessorPool} for better scaling in multiprocessor systems. The default
 * pool size will be used.
 * 
 * @see SimpleIoProcessorPool
 * 
 * @param sessionConfig
 *            the default configuration for the managed {@link IoSession}
 * @param processorClass a {@link Class} of {@link IoProcessor} for the associated {@link IoSession}
 *            type.
 */
protected AbstractPollingIoConnector(IoSessionConfig sessionConfig, Class<? extends IoProcessor<T>> processorClass) {
    this(sessionConfig, null, new SimpleIoProcessorPool<T>(processorClass), true);
}
 
Example #15
Source File: NioSocketConnector.java    From jane with GNU Lesser General Public License v3.0 2 votes vote down vote up
/**
 * You need to provide a default session configuration, a class of {@link IoProcessor}
 * which will be instantiated in a {@link SimpleIoProcessorPool} for better scaling in multiprocessor systems.
 * The default pool size will be used.
 */
public NioSocketConnector() {
	super(new SimpleIoProcessorPool());
}
 
Example #16
Source File: NioSocketConnector.java    From jane with GNU Lesser General Public License v3.0 2 votes vote down vote up
/**
 * You need to provide a default session configuration, a class of {@link IoProcessor}
 * which will be instantiated in a {@link SimpleIoProcessorPool} for using multiple thread
 * for better scaling in multiprocessor systems.
 *
 * @param processorCount the number of processor to create and place in a {@link SimpleIoProcessorPool}
 */
public NioSocketConnector(int processorCount) {
	super(new SimpleIoProcessorPool(processorCount));
}
 
Example #17
Source File: NioSocketAcceptor.java    From jane with GNU Lesser General Public License v3.0 2 votes vote down vote up
/**
 * You need to provide a default session configuration, a class of {@link IoProcessor}
 * which will be instantiated in a {@link SimpleIoProcessorPool} for better scaling in multiprocessor systems.
 * The default pool size will be used.
 */
public NioSocketAcceptor() {
	super(new SimpleIoProcessorPool());
}
 
Example #18
Source File: NioSocketAcceptor.java    From jane with GNU Lesser General Public License v3.0 2 votes vote down vote up
/**
 * You need to provide a default session configuration, a class of {@link IoProcessor}
 * which will be instantiated in a {@link SimpleIoProcessorPool} for using multiple thread
 * for better scaling in multiprocessor systems.
 *
 * @param processorCount the number of processor to create and place in a {@link SimpleIoProcessorPool}
 */
public NioSocketAcceptor(int processorCount) {
	super(new SimpleIoProcessorPool(processorCount));
}