感謝所有的指針。
能夠完成我的項目。
這些是我的筆記。
A.版本:
Accumulo 1.5
節儉0.90
單聲道3.2.5用於從C#連接到Accumulo
B.策略/選項:
Accumulo代理API
C.與C#綁定的Accumulo代理服務器:
演出運行Accumulo
1.安裝單3.2.5
2.一個節點上執行以下操作安裝節儉0.90
3.配置的Accumulo代理服務
修改文件$ ACCUMULO_HOME /代理/代理。性能;
具體更新實例名稱,和動物園管理員
4.開始代理daemon-
${ACCUMULO_HOME}/bin/accumulo proxy -p ${ACCUMULO_HOME}/proxy/proxy.properties
5.Generated C#綁定,使用proxy.thrift IDL文件
thrift --gen csharp $ACCUMULO_HOME/proxy/thrift/proxy.thrift
這導致在$ {ACCUMULO_HOME}/proxy/thrift/
之下創建一個名爲gen-csharp的目錄。6.在C#項目中,下面的D部分需要gen-csharp下的文件。
7. Thrift.dll,也是需要的。
D. C#項目 - Accumulo客戶端:
1.創建一個類型庫的項目。
2.增加了在步驟C5下GEN-CSHARP的文件,上述到庫
3.增加參考thrift.dll
4.內置庫
E.從C#連接到Accumulo
在C#項目,讀取/寫入Accumulo,
1.增加了參考 - thrift.dll
2.增加參考建在部分d圖書館,上述
3.在Accumulo服務器,開始代理(請參閱步驟C4,陽離子)
下面是一些示例代碼,讀取數據,來嘗試這個功能了..
using System;
using System.Text;
using System.Collections.Generic;
using Thrift.Protocol;
using Thrift.Transport;
namespace AccumuloIntegratorPrototype
{
class MainClass
{
static byte[] GetBytes(string str)
{
return Encoding.ASCII.GetBytes(str);
}
static string GetString(byte[] bytes)
{
return Encoding.ASCII.GetString(bytes);
}
public static void Main (string[] args)
{
try
{
String accumuloProxyServerIP = "xxx.xxx.x.xx";//IP
int accumuloProxyServerPort = 42424;//Port Number
TTransport transport = new TSocket(accumuloProxyServerIP, accumuloProxyServerPort);
transport = new TFramedTransport(transport);
TCompactProtocol protocol = new TCompactProtocol(transport);
transport.Open();
String principal = "root";//Application ID
Dictionary<string, string> passwd = new Dictionary<string,string>();
passwd.Add("password", "xxxxx");//Password
AccumuloProxy.Client client = new AccumuloProxy.Client(protocol);
byte[] loginToken = client.login(principal, passwd);//Login token
//{{
//Read a range of rows from Accumulo
var bScanner = new BatchScanOptions();
Range range = new Range();
range.Start = new Key();
range.Start.Row = GetBytes("d001");
//Need the \0 only if you need to get a single row back
//Otherwise, its not needed
range.Stop = new Key();
range.Stop.Row = GetBytes("d001\0");
bScanner.Ranges = new List<Range>();
bScanner.Ranges.Add(range);
String scanId = client.createBatchScanner(loginToken, "departments", bScanner);
var more = true;
while (more)
{
var scan = client.nextK(scanId, 10);
more = scan.More;
foreach (var entry in scan.Results)
{
Console.WriteLine("Row = " + GetString(entry.Key.Row));
Console.WriteLine("{0} {1}:{2} [{3}] {4} {5}", GetString(entry.Key.Row), GetString(entry.Key.ColFamily), GetString(entry.Key.ColQualifier), GetString(entry.Key.ColVisibility), GetString(entry.Value),(long)entry.Key.Timestamp);
}
}
client.closeScanner(scanId);
client.Dispose();
transport.Close();
}catch (Exception e)
{
Console.WriteLine(e);
}
//}}
}
}
}
具體關於版本,Accumulo 1.4.x的依賴節儉0.6.1同時Accumulo 1.5.X並且更多取決於Thrift 0.9.0。 – elserj
除非要重新實現所有Java客戶端代碼,否則不應使用core/src/main/thrift中的節點IDL文件。這個答案應該指向proxy/src/main/thrift中的節儉代理IDL文件。這就是原來的海報似乎無論如何使用。還應該提到,應該真正啓動代理。 – Christopher
謝謝,克里斯托弗和elserj。根據需要編輯我的答案。 – JensG