com.alibaba.otter.canal.client.impl.SimpleCanalConnector Java Examples
The following examples show how to use
com.alibaba.otter.canal.client.impl.SimpleCanalConnector.
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: CanalTCPConsumer.java From canal with Apache License 2.0 | 6 votes |
@Override public void init(Properties properties, String destination, String groupId) { // load config String host = properties.getProperty(TCPConstants.CANAL_TCP_HOST); String username = properties.getProperty(TCPConstants.CANAL_TCP_USERNAME); String password = properties.getProperty(TCPConstants.CANAL_TCP_PASSWORD); String zkHosts = properties.getProperty(TCPConstants.CANAL_TCP_ZK_HOSTS); String batchSizePro = properties.getProperty(TCPConstants.CANAL_TCP_BATCH_SIZE); if (batchSizePro != null) { batchSize = Integer.parseInt(batchSizePro); } if (host != null) { String[] ipPort = host.split(":"); SocketAddress sa = new InetSocketAddress(ipPort[0], Integer.parseInt(ipPort[1])); this.canalConnector = new SimpleCanalConnector(sa, username, password, destination); } else { this.canalConnector = new ClusterCanalConnector(username, password, destination, new ClusterNodeAccessStrategy(destination, ZkClientx.getZkClient(zkHosts))); } }
Example #2
Source File: CanalInterceptor.java From skywalking with Apache License 2.0 | 5 votes |
@Override public void beforeMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class<?>[] argumentsTypes, MethodInterceptResult result) throws Throwable { CanalEnhanceInfo canalEnhanceInfo = (CanalEnhanceInfo) objInst.getSkyWalkingDynamicField(); SimpleCanalConnector connector = (SimpleCanalConnector) objInst; String url = canalEnhanceInfo.getUrl(); if (Objects.equals(url, "") || url == null) { InetSocketAddress address = (InetSocketAddress) connector.getNextAddress(); String runningAddress = address.getAddress().toString() + ":" + address.getPort(); runningAddress = runningAddress.replace('/', ' '); url = runningAddress; List<InetSocketAddress> socketAddressList = (List<InetSocketAddress>) ContextManager.getRuntimeContext() .get("currentAddress"); if (socketAddressList != null && socketAddressList.size() > 0) { for (InetSocketAddress socketAddress : socketAddressList) { String currentAddress = socketAddress.getAddress().toString() + ":" + socketAddress.getPort(); currentAddress = currentAddress.replace('/', ' '); if (!currentAddress.equals(runningAddress)) { url = url + "," + currentAddress; } } } } String batchSize = allArguments[0].toString(); String destination = canalEnhanceInfo.getDestination(); AbstractSpan activeSpan = ContextManager.createExitSpan("Canal/" + destination, url) .start(System.currentTimeMillis()); activeSpan.setComponent(ComponentsDefine.CANAL); activeSpan.tag(Tags.ofKey("batchSize"), batchSize); activeSpan.tag(Tags.ofKey("destination"), destination); }
Example #3
Source File: CanalConnectors.java From canal-1.1.3 with Apache License 2.0 | 3 votes |
/** * 创建单链接的客户端链接 * * @param address * @param destination * @param username * @param password * @return */ public static CanalConnector newSingleConnector(SocketAddress address, String destination, String username, String password) { SimpleCanalConnector canalConnector = new SimpleCanalConnector(address, username, password, destination); canalConnector.setSoTimeout(60 * 1000); canalConnector.setIdleTimeout(60 * 60 * 1000); return canalConnector; }
Example #4
Source File: CanalConnectors.java From canal with Apache License 2.0 | 3 votes |
/** * 创建单链接的客户端链接 * * @param address * @param destination * @param username * @param password * @return */ public static CanalConnector newSingleConnector(SocketAddress address, String destination, String username, String password) { SimpleCanalConnector canalConnector = new SimpleCanalConnector(address, username, password, destination); canalConnector.setSoTimeout(60 * 1000); canalConnector.setIdleTimeout(60 * 60 * 1000); return canalConnector; }