Ejemplo n.º 1
0
    internal static void ExecuteCommandEvent(string database, EventCommand waitingevent)
    {
      var store = new ObjectStoreWrapper(database);

      LogWriter.LogInformation("Executing waiting event", LogEntryType.Information);
      #region Execute inline global event handlers
      foreach (var ge in _globaleventhandlers)
      {
        try
        {
          if (ge != null) ge(store, waitingevent);
        }
        catch (Exception ex)
        {
          LogWriter.LogException(ex);
        }
      }
      #endregion

      var command = JObject.Parse(waitingevent.Command);

      var currenthandlers = ChechHandlers(command);
      if (currenthandlers != null)
        foreach (var hh in currenthandlers)
        {
          try
          {
            hh.HandleCommand(store, command);
          }
          catch (Exception ex)
          {
            LogWriter.LogException(ex);
          }
        }
    }
Ejemplo n.º 2
0
    public long LogCommand(EventCommand command)
    {
      lock (_filelock)
      {
        CommandSN++;
        if (Configuration.EnableJournaling)
          if (OpenLogFile())
          {
            // Writing the journal
            if (_ensureatomicwrites)
              _logfile.Flush();

            _logbuffer.Seek(0, SeekOrigin.Begin);
            _logbuffer.SetLength(0);

            _writer.Write('K');
            _writer.Write(CommandSN);
            _writer.Write(command.CommandMarker ?? string.Empty);
            _writer.Write('D');
            _writer.Write(command.Command);
            _writer.Flush();

            // this should be an atomic operation due to filestream flag used during open.
            _logfile.Write(_logbuffer.ToArray(), 0, (int)_logbuffer.Length);
            _logfile.Flush(_ensureatomicwrites);

            if (_logfile.Length - _logfile.Position < _logfilefreespace)
            {
              IncreaseFileSize();
            }
          }
      }
      return CommandSN;
    }
Ejemplo n.º 3
0
        public long LogCommand(EventCommand command)
        {
            lock (_filelock)
              {
            CommandSN++;
            if (Configuration.EnableJournaling)
              if (OpenLogFile())
              {
            // Writing the journal
            _writer.Write('K');
            _writer.Write(CommandSN);
            _writer.Write(command.CommandMarker ?? string.Empty);
            _writer.Write('D');
            _writer.Write((int)command.Command.Length);
            _writer.Write(command.Command);
            _writer.Flush();
            //_logfile.Flush();

            if (_logfile.Length - _logfile.Position < _logfilefreespace)
            {
              IncreaseFileSize();
            }
              }
              }
              return CommandSN;
        }
Ejemplo n.º 4
0
    public void GlobalEvent(EventMessage message)
    {
      var store = StoreManager.GetEventStore(message.Database);

      EventCommand cmd = new EventCommand() { Command = message.Command, CommandMarker = message.CommandMarker };
      cmd.SetMarker(P2PConfiguration.NoRedispatch);

      store.Enqueue(cmd);
    }
Ejemplo n.º 5
0
        public long Enqueue(EventCommand command)
        {
            var csn = _journal.LogCommand(command);
              command.CommandSN = csn;
              lock (_waitingevents)
            _waitingevents.Enqueue(command);

              CommandsReady.Set();

              return csn;
        }
Ejemplo n.º 6
0
 public long Enqueue(string command)
 {
   var cmd = new EventCommand() { Command = command };
   return Enqueue(cmd);
 }
Ejemplo n.º 7
0
 internal static void WriteCommand(BinaryWriter bw, EventCommand command)
 {
   bw.Write('K');
   bw.Write(command.CommandSN);
   bw.Write(command.CommandMarker ?? string.Empty);
   bw.Write('D');
   bw.Write(command.Command);
 }