예제 #1
0
 //Number of tries to attempt notification
 //Time (ms) to wait between retrying notification
 // Timeout (ms) on the connection and notification
 //URL to notify read from the config
 //Proxy to use for notification
 /// <summary>
 /// Parse the URL that needs to be notified of the end of the job, along
 /// with the number of retries in case of failure, the amount of time to
 /// wait between retries and proxy settings
 /// </summary>
 /// <param name="conf">the configuration</param>
 public virtual void SetConf(Configuration conf)
 {
     this.conf = conf;
     numTries  = Math.Min(conf.GetInt(MRJobConfig.MrJobEndRetryAttempts, 0) + 1, conf.GetInt
                              (MRJobConfig.MrJobEndNotificationMaxAttempts, 1));
     waitInterval = Math.Min(conf.GetInt(MRJobConfig.MrJobEndRetryInterval, 5000), conf
                             .GetInt(MRJobConfig.MrJobEndNotificationMaxRetryInterval, 5000));
     waitInterval = (waitInterval < 0) ? 5000 : waitInterval;
     timeout      = conf.GetInt(JobContext.MrJobEndNotificationTimeout, JobContext.DefaultMrJobEndNotificationTimeout
                                );
     userUrl   = conf.Get(MRJobConfig.MrJobEndNotificationUrl);
     proxyConf = conf.Get(MRJobConfig.MrJobEndNotificationProxy);
     //Configure the proxy to use if its set. It should be set like
     //proxyType@proxyHostname:port
     if (proxyConf != null && !proxyConf.Equals(string.Empty) && proxyConf.LastIndexOf
             (":") != -1)
     {
         int        typeIndex = proxyConf.IndexOf("@");
         Proxy.Type proxyType = Proxy.Type.Http;
         if (typeIndex != -1 && Sharpen.Runtime.Substring(proxyConf, 0, typeIndex).CompareToIgnoreCase
                 ("socks") == 0)
         {
             proxyType = Proxy.Type.Socks;
         }
         string hostname = Sharpen.Runtime.Substring(proxyConf, typeIndex + 1, proxyConf.LastIndexOf
                                                         (":"));
         string portConf = Sharpen.Runtime.Substring(proxyConf, proxyConf.LastIndexOf(":")
                                                     + 1);
         try
         {
             int port = System.Convert.ToInt32(portConf);
             proxyToUse = new Proxy(proxyType, new IPEndPoint(hostname, port));
             Org.Mortbay.Log.Log.Info("Job end notification using proxy type \"" + proxyType +
                                      "\" hostname \"" + hostname + "\" and port \"" + port + "\"");
         }
         catch (FormatException)
         {
             Org.Mortbay.Log.Log.Warn("Job end notification couldn't parse configured proxy's port "
                                      + portConf + ". Not going to use a proxy");
         }
     }
 }
예제 #2
0
 public Proxy(Proxy.Type prm1, SocketAddress prm2)
 {
 }