Commit Graph

154 Commits

Author SHA1 Message Date
Gary Russell
57755a07ed INT-2635 Set Buffer Size for Piped Streams
Improve performance.

For NIO sockets, a pair of PipedInput/OutputStreams are
used to transfer data from the reading thread to the
assembling thread.

The stream used the default buffer size (1024) which was
inefficient for large messages.

This change uses the underlying socket's receiveBufferSize
attribute to set the size of the piped stream, allowing
for more efficient data transfer.

Also adjusts the mocks in the deadlock detection test
to ensure the received data is larger than the pipe
buffer size.
2012-06-28 11:07:00 -04:00
Gary Russell
ae0abc4f6c INT-2515 More Orderly Shutdown
* Add beginShutdown() and endShutdown() to OrderlyShutdownCapable
* JMS/AMQP stop listener containers
* TCP (server side)
** after beginShutdown() disallow new connections, drop (log) new messages
** after endShutdown() close server socket
* HTTP (server side)
** after beginShutdown() disallow any new requests (503 Service Unavailable)

* Docbook updates
** What's new section
** Orderly Shutdown section.
2012-06-26 10:31:22 -04:00
Oleg Zhurakousky
2b49c66f64 INT-1141 Improve on how MessageHandlers are stored
INT-1141 polished code

INT-1141 added tests

INT-1141 improved how iterator is obtaind from OrderAwareLikedHashSet

INT-1141 polishing

INT-1141 stashed commit with List-based collection and performance tests

INT-1141 improved OrderedAwareLinkedHashSet

INT-1141 polishing

INT-1141, INT-2627 improved LoadBalancingStrategy and
RoundRobinLoadBalancingStrategy to obtain handler's iterator faster

INT-1141 improved getHandlerIterator method to ensure that it only executes reordering logic if there are more then one handler

INT-1141 simplified OrderedAwareLinkedHashSet to not to extend from LinkedHashSet

INT-1141
changed OrderedAwareLinkedHashSet to OrderedAwareCopyOnWriteArraySetTests, imporoved array creation in RoundRobinLoadBalancingStrategy

INT-1141 polished failing tests and RoundRobinLoadBalancingStrategy. Removed 'transient' from OrderedAwareCopyOnWriteArraySet
2012-06-21 13:03:50 -04:00
Gunnar Hillert
0269de0f98 INT-2564 Move Some SocketTestUtils to Test Module
Move SocketTestUtils.findAvailableServerSocket to Test Module

For reference see: https://jira.springsource.org/browse/INT-2564

* Move SocketTestUtils.findAvailableServerSocket to Spring Integration Test Module
* Fix tests
2012-06-21 12:35:22 -04:00
Artem Bilan
de73c39488 INT-2605: add SmartLifecycle support for 'chain'
* polishing TCP test to use SmartLifecycle from 'chain'
* polishing XSD to exclude using 'poller' element inside 'nested-chain'

INT-2605: eliminate breaking change in the XSD
2012-06-21 10:06:47 -04:00
Gary Russell
011953a5b6 INT-2590 Add TestingUtility
Added testing utility from samples to provide a tool for
users to wait for servers to start during tests.

Also refactored all tests that had similar code to use
this class.

Also corrected two failing tests that needed this wait.
2012-06-07 13:59:07 -04:00
Artem Bilan
5bc41bc60b INT-1029: Support for outbound-gateways in chain
XSD refactoring: remove use="required" from 'request-channel' attribute of all 'outbound-gateways'
Tests for all 'outbound-gateways' inside the <chain>
2012-06-07 13:20:56 -04:00
Gary Russell
48e972bf46 INT-2604 Remove Deprecated Header
The IPHeaders.CONNECTION_SEQ was replaced by the
standard sequenceNumber header (when applySequence is true)
in 2.1, in order to facilitate resequencing using the
standard resequencer.

This header was deprecated at that time. It is now
removed.

