com.alibaba.otter.canal.sink.CanalEventSink Java Examples

The following examples show how to use com.alibaba.otter.canal.sink.CanalEventSink. 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: 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 #2
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 #3
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 #4
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 #5
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);
}
 
Example #6
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 #7
Source File: GatewayEventSink.java    From DataLink with Apache License 2.0 4 votes vote down vote up
public void registerEventSink(String destination, CanalEventSink eventSink) {
    this.attachedEventSinks.put(destination, eventSink);
    logger.info("registered an event sink from endpoint instance {}.", destination);
}
 
Example #8
Source File: AbstractEventParser.java    From canal with Apache License 2.0 4 votes vote down vote up
public void setEventSink(CanalEventSink<List<CanalEntry.Entry>> eventSink) {
    this.eventSink = eventSink;
}
 
Example #9
Source File: AbstractCanalInstance.java    From canal with Apache License 2.0 4 votes vote down vote up
@Override
public CanalEventSink getEventSink() {
    return eventSink;
}
 
Example #10
Source File: CanalInstanceWithSpring.java    From canal with Apache License 2.0 4 votes vote down vote up
public void setEventSink(CanalEventSink<List<CanalEntry.Entry>> eventSink) {
    this.eventSink = eventSink;
}
 
Example #11
Source File: AbstractEventParser.java    From DBus with Apache License 2.0 4 votes vote down vote up
public void setEventSink(CanalEventSink<List<CanalEntry.Entry>> eventSink) {
    this.eventSink = eventSink;
}
 
Example #12
Source File: CanalInstanceWithSpring.java    From canal-1.1.3 with Apache License 2.0 4 votes vote down vote up
public void setEventSink(CanalEventSink<List<CanalEntry.Entry>> eventSink) {
    this.eventSink = eventSink;
}
 
Example #13
Source File: GatewayEventSink.java    From DataLink with Apache License 2.0 4 votes vote down vote up
public GatewayEventSink(Canal gwCanal, CanalEventSink eventSink, GatewayEventStore gatewayEventStore) {
    this.gwCanal = gwCanal;
    this.eventSink = eventSink;
    this.gatewayEventStore = gatewayEventStore;
    this.attachedEventSinks = new ConcurrentHashMap<>();
}
 
Example #14
Source File: AbstractEventParser.java    From canal-1.1.3 with Apache License 2.0 4 votes vote down vote up
public void setEventSink(CanalEventSink<List<CanalEntry.Entry>> eventSink) {
    this.eventSink = eventSink;
}
 
Example #15
Source File: AbstractCanalInstance.java    From canal-1.1.3 with Apache License 2.0 4 votes vote down vote up
@Override
public CanalEventSink getEventSink() {
    return eventSink;
}
 
Example #16
Source File: CanalInstance.java    From canal with Apache License 2.0 votes vote down vote up
CanalEventSink getEventSink(); 
Example #17
Source File: CanalInstance.java    From canal-1.1.3 with Apache License 2.0 votes vote down vote up
CanalEventSink getEventSink();