Commit Graph

1924 Commits

Author SHA1 Message Date
Bryan Duxbury
49b38015a6 THRIFT-753. java: Don't look up TFieldIdEnum values with a map
Instead of using a generated map, use a big switch statement.

git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@930618 13f79535-47bb-0310-9956-ffa450edef68
2010-04-04 04:01:07 +00:00
Bryan Duxbury
b1f7f7973b THRIFT-746. java: Generated services Iface/Client inner classes do not derive from base classes
This patch causes all generated Client classes to inherit from TServiceClient, an interface that provides a way to get the protocols the Client is using. Also, it causes a new TServiceClientFactory implementation to generated for each Service, which provides a generic, reflection-free way to get Clients. These changes make it easier to build generic pools of Client objects.

Patch: Mathias Herberts

git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@930601 13f79535-47bb-0310-9956-ffa450edef68
2010-04-03 23:19:52 +00:00
Bryan Duxbury
88569a25d1 THRIFT-752. java: Use a faster Stack implementation in TCompactProtocol
This patch adds ShortStack, an internal implementation of Stack that works directly on primitive short objects, and makes TCompactProtocol use this. A brief performance test shows that this makes serialization about 8% faster and deserialization about 15% faster, though the actual gain you see will be dependent on the nature of your structs - the more levels, the more gain.

git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@930593 13f79535-47bb-0310-9956-ffa450edef68
2010-04-03 22:52:03 +00:00
Bryan Duxbury
75526c999e java: Enhance TMemoryInputTransport to allow operation on specific range of a buffer rather than the whole thing. This will allow us to avoid making array copies in some instances.
git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@930574 13f79535-47bb-0310-9956-ffa450edef68
2010-04-03 20:25:04 +00:00
Bryan Duxbury
c81a10a432 java: add a basic test for TMemoryInputTransport
git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@930568 13f79535-47bb-0310-9956-ffa450edef68
2010-04-03 19:45:20 +00:00
Bryan Duxbury
c5de56cdfd java: reorganize ProtocolTestBase slightly
git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@930530 13f79535-47bb-0310-9956-ffa450edef68
2010-04-03 15:18:47 +00:00
Bryan Duxbury
ea7910faf3 THRIFT-663. java: JavaBean code generator produces incorrect setter methods
This patch causes the beans option to suppress the builder-style setter methods. It also adds a new 'private-members' option that leaves the builder-style methods, but makes the actual instance variables private.

git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@930474 13f79535-47bb-0310-9956-ffa450edef68
2010-04-03 05:04:48 +00:00
Bryan Duxbury
5557beffae THRIFT-723: java: Thrift buffers with set and map types in Java should implement Comparable
This makes structs that contain sets and maps in their hierarchy Comparable.

git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@928944 13f79535-47bb-0310-9956-ffa450edef68
2010-03-29 23:57:09 +00:00
Bryan Duxbury
b35240f4d5 java: Make TProtocolFactory extend Serializable.
git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@928901 13f79535-47bb-0310-9956-ffa450edef68
2010-03-29 21:12:10 +00:00
Bryan Duxbury
547edc7ae0 THRIFT-363. java: Maven Deploy
This commit adds changes to build.xml so that we can generate a POM file and publish the artifact to the Apache Maven repo. For now, we haven't published yet - we'll do that at the next release.