Users that were relying on this header should set
applySequence to true on the connection factory.
2012-06-07 13:00:18 -04:00
Gary Russell
7ede0eb4e6 INT-2459 Add Support for TCP Failover
Implemented a ConnectionFactory that wraps a list
of connection factories, used to fail over if
a connection fails.

INT-2459 Polishing

Rebase; fix test; move boolean resets to finally block
in server factories.

INT-2459 Polishing

PR Review

Fix a test that could block indefinitely when error
in code under test.
2012-06-07 12:25:42 -04:00
Gary Russell
9f3e8aab4a INT-2264, INT-2263 TCP GW Reconcile reply-timeout
reply-timeout had the wrong function, when compared to
other gateways.

Add remote-timeout to reflect the time we will wait
for a reply from the remote system

Make reply-timeout set the sendTimeout on the messaging template

Set remore-timeout to reply-timeout (if set) unless remote-timeout
is explicitly set.

Update reference doc, and migration guide on Wiki.
2012-06-05 10:05:48 -04:00
Gary Russell
90fe92ae29 INT-2419 Thread Starvation Detection
Previously, it was possible to run out of threads in
a fixed thread pool, and this could cause an indefinite
deadlock.

With this change, the deadlock is detected causing the
current message to fail, but freeing up the stuck
threads.

This was only seen with very small thread pools but
the potential was there for the condition to occur
under extreme conditions.

INT-2419 Deprecate poolSize Property

INT-2419 Polishing

Add note about OOM possibility now that an
unbounded task executor is used by default.
2012-06-01 12:08:43 -04:00
Gary Russell
fcd3771c17 INT-2588 Remove Deprecation
@ExpectedException is deprecated.

Also fixes a sporadic timing issue in the client mode test;
the default retry interval is 60 seconds and we only wait
10 seconds for the connection. If the initial connection
fails, we don't retry before the timeout.

INT-2527 Remove Event Deprecation

