static void Main(string[] args) { // Initialize log4net l4n.Config.XmlConfigurator.Configure(); // Create log var log = new LogEntry(); log.Category = "Program"; log.Message = "This is a test error message from the program"; // Connect var socket = new TSocket("192.168.1.144", 65510, 300); var transport = new TFramedTransport(socket); var protocol = new TBinaryProtocol(transport, false, false); var scribeClient = new scribe.Client(protocol); transport.Open(); // Send var logs = new List <LogEntry>(); logs.Add(log); var result = scribeClient.Log(logs); // Close transport.Close(); // use log4net to log var logger = l4n.LogManager.GetLogger("ScribeAppender.Test.Program"); logger.Debug("This is a test error message from the logger"); }
public async Task <Client> create_and_open(bool enableRPCCompression) { TcpClient tcp_client = new TcpClient(this.host, this.port); TSIService.Client client; long sessionId, statementId; var transport = new TFramedTransport(new TSocketTransport(tcp_client, null)); if (!transport.IsOpen) { try{ await transport.OpenAsync(new CancellationToken()); } catch (TTransportException) { throw; } } if (enableRPCCompression) { client = new TSIService.Client(new TCompactProtocol(transport)); } else { client = new TSIService.Client(new TBinaryProtocol(transport)); } var open_req = new TSOpenSessionReq(protocol_version, zoneId); open_req.Username = username; open_req.Password = password; try{ var open_resp = await client.openSessionAsync(open_req); if (open_resp.ServerProtocolVersion != protocol_version) { var message = String.Format("Protocol Differ, Client version is {0} but Server version is {1}", protocol_version, open_resp.ServerProtocolVersion); throw new TException(message, null); } if (open_resp.ServerProtocolVersion == 0) { throw new TException("Protocol not supported", null); } sessionId = open_resp.SessionId; statementId = await client.requestStatementIdAsync(sessionId); } catch (Exception) { transport.Close(); throw; } is_close = false; var return_client = new Client(); return_client.client = client; return_client.sessionId = sessionId; return_client.statementId = statementId; return_client.transport = transport; return(return_client); }
public static void Main(string[] args) { try { //Accumulo details String accumuloProxyServerIP = "192.168.1.44"; //IP int accumuloProxyServerPort = 42424; //Port Number //Connect to Accumulo proxy server 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); } //}} }
protected virtual void Dispose(bool disposing) { if (!_disposed) { if (disposing) { _transport.Close(); _transport.Dispose(); _transport = null; } } _disposed = true; }
static void Execute(int port) { try { TTransport trans; trans = new TSocket("localhost", port); trans = new TFramedTransport(trans); trans.Open(); TProtocol Protocol = new TBinaryProtocol(trans, true, true); TMultiplexedProtocol multiplex; multiplex = new TMultiplexedProtocol(Protocol, Constants.NAME_BENCHMARKSERVICE); BenchmarkService.Iface bench = new BenchmarkService.Client(multiplex); multiplex = new TMultiplexedProtocol(Protocol, Constants.NAME_AGGR); Aggr.Iface aggr = new Aggr.Client(multiplex); for (sbyte i = 1; 10 >= i; ++i) { aggr.addValue(bench.fibonacci(i)); } foreach (int k in aggr.getValues()) { Console.Write(k.ToString() + " "); Console.WriteLine(""); } trans.Close(); } catch (Exception e) { Console.WriteLine(e.Message); } }