Exemple #1
0
 private GatEvent BuildThriftEvent(IGatEvent evt)
 {
     GatEvent ret = new GatEvent();
     //required
     ret.Id = evt.Id;
     ret.Type = (Gat.Event.Thrift.GatEventType)(int)evt.Type;
     //optional
     if (evt.Catalog != null)
     {
         ret.Catalog = evt.Catalog;
     }
     if (evt.RowSet != null)
     {
         ret.RowSet = BuildThriftRowSet(evt.RowSet);
     }
     if (evt.Schema != null)
     {
         ret.Schema = evt.Schema;
     }
     if (evt.Sql != null)
     {
         ret.Sql = evt.Sql;
     }
     if (evt.Table != null)
     {
         ret.Table = evt.Table;
     }
     return ret;
 }
Exemple #2
0
 public RunnerDelegate PrepareAction(IGatEvent evt, bool forceClone)
 {
     //we clone anyways, regardless of whether forced since we go over the wire
     GatEvent clonedEvt = BuildThriftEvent(evt);
     TTransport transport = new TSocket(_host, _port);
     GatConsumer.Client client = new GatConsumer.Client(new TBinaryProtocol(transport));
     transport.Open();
     return new RunnerDelegate(delegate()
     {
         try
         {
             return new ThriftEventResponse(client.onEvent(clonedEvt));
         }
         finally
         {
             try { transport.Close(); }
             catch (Exception) { }
         }
     });
 }
Exemple #3
0
 public static IGatEventResponse RunSync(IAction action, IGatEvent evt)
 {
     return action.PrepareAction(evt, false).Invoke();
 }
Exemple #4
0
 public static void RunAsync(IAction action, IGatEvent evt)
 {
     action.PrepareAction(evt, true).BeginInvoke(null, null);
 }