.
.
.
. :
Accumulo 1.5
Thrift 0.90
Mono 3.2.5
. /, Accumulo #:
API - Accumulo
. Accumulo Proxy #:
node Accumulo
1. Mono 3.2.5
2. Thrift 0.90
3. - Accumulo
$ACCUMULO_HOME/proxy/proxy.properties;
, zookeeper
4. - -
${ACCUMULO_HOME}/bin/accumulo proxy -p ${ACCUMULO_HOME}/proxy/proxy.properties
5.Generated #, IDL proxy.thrift
thrift --gen csharp $ACCUMULO_HOME/proxy/thrift/proxy.thrift
gen-csharp ${ACCUMULO_HOME}/proxy/thrift/
6. gen-csharp #, D .
7. Thrift.dll .
. # - Accumulo:
1. .
2. gen-csharp C5,
3. thrift.dll
4.
E. Accumulo #
#, / 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";
int accumuloProxyServerPort = 42424;
TTransport transport = new TSocket(accumuloProxyServerIP, accumuloProxyServerPort);
transport = new TFramedTransport(transport);
TCompactProtocol protocol = new TCompactProtocol(transport);
transport.Open();
String principal = "root";
Dictionary<string, string> passwd = new Dictionary<string,string>();
passwd.Add("password", "xxxxx");
AccumuloProxy.Client client = new AccumuloProxy.Client(protocol);
byte[] loginToken = client.login(principal, passwd);
var bScanner = new BatchScanOptions();
Range range = new Range();
range.Start = new Key();
range.Start.Row = GetBytes("d001");
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);
}
}
}
}