Thanks Josh for writing
I have DAL written in java we have requirement to give common platform to
other team (c++ and c#) these two teams also want to access same DAL for
this I want to use thrift.
I tried tutorials on Net and I am able to connect from both side java
(Client and server) but I don't know how to connect with C++, also for this
I did't genrate any code viea thrift.
I simple start thrift which is coming with HDP distribution
below is the java code
public class ThriftClient {
static CharsetDecoder decoder = null;
public static Hbase.Client client=null;
public static void main(String args[]){
String host=<IP address>
int port= 9090;
try {
TTransport transport = new TSocket(host, port);
TProtocol protocol = new TBinaryProtocol(transport, true, true);
client = new Hbase.Client(protocol);
transport.open();
test();
} catch (TTransportException e) {
e.printStackTrace();
}}
public static void test(){
System.out.println("scanning tables...");
try {
for (ByteBuffer name : client.getTableNames()) {
System.out.println(" found: " + utf8(name.array()));
}
} catch (IOError e) {
e.printStackTrace();
} catch (TException e) {
e.printStackTrace();
}
}
private static String utf8(byte[] buf) {
try {
decoder = Charset.forName("UTF-8").newDecoder();
return decoder.decode(ByteBuffer.wrap(buf)).toString();
} catch (CharacterCodingException e) {
return "[INVALID UTF-8]";
}
}
private static byte[] bytes(String s) {
try {
return s.getBytes("UTF-8");
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
return null;
}
}
}
Please guide me how can I genrate code for c++ (client) and server which
will responsible to call my DAL
PSI am using Java 8
Hbase 1.1.2
Thanks
Manjeet
On Mon, Jan 23, 2017 at 10:26 PM, Josh Elser <[email protected]> wrote:
>
>
> Manjeet Singh wrote:
>
>>
>> I come to know about thrift but as per my understanding on thrift client
>> and server should be on same language thrift only give direct access to
>> other language (correct me if I am wrong)
>>
>
> You are incorrect. One of the features of Thrift is that the client and
> server can be implemented in different languages. A Java client can talk to
> a Ruby server, a C++ client can talk to a Java server, etc.
>
>
> if above statement is wrong so is it possible as showing in below image
>>
>>
>> Inline image 2
>>
>
> Reminder: images are stripped by the mailing list.
>
> second How can i generate c++ code from thrift ( I am using HDP which
>> already having hbase thrift so do I need to download separate thrift)
>>
>
> You need to have the correct version of Thrift installed to generate the
> code for other languages (than Java which is bundled) from the IDL.
>
> See http://thrift.apache.org/ for more details on how to generate the
> bindings in other languages.
>
> e.g. `thrift --gen <language> <Thrift filename>`
>
--
luv all