当前位置: 首页>>代码示例>>C#>>正文


C# Protocol.TBinaryProtocol类代码示例

本文整理汇总了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();
        }
开发者ID:amwtke,项目名称:elastic-log4net-thrift-test,代码行数:30,代码来源:Program.cs

示例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);
 }
开发者ID:evernote,项目名称:evernote-demo-metro,代码行数:7,代码来源:Wrapper.cs

示例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");
                }
            }
        }
开发者ID:acesir,项目名称:hdfs-daemon,代码行数:34,代码来源:Main.aspx.cs

示例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;
        }
开发者ID:codesharp,项目名称:HtmlAbbreviation,代码行数:25,代码来源:DefaultEverNoteService.cs

示例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);
            }

        }
开发者ID:ConfusedReality,项目名称:pkg_serialization_thrift,代码行数:60,代码来源:CsharpClient.cs

示例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();
        }
开发者ID:zbw911,项目名称:CS4Hadoop,代码行数:25,代码来源:Program.cs

示例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");
        }
开发者ID:bowlofstew,项目名称:log4net-4-scribe,代码行数:29,代码来源:Program.cs

示例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;
        }
开发者ID:HappiestTeam,项目名称:Spikes,代码行数:25,代码来源:DefaultTransportConnectionFactory.cs

示例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;
            }
开发者ID:sidshetye,项目名称:SerializersCompare,代码行数:34,代码来源:ThriftClientServerExpt.cs

示例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;
        }
开发者ID:HappiestTeam,项目名称:Spikes,代码行数:35,代码来源:BufferedTransportConnectionFactory.cs

示例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 );
 }
开发者ID:kmurray-bluevenn,项目名称:Research,代码行数:7,代码来源:JobInfo.cs

示例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();
        }
开发者ID:gongice,项目名称:ddu,代码行数:30,代码来源:CassandraClient.cs

示例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;
        }
开发者ID:HappiestTeam,项目名称:Spikes,代码行数:30,代码来源:BufferedTransportConnectionFactory.cs

示例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;

               }
        }
开发者ID:cvs1989,项目名称:hooyeswidget,代码行数:35,代码来源:HdfsClient.cs

示例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();
 }
开发者ID:shshen,项目名称:bigqueue,代码行数:7,代码来源:Program.cs


注:本文中的Thrift.Protocol.TBinaryProtocol类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。