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

The following examples show how to use com.alibaba.otter.canal.instance.core.CanalInstance#getDestination() . 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: ParserCollector.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();
    ParserMetricsHolder holder;
    CanalEventParser parser = instance.getEventParser();
    if (parser instanceof AbstractMysqlEventParser) {
        holder = singleHolder(destination, (AbstractMysqlEventParser)parser, "0");
    } else if (parser instanceof GroupEventParser) {
        holder = groupHolder(destination, (GroupEventParser)parser);
    } else {
        throw new IllegalArgumentException("CanalEventParser must be either AbstractMysqlEventParser or GroupEventParser.");
    }
    Preconditions.checkNotNull(holder);
    ParserMetricsHolder old = instances.put(destination, holder);
    if (old != null) {
        logger.warn("Remove stale ParserCollector for instance {}.", destination);
    }
}
 
Example 4
Source File: ParserCollector.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();
    ParserMetricsHolder holder;
    CanalEventParser parser = instance.getEventParser();
    if (parser instanceof AbstractMysqlEventParser) {
        holder = singleHolder(destination, (AbstractMysqlEventParser)parser, "0");
    } else if (parser instanceof GroupEventParser) {
        holder = groupHolder(destination, (GroupEventParser)parser);
    } else {
        throw new IllegalArgumentException("CanalEventParser must be either AbstractMysqlEventParser or GroupEventParser.");
    }
    Preconditions.checkNotNull(holder);
    ParserMetricsHolder old = instances.put(destination, holder);
    if (old != null) {
        logger.warn("Remove stale ParserCollector for instance {}.", destination);
    }
}
 
Example 5
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 6
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 7
Source File: StoreCollector.java    From canal-1.1.3 with Apache License 2.0 5 votes vote down vote up
@Override
public void register(CanalInstance instance) {
    final String destination = instance.getDestination();
    StoreMetricsHolder holder = new StoreMetricsHolder();
    CanalEventStore store = instance.getEventStore();
    if (!(store instanceof MemoryEventStoreWithBuffer)) {
        throw new IllegalArgumentException("EventStore must be MemoryEventStoreWithBuffer");
    }
    MemoryEventStoreWithBuffer memStore = (MemoryEventStoreWithBuffer) store;
    holder.batchMode = memStore.getBatchMode();
    holder.putSeq = memStore.getPutSequence();
    holder.ackSeq = memStore.getAckSequence();
    holder.destLabelValues = Collections.singletonList(destination);
    holder.size = memStore.getBufferSize();
    holder.storeLabelValues = Arrays.asList(destination, holder.batchMode.name(), Integer.toString(holder.size));
    holder.putExecTime = memStore.getPutExecTime();
    holder.getExecTime = memStore.getGetExecTime();
    holder.ackExecTime = memStore.getAckExecTime();
    holder.putTableRows = memStore.getPutTableRows();
    holder.getTableRows = memStore.getGetTableRows();
    holder.ackTableRows = memStore.getAckTableRows();
    Preconditions.checkNotNull(holder.batchMode);
    Preconditions.checkNotNull(holder.putSeq);
    Preconditions.checkNotNull(holder.ackSeq);
    if (holder.batchMode.isMemSize()) {
        holder.putMemSize = memStore.getPutMemSize();
        holder.ackMemSize = memStore.getAckMemSize();
        Preconditions.checkNotNull(holder.putMemSize);
        Preconditions.checkNotNull(holder.ackMemSize);
    }
    StoreMetricsHolder old = instances.putIfAbsent(destination, holder);
    if (old != null) {
        logger.warn("Remote stale StoreCollector for instance {}.", destination);
    }
}
 
Example 8
Source File: MetaCollector.java    From canal with Apache License 2.0 5 votes vote down vote up
@Override
public void register(CanalInstance instance) {
    final String destination = instance.getDestination();
    MetaMetricsHolder holder = new MetaMetricsHolder();
    String mode = (instance instanceof CanalInstanceWithSpring) ? "spring" : "manager";
    holder.infoLabelValues = Arrays.asList(destination, mode);
    holder.destLabelValues = Collections.singletonList(destination);
    holder.metaManager = instance.getMetaManager();
    Preconditions.checkNotNull(holder.metaManager);
    MetaMetricsHolder old = instances.put(destination, holder);
    if (old != null) {
        logger.warn("Remove stale MetaCollector for instance {}.", destination);
    }
}
 
