public void submit(final EventHandler eh) { Executor executor = getExecutor(eh.getEventType().getExecutorServiceType()); if (executor == null) { // This happens only when events are submitted after shutdown() was // called, so dropping them should be "ok" since it means we're // shutting down. LOG.error("Cannot submit [" + eh + "] because the executor is missing." + " Is this process shutting down?"); } else { executor.submit(eh); } }
@Override public String toString() { return "Event #" + getSeqid() + " of type " + eventType + " (" + getInformativeName() + ")"; }
/** * Default prioritized runnable comparator which implements a FIFO ordering. * <p> * Subclasses should not override this. Instead, if they want to implement * priority beyond FIFO, they should override {@link #getPriority()}. */ @Override public int compareTo(Runnable o) { EventHandler eh = (EventHandler)o; if(getPriority() != eh.getPriority()) { return (getPriority() < eh.getPriority()) ? -1 : 1; } return (this.seqid < eh.seqid) ? -1 : 1; }
@Override public void run() { try (TraceScope scope = TraceUtil.createTrace(this.getClass().getSimpleName(), parent)) { process(); } catch(Throwable t) { handleException(t); } }
/** * Submit the event to the queue for handling. * @param event */ void submit(final EventHandler event) { // If there is a listener for this type, make sure we call the before // and after process methods. EventHandlerListener listener = this.eventHandlerListeners.get(event.getEventType()); if (listener != null) { event.setListener(listener); } this.threadPoolExecutor.execute(event); }
@Override public void run() { TraceScope chunk = Trace.startSpan(this.getClass().getSimpleName(), parent); try { if (getListener() != null) getListener().beforeProcess(this); process(); if (getListener() != null) getListener().afterProcess(this); } catch(Throwable t) { handleException(t); } finally { chunk.close(); } }
public void run() { try { if (getListener() != null) getListener().beforeProcess(this); process(); if (getListener() != null) getListener().afterProcess(this); } catch(Throwable t) { LOG.error("Caught throwable while processing event " + eventType, t); } }
@Override public String getInformativeName() { if (serverName != null) { return this.getClass().getSimpleName() + " for " + serverName; } else { return super.getInformativeName(); } }
@Override public TakeSnapshotHandler prepare() throws Exception { super.prepare(); // after this, you should ensure to release this lock in case of exceptions this.tableLock.acquire(); try { this.htd = loadTableDescriptor(); // check that .tableinfo is present } catch (Exception e) { this.tableLock.release(); throw e; } return this; }
/** * Submit the event to the queue for handling. * @param event */ void submit(final EventHandler event) { // If there is a listener for this type, make sure we call the before // and after process methods. EventHandlerListener listener = this.eventHandlerListeners.get(event.getEventType()); if (listener != null) { event.setListener(listener); } this.threadPoolExecutor.execute(event); }
public TakeSnapshotHandler prepare() throws Exception { super.prepare(); this.tableLock.acquire(); // after this, you should ensure to release this lock in // case of exceptions boolean success = false; try { this.htd = loadTableDescriptor(); // check that .tableinfo is present success = true; } finally { if (!success) { releaseTableLock(); } } return this; }
@Override public String toString() { return "Event #" + getSeqid() + " of type " + eventType + " (" + getInformativeName() + ")"; }
public void submit(final EventHandler eh) { Executor executor = getExecutor(getExecutorServiceType(eh.getEventType())); if (executor == null) { // This happens only when events are submitted after shutdown() was // called, so dropping them should be "ok" since it means we're // shutting down. LOG.error("Cannot submit [" + eh + "] because the executor is missing." + " Is this process shutting down?"); } else { executor.submit(eh); } }
/** * Default prioritized runnable comparator which implements a FIFO ordering. * <p> * Subclasses should not override this. Instead, if they want to implement * priority beyond FIFO, they should override {@link #getPriority()}. */ @Override public int compareTo(Runnable o) { EventHandler eh = (EventHandler)o; if(getPriority() != eh.getPriority()) { return (getPriority() < eh.getPriority()) ? -1 : 1; } return (this.seqid < eh.seqid) ? -1 : 1; }
@Override public String toString() { return "Event #" + getSeqid() + " of type " + eventType + " (" + getInformativeName() + ")"; }
public void submit(final EventHandler eh) { Executor executor = getExecutor(eh.getEventType().getExecutorServiceType()); if (executor == null) { // This happens only when events are submitted after shutdown() was // called, so dropping them should be "ok" since it means we're // shutting down. LOG.error("Cannot submit [" + eh + "] because the executor is missing." + " Is this process shutting down?"); } else { executor.submit(eh); } }
/** * Default prioritized runnable comparator which implements a FIFO ordering. * <p> * Subclasses should not override this. Instead, if they want to implement * priority beyond FIFO, they should override {@link #getPriority()}. */ @Override public int compareTo(Runnable o) { EventHandler eh = (EventHandler)o; if(getPriority() != eh.getPriority()) { return (getPriority() < eh.getPriority()) ? -1 : 1; } return (this.seqid < eh.seqid) ? -1 : 1; }