本文整理汇总了C#中Thrift.Protocol.TBinaryProtocol类的典型用法代码示例。如果您正苦于以下问题:C# TBinaryProtocol类的具体用法?C# TBinaryProtocol怎么用?C# TBinaryProtocol使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
TBinaryProtocol类属于Thrift.Protocol命名空间,在下文中一共展示了TBinaryProtocol类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Main
static void Main(string[] args)
{
MessageObject mo1 = new MessageObject{TimeStamp = DateTime.Now, Message="begin process...."};
LogHelper.WriteLogInfo(typeof(Program), mo1);
TTransport transport = new TSocket("localhost", 7911);
TProtocol protocol = new TBinaryProtocol(transport);
ThriftCase.Client client = new ThriftCase.Client(protocol);
transport.Open();
Console.WriteLine("Client calls .....");
map.Add("blog", "http://www.javabloger.com");
client.testCase1(10, 21, "3");
client.testCase2(map);
client.testCase3();
Blog blog = new Blog();
//blog.setContent("this is blog content".getBytes());
blog.CreatedTime = DateTime.Now.Ticks;
blog.Id = "123456";
blog.IpAddress = "127.0.0.1";
blog.Topic = "this is blog topic";
blogs.Add(blog);
client.testCase4(blogs);
transport.Close();
//LogHelper.WriteLog(typeof(Program), "end process......");
Console.ReadKey();
}
示例2: Wrapper
public Wrapper()
{
Uri userStoreUrl = new Uri("https://" + evernoteHost + "/edam/user");
TTransport userStoreTransport = new THttpClient(userStoreUrl);
TProtocol userStoreProtocol = new TBinaryProtocol(userStoreTransport);
userStore = new UserStore.Client(userStoreProtocol);
}
示例3: GetHBaseImage
public void GetHBaseImage(string rowKey = "20150822180801118")
{
var socket = new TSocket(hbaseThrif, hbaseThrifPort);
var transport = new TBufferedTransport(socket);
var protocol = new TBinaryProtocol(transport);
Hbase.Client hbaseClient = new Hbase.Client(protocol);
transport.Open();
//List<byte[]> tableNames = hc.getTableNames();
byte[] table = Encoding.UTF8.GetBytes("FiservImages");
byte[] row = Encoding.UTF8.GetBytes(rowKey);
byte[] column = Encoding.UTF8.GetBytes("ImageData:Image");
List<TRowResult> results = hbaseClient.getRow(table, row, null);
TCell t = new TCell();
//t.
foreach (TRowResult result in results)
{
//result.Columns[column]
//result.Columns;
Dictionary<byte[], TCell> konj;
konj = result.Columns;
//string s = Encoding.UTF8.GetString(result.Columns[column].Value);
foreach (KeyValuePair<byte[], TCell> singleRow in konj)
{
//File.WriteAllBytes(@"c:\test\output.docx", singleRow.Value.Value);
OpenFile(singleRow.Value.Value, "output.docx");
}
}
}
示例4: GetDefaultNoteBookNotes
public IEnumerable<EverNote> GetDefaultNoteBookNotes(string authToken)
{
var noteStoreUrl = GetNoteStoreUrl(authToken);
var transport = new THttpClient(new Uri(noteStoreUrl));
var protocol = new TBinaryProtocol(transport);
var noteStore = new NoteStore.Client(protocol);
var notes = new List<EverNote>();
var notebooks = noteStore.listNotebooks(authToken);
foreach (Notebook notebook in notebooks)
{
if (notebook.DefaultNotebook)
{
var findResult = noteStore.findNotes(authToken, new NoteFilter { NotebookGuid = notebook.Guid }, 0, int.MaxValue);
foreach (var note in findResult.Notes)
{
notes.Add(new EverNote(note.Guid, note.Title));
}
break;
}
}
return notes;
}
示例5: Main
public static void Main()
{
try
{
TTransport transport = new TSocket("localhost", 9090);
TProtocol protocol = new TBinaryProtocol(transport);
Calculator.Client client = new Calculator.Client(protocol);
transport.Open();
try
{
client.ping();
Console.WriteLine("ping()");
int sum = client.add(1, 1);
Console.WriteLine("1+1={0}", sum);
Work work = new Work();
work.Op = Operation.DIVIDE;
work.Num1 = 1;
work.Num2 = 0;
try
{
int quotient = client.calculate(1, work);
Console.WriteLine("Whoa we can divide by 0");
}
catch (InvalidOperation io)
{
Console.WriteLine("Invalid operation: " + io.Why);
}
work.Op = Operation.SUBTRACT;
work.Num1 = 15;
work.Num2 = 10;
try
{
int diff = client.calculate(1, work);
Console.WriteLine("15-10={0}", diff);
}
catch (InvalidOperation io)
{
Console.WriteLine("Invalid operation: " + io.Why);
}
SharedStruct log = client.getStruct(1);
Console.WriteLine("Check log: {0}", log.Value);
}
finally
{
transport.Close();
}
}
catch (TApplicationException x)
{
Console.WriteLine(x.StackTrace);
}
}
示例6: query
public static void query()
{
var transport = new TBufferedTransport(new TSocket("hserver", 10000));
var protocol = new TBinaryProtocol(transport);
var client = new ThriftHive.Client(protocol);
transport.Open();
//client.execute("CREATE TABLE r(a STRING, b INT, c DOUBLE)");
//client.execute("LOAD TABLE LOCAL INPATH '/path' INTO TABLE r");
client.execute("SELECT * FROM pokes where foo=180");
while (true)
{
var row = client.fetchOne();
if (string.IsNullOrEmpty(row))
break;
System.Console.WriteLine(row);
}
client.execute("SELECT * FROM pokes");
var all = client.fetchAll();
System.Console.WriteLine(all);
transport.Close();
}
示例7: Main
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");
}
示例8: Create
public IClient Create(IEndpoint endpoint, IClientPool ownerPool)
{
TSocket socket = null;
if (endpoint.Timeout == 0)
{
socket = new TSocket(endpoint.Address, endpoint.Port);
}
else
{
socket = new TSocket(endpoint.Address, endpoint.Port, endpoint.Timeout);
}
TcpClient tcpClient = socket.TcpClient;
TProtocol protocol = new TBinaryProtocol(socket);
CassandraClient cassandraClient = new CassandraClient(protocol);
IClient client = new DefaultClient()
{
CassandraClient = cassandraClient,
Endpoint = endpoint,
OwnerPool = ownerPool,
TcpClient = tcpClient,
Created = DateTime.Now
};
return client;
}
示例9: Run
public int Run()
{
int c = 0;
try
{
TTransport transport = new TSocket(Host, Port);
TProtocol protocol = new TBinaryProtocol(transport);
var client = new MultiplicationService.Client(protocol);
Console.WriteLine("Thrift client opening transport to {0} on port {1} ...", Host, Port);
transport.Open();
int a, b;
Console.Write("Enter 1st integer : ");
int.TryParse(Console.ReadLine(), out a);
Console.Write("Enter 2nd integer : ");
int.TryParse(Console.ReadLine(), out b);
c = client.multiply(a, b);
Console.WriteLine("{0} x {1} = {2}", a, b, c);
Console.WriteLine("Thrift client closing transport ...");
transport.Close();
}
catch (TApplicationException x)
{
Console.WriteLine(x.StackTrace);
}
return c;
}
示例10: Create
public IClient Create(IEndpoint endpoint, IClientPool ownerPool)
{
TSocket socket = null;
TTransport transport = null;
if (endpoint.Timeout == 0)
{
socket = new TSocket(endpoint.Address, endpoint.Port);
}
else
{
socket = new TSocket(endpoint.Address, endpoint.Port, endpoint.Timeout);
}
TcpClient tcpClient = socket.TcpClient;
if (this.isBufferSizeSet)
{
transport = new TBufferedTransport(socket, this.bufferSize);
}
else
{
transport = new TBufferedTransport(socket);
}
TProtocol protocol = new TBinaryProtocol(transport);
CassandraClient cassandraClient = new CassandraClient(protocol);
IClient client = new DefaultClient() {
CassandraClient = cassandraClient,
Endpoint = endpoint,
OwnerPool = ownerPool,
TcpClient = tcpClient,
Created = DateTime.Now
};
return client;
}
示例11: btnExit_Click
private void btnExit_Click( object sender, EventArgs e )
{
TTransport trans = OpenTransport();
TBinaryProtocol binaryProtocol = new TBinaryProtocol( trans );
DataProvider.Client client = new DataProvider.Client( binaryProtocol );
client.DeleteJob( m_JobNumber );
}
示例12: Main
static void Main(string[] args)
{
//�������ݿ�����
TTransport transport = new TSocket("192.168.10.2", 9160);
TProtocol protocol = new TBinaryProtocol(transport);
Cassandra.Client client = new Cassandra.Client(protocol);
transport.Open();
System.Text.Encoding utf8Encoding = System.Text.Encoding.UTF8;
long timeStamp = DateTime.Now.Millisecond;
ColumnPath nameColumnPath = new ColumnPath()
{
Column_family = "Standard1",
Column = utf8Encoding.GetBytes("age")
};
//�����
client.insert("Keyspace1",
"studentA",
nameColumnPath,
utf8Encoding.GetBytes("18"),
timeStamp,
ConsistencyLevel.ONE);
//��ȡ����
ColumnOrSuperColumn returnedColumn = client.get("Keyspace1", "studentA", nameColumnPath, ConsistencyLevel.ONE);
Console.WriteLine("Keyspace1/Standard1: age: {0}, value: {1}", utf8Encoding.GetString(returnedColumn.Column.Name), utf8Encoding.GetString(returnedColumn.Column.Value));
//�ر�����
transport.Close();
}
示例13: Create
public CassandraClient Create(CassandraEndpoint endpoint)
{
TSocket socket = null;
TTransport transport = null;
if (endpoint.Timeout == 0)
{
socket = new TSocket(endpoint.Address, endpoint.Port);
}
else
{
socket = new TSocket(endpoint.Address, endpoint.Port, endpoint.Timeout);
}
if (this.isBufferSizeSet)
{
transport = new TBufferedTransport(socket, this.bufferSize);
}
else
{
transport = new TBufferedTransport(socket);
}
TProtocol protocol = new TBinaryProtocol(transport);
Cassandra.Client cassandraClient = new Cassandra.Client(protocol);
CassandraClient client = new CassandraClient(cassandraClient, endpoint);
this.logger.Debug(logger.StringFormatInvariantCulture("Created a new connection using: '{0}'", endpoint.ToString()));
return client;
}
示例14: Connect
//获取连接
public ThriftHadoopFileSystem.Client Connect(out TBufferedTransport tsport)
{
if (HostServer == null)
{
throw new ArgumentNullException("HostServer");
}
if (Port == 0)
{
throw new ArgumentNullException("Port");
}
TSocket hadoop_socket = new TSocket(HostServer, Port);
//hadoop_socket.Timeout = 10000;// Ten seconds
tsport = new TBufferedTransport(hadoop_socket);
TBinaryProtocol hadoop_protocol = new TBinaryProtocol(tsport, false, false);
ThriftHadoopFileSystem.Client client = new ThriftHadoopFileSystem.Client(hadoop_protocol);
try
{
tsport.Open();
return client;
}
catch (Exception ex)
{
//throw (new Exception("打开连接失败!", ex));
tsport = null;
return null;
}
}
示例15: initClient
private void initClient()
{
transport = new TFramedTransport(new TSocket(SERVER_IP, SERVER_PORT, TIME_OUT));
TProtocol protocol = new TBinaryProtocol(transport);
client = new BigQueueService.Client(protocol);
transport.Open();
}