org.apache.mina.core.session.IoSessionConfig Java Examples
The following examples show how to use
org.apache.mina.core.session.IoSessionConfig.
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: MinaRemotingClient.java From light-task-scheduler with Apache License 2.0 | 6 votes |
@Override protected void clientStart() throws RemotingException { try { connector = new NioSocketConnector(); //TCP Connector // connector.getFilterChain().addFirst("logging", new MinaLoggingFilter()); connector.getFilterChain().addLast("codec", new ProtocolCodecFilter(new MinaCodecFactory(getCodec()))); connector.getFilterChain().addLast("mdc", new MdcInjectionFilter()); connector.setHandler(new MinaHandler(this)); IoSessionConfig cfg = connector.getSessionConfig(); cfg.setReaderIdleTime(remotingClientConfig.getReaderIdleTimeSeconds()); cfg.setWriterIdleTime(remotingClientConfig.getWriterIdleTimeSeconds()); cfg.setBothIdleTime(remotingClientConfig.getClientChannelMaxIdleTimeSeconds()); } catch (Exception e) { throw new RemotingException("Mina Client start error", e); } }
Example #2
Source File: MinaRemotingServer.java From light-task-scheduler with Apache License 2.0 | 6 votes |
@Override protected void serverStart() throws RemotingException { acceptor = new NioSocketAcceptor(); //TCP Acceptor // acceptor.getFilterChain().addFirst("logging", new MinaLoggingFilter()); acceptor.getFilterChain().addLast("codec", new ProtocolCodecFilter(new MinaCodecFactory(getCodec()))); acceptor.getFilterChain().addLast("mdc", new MdcInjectionFilter()); acceptor.setHandler(new MinaHandler(this)); IoSessionConfig cfg = acceptor.getSessionConfig(); cfg.setReaderIdleTime(remotingServerConfig.getReaderIdleTimeSeconds()); cfg.setWriterIdleTime(remotingServerConfig.getWriterIdleTimeSeconds()); cfg.setBothIdleTime(remotingServerConfig.getServerChannelMaxIdleTimeSeconds()); bindAddress = new InetSocketAddress(remotingServerConfig.getListenPort()); try { acceptor.bind(bindAddress); } catch (IOException e) { throw new RemotingException("Start Mina server error", e); } }
Example #3
Source File: FrameDecoderTest.java From neoscada with Eclipse Public License 1.0 | 6 votes |
protected void testFrames ( final String resourceName, final Frame... expectedFrames ) throws Exception { final FrameDecoder decoder = new FrameDecoder (); final MockProtocolDecoderOutput out = new MockProtocolDecoderOutput (); final DummySession session = new DummySession (); session.setTransportMetadata ( new DefaultTransportMetadata ( "eclipse.scada", "test", false, true, SocketAddress.class, IoSessionConfig.class, Object.class ) ); for ( final IoBuffer data : BufferLoader.loadBuffersFromResource ( FrameDecoderTest.class, resourceName ) ) { System.out.println ( "Pushing data packet - " + data.getHexDump () ); decoder.decode ( session, data, out ); } out.assertMessages ( expectedFrames ); }
Example #4
Source File: MulticastDatagramSessionConfig.java From sailfish-core with Apache License 2.0 | 5 votes |
@Override protected void doSetAll(IoSessionConfig config) { if(config instanceof DefaultMulticastDatagramSessionConfig) { setSoTimeout(((DefaultMulticastDatagramSessionConfig)config).getSoTimeout()); } super.doSetAll(config); }
Example #5
Source File: AbstractIoService.java From neoscada with Eclipse Public License 1.0 | 5 votes |
/** * Constructor for {@link AbstractIoService}. You need to provide a default * session configuration and an {@link Executor} for handling I/O events. If * a null {@link Executor} is provided, a default one will be created using * {@link Executors#newCachedThreadPool()}. * * @param sessionConfig * the default configuration for the managed {@link IoSession} * @param executor * the {@link Executor} used for handling execution of I/O * events. Can be <code>null</code>. */ protected AbstractIoService(IoSessionConfig sessionConfig, Executor executor) { if (sessionConfig == null) { throw new IllegalArgumentException("sessionConfig"); } if (getTransportMetadata() == null) { throw new IllegalArgumentException("TransportMetadata"); } if (!getTransportMetadata().getSessionConfigType().isAssignableFrom(sessionConfig.getClass())) { throw new IllegalArgumentException("sessionConfig type: " + sessionConfig.getClass() + " (expected: " + getTransportMetadata().getSessionConfigType() + ")"); } // Create the listeners, and add a first listener : a activation listener // for this service, which will give information on the service state. listeners = new IoServiceListenerSupport(this); listeners.add(serviceActivationListener); // Stores the given session configuration this.sessionConfig = sessionConfig; // Make JVM load the exception monitor before some transports // change the thread context class loader. ExceptionMonitor.getInstance(); if (executor == null) { this.executor = Executors.newCachedThreadPool(); createdExecutor = true; } else { this.executor = executor; createdExecutor = false; } threadName = getClass().getSimpleName() + '-' + id.incrementAndGet(); }
Example #6
Source File: WrapperNioSocketAcceptor.java From sailfish-core with Apache License 2.0 | 4 votes |
public IoSessionConfig getSessionConfig() { return nioSocketAcceptor.getSessionConfig(); }
Example #7
Source File: WebSocketServerTest.java From red5-websocket with Apache License 2.0 | 4 votes |
@Override public IoSessionConfig getConfig() { // TODO Auto-generated method stub return null; }
Example #8
Source File: AbstractPollingConnectionlessIoAcceptor.java From neoscada with Eclipse Public License 1.0 | 4 votes |
/** * Creates a new instance. */ protected AbstractPollingConnectionlessIoAcceptor( IoSessionConfig sessionConfig ) { this( sessionConfig, null ); }
Example #9
Source File: DefaultTransportMetadata.java From neoscada with Eclipse Public License 1.0 | 4 votes |
public Class<? extends IoSessionConfig> getSessionConfigType() { return sessionConfigType; }
Example #10
Source File: DefaultTransportMetadata.java From neoscada with Eclipse Public License 1.0 | 4 votes |
public DefaultTransportMetadata(String providerName, String name, boolean connectionless, boolean fragmentation, Class<? extends SocketAddress> addressType, Class<? extends IoSessionConfig> sessionConfigType, Class<?>... envelopeTypes) { if (providerName == null) { throw new IllegalArgumentException("providerName"); } if (name == null) { throw new IllegalArgumentException("name"); } providerName = providerName.trim().toLowerCase(); if (providerName.length() == 0) { throw new IllegalArgumentException("providerName is empty."); } name = name.trim().toLowerCase(); if (name.length() == 0) { throw new IllegalArgumentException("name is empty."); } if (addressType == null) { throw new IllegalArgumentException("addressType"); } if (envelopeTypes == null) { throw new IllegalArgumentException("envelopeTypes"); } if (envelopeTypes.length == 0) { throw new IllegalArgumentException("envelopeTypes is empty."); } if (sessionConfigType == null) { throw new IllegalArgumentException("sessionConfigType"); } this.providerName = providerName; this.name = name; this.connectionless = connectionless; this.fragmentation = fragmentation; this.addressType = addressType; this.sessionConfigType = sessionConfigType; Set<Class<? extends Object>> newEnvelopeTypes = new IdentityHashSet<Class<? extends Object>>(); for (Class<? extends Object> c : envelopeTypes) { newEnvelopeTypes.add(c); } this.envelopeTypes = Collections.unmodifiableSet(newEnvelopeTypes); }
Example #11
Source File: WrapperNioSocketConnector.java From sailfish-core with Apache License 2.0 | 4 votes |
public IoSessionConfig getSessionConfig() { return nioSocketConnector.getSessionConfig(); }
Example #12
Source File: DefaultVmPipeSessionConfig.java From neoscada with Eclipse Public License 1.0 | 4 votes |
@Override protected void doSetAll(IoSessionConfig config) { // Do nothing }
Example #13
Source File: MulticastSocketConnector.java From sailfish-core with Apache License 2.0 | 4 votes |
@Override public IoSessionConfig getSessionConfig() { return sessionConfig; }
Example #14
Source File: ProxyConnector.java From neoscada with Eclipse Public License 1.0 | 4 votes |
/** * Creates a new proxy connector. * @see AbstractIoConnector(IoSessionConfig, Executor). */ public ProxyConnector(final SocketConnector connector, IoSessionConfig config, Executor executor) { super(config, executor); setConnector(connector); }
Example #15
Source File: ProxyConnector.java From neoscada with Eclipse Public License 1.0 | 4 votes |
/** * {@inheritDoc} */ @Override public IoSessionConfig getSessionConfig() { return connector.getSessionConfig(); }
Example #16
Source File: AbstractIoService.java From neoscada with Eclipse Public License 1.0 | 4 votes |
/** * {@inheritDoc} */ public IoSessionConfig getSessionConfig() { return sessionConfig; }
Example #17
Source File: AbstractPollingIoConnector.java From neoscada with Eclipse Public License 1.0 | 2 votes |
/** * Constructor for {@link AbstractPollingIoConnector}. You need to provide a default * session configuration, a default {@link Executor} will be created using * {@link Executors#newCachedThreadPool()}. * * {@see AbstractIoService#AbstractIoService(IoSessionConfig, Executor)} * * @param sessionConfig * the default configuration for the managed {@link IoSession} * @param processor the {@link IoProcessor} for processing the {@link IoSession} of this transport, triggering * events to the bound {@link IoHandler} and processing the chains of {@link IoFilter} */ protected AbstractPollingIoConnector(IoSessionConfig sessionConfig, IoProcessor<T> processor) { this(sessionConfig, null, processor, false); }
Example #18
Source File: MockIOSession.java From mapleLemon with GNU General Public License v2.0 | 2 votes |
/** * Does nothing. * * @return */ @Override public IoSessionConfig getConfig() { return null; }
Example #19
Source File: AbstractPollingIoAcceptor.java From neoscada with Eclipse Public License 1.0 | 2 votes |
/** * Constructor for {@link AbstractPollingIoAcceptor}. You need to provide a default * session configuration and an {@link Executor} for handling I/O events. If a * null {@link Executor} is provided, a default one will be created using * {@link Executors#newCachedThreadPool()}. * * {@see AbstractIoService#AbstractIoService(IoSessionConfig, Executor)} * * @param sessionConfig * the default configuration for the managed {@link IoSession} * @param executor * the {@link Executor} used for handling asynchronous execution of I/O * events. Can be <code>null</code>. * @param processor the {@link IoProcessor} for processing the {@link IoSession} of this transport, triggering * events to the bound {@link IoHandler} and processing the chains of {@link IoFilter} */ protected AbstractPollingIoAcceptor(IoSessionConfig sessionConfig, Executor executor, IoProcessor<S> processor) { this(sessionConfig, executor, processor, false); }
Example #20
Source File: AbstractPollingIoAcceptor.java From neoscada with Eclipse Public License 1.0 | 2 votes |
/** * Constructor for {@link AbstractPollingIoAcceptor}. You need to provide a default * session configuration, a default {@link Executor} will be created using * {@link Executors#newCachedThreadPool()}. * * {@see AbstractIoService#AbstractIoService(IoSessionConfig, Executor)} * * @param sessionConfig * the default configuration for the managed {@link IoSession} * @param processor the {@link IoProcessor} for processing the {@link IoSession} of this transport, triggering * events to the bound {@link IoHandler} and processing the chains of {@link IoFilter} */ protected AbstractPollingIoAcceptor(IoSessionConfig sessionConfig, IoProcessor<S> processor) { this(sessionConfig, null, processor, false); }
Example #21
Source File: AbstractPollingIoAcceptor.java From neoscada with Eclipse Public License 1.0 | 2 votes |
/** * 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 #22
Source File: AbstractPollingIoAcceptor.java From neoscada with Eclipse Public License 1.0 | 2 votes |
/** * 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 #23
Source File: AbstractPollingIoConnector.java From neoscada with Eclipse Public License 1.0 | 2 votes |
/** * Constructor for {@link AbstractPollingIoConnector}. You need to provide a default * session configuration and an {@link Executor} for handling I/O events. If * null {@link Executor} is provided, a default one will be created using * {@link Executors#newCachedThreadPool()}. * * {@see AbstractIoService#AbstractIoService(IoSessionConfig, Executor)} * * @param sessionConfig * the default configuration for the managed {@link IoSession} * @param executor * the {@link Executor} used for handling asynchronous execution of I/O * events. Can be <code>null</code>. * @param processor the {@link IoProcessor} for processing the {@link IoSession} of this transport, triggering * events to the bound {@link IoHandler} and processing the chains of {@link IoFilter} */ protected AbstractPollingIoConnector(IoSessionConfig sessionConfig, Executor executor, IoProcessor<T> processor) { this(sessionConfig, executor, processor, false); }
Example #24
Source File: AbstractPollingIoConnector.java From neoscada with Eclipse Public License 1.0 | 2 votes |
/** * 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 #25
Source File: AbstractPollingIoConnector.java From neoscada with Eclipse Public License 1.0 | 2 votes |
/** * 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 #26
Source File: AbstractIoConnector.java From neoscada with Eclipse Public License 1.0 | 2 votes |
/** * Constructor for {@link AbstractIoConnector}. You need to provide a default * session configuration and an {@link Executor} for handling I/O events. If * null {@link Executor} is provided, a default one will be created using * {@link Executors#newCachedThreadPool()}. * * {@see AbstractIoService#AbstractIoService(IoSessionConfig, Executor)} * * @param sessionConfig * the default configuration for the managed {@link IoSession} * @param executor * the {@link Executor} used for handling execution of I/O * events. Can be <code>null</code>. */ protected AbstractIoConnector(IoSessionConfig sessionConfig, Executor executor) { super(sessionConfig, executor); }
Example #27
Source File: TransportMetadata.java From neoscada with Eclipse Public License 1.0 | 2 votes |
/** * Returns the type of the {@link IoSessionConfig} of the service */ Class<? extends IoSessionConfig> getSessionConfigType();
Example #28
Source File: IoService.java From neoscada with Eclipse Public License 1.0 | 2 votes |
/** * Returns the default configuration of the new {@link IoSession}s * created by this service. */ IoSessionConfig getSessionConfig();
Example #29
Source File: AbstractIoAcceptor.java From neoscada with Eclipse Public License 1.0 | 2 votes |
/** * Constructor for {@link AbstractIoAcceptor}. You need to provide a default * session configuration and an {@link Executor} for handling I/O events. If * null {@link Executor} is provided, a default one will be created using * {@link Executors#newCachedThreadPool()}. * * {@see AbstractIoService#AbstractIoService(IoSessionConfig, Executor)} * * @param sessionConfig * the default configuration for the managed {@link IoSession} * @param executor * the {@link Executor} used for handling execution of I/O * events. Can be <code>null</code>. */ protected AbstractIoAcceptor(IoSessionConfig sessionConfig, Executor executor) { super(sessionConfig, executor); defaultLocalAddresses.add(null); }