Java Code Examples for com.alibaba.otter.canal.instance.core.CanalInstance#getEventSink()

The following examples show how to use com.alibaba.otter.canal.instance.core.CanalInstance#getEventSink() . 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 vote down vote up
@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 vote down vote up
@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: SinkCollector.java    From canal with Apache License 2.0 6 votes vote down vote up
@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 4
Source File: EntryCollector.java    From canal with Apache License 2.0 6 votes vote down vote up
@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 5
Source File: EntryCollector.java    From canal-1.1.3 with Apache License 2.0 5 votes vote down vote up
@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 6
Source File: EntryCollector.java    From canal with Apache License 2.0 5 votes vote down vote up
@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);
}