private TTransport CreateInstance()
        {
            TTransport transport = new TFramedTransport(new TSocket(Conf.TSeriviceHost, Conf.TServicePort));

            transport.Open();
            return(transport);
        }
Example #2
0
        public static void TestClient()
        {
            TTransport           transport = new TFramedTransport(new TSocket("localhost", 9090));
            TProtocol            protocol  = new TBinaryProtocol(transport);
            TMultiplexedProtocol mp        = new TMultiplexedProtocol(protocol, "search_service");

            SearchService.Client client = new SearchService.Client(mp);

            transport.Open();

            SearchRequest req = new SearchRequest();

            req.FileMask     = "*.bat";
            req.StartPath    = "c:\\";
            req.IgnoreErrors = true;
            var result = client.Search(req);

            Debug.WriteLine("P10");

            client.Delay1(2000);
            client.Delay2(1000);

            Task t1 = Task.Factory.StartNew(() => { Debug.WriteLine("T1:begin"); client.Delay1(2000); Debug.WriteLine("T1:end"); });
            Task t2 = Task.Factory.StartNew(() => { Debug.WriteLine("T2:begin"); client.Delay2(1000); Debug.WriteLine("T2:end"); });

            Debug.WriteLine("P20");

            t2.Wait();

            Debug.WriteLine("P30");

            t1.Wait();

            Debug.WriteLine("P40");
        }
Example #3
0
        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");
        }
Example #4
0
        protected virtual I ConnectClient(bool silent = false)
        {
            const int TIMEOUT = 15 * 1000;

            try
            {
                // try to connect this server using timeout
                if (!silent)
                {
                    Console.Write("Testing for server at {0}:{1} ... ", Server, Port);
                }
                using (var test = new TSocket(Server, Port, TIMEOUT))
                    test.Open();

                if (!silent)
                {
                    Console.WriteLine("OK", Server, Port);
                }
                var trans = new TFramedTransport(new TSocket(Server, Port, TIMEOUT));
                var proto = new TBinaryProtocol(trans);
                var mplex = new TMultiplexedProtocol(proto, MultiplexName());

                trans.Open();
                return(ClientFactory(mplex));
            }
            catch (Exception e)
            {
                Console.WriteLine("Machine {0} port {1}: {2}", Server, Port, e.Message);
            }

            throw new Exception(string.Format("{0}: Can't reach a server at {1}:{2} ... ", DateTime.UtcNow, Server, Port));
        }
Example #5
0
        public static Cassandra.Client GetWebClient()
        {
            var transport = new TFramedTransport(new TSocket("localhost", 9160));
            var client    = new Cassandra.Client(new TBinaryProtocol(transport));

            transport.Open();
            client.set_keyspace(_keySpace);
            return(client);
        }
Example #6
0
        protected RemoteController.Client CreateRemoteController()
        {
            TTransport transport = new TFramedTransport(new TSocket("localhost", 9701));

            transport.Open();
            TProtocol protocol = new TBinaryProtocol(transport);

            return(new ThreadSafeRemoteController(protocol));
        }
Example #7
0
        public override void Open(string hostname)
        {
            base.Open(hostname);

            TTransport transport = new TFramedTransport(new TSocket(hostname, 9160));
            TProtocol  protocol  = new TBinaryProtocol(transport);

            _client = new Cassandra.Client(protocol);

            transport.Open();
        }
Example #8
0
        public static Cassandra.Client GetClient(string keyspace, ref TTransport transport)
        {
            TTransport frameTransport = new TFramedTransport(new TSocket("localhost", 9160));
            TProtocol  frameProtocol  = new TBinaryProtocol(frameTransport);
            var        client         = new Cassandra.Client(frameProtocol, frameProtocol);

            frameTransport.Open();
            client.set_keyspace(keyspace);
            transport = frameTransport;
            return(client);
        }
Example #9
0
        public ThriftClient(string host, int port)
        {
            if (host == null)
            {
                throw new ArgumentNullException("host");
            }

            _transport = new TFramedTransport(new TSocket(host, port));
            TProtocol protocol = new TCompactProtocol(_transport);

            _client = new ThriftSourceProtocol.Client(protocol);
            _transport.Open();
        }
Example #10
0
        /// <summary>
        /// create an instance
        /// </summary>
        /// <returns></returns>
        private TTransport CreateInstance()
        {
            TSocket socket = new TSocket(config.Host, config.Port);

            if (config.Timeout > 0)
            {
                socket.Timeout = config.Timeout;
            }

            TTransport transport = new TFramedTransport(socket);

            transport.Open();
            return(transport);
        }
Example #11
0
 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);
     }
     //}}
 }
        private void Run()
        {
            try
            {
                TTransport trans;
                trans = new TSocket("localhost", 9090);
                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);

                sbyte i;
                for (i = 1; 10 >= i; ++i)
                {
                    aggr.addValue(bench.fibonacci(i));
                }

                foreach (int k in aggr.getValues())
                {
                    Console.Write(k + " ");
                    Console.WriteLine("");
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }
        }