com.alibaba.otter.canal.sink.entry.EntryEventSink Java Examples
The following examples show how to use
com.alibaba.otter.canal.sink.entry.EntryEventSink.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SinkCollector.java From canal-1.1.3 with Apache License 2.0 | 6 votes |
@Override public void register(CanalInstance instance) { final String destination = instance.getDestination(); SinkMetricsHolder holder = new SinkMetricsHolder(); holder.destLabelValues = Collections.singletonList(destination); CanalEventSink sink = instance.getEventSink(); if (!(sink instanceof EntryEventSink)) { throw new IllegalArgumentException("CanalEventSink must be EntryEventSink"); } EntryEventSink entrySink = (EntryEventSink) sink; holder.eventsSinkBlockingTime = entrySink.getEventsSinkBlockingTime(); Preconditions.checkNotNull(holder.eventsSinkBlockingTime); SinkMetricsHolder old = instances.put(destination, holder); if (old != null) { logger.warn("Remote stale SinkCollector for instance {}.", destination); } }
Example #2
Source File: EntryCollector.java From canal-1.1.3 with Apache License 2.0 | 6 votes |
@Override public void register(CanalInstance instance) { final String destination = instance.getDestination(); EntryMetricsHolder holder = new EntryMetricsHolder(); holder.destLabelValues = Collections.singletonList(destination); CanalEventSink sink = instance.getEventSink(); if (!(sink instanceof EntryEventSink)) { throw new IllegalArgumentException("CanalEventSink must be EntryEventSink"); } EntryEventSink entrySink = (EntryEventSink) sink; PrometheusCanalEventDownStreamHandler handler = assembleHandler(entrySink); holder.latestExecTime = handler.getLatestExecuteTime(); holder.transactionCounter = handler.getTransactionCounter(); Preconditions.checkNotNull(holder.latestExecTime); Preconditions.checkNotNull(holder.transactionCounter); EntryMetricsHolder old = instances.put(destination, holder); if (old != null) { logger.warn("Remove stale EntryCollector for instance {}.", destination); } }
Example #3
Source File: EntryCollector.java From canal-1.1.3 with Apache License 2.0 | 6 votes |
private void unloadHandler(EntryEventSink entrySink) { List<CanalEventDownStreamHandler> handlers = entrySink.getHandlers(); int i = 0; for (; i < handlers.size(); i++) { if (handlers.get(i) instanceof PrometheusCanalEventDownStreamHandler) { break; } } entrySink.removeHandler(i); // Ensure no PrometheusCanalEventDownStreamHandler handlers = entrySink.getHandlers(); for (CanalEventDownStreamHandler handler : handlers) { if (handler instanceof PrometheusCanalEventDownStreamHandler) { throw new IllegalStateException("Multiple prometheusCanalEventDownStreamHandler exists in handlers."); } } }
Example #4
Source File: SinkCollector.java From canal with Apache License 2.0 | 6 votes |
@Override public void register(CanalInstance instance) { final String destination = instance.getDestination(); SinkMetricsHolder holder = new SinkMetricsHolder(); holder.destLabelValues = Collections.singletonList(destination); CanalEventSink sink = instance.getEventSink(); if (!(sink instanceof EntryEventSink)) { throw new IllegalArgumentException("CanalEventSink must be EntryEventSink"); } EntryEventSink entrySink = (EntryEventSink) sink; holder.eventsSinkBlockingTime = entrySink.getEventsSinkBlockingTime(); Preconditions.checkNotNull(holder.eventsSinkBlockingTime); SinkMetricsHolder old = instances.put(destination, holder); if (old != null) { logger.warn("Remote stale SinkCollector for instance {}.", destination); } }
Example #5
Source File: EntryCollector.java From canal with Apache License 2.0 | 6 votes |
@Override public void register(CanalInstance instance) { final String destination = instance.getDestination(); EntryMetricsHolder holder = new EntryMetricsHolder(); holder.destLabelValues = Collections.singletonList(destination); CanalEventSink sink = instance.getEventSink(); if (!(sink instanceof EntryEventSink)) { throw new IllegalArgumentException("CanalEventSink must be EntryEventSink"); } EntryEventSink entrySink = (EntryEventSink) sink; PrometheusCanalEventDownStreamHandler handler = assembleHandler(entrySink); holder.latestExecTime = handler.getLatestExecuteTime(); holder.transactionCounter = handler.getTransactionCounter(); Preconditions.checkNotNull(holder.latestExecTime); Preconditions.checkNotNull(holder.transactionCounter); EntryMetricsHolder old = instances.put(destination, holder); if (old != null) { logger.warn("Remove stale EntryCollector for instance {}.", destination); } }
Example #6
Source File: EntryCollector.java From canal with Apache License 2.0 | 6 votes |
private void unloadHandler(EntryEventSink entrySink) { List<CanalEventDownStreamHandler> handlers = entrySink.getHandlers(); int i = 0; for (; i < handlers.size(); i++) { if (handlers.get(i) instanceof PrometheusCanalEventDownStreamHandler) { break; } } entrySink.removeHandler(i); // Ensure no PrometheusCanalEventDownStreamHandler handlers = entrySink.getHandlers(); for (CanalEventDownStreamHandler handler : handlers) { if (handler instanceof PrometheusCanalEventDownStreamHandler) { throw new IllegalStateException("Multiple prometheusCanalEventDownStreamHandler exists in handlers."); } } }
Example #7
Source File: EntryCollector.java From canal-1.1.3 with Apache License 2.0 | 5 votes |
@Override public void unregister(CanalInstance instance) { final String destination = instance.getDestination(); CanalEventSink sink = instance.getEventSink(); if (!(sink instanceof EntryEventSink)) { throw new IllegalArgumentException("CanalEventSink must be EntryEventSink"); } unloadHandler((EntryEventSink) sink); instances.remove(destination); }
Example #8
Source File: EntryCollector.java From canal-1.1.3 with Apache License 2.0 | 5 votes |
private PrometheusCanalEventDownStreamHandler assembleHandler(EntryEventSink entrySink) { PrometheusCanalEventDownStreamHandler ph = new PrometheusCanalEventDownStreamHandler(); List<CanalEventDownStreamHandler> handlers = entrySink.getHandlers(); for (CanalEventDownStreamHandler handler : handlers) { if (handler instanceof PrometheusCanalEventDownStreamHandler) { throw new IllegalStateException("PrometheusCanalEventDownStreamHandler already exists in handlers."); } } entrySink.addHandler(ph, 0); return ph; }
Example #9
Source File: EntryCollector.java From canal with Apache License 2.0 | 5 votes |
@Override public void unregister(CanalInstance instance) { final String destination = instance.getDestination(); CanalEventSink sink = instance.getEventSink(); if (!(sink instanceof EntryEventSink)) { throw new IllegalArgumentException("CanalEventSink must be EntryEventSink"); } unloadHandler((EntryEventSink) sink); instances.remove(destination); }
Example #10
Source File: EntryCollector.java From canal with Apache License 2.0 | 5 votes |
private PrometheusCanalEventDownStreamHandler assembleHandler(EntryEventSink entrySink) { PrometheusCanalEventDownStreamHandler ph = new PrometheusCanalEventDownStreamHandler(); List<CanalEventDownStreamHandler> handlers = entrySink.getHandlers(); for (CanalEventDownStreamHandler handler : handlers) { if (handler instanceof PrometheusCanalEventDownStreamHandler) { throw new IllegalStateException("PrometheusCanalEventDownStreamHandler already exists in handlers."); } } entrySink.addHandler(ph, 0); return ph; }