[C #] operating HBase series through Thrift (1)

Source: Internet
Author: User

Question: C # several methods to call Java

1. Publish Java interfaces through WebService. C # can be conveniently called.

2. Use C ++ to call Java through JNI, and C # To Call The C ++ Interface

3. Use the open-source library to directly use C # To Call Java. For details, click


4. Use IKVM to implement C # Call Java,

 


The reason for this is that my client needs to call the HBase interface (implemented in Java). At the beginning, I used the WS Method for calling. This method is simple and versatile. Later, I found the third method mentioned above and called it successfully. However, the buddy who wrote this library seems to have not maintained the library he wrote. There are several obvious bugs in it, in addition, the memory error will be reported during the loop call time. Because JNI is not familiar with it, the method will be abandoned. If you are interested in this method, you can improve it for him, again, this open-source library depends on jvm. dll, only 32-bit JavaJDK. The second and fourth methods have not been studied in depth.

 


In the end, I didn't use any of the above methods, but I used Thrift. Although it is a little slower than Java API, it is still within the acceptable range. Next we will go to the topic:

 


Preparation phase:
 

Generate Thrfit interface class:
1. Obtain the HBase. Thrift file from the HBase package. (.. \ Hbase-0.94.6.1 \ src \ main \ resources \ org \ apache \ hadoop \ hbase \ thrift in this directory)

2. Put the thrift-0.9.0.exe and HBase. Thrift files in the agreed directory (of course, they can be in different directories)

3. Go to the command line, and the Thrift-0.9.0.exe-gen CSharp HBase. Thrift directory is named gen-csharp.

Build a solution

The code of the prepared Project has been completed. Create a VS Project and introduce the source code Project of Thrift and the newly generated interface class.

 

Start the Thrift service of the Cluster
Hbase-daemon.sh start thrift port default 9090

Write test code


 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.