git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@928494 13f79535-47bb-0310-9956-ffa450edef68
2010-03-28 21:02:38 +00:00
Bryan Duxbury
e5e5c7b9d2 java: Move contents of CompareTest into TestStruct; delete old version
git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@928159 13f79535-47bb-0310-9956-ffa450edef68
2010-03-27 06:24:12 +00:00
Bryan Duxbury
981869c6ac java: Move contents of DeepCopyTest to TestStruct; delete old version
git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@928157 13f79535-47bb-0310-9956-ffa450edef68
2010-03-27 06:13:09 +00:00
Bryan Duxbury
c23e09e7b0 java: Move contents of IdentityTest into TestStruct
git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@928153 13f79535-47bb-0310-9956-ffa450edef68
2010-03-27 05:56:26 +00:00
Bryan Duxbury
d10f2bb480 java: get rid of old OverloadNonblockingServer.java (since it's not actually a test), move Fixtures up to o.a.thrift
git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@928103 13f79535-47bb-0310-9956-ffa450edef68
2010-03-26 23:45:41 +00:00
Bryan Duxbury
dffa072afc java: convert PartialDeserializeTest to testcase of TestTDeserializer (new junit test); add apache header to a few of the new test files.
git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@928101 13f79535-47bb-0310-9956-ffa450edef68
2010-03-26 23:38:23 +00:00
Bryan Duxbury
dd6dc838d9 java: convert Framed Transport test to JUnit, remove old version of test
git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@928100 13f79535-47bb-0310-9956-ffa450edef68
2010-03-26 23:30:35 +00:00
Bryan Duxbury
bf0595fcb8 java: Convert TJSONProtocol test to JUnit, making a few minor changes to ProtocolTestBase in the process.
git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@927967 13f79535-47bb-0310-9956-ffa450edef68
2010-03-26 16:59:46 +00:00
Bryan Duxbury
61a1ad4d9d java: Stop trying to run the deprecated version of binary and compact protocol tests, since they don't exist anymore
git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@927701 13f79535-47bb-0310-9956-ffa450edef68
2010-03-26 05:59:59 +00:00
Bryan Duxbury
98c45872f9 java: Convert Binary and Compact protocol tests to JUnit
git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@927699 13f79535-47bb-0310-9956-ffa450edef68
2010-03-26 05:58:34 +00:00
Bryan Duxbury
5af1b97173 THRIFT-719. java: Update Nonblocking and HsHa server to avoid an extra buffer copy
This patch causes Nonblocking and HsHa servers to explicitly enforce use of TFramedTransport and make sure that the actual invoker is deserializing from a TMemoryInputTransport. This should provide a substantial boost in performance.

git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@927695 13f79535-47bb-0310-9956-ffa450edef68
2010-03-26 05:12:27 +00:00
Bryan Duxbury
951e7e2480 java: Add JUnit to ivy config. Convert Nonblocking server tests to use JUnit. Framework laid to convert the remainder of the tests.
git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@927693 13f79535-47bb-0310-9956-ffa450edef68
2010-03-26 05:05:59 +00:00
Bryan Duxbury
15b7b28794 THRIFT-701. java: Generated classes take up more space in jar than needed
Use a static {} block instead of an anonymous inner class to define metaDataMap. This saves some space in jars generated by avoiding the internal class.

git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@926466 13f79535-47bb-0310-9956-ffa450edef68
2010-03-23 05:39:18 +00:00
Bryan Duxbury
27c9785758 THRIFT-739. java: TCompactProtocol isn't suitable for reuse in partialDeserialize
This patch changes TProtocol to support a reset() method that should clear any internal state. Stateless protocols can ignore it; stateful ones should implement it. TDeserializer has been updated to take advantage of this method.

git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@926460 13f79535-47bb-0310-9956-ffa450edef68
2010-03-23 03:50:16 +00:00
David Reiss
318a328aec THRIFT-736. cpp: Check for availability of pthread_mutex_timedlock
r920679 introduced a call to pthread_mutex_timedlock, which is not
available on all UNIX variants.  In particular, it is missing on Mac OS.
Add a preprocessor check for the relevant feature macro.  If it fails,
just use a trylock.

git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@925940 13f79535-47bb-0310-9956-ffa450edef68
2010-03-22 02:34:57 +00:00
Bryan Duxbury
f35a9b9152 THRIFT-738. java: TCompactProtocol throws RuntimeException when it can't identify a type identifier
This patch causes it to throw TProtocolException instead.

git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@924364 13f79535-47bb-0310-9956-ffa450edef68
2010-03-17 16:47:41 +00:00
Bryan Duxbury
3f4ca0e8fd THRIFT-734. java: Can't use primitive types in service definitions for bean generated code
git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@923566 13f79535-47bb-0310-9956-ffa450edef68
2010-03-16 03:13:26 +00:00
David Reiss
5f013bb45d cpp: Fix build problems introduced by r920682
git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@921591 13f79535-47bb-0310-9956-ffa450edef68
2010-03-10 22:11:26 +00:00
David Reiss
767c1a90fe cpp: Minor TSocketPool cleanups
- Make sure the underlying socket is always closed.
- Don't reconnect on repeated calls to open.
- Move some code outside of a try block.

git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@920691 13f79535-47bb-0310-9956-ffa450edef68
2010-03-09 05:20:28 +00:00
David Reiss
450c240592 cpp: Make an implicit virtual declaration explicit
This changes nothing since it's already declared virtual in the parent,
but this is clearer.

git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@920690 13f79535-47bb-0310-9956-ffa450edef68
2010-03-09 05:20:26 +00:00
David Reiss
472fffb375 cpp: Don't leak memory on realloc failure in TNonblockingServer
git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@920689 13f79535-47bb-0310-9956-ffa450edef68
2010-03-09 05:20:24 +00:00
David Reiss
ccd4bdb2ae cpp: Implement peek() for TFileTransport
git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@920688 13f79535-47bb-0310-9956-ffa450edef68
2010-03-09 05:20:21 +00:00
David Reiss
336c29dbbe cpp: Prevent TFileTransport seekToEnd from leaking memory
In seekToEnd we loop on readEvent to skip through the last chunk, but
the complete events returned are disowned by readState_ and therefore
must be freed by the caller.

git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@920687 13f79535-47bb-0310-9956-ffa450edef68
2010-03-09 05:20:19 +00:00
David Reiss
8af018bf13 cpp: Prevent TFileTransport from throwing uncaught exceptions
FilleTransport::writerThread throws exceptions. This function is run
inside the writer thread, so these exceptions are not caught. When these
exceptions happen, the system aborts.

The fix is to first eliminate all the throw commands inside this function. In
addition, add some error recovery logic into the code: whenever an IO error
happens, we enter into an error recovery mode. Go to sleep for a few seconds
then try to reopen the file.

Note: Currently, when errors happen, we drop events.

git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@920686 13f79535-47bb-0310-9956-ffa450edef68
2010-03-09 05:20:17 +00:00
David Reiss
1c20c871d2 cpp: Add setLowRTO to TSocket
low tcp RTO might mitigate TCP incast problems. Adding the setLowRTO
function to TSocket allows us to experiment with a solution.

git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@920685 13f79535-47bb-0310-9956-ffa450edef68
2010-03-09 05:20:14 +00:00
David Reiss
71a1530c74 cpp: Fix memory corruption bug in TBufferedTransport::borrowSlow()
On one code path, the code would read data past the end of its buffer.

git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@920684 13f79535-47bb-0310-9956-ffa450edef68
2010-03-09 05:20:12 +00:00
David Reiss
eee98bede4 cpp: Disable IPV6_V6ONLY only if the socket is an AF_INET6 socket
Some systems may disable IPV6 completely.  Ensure that we only disable
IPV6_V6ONLY if the socket is AF_INET6

No longer see the warning:

Thrift: Wed Jul 22 18:08:36 2009 TServerSocket::listen() IPV6_V6ONLY Protocol not available

git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@920683 13f79535-47bb-0310-9956-ffa450edef68
2010-03-09 05:20:10 +00:00
David Reiss
ac110e4f1c cpp: Eliminate circular dependency between thrift libraries
Previously, Thrift.cpp contained TApplicationException, which was using
TProtocol methods, defined in TProtocol.h.  This caused a circular
dependency since libprotocol depends on Thrift.h.  This change moves
TApplicationException into its own file.

git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@920682 13f79535-47bb-0310-9956-ffa450edef68
2010-03-09 05:20:07 +00:00
David Reiss
7a2065d3db cpp: Add profiling hooks to Mutex, ReadWriteMutex() classes
Extend the Thrift C++ Concurrency library by allowing a user to register
a callback and a sample rate for lock primitive contention profiling.
The callback will be invoked approximately once every sampleRate calls
to Mutex::lock(), Mutex::timedlock(), ReadWriteLock::acquireRead(), or
ReadWriteLock::acquireWrite().

The callback receives a pointer to the mutex responsible and the time
waited on the lock in micros (whether the lock was successfuly acquire
or not).  The user can then implement a registry of his choice to
log/collect this data as needed.

This can all be easily compiled out if it harms performance.  By
default, there is no profiling callback, so the overhead is minimal
(one branch).

git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@920681 13f79535-47bb-0310-9956-ffa450edef68
2010-03-09 05:20:04 +00:00
David Reiss
4cc0755b33 cpp: Fix a race/deadlock in ThreadManager
When removing a task from the pending queue, we were only notifying a
blocked thread waiting to enqueue a task if the number of pending tasks
was exactly one less than the limit.  However, if two tasks are finished
at about the same time, this can result in two spots being freed up with
only one notify.  With this change, we always notify on task completion,
eliminating the race/deadlock.

git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@920680 13f79535-47bb-0310-9956-ffa450edef68
2010-03-09 05:20:01 +00:00
David Reiss
4e19f1914e cpp: non-blocking add for ThreadManager
It's rare for the ThreadManager mutex to be contended, but it is
possible.  For nonblocking applications, it is necessary to have a
strict timeout for the lock acquisition.  With this change, that timeout
is enforced.  Also add timeout parameters to Mutex::lock and
Guard::Guard to support this feature.

git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@920679 13f79535-47bb-0310-9956-ffa450edef68
2010-03-09 05:19:59 +00:00
David Reiss
6c1ee214c4 cpp: Extend FunctionRunner to support periodic calls (in a thread)
git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@920678 13f79535-47bb-0310-9956-ffa450edef68
2010-03-09 05:19:56 +00:00
David Reiss
a1a15112fe cpp: TSocket: call a second gettimeofday only for error checking
Previously, we called gettimeofday twice for every send, which is
costly.  Now, we only make the second call if send fails with EAGAIN.

git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@920677 13f79535-47bb-0310-9956-ffa450edef68
2010-03-09 05:19:54 +00:00
David Reiss
eed92991cf cpp: TSocketPool: Optimize the case of a single server in the pool.
git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@920676 13f79535-47bb-0310-9956-ffa450edef68
2010-03-09 05:19:52 +00:00
David Reiss
8106ba617a cpp: TSocketPool: make it possible to add servers by struct
git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@920675 13f79535-47bb-0310-9956-ffa450edef68
2010-03-09 05:19:50 +00:00
David Reiss
9c22ba4103 cpp: TTransport: set END_OF_FILE TException code if read returns 0
git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@920674 13f79535-47bb-0310-9956-ffa450edef68
2010-03-09 05:19:47 +00:00
David Reiss
068f4169b9 cpp: TNonblockingServer: Allow unrun tasks to expire after a time limit
Enhance ThreadManager to allow a expiration time interval to be assigned
to tasks, and expire those tasks after that time limit has passed.
Enhance TNonblockingServer to utilize this capability so it can be used
for overload resilience.

Note: expired entries are only removed from the queue head, so the
mechanism in ThreadManager may not do what you expect if you have
heterogeneous expiration times. That's not an issue with
TNonblockingServer (which will give all tasks the same limit) and might
not be in other cases where most tasks have the same limit and the rest
execute quickly. A full-up timeout queue would be more complex and have
greater overhead than that used here. It's unnecessary for the task at
hand so I didn't go that route...

The TNonblocking interface is simple: a setTaskExpireTime() accepts a
64-bit millisecond argument. 0 means infinite. A getTaskExpireTime()
accessor completes the interface.

The ThreadManager interface involves an added argument to add() for the
expiration interval and a setExpireCallback() function for setting a
callback that is called for expired tasks (for this project this is
necessary to shut down the associated connection).

git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@920673 13f79535-47bb-0310-9956-ffa450edef68
2010-03-09 05:19:45 +00:00
David Reiss
58e4d2c6e3 cpp: Log unexpected exceptions in TThreadPoolServer
git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@920672 13f79535-47bb-0310-9956-ffa450edef68
2010-03-09 05:19:43 +00:00
David Reiss
450e35d2a3 cpp: Fix max TCP port number
git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@920671 13f79535-47bb-0310-9956-ffa450edef68
2010-03-09 05:19:41 +00:00
David Reiss
9e8073c5cd Eliminate some trailing whitespace
git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@920670 13f79535-47bb-0310-9956-ffa450edef68
2010-03-09 05:19:39 +00:00
David Reiss
e96fa5502f cpp: Add enum and constructor to RWGuard to make read/write more visible
git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@920669 13f79535-47bb-0310-9956-ffa450edef68
2010-03-09 05:19:37 +00:00