Insert the event in an ordered manner, if timestamp information is
available in this trace.

@param event
the event to be inserted.
@return index of the inserted event.
15992
public int insertOrdered(XEvent event) {
		try {
			return events.insertOrdered(event);
		} catch (IOException e) {
			e.printStackTrace();
			return -1;
		}
	}
1046716
@Override
  public  String getIndexName(Event event) {
    String realIndexPrefix = BucketPath.escapeString(event.getIndexPrefix() != null ? event.getIndexPrefix() : indexPrefix, event.getHeaders());
    if(event.getIndexTimestamp() != null){

      String indexName = new StringBuilder(realIndexPrefix).append('-')
              .append(event.getIndexTimestamp()).toString();
      if(logger.isDebugEnabled())
        logger.debug("Index Name = " + indexName);
      return indexName;
    }
    else {
      TimestampedEvent timestampedEvent = new TimestampedEvent(event);
      long timestamp = timestampedEvent.getTimestamp();
      String indexName = new StringBuilder(realIndexPrefix).append('-')
              .append(fastDateFormat.format(timestamp)).toString();
      if(logger.isDebugEnabled())
        logger.debug("Index Name = " + indexName);
      return indexName;
    }
  }
1152602
public double getValueAt(int index) {
		if(index <0 || index>=insertSeq.size())
			throw new IndexOutOfBoundsException();
		return insertSeq.get(index);
	}
530109
public void onGeometryIndexMarkForDeletionBegin(GeometryIndexMarkForDeletionBeginEvent event) {
		for (GeometryIndex index : event.getIndices()) {
			update(index, false);
		}
	}
343312
public synchronized void insert(XEvent event, int index)
			throws IndexOutOfBoundsException, IOException {
		if (index < 0 || index > size) {
			throw new IndexOutOfBoundsException();
		}
		// check if we can append
		if (index == size) {
			append(event);
			return;
		}
		// adjust size and overflow size
		size++;
		overflowSize++;
		// add to overflow set
		for (int i = overflowSize - 2; i >= 0; i--) {
			if (overflowIndices[i] >= index) {
				overflowIndices[i + 1] = overflowIndices[i] + 1;
				overflowEntries[i + 1] = overflowEntries[i];
			} else {
				overflowIndices[i + 1] = index;
				overflowEntries[i + 1] = event;
				if (overflowSize == overflowIndices.length) {
					consolidate();
				}
				return;
			}
		}
		// if we arrive here, we must insert at zero
		overflowIndices[0] = index;
		overflowEntries[0] = event;
		if (overflowSize == overflowIndices.length) {
			consolidate();
		}
	}
889289
public synchronized String doLayout(ILoggingEvent event) {

		// Reset working buffer. If the buffer is too large, then we need a new
		// one in order to avoid the penalty of creating a large array.
		if (buf.capacity() > UPPER_LIMIT) {
			buf = new StringBuilder(DEFAULT_SIZE);
		} else {
			buf.setLength(0);
		}

		Map<String, String> mdc = event.getMDCPropertyMap();
		buf.append("{");
		appendKeyValue(buf, "source", source, mdc);
		buf.append(COMMA);
		appendKeyValue(buf, "host", sourceHost, mdc);
		buf.append(COMMA);
		appendKeyValue(buf, "path", sourcePath, mdc);
		buf.append(COMMA);
		appendKeyValue(buf, "type", type, mdc);
		buf.append(COMMA);
		appendKeyValue(buf, "tags", tags, mdc);
		buf.append(COMMA);
		appendKeyValue(buf, "message", event.getFormattedMessage(), null);
		buf.append(COMMA);
		appendKeyValue(buf, "@timestamp",
				df.format(new Date(event.getTimeStamp())), null);
		buf.append(COMMA);

		// ---- fields ----
		appendKeyValue(buf, "logger", event.getLoggerName(), null);
		buf.append(COMMA);
		appendKeyValue(buf, "level", event.getLevel().toString(), null);
		buf.append(COMMA);
		appendKeyValue(buf, "thread", event.getThreadName(), null);
		IThrowableProxy tp = event.getThrowableProxy();
		if (tp != null) {
			buf.append(COMMA);
			String throwable = ThrowableProxyUtil.asString(tp);
			appendKeyValue(buf, "throwable", throwable, null);
		}
		if (locationInfo) {
			StackTraceElement[] callerDataArray = event.getCallerData();
			if (callerDataArray != null
					&& callerDataArray.length > callerStackIdx) {
				buf.append(COMMA);
				buf.append("\"location\":{");
				StackTraceElement immediateCallerData = callerDataArray[callerStackIdx];
				appendKeyValue(buf, "class",
						immediateCallerData.getClassName(), null);
				buf.append(COMMA);
				appendKeyValue(buf, "method",
						immediateCallerData.getMethodName(), null);
				buf.append(COMMA);
				appendKeyValue(buf, "file", immediateCallerData.getFileName(),
						null);
				buf.append(COMMA);
				appendKeyValue(buf, "line",
						Integer.toString(immediateCallerData.getLineNumber()),
						null);
				buf.append("}");
			}
		}

		/*
		 * <log4j:properties> <log4j:data name="name" value="value"/>
		 * </log4j:properties>
		 */
		if (properties) {
			Map<String, String> propertyMap = event.getMDCPropertyMap();
			if ((propertyMap != null) && (propertyMap.size() != 0)) {
				Set<Entry<String, String>> entrySet = propertyMap.entrySet();
				buf.append(COMMA);
				buf.append("\"properties\":{");
				Iterator<Entry<String, String>> i = entrySet.iterator();
				while (i.hasNext()) {
					Entry<String, String> entry = i.next();
					appendKeyValue(buf, entry.getKey(), entry.getValue(), null);
					if (i.hasNext()) {
						buf.append(COMMA);
					}
				}
				buf.append("}");
			}
		}

		if(additionalFields != null) {
			for(AdditionalField field : additionalFields) {
				buf.append(COMMA);
				appendKeyValue(buf, field.getKey(), field.getValue(), mdc);
			}
		}

		buf.append("}");

		return buf.toString();
	}
