Ejemplo n.º 1
0
        /// <exception cref="System.Exception"/>
        public virtual int Run(string[] argv)
        {
            List <string> args = new List <string>();

            foreach (string arg in argv)
            {
                args.AddItem(arg);
            }
            if (StringUtils.PopOption("-h", args) || StringUtils.PopOption("-help", args))
            {
                Usage();
                return(0);
            }
            else
            {
                if (args.Count == 0)
                {
                    Usage();
                    return(0);
                }
            }
            string hostPort = StringUtils.PopOptionWithArgument("-host", args);

            if (hostPort == null)
            {
                System.Console.Error.WriteLine("You must specify a host with -host.");
                return(1);
            }
            if (args.Count < 0)
            {
                System.Console.Error.WriteLine("You must specify an operation.");
                return(1);
            }
            RPC.SetProtocolEngine(GetConf(), typeof(TraceAdminProtocolPB), typeof(ProtobufRpcEngine
                                                                                  ));
            IPEndPoint           address = NetUtils.CreateSocketAddr(hostPort);
            UserGroupInformation ugi     = UserGroupInformation.GetCurrentUser();
            Type xface = typeof(TraceAdminProtocolPB);

            proxy = (TraceAdminProtocolPB)RPC.GetProxy(xface, RPC.GetProtocolVersion(xface),
                                                       address, ugi, GetConf(), NetUtils.GetDefaultSocketFactory(GetConf()), 0);
            remote = new TraceAdminProtocolTranslatorPB(proxy);
            try
            {
                if (args[0].Equals("-list"))
                {
                    return(ListSpanReceivers(args.SubList(1, args.Count)));
                }
                else
                {
                    if (args[0].Equals("-add"))
                    {
                        return(AddSpanReceiver(args.SubList(1, args.Count)));
                    }
                    else
                    {
                        if (args[0].Equals("-remove"))
                        {
                            return(RemoveSpanReceiver(args.SubList(1, args.Count)));
                        }
                        else
                        {
                            System.Console.Error.WriteLine("Unrecognized tracing command: " + args[0]);
                            System.Console.Error.WriteLine("Use -help for help.");
                            return(1);
                        }
                    }
                }
            }
            finally
            {
                remote.Close();
            }
        }
Ejemplo n.º 2
0
 public TraceAdminProtocolTranslatorPB(TraceAdminProtocolPB rpcProxy)
 {
     this.rpcProxy = rpcProxy;
 }