@Test @ExpectedException... -> @Test(expected...
2012-05-25 15:30:24 -04:00
Gary Russell
33c0da2341 INT-2581 Fix Failing Test (Timing)
When sending a message to the server, we checked that the
user hook for the socket creation was called. However,
it was possible (likely) that we tested the counter before
the socket actually opened.
2012-05-23 13:11:34 -04:00
Gary Russell
5c0c55409b INT-2153 SSL Support
Add strategy interfaces
 - obtaining ServerSocketFactory and SocketFactory
 - post processing ServerSockets and Sockets
 - obtaining initialized SSLContext

Provide SSL and non-SSL implementations of the strategies, to
serve up the appropriate socket factories, and do nothing in the
post processing methods.

The postprocessors allow the user to modify sockets after
configured attributes have been applied but before the sockets
are used.

This is particularly useful with SSL in case additional SSL
options need to be applied.

Docs

Polishing JavaDocs

Polishing

Javadocs, polishing

Polishing

Polishing

INT-2153 Polishing

PR Review

White Space

INT-2513 Polishing

Fixed method names.
2012-05-23 12:45:24 -04:00
Gary Russell
59d7432eef INT-2417 Alias Endpoints with Generated Names
Handlers for consumer endpoints get a generated name
derived from the endpoint class name.

It is useful (for example for autowiring in tests)
to give the handlers a well-known name.

If the endpoint has an ID attribute, the handler
now gets a bean name of "<ID>.handler".
2012-05-17 16:10:02 -04:00
Artem Bilan
45c429ee2b INT-2275: any outbound-channel-adapter in <chain>
Add re-init logic for nested chains
Add logic about nested element for AbstractChannelAdapterParser
Refactor of DefaultOutboundChannelAdapterParser
Test for non-last nested chain with some outbound-channel-adapter
Improve XSD for chain-type
Manual outbound-channel-adapter ability for chain
Integration tests for all outbound-channel-adapter within <chain>
Remove redundant 'return-value-required' attribute from <stored-proc-outbound-channel-adapter>
Add support 'expectReply' for FileWritingMessageHandler

INT-2275 polishing & refactor FileOutbound*Parser

HttpRequestExecutingMessageHandlerTests polishing

INT-2275: polishing JavaDoc
2012-05-14 12:41:39 -04:00
Gary Russell
0a12a496cc INT-2485 Orderly Shutdown
Initial commit - @ManagedOperation on IMBE

- can be invoked via JMX, <control-bus/>, or getting a reference to
the IMBE from the application context.

INT-2485 Updates After Review Comments (JIRA)

* Shutdown Schedulers first, and wait for them
* Add a force parameter, which overrides thread pool shutdown options
* Shutdown Sources/Channels after all thread pools have stopped
* Mark other components as OrderlyShutdownCapable (e.g. JMS/AMQP Listener containers) and shut them down first
* Wait for remaining time to allow for quiescence

Also
* remove TimeUnit parameter (not JMX-friendly); time limit is now always milliseconds
* If thread pools don't stop in time limit, force them down.

INT-2485 Handle Self-Destruction

Add shutdown-executor to IMBE.

When the shutdown was called on a Spring-Managed thread, the shutdown
was not clean because we timed out waiting for the current thread to
terminate. After that, we force terminated other components.

Now, by providing a dedicated Executor for the shutdown process, it
is used for the shutdown instead of the current thread. This Executor
is *not* shutdown.

It is not necessary to provide an Executor if the stopActiveComponents()
method is called on some other thread that is not involved in the
shutdown.

Also adds executor name to logs, when available.

INT-2485 Polishing

Fix MBean object name collision when running all tests.

INT-2485 Enable TCP Shutdown

Make TCP connection factories 'OrderlyShutdownCapable' so
they are stopped before schedulers/executors in order for
them to release any executor threads they are holding.

INT-2485 Polishing

Didn't need DirectFieldAccessor - scheduler and executor have
an accessor for the native ExecutorService.

Copyrights

INT-2485 Polishing

schemaLocation version.

INT-2485 PR Review Polishing
2012-05-10 08:10:00 -04:00
Gary Russell
b271a7c42c INT-2519 Fix Failing Test
Depending on timing, it was possible the event the test
case was waiting for would never happen. With no timeout
the selector will block until the next IO event occurs,
and there is none in this test.

Adding a call to factory.close() forces a wakeup of
the selector, which will force the harvest to occur.

This is a test-only problem.
2012-05-08 14:33:14 -04:00
Gary Russell
120b2a3893 INT-2519 Fix Memory Leak
When using NIO, a Map of connections is maintained (keyed
by the SocketChannel) and used to manage registrations
for NIO events, timeouts etc.

When a connection is closed, the corresponding entry
should be removed from the map. The code to do this
is in AbstractConnectionFactory.processNioSelections().
However, if no socket timeout (soTimeout) has been set,
or it was explicitly set to 0, connections are not
removed from the map. This was because the timeout
logic and map cleanup is done in the same iteration
loop.

Now, if soTimeout is not set, the clean up loop
operates every nioHarvestInterval milliseconds
(default 2000), we don't want to run it on
every selector event.

In addition, it runs if the selectionCount is
zero - this might occur when a socket
is closed, when the selector.wakeup() is called.

INT-2519 Polishing

Rename connections field in NIO connection factories. Name
collision caused TestUtils problem on some platforms.
2012-05-07 12:59:34 -04:00
Gary Russell
87f487007d INT-1871 Remove Schema Versions
Schemas update to 2.2 after the PR and the new
test config had 2.1 versioned schemas.

INT-1871 polishing, removed unused import
2012-05-07 09:23:11 -04:00
Gary Russell
411aa296a4 INT-1871 TCP CachingClientConnectionFactory
Pool based on algorithm used for spring-integration-file
CachingSessionFactory introduced by INT-2146. Refactored
that code to use the common SimplePool.

One difference to the previous implementation is the
ability to change the pool size dynamically.

If the size is reduced and more than the new size are
in use, items are closed as they are returned until
the pool size is as requested.

Initial commit.

Allow Pool Size Changes

Factor out Pool

Polishing

Pool Tests

Default forever

Javadocs, File

Polishing

INT-1871 PR Polishing

* Consistent/cleaner method names
* Track checkouts; reject release of 'foreign' objects.
* Add 'getAllocatedCount()'
2012-05-07 08:25:11 -04:00
Gary Russell
409cc95607 INT-2511 Change Default Socket Timeout
Previously, when a client connection factory was used by
both an inbound and outbound adapter, the socket timeout
defaulted to 10 seconds.

This was inappropriate because, often, collaborating
channel adapters are used for aysnchronous messaaging and,
even when used for request/response, it is generatlly not
appropriate to timeout the socket due to a lack of recent
send activity.
2012-05-04 10:32:17 -04:00
Gary Russell
95cd202be6 INT-2536 Create 2.2 Schemas
Add 2.2 versions of module schemas.

JMX is already covered by an existing pull request.

INT-2536 Schema Check

Bump version for schema check in
AbstractIntegrationNamespaceHandler.

INT-2536 Remove Schema Versions

Some test config files had 2.1 versioned schemas.
2012-05-04 10:04:01 -04:00
Gary Russell
292aa90599 INT-2404 Fix Auto-Created Channel; Event, TCP, UDP
The AbstractChannelAdapterParser creates an implicit DirectChannel
if the adapter has no 'channel' attribute.

The Event, TCP, and UDP channel adapter parsers did not bind
this channel to the adapter and AC initialization failed with
'outputChannel is required'.

Further, the event schema marked the channel as being 'required',
precluding this feature.

INT-2407 Remove Channel use="required"

Parsers automatically generate the channel when none is provided.

- JMX
- JDBC
- SFTP
- Redis
- Feed
- XMPP
- Mail
- FTP
- HTTP
2012-01-23 10:12:34 -05:00
Gary Russell
f76f63f23a NT-2400 Fix tool:expected-type Classes
* MessageChannel was moved from core to the base package.
* ChannelResolver moved from core to support.
* TcpConnectionInterceptorFactoryChain was incorrect.
2012-01-13 13:21:41 -05:00
Gary Russell
b59ee8e352 INT-2369 package-info IP
INT-2360 package-info Core

INT-2361 package-info AMQP

INT-2362 package-info Event

INT-2363 package-info Feed

INT-2364 package-info File

INT-2365 INT-2380 package-info (S)FTP

INT-2366 package-info GemFire

INT-2367 package-info Groovy

INT-2368 package-info Http

INT-2378 package-info Scripting

INT-2372 package-info JMS
2012-01-05 14:42:24 -05:00
Gary Russell
3c49cb3480 INT-2333 Mac OSX TCP Workaround on Server Side
Mac OSX problem was encountered only on the client; similar
code exists on the server side, so the workaround should
be implemented there too; just in case.
2011-12-22 16:26:50 -05:00
Gary Russell
49c52353cd INT-2333 Work Around for MAC OSX JVM Bug
Selector.select() throws CancelledKeyException when selecting
on a closed socket.

http://java.net/jira/browse/MACOSX_PORT-526

Work around is to catch the exception and continue.
2011-12-22 15:53:03 -05:00
Gary Russell
0f01ba20ea INT-2332 Remove Benign Exceptions From Maven Build
The IP module produced a significant number of benign exceptions
during a maven build. Due to auto-startup adapters with a
small retry-interval for client-mode adapters.
2011-12-21 23:34:47 -05:00
Gary Russell
0f46176c3d INT-2287 Timing Hole With Send-and-Forget TCP
If a tcp client connection factory was configured for single-use
connections (one socket per message), and it was used by an outbound
channel adapter (send and forget), the socket is closed immediately
after sending the message.

This could cause issues with the connection handling because certain
failures could occur. For example, the close could occur before we
ever registered the channel for read selection, resulting in a
ClosedChannelException. Secondly, there was a small timing hole
where a selection key could be invalidated between the isValid()
call and isReadable().

These problems have been corrected.
2011-11-30 16:23:33 -05:00
Gary Russell
3fff33c99b INT-2268 Fix Spurious Failing Test
Occasional test failures caused because test HelloWorldInterceptor
could prematurely close the connection, depending on timing.

Also added some minor cleanup to the tests themselves.
2011-11-29 11:50:32 -05:00
Mark Fisher
6c1454ae3d INT-2238 removing warnings in JavaDoc 2011-11-22 21:48:34 -05:00
Oleg Zhurakousky
43f60dae08 INT-2238 interim commit
INT-2238 fixing warning comments

INT-2238 fixing warning comments

INT-2238 fixing warning comments
2011-11-22 21:10:32 -05:00
Gary Russell
7c3f2ee8c4 INT-2184 Lifecycle Problem With TCP OB Adapter
Autostartup defaulted to false and isRunning() returned
the status of the associated connection factory instead
of its own status. Precluded it being started because
LifeCycle processor thought it was already started.
2011-10-17 11:56:48 -04:00
Gary Russell
e9778b7526 INT-2167 Code Polishing
Missing braces.

Add private constructors to utility classes.

Remove unnecessary logger overrides.

Remove unnecessary null check.

Remove redundant 'implements BeanNameAware'.

Improve Synchronization in UDP.

Removed Unused Obsolete Constants
2011-10-17 11:50:21 -04:00
Gary Russell
57121604d3 INT-1872 Allow Indefinite Socket Timeout
Previously, for single-use server sockets, and for client sockets
that have a collaborating inbound adapter, the socket timeout
was set to 10 seconds, with no way to set to infinity. The work
around was to set it to Integer.MAX_VALUE.

The intent was to avoid DoS attacks and mis-behaved clients, but
some users have expressed a desire to be able to set an infinite
timeout in both scenarios.

A future release may remove the 10 second default from the client
socket that has a collaborating inbound adapter, and default to
infinity. For this reason, that case now emits a warning.

The default 10 second timeout on single-use server sockets will
likely remain.

INT-1872 Remove WARN Log

We decided to eliminate the log message regarding a possible
future change to the default timeout for client sockets used
for request/reply.
2011-10-17 11:45:08 -04:00
Gary Russell
9f302172c6 INT-2183 Fix Multicast Regression Issue
Multicast tests are @Ignored because multicast has specific
requirements on the build machine. A regression issue was
introduced by INT-2050.
2011-10-15 13:53:53 -04:00
Gary Russell
a7bda6bbb2 INT-1770 Support Client Mode For TCP Endpoints
Add client mode for inbound endpoints, and for the
outbound adapter.

INT-1770 Allow Inbound Adapter to Open Connection

Normally, inbound adapters use server sockets and wait for incoming
connection. There are use cases where the adapter should establish
the connection and wait for inbound messages.

INT-1770 Open Connection on Start

Allow configuration of outbound adapter to permit
connection establishment when the adapter is started
rather than when the first message arrives.

INT-1770 Allow Inbound Gateway to Open Connection

Normally, inbound gateways listen for connections. There are
use cases where an inbound gateway might open the connection
and then wait for incoming requests.

INT-1770 Parsers

Update parsers and tests to support attributes for setting
endpoints in client-mode.

INT-1770 Docs

Update reference with client-mode information.

INT-1770 Add Control Bus for Client Mode

Enable control bus commands to check status and to attempt
connection establishment.
2011-10-14 18:10:06 -04:00
Gary Russell
1cb7990f6c INT-2179 Fix NPE If Connection Id Header Missing
ip_connection_id header is used to determine to which socket
a message should be written. If this header is missing, we
can't send the message and we log an error. Previously, an
NPE was thrown.

This applies to inbound gateway replies and asynchronous
outbound server messages.
2011-10-13 17:08:10 -04:00
Mark Fisher
e09a5da3ec versionless schemas for http and ip modules 2011-10-10 12:49:30 -04:00
Gary Russell
7ff2861168 INT-2168 Reinstate Port in Tcp Connection Id
Port was always zero; broken by INT-1822.
2011-10-05 17:41:15 -04:00
Gary Russell
7981855c78 INT-2050 Code Polishing
INT-1876 Add AutoStart and Phase to TCP Endpoints

There was no way for an application to control the startup
of TCP endpoints. This is particularly an issue for controlling
availability of inbound endpoints.

The TCP Endpoints are mostly static, with dynamic behavior
being contained in connection factories. The factories
implement SmartLifecycle but there is no way to
configure auto-startup.

Adds auto-startup and phase attributes to all TCP endpoints

Starting/stopping an endpoint will start/stop the underlying
connection factory. When a connection factory is stopped,
all open connections are closed, and no new connections will
be acceptedi (inbound) or allowex (outbound).

While the factories implement SmartLifecycle, they return
false to auto-startup. We rely on the fact that
the endpoints are dependent on factories and
the factories will be started because of this dependency.

Finally, with collaborating endpoints (where an inbound and
outbound adapter are bound to the same factory), starting/
stopping one endpoint will affect the collaborating
endpoint too.

INT-1876 Polish Schema Docs

Doc was incorrectly talking about connection factories instead
of endpoints.

INT-2162 Add apply-sequence to Connection Factory

When messages are generated as a result of incoming tcp messages, and this
attribute is true (default=false), the sequenceNumber and
correlationId headers will be set. This will facilitate
downstream resequencing if necessary.

The 'ip_connection_id' header is still required for internal correlation
of reply messages to the right socket (regardless of whether downstream
components have altered the correlationId), and will contain the same value
as the correlationId (if set). This will not use up more memory for the
header content because they will both point to the same heap object.

The 'ip_connection_seq' header is deprecated and may be removed
in a future release.

TcpConnection.getConnectionSeq() has been renamed to
incrementAndGetConnectionSequence() because it is not a simple
getter method, it increments the connection's sequence number.

INT-2162 Update Docs for apply-sequence

Add documentation for apply-sequence attribute on
TCP Connection Factories.
2011-10-03 15:20:57 -04:00
Gary Russell
5624feacc0 INT-2154 Minor Refactoring
Factor out socket creation to a protected method, to facilitate
easier subclassing, enabling something other than the default
Socket factories to be used.
2011-09-27 11:56:17 -04:00
Mark Fisher
9f59001230 removed deprecated trigger sub-elements non-core 2011-08-31 12:54:22 -04:00
Mark Fisher
7c5603fe83 INT-2092 update schema imports to use 2.1 version 2011-08-31 05:26:02 -04:00
Oleg Zhurakousky
935cd01d07 INT-1512 changed the type of ID attribute to be xsd:string in all related 2.1 schema files 2011-08-08 23:34:12 -04:00
Mark Fisher
3e71b5a83b INT-2004 added 2.1 versions of all XML schemas and adjusted spring.schemas files accordingly 2011-08-05 11:07:20 -04:00
Gary Russell
9b626c946b INT-1937 Fix NIO Connection State on Exception 2011-06-11 10:35:12 -04:00
Gary Russell
fc7f3e9f83 INT-1895 Use FactoryBean to Allow Late-Binding of using-nio Attribute 2011-06-09 19:16:36 -04:00
Oleg Zhurakousky
765503daa4 polishing, fixed warning messages 2011-05-03 19:20:57 -04:00