Example 9
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 10
Source File: MetaCollector.java    From canal-1.1.3 with Apache License 2.0 5 votes vote down vote up
@Override
public void register(CanalInstance instance) {
    final String destination = instance.getDestination();
    MetaMetricsHolder holder = new MetaMetricsHolder();
    String mode = (instance instanceof CanalInstanceWithSpring) ? "spring" : "manager";
    holder.infoLabelValues = Arrays.asList(destination, mode);
    holder.destLabelValues = Collections.singletonList(destination);
    holder.metaManager = instance.getMetaManager();
    Preconditions.checkNotNull(holder.metaManager);
    MetaMetricsHolder old = instances.put(destination, holder);
    if (old != null) {
        logger.warn("Remove stale MetaCollector for instance {}.", destination);
    }
}
 
Example 11
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 12
Source File: StoreCollector.java    From canal with Apache License 2.0 5 votes vote down vote up
@Override
public void register(CanalInstance instance) {
    final String destination = instance.getDestination();
    StoreMetricsHolder holder = new StoreMetricsHolder();
    CanalEventStore store = instance.getEventStore();
    if (!(store instanceof MemoryEventStoreWithBuffer)) {
        throw new IllegalArgumentException("EventStore must be MemoryEventStoreWithBuffer");
    }
    MemoryEventStoreWithBuffer memStore = (MemoryEventStoreWithBuffer) store;
    holder.batchMode = memStore.getBatchMode();
    holder.putSeq = memStore.getPutSequence();
    holder.ackSeq = memStore.getAckSequence();
    holder.destLabelValues = Collections.singletonList(destination);
    holder.size = memStore.getBufferSize();
    holder.storeLabelValues = Arrays.asList(destination, holder.batchMode.name(), Integer.toString(holder.size));
    holder.putExecTime = memStore.getPutExecTime();
    holder.getExecTime = memStore.getGetExecTime();
    holder.ackExecTime = memStore.getAckExecTime();
    holder.putTableRows = memStore.getPutTableRows();
    holder.getTableRows = memStore.getGetTableRows();
    holder.ackTableRows = memStore.getAckTableRows();
    Preconditions.checkNotNull(holder.batchMode);
    Preconditions.checkNotNull(holder.putSeq);
    Preconditions.checkNotNull(holder.ackSeq);
    if (holder.batchMode.isMemSize()) {
        holder.putMemSize = memStore.getPutMemSize();
        holder.ackMemSize = memStore.getAckMemSize();
        Preconditions.checkNotNull(holder.putMemSize);
        Preconditions.checkNotNull(holder.ackMemSize);
    }
    StoreMetricsHolder old = instances.putIfAbsent(destination, holder);
    if (old != null) {
        logger.warn("Remote stale StoreCollector for instance {}.", destination);
    }
}
 
Example 13
Source File: MetaCollector.java    From canal with Apache License 2.0 4 votes vote down vote up
@Override
public void unregister(CanalInstance instance) {
    final String destination = instance.getDestination();
    instances.remove(destination);
}
 
Example 14
Source File: ParserCollector.java    From canal with Apache License 2.0 4 votes vote down vote up
@Override
public void unregister(CanalInstance instance) {
    final String destination = instance.getDestination();
    instances.remove(destination);
}
 
Example 15
Source File: StoreCollector.java    From canal with Apache License 2.0 4 votes vote down vote up
@Override
public void unregister(CanalInstance instance) {
    final String destination = instance.getDestination();
    instances.remove(destination);
}
 
Example 16
Source File: SinkCollector.java    From canal with Apache License 2.0 4 votes vote down vote up
@Override
public void unregister(CanalInstance instance) {
    final String destination = instance.getDestination();
    instances.remove(destination);
}
 
Example 17
Source File: MetaCollector.java    From canal-1.1.3 with Apache License 2.0 4 votes vote down vote up
@Override
public void unregister(CanalInstance instance) {
    final String destination = instance.getDestination();
    instances.remove(destination);
}
 
Example 18
Source File: ParserCollector.java    From canal-1.1.3 with Apache License 2.0 4 votes vote down vote up
@Override
public void unregister(CanalInstance instance) {
    final String destination = instance.getDestination();
    instances.remove(destination);
}
 
Example 19
Source File: StoreCollector.java    From canal-1.1.3 with Apache License 2.0 4 votes vote down vote up
@Override
public void unregister(CanalInstance instance) {
    final String destination = instance.getDestination();
    instances.remove(destination);
}
 
Example 20
Source File: SinkCollector.java    From canal-1.1.3 with Apache License 2.0 4 votes vote down vote up
@Override
public void unregister(CanalInstance instance) {
    final String destination = instance.getDestination();
    instances.remove(destination);
}