686982
public synchronized void addEvent(WorkManagerEvent event)
   {
      if (trace)
         log.tracef("addEvent(%s)", event);

      List<WorkManagerEvent> e = events.get(event.getAddress().getWorkManagerName());

      if (e == null)
      {
         e = new ArrayList<WorkManagerEvent>();
         events.put(event.getAddress().getWorkManagerName(), e);
      }

      e.add(event);
   }
752805
@SuppressWarnings("PMD.SwitchStmtsShouldHaveDefault")
  public void dispatch(@NonNull JCacheEntryEvent<K, V> event) {
    try {
      if (event.getSource().isClosed()) {
        return;
      }
      switch (event.getEventType()) {
        case CREATED:
          onCreated(event);
          return;
        case UPDATED:
          onUpdated(event);
          return;
        case REMOVED:
          onRemoved(event);
          return;
        case EXPIRED:
          onExpired(event);
          return;
      }
      throw new IllegalStateException("Unknown event type: " + event.getEventType());
    } catch (Exception e) {
      logger.log(Level.WARNING, null, e);
    } catch (Throwable t) {
      logger.log(Level.SEVERE, null, t);
    }
  }
973399
public boolean add(XEvent event) {
		try {
			events.append(event);
		} catch (IOException e) {
			e.printStackTrace();
			return false;
		}
		return true;
	}
944993
public Date extractTimestamp(XEvent event) {
		XAttributeTimestamp timestampAttribute = (XAttributeTimestamp) event
				.getAttributes().get(KEY_TIMESTAMP);
		if (timestampAttribute == null) {
			return null;
		} else {
			return timestampAttribute.getValue();
		}
	}
226663
private LoggingEvent appendStackTraceToEvent(final LoggingEvent event) {
    String message = event.getMessage().toString();
    // If there is a stack trace available, print it out
    if (event.getThrowableInformation() != null) {
      final String[] s = event.getThrowableStrRep();
      for (final String line : s) {
        message += "\n" + line;
      }
    }
    message = message
        .replace("\\", "\\\\")
        .replace("\n", "\\n")
        .replace("\"", "\\\"")
        .replace("\t", "\\t");

    final Throwable throwable = event.getThrowableInformation() == null ? null
        : event.getThrowableInformation().getThrowable();
    return new LoggingEvent(event.getFQNOfLoggerClass(),
        event.getLogger(),
        event.getTimeStamp(),
        event.getLevel(),
        message,
        throwable);
  }
815161
@Override
    public void add(Event event) {
        if (getNumStoredEvents() >= maxEvents) {
            logger.warn("Not adding Event because at least "
                + Integer.toString(maxEvents) + " events are already stored: " + event.getId());
            return;
        }

        File eventFile = new File(bufferDir.getAbsolutePath(), event.getId().toString() + FILE_SUFFIX);
        if (eventFile.exists()) {
            logger.trace("Not adding Event to offline storage because it already exists: "
                + eventFile.getAbsolutePath());
            return;
        } else {
            logger.debug("Adding Event to offline storage: " + eventFile.getAbsolutePath());
        }

        try (FileOutputStream fileOutputStream = new FileOutputStream(eventFile);
             ObjectOutputStream objectOutputStream = new ObjectOutputStream(fileOutputStream)) {
            objectOutputStream.writeObject(event);
        } catch (Exception e) {
            logger.error("Error writing Event to offline storage: " + event.getId(), e);
        }

        logger.debug(Integer.toString(getNumStoredEvents())
            + " stored events are now in dir: "
            + bufferDir.getAbsolutePath());
    }
1179582
private void onInsert(EventLog log)
    {
        if (insertEvents == null)
        {
            insertEvents = new ConcurrentHashMap<Object, EventLog>();
        }

        insertEvents.put(log.getEntityId(), log);

    }
253690
@CacheEntryModified
   public void cacheEntryModified(CacheEntryModifiedEvent<Serializable, Object> event)
   {
      if (!event.isPre() && event.getKey().equals(updateKey))
      {
         Object value = event.getValue();
         localUpdateInProgress = value != null ? (Boolean)value : false;

         for (IndexUpdateMonitorListener listener : listeners)
         {
            listener.onUpdateInProgressChange(localUpdateInProgress);
         }
      }
   }
1285796
public void handleEvent(Event event) {
        String topic = event.getTopic();
        if (topic.equals(TOPIC_QUEUED_WORK_NAME)) {
            Runnable r = event.getProperty(KEY_RUNNABLE, Runnable.class);
            if (null != r) {
                r.run();
            } else {
                if (TraceComponent.isAnyTracingEnabled() && tc.isEventEnabled()) {
                    Tr.event(tc, "Unable to find runnable in event; " + topic);
                }
            }
        }
    }
1177
public EventDetails withEventMetadata(java.util.Map<String, String> eventMetadata) {
        setEventMetadata(eventMetadata);
        return this;
    }
1061526
def PushEvent(self, event):
    
    event_string = event.GetAttributeValuesString()
    heap_values = (event.timestamp, event.timestamp_desc, event_string, event)
    heapq.heappush(self._heap, heap_values)