Java Code Examples for org.apache.commons.lang.StringUtils#endsWithIgnoreCase()

The following examples show how to use org.apache.commons.lang.StringUtils#endsWithIgnoreCase() . These examples are extracted from open source projects. 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 Project: canal   File: MysqlDumpTest.java    License: Apache License 2.0 6 votes vote down vote up
private void printXAInfo(List<Pair> pairs) {
    if (pairs == null) {
        return;
    }

    String xaType = null;
    String xaXid = null;
    for (Pair pair : pairs) {
        String key = pair.getKey();
        if (StringUtils.endsWithIgnoreCase(key, "XA_TYPE")) {
            xaType = pair.getValue();
        } else if (StringUtils.endsWithIgnoreCase(key, "XA_XID")) {
            xaXid = pair.getValue();
        }
    }

    if (xaType != null && xaXid != null) {
        System.out.println(" ------> " + xaType + " " + xaXid);
    }
}
 
Example 2
Source Project: canal   File: BaseCanalClientTest.java    License: Apache License 2.0 6 votes vote down vote up
protected void printXAInfo(List<Pair> pairs) {
    if (pairs == null) {
        return;
    }

    String xaType = null;
    String xaXid = null;
    for (Pair pair : pairs) {
        String key = pair.getKey();
        if (StringUtils.endsWithIgnoreCase(key, "XA_TYPE")) {
            xaType = pair.getValue();
        } else if (StringUtils.endsWithIgnoreCase(key, "XA_XID")) {
            xaXid = pair.getValue();
        }
    }

    if (xaType != null && xaXid != null) {
        logger.info(" ------> " + xaType + " " + xaXid);
    }
}
 
Example 3
Source Project: ymate-platform-v2   File: WebUtils.java    License: Apache License 2.0 6 votes vote down vote up
public static IView buildErrorView(IWebMvc owner, String resourceName, int code, String msg, String redirectUrl, int timeInterval, Map<String, Object> data) {
    IView _view;
    String _errorViewPath = __doGetConfigValue(owner.getOwner(), IWebMvcModuleCfg.PARAMS_ERROR_VIEW, "error.jsp");
    if (StringUtils.endsWithIgnoreCase(_errorViewPath, ".ftl")) {
        _view = View.freemarkerView(owner, _errorViewPath);
    } else if (StringUtils.endsWithIgnoreCase(_errorViewPath, ".vm")) {
        _view = View.velocityView(owner, _errorViewPath);
    } else {
        _view = View.jspView(owner, _errorViewPath);
    }
    _view.addAttribute(Type.Const.PARAM_RET, code);
    _view.addAttribute(Type.Const.PARAM_MSG, errorCodeI18n(owner, resourceName, code, msg));
    if (data != null && !data.isEmpty()) {
        _view.addAttribute(Type.Const.PARAM_DATA, data);
    }
    //
    if (StringUtils.isNotBlank(redirectUrl) && timeInterval > 0) {
        _view.addHeader("REFRESH", timeInterval + ";URL=" + redirectUrl);
    }
    //
    return _view;
}
 
Example 4
private void exportSelectedProductsListOptionClicked() {
    RepositoryProduct[] selectedProducts = this.repositoryOutputProductListPanel.getProductListPanel().getSelectedProducts();
    if (selectedProducts.length > 0) {
        // there are selected products
        String extension = ".txt";
        FileFilter fileFilter = CustomFileChooser.buildFileFilter(extension, "*.txt");
        Path selectedFilePath = showDialogToSaveLocalFile("Export selected product list", fileFilter);
        if (selectedFilePath != null) {
            boolean canContinue = true;
            String fileName = selectedFilePath.getFileName().toString();
            if (!StringUtils.endsWithIgnoreCase(fileName, extension)) {
                fileName += extension;
                selectedFilePath = selectedFilePath.getParent().resolve(fileName); // add the '.txt' extension
            }
            if (Files.exists(selectedFilePath)) {
                StringBuilder message = new StringBuilder();
                message.append("The selected file '")
                        .append(selectedFilePath.toString())
                        .append("' already exists.")
                        .append("\n\n")
                        .append("Are you sure you want to overwrite?");
                int answer = showConfirmDialog("Delete local products", message.toString(), JOptionPane.YES_NO_OPTION);
                if (answer != JOptionPane.YES_OPTION) {
                    canContinue = false;
                }
            }
            if (canContinue) {
                Path[] localProductPaths = new Path[selectedProducts.length];
                for (int i=0; i<selectedProducts.length; i++) {
                    localProductPaths[i] = ((LocalRepositoryProduct)selectedProducts[i]).getPath();
                }
                ExportLocalProductListPathsRunnable runnable = new ExportLocalProductListPathsRunnable(this, selectedFilePath, localProductPaths);
                runnable.executeAsync(); // start the thread
            }
        }
    }
}
 
Example 5
Source Project: ad   File: MyConsumer.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * 手动同步提交消息位移
 */
private static void generalConsumerMessageSyncCommit() {
    properties.put("auto.commit.offset", "false");
    consumer = new KafkaConsumer<>(properties);
    consumer.subscribe(Collections.singleton("kafka-topic"));
    try {
        while (true) {
            boolean flag = true;
            ConsumerRecords<String, String> records = consumer.poll(100);
            for (ConsumerRecord<String, String> record : records) {
                log.debug(String.format("topic = %s, partition = %s, key = %s, value = %s",
                        record.topic(), record.partition(), record.key(), record.value())
                );
                if (StringUtils.endsWithIgnoreCase("done", record.value())) {
                    flag = false;
                }
            }
            try {
                // 发起提交, 当前线程会阻塞, 如果发生异常会进行重试直到成功或者抛出 CommitFailedException
                consumer.commitSync();
            } catch (CommitFailedException e) {
                log.error("commit failed error: {}", e.getMessage());
            }
            if (!flag) {
                break;
            }
        }
    } finally {
        consumer.close();
    }
}
 
Example 6
Source Project: azure-devops-intellij   File: UrlHelper.java    License: MIT License 5 votes vote down vote up
public static boolean isOrganizationHost(final String host) {
   if (StringUtils.equalsIgnoreCase(host, HOST_AZURE) ||
           StringUtils.endsWithIgnoreCase(host, HOST_AZURE_ORG)) {
        return true;
   }
   return false;
}
 
Example 7
Source Project: atlas   File: NativeSoFilter.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public boolean accept(File file) {

    if (file.isDirectory()) {
        return true;
    } else {
        String fileName = file.getName();
        if(null != removeSoFiles  && removeSoFiles.size() > 0){
            if(removeSoFiles.contains(fileName)){
                return false;
            }
        }

        String path = file.getAbsolutePath();
        boolean isSupportAbi = false;
        if(null != supportAbis && supportAbis.size() > 0) {
            for (String supportAbi : supportAbis) {
                String abi = File.separator + supportAbi + File.separator + fileName;
                if (path.indexOf(abi) > 0) {
                    isSupportAbi = true;
                    break;
                }
            }
        }else{
            isSupportAbi=true;
        }
        if (isSupportAbi
            && (StringUtils.endsWithIgnoreCase(fileName, ".so") || "gdbserver".equalsIgnoreCase(fileName))) {
            return true;
        }
    }
    return false;
}
 
Example 8
Source Project: ad   File: MyConsumer.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * 混合使用同步提交和异步提交
 * 若之前的提交失败, 则那次提交的位移号一定是偏小, 靠后的提交位移号必定偏大一些
 */
private static void mixSyncAndAsyncCommit() {
    properties.put("auto.commit.offset", "false");
    consumer = new KafkaConsumer<>(properties);
    consumer.subscribe(Collections.singleton("kafka-topic"));
    try {
        while (true) {
            boolean flag = true;
            ConsumerRecords<String, String> records = consumer.poll(100);
            for (ConsumerRecord<String, String> record : records) {
                log.debug(String.format("topic = %s, partition = %s, key = %s, value = %s",
                        record.topic(), record.partition(), record.key(), record.value())
                );
                if (StringUtils.endsWithIgnoreCase("done", record.value())) {
                    flag = false;
                }
            }
            consumer.commitAsync();
            if (!flag) {
                break;
            }
        }
    } catch (Exception e) {
        log.error("commit async error: {}", e.getMessage());
    } finally {
        try {
            consumer.commitSync();
        } finally {
            consumer.close();
        }
    }
}
 
Example 9
Source Project: canal   File: CharsetUtil.java    License: Apache License 2.0 5 votes vote down vote up
public static String getJavaCharset(String charset) {
    if ("utf8".equals(charset)) {
        return charset;
    }

    if (StringUtils.endsWithIgnoreCase(charset, "utf8mb4")) {
        return "utf-8";
    }

    if (StringUtils.endsWithIgnoreCase(charset, "binary")) {
        return "iso_8859_1";
    }

    return charset;
}
 
Example 10
Source Project: atlas   File: CodeInjectByJavassist.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * The injection of code for the specified jar package
 *
 * @param inJar
 * @param outJar
 * @throws IOException
 * @throws NotFoundException
 * @throws CannotCompileException
 */
public static List<String> inject(ClassPool pool,
                                  File inJar,
                                  File outJar,
                                  InjectParam injectParam) throws Exception {
    List<String> errorFiles = new ArrayList<String>();
    JarFile jarFile = newJarFile(inJar);

    outJar.getParentFile().mkdirs();
    FileOutputStream fileOutputStream = new FileOutputStream(outJar);
    JarOutputStream jos = new JarOutputStream(new BufferedOutputStream(fileOutputStream));
    Enumeration<JarEntry> jarFileEntries = jarFile.entries();
    JarEntry jarEntry = null;
    while (jarFileEntries.hasMoreElements()) {
        jarEntry = jarFileEntries.nextElement();
        String name = jarEntry.getName();
        String className = StringUtils.replace(name, File.separator, "/");
        className = StringUtils.replace(className, "/", ".");
        className = StringUtils.substring(className, 0, className.length() - 6);
        if (!StringUtils.endsWithIgnoreCase(name, ".class")) {
            InputStream inputStream = jarFile.getInputStream(jarEntry);
            copyStreamToJar(inputStream, jos, name, jarEntry.getTime(), jarEntry);
            IOUtils.closeQuietly(inputStream);
        } else {
            byte[] codes;

            codes = inject(pool, className, injectParam);
            InputStream classInstream = new ByteArrayInputStream(codes);
            copyStreamToJar(classInstream, jos, name, jarEntry.getTime(), jarEntry);

        }
    }
    jarFile.close();
    IOUtils.closeQuietly(jos);
    return errorFiles;
}
 
Example 11
Source Project: DataLink   File: JobQueueScanUtil.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * 每个job执行完后,检查整个job队列的状态,如果整个队列的任务都执行完了
 * 则发送邮件通知
 * @param queueId
 */
private static void checkWholeQueueStat(long queueId, String executIdStr) {
    List<JobQueue> list = jobQueueService.allQueueStatByQueueId(queueId);
    if(list==null || list.size()==0) {
        //如果整个队列都被删除了,直接返回
        return;
    }
    JobQueueInfo jobQueueInfo = jobQueueService.getJobQueueInfoById(queueId);
    String failToStop = jobQueueInfo.getFailToStop();
    boolean isFailToStop = false;
    if(StringUtils.isBlank(failToStop)) {
        isFailToStop = false;
    } else {
        isFailToStop = Boolean.parseBoolean(failToStop);
    }
    JobExecutionInfo jobExecutionInfo = jobService.getJobExecutionById(Long.parseLong(executIdStr));
    //如果job队列的设置了 任务失败就不继续执行, 并且 当前执行完的这个任务状态是 失败,则丢弃剩余的任务
    if(isFailToStop && StringUtils.endsWithIgnoreCase(FAILED_STAT,jobExecutionInfo.getState())) {
        //将所有剩余的任务状态改为丢弃
        jobQueueService.abandoneRemainJob(queueId);
        list = jobQueueService.allQueueStatByQueueId(queueId);
        finshJobQueue(jobQueueInfo,queueId,list);
        return;
    }

    boolean isFinish = true;
    for(JobQueue q : list) {
        String state = q.getJobState().toUpperCase();
        if(!JOB_FINAL_STATE.contains(state)) {
            isFinish = false;
        }
    }
    if(isFinish) {
        finshJobQueue(jobQueueInfo,queueId,list);
    }
}
 
Example 12
/**
 * Gain table table.
 *
 * @param connection the connection
 * @param tableName  the table name
 * @param cfTable    the cf table
 * @return the table
 * @throws SQLException the sql exception
 */
public Table gainTable(Connection connection, String tableName, CfTable cfTable)
        throws SQLException {
    //支持分表,逻辑表
    String physicalName = cfTable == null ? tableName : cfTable.getPhysicalName();
    //物理表
    String logicName = tableName;
    for (String splitTableSuffix : ConfigUtil.getConfig().getSplitTableSuffixs()) {
        if (StringUtils.endsWithIgnoreCase(tableName, splitTableSuffix)) {
            logicName = StringUtils.replace(logicName, splitTableSuffix, "");
            break;
        }
    }
    //自定义字段类型
    List<CfColumn> cfColumns = cfTable == null ? null : cfTable.getColumns();
    //生成table
    Table table = new Table();
    table.setSqlName(logicName);
    for (String pre : ConfigUtil.getConfig().getTablePrefixs()) {
        if (!StringUtils.endsWith(pre, "_")) {
            pre = pre + "_";
        }

        if (StringUtils.startsWith(logicName, StringUtils.upperCase(pre))) {
            table.setJavaName(CamelCaseUtils.toCapitalizeCamelCase(StringUtils.substring(
                    logicName, pre.length())));
            break;/* 取第一个匹配的 */
        }
    }
    if (StringUtils.isBlank(table.getJavaName())) {
        table.setJavaName(CamelCaseUtils.toCapitalizeCamelCase(logicName));
    }
    table.setPhysicalName(physicalName);
    table.setRemark(logicName);
    //填充字段
    fillColumns(connection, physicalName, table, cfColumns);
    return table;
}
 
Example 13
/**
 * Gets java type.
 *
 * @param column the column
 * @param cfColumns the cf columns
 * @return the java type
 */
private String getJavaType(Column column, List<CfColumn> cfColumns) {
    if (cfColumns != null && cfColumns.size() > 0) {
        for (CfColumn cfColumn : cfColumns) {
            if (StringUtils.endsWithIgnoreCase(column.getSqlName(), cfColumn.getName())) {
                return cfColumn.getJavatype();
            }
        }
    }
    String javaType = TypeMapEnum.getByJdbcType(column.getSqlType()).getJavaType();
    String custJavaType = ConfigUtil.getConfig().getTypeMap().get(javaType);
    return StringUtils.isBlank(custJavaType) ? javaType : custJavaType;
}
 
Example 14
Source Project: atlas   File: ApkFileListUtils.java    License: Apache License 2.0 5 votes vote down vote up
private static boolean isImageFile(String name) {
    for (String imgExt : IMG_EXTENSIONS) {
        if (StringUtils.endsWithIgnoreCase(name, imgExt)) {
            return true;
        }
    }
    return false;
}
 
Example 15
@Override
public boolean accept(File file) {
    if (file.isDirectory()) {
        return true;
    }
    return StringUtils.endsWithIgnoreCase(file.getName(), this.extension);
}
 
Example 16
Source Project: datacollector   File: MapreduceUtils.java    License: Apache License 2.0 5 votes vote down vote up
@VisibleForTesting
static void addJarsToJob(Configuration conf, boolean allowMultiple, URL[] jarUrls, String... jarPatterns) {

  final List<String> allMatches = new LinkedList<>();
  final List<URL> patternMatches = new LinkedList<>();

  for (String pattern : jarPatterns) {
    if (LOG.isTraceEnabled()) {
      LOG.trace("Looking for pattern {}", pattern);
    }
    for (URL url : jarUrls) {
      if (LOG.isTraceEnabled()) {
        LOG.trace("Looking in jar {}", url);
      }
      final String file = url.getFile();
      if (StringUtils.endsWithIgnoreCase(file, ".jar") && StringUtils.containsIgnoreCase(file, pattern)) {
        allMatches.add(url.toString());
        patternMatches.add(url);

        if (LOG.isDebugEnabled()) {
          LOG.debug("Found jar {} for pattern {}", url, pattern);
        }
      }
    }

    if (patternMatches.isEmpty()) {
      throw new IllegalArgumentException(String.format("Did not find any jars for pattern %s", pattern));
    } else if (!allowMultiple && patternMatches.size() > 1) {
      throw new IllegalArgumentException(String.format(
          "Found multiple jars for pattern %s: %s",
          pattern,
          StringUtils.join(patternMatches, JAR_SEPARATOR)
      ));
    }
    patternMatches.clear();
  }

  appendJars(conf, allMatches);
}
 
Example 17
Source Project: canal   File: LocalBinLogConnection.java    License: Apache License 2.0 4 votes vote down vote up
public void dump(long timestampMills, SinkFunction func) throws IOException {
    List<File> currentBinlogs = binlogs.currentBinlogs();
    File current = currentBinlogs.get(currentBinlogs.size() - 1);
    long timestampSeconds = timestampMills / 1000;

    String binlogFilename = null;
    long binlogFileOffset = 0;

    FileLogFetcher fetcher = new FileLogFetcher(bufferSize);
    LogDecoder decoder = new LogDecoder();
    decoder.handle(LogEvent.FORMAT_DESCRIPTION_EVENT);
    decoder.handle(LogEvent.QUERY_EVENT);
    decoder.handle(LogEvent.XID_EVENT);
    LogContext context = new LogContext();
    try {
        fetcher.open(current);
        context.setLogPosition(new LogPosition(current.getName()));
        while (running) {
            boolean needContinue = true;
            String lastXidLogFilename = current.getName();
            long lastXidLogFileOffset = 0;

            binlogFilename = lastXidLogFilename;
            binlogFileOffset = lastXidLogFileOffset;
            while (fetcher.fetch()) {
                LogEvent event = decoder.decode(fetcher, context);
                if (event != null) {
                    if (serverId != 0 && event.getServerId() != serverId) {
                        throw new ServerIdNotMatchException("unexpected serverId " + serverId + " in binlog file !");
                    }

                    if (event.getWhen() > timestampSeconds) {
                        break;
                    }

                    needContinue = false;
                    if (LogEvent.QUERY_EVENT == event.getHeader().getType()) {
                        if (StringUtils.endsWithIgnoreCase(((QueryLogEvent) event).getQuery(), "BEGIN")) {
                            binlogFilename = lastXidLogFilename;
                            binlogFileOffset = lastXidLogFileOffset;
                        } else if (StringUtils.endsWithIgnoreCase(((QueryLogEvent) event).getQuery(), "COMMIT")) {
                            lastXidLogFilename = current.getName();
                            lastXidLogFileOffset = event.getLogPos();
                        }
                    } else if (LogEvent.XID_EVENT == event.getHeader().getType()) {
                        lastXidLogFilename = current.getName();
                        lastXidLogFileOffset = event.getLogPos();
                    } else if (LogEvent.FORMAT_DESCRIPTION_EVENT == event.getHeader().getType()) {
                        lastXidLogFilename = current.getName();
                        lastXidLogFileOffset = event.getLogPos();
                    }
                }
            }

            if (needContinue) {// 读取下一个
                fetcher.close(); // 关闭上一个文件

                File nextFile = binlogs.getBefore(current);
                if (nextFile == null) {
                    break;
                }

                current = nextFile;
                fetcher.open(current);
                context.setLogPosition(new LogPosition(current.getName()));
            } else {
                break;// 跳出
            }
        }
    } finally {
        if (fetcher != null) {
            fetcher.close();
        }
    }

    dump(binlogFilename, binlogFileOffset, func);
}
 
Example 18
Source Project: canal   File: LocalBinLogConnection.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public void dump(long timestampMills, MultiStageCoprocessor coprocessor) throws IOException {
    List<File> currentBinlogs = binlogs.currentBinlogs();
    File current = currentBinlogs.get(currentBinlogs.size() - 1);
    long timestampSeconds = timestampMills / 1000;

    String binlogFilename = null;
    long binlogFileOffset = 0;

    FileLogFetcher fetcher = new FileLogFetcher(bufferSize);
    LogDecoder decoder = new LogDecoder();
    decoder.handle(LogEvent.FORMAT_DESCRIPTION_EVENT);
    decoder.handle(LogEvent.QUERY_EVENT);
    decoder.handle(LogEvent.XID_EVENT);
    LogContext context = new LogContext();
    try {
        fetcher.open(current);
        context.setLogPosition(new LogPosition(current.getName()));
        while (running) {
            boolean needContinue = true;
            String lastXidLogFilename = current.getName();
            long lastXidLogFileOffset = 0;

            binlogFilename = lastXidLogFilename;
            binlogFileOffset = lastXidLogFileOffset;
            while (fetcher.fetch()) {
                LogEvent event = decoder.decode(fetcher, context);
                if (event != null) {
                    if (serverId != 0 && event.getServerId() != serverId) {
                        throw new ServerIdNotMatchException("unexpected serverId " + serverId + " in binlog file !");
                    }

                    if (event.getWhen() > timestampSeconds) {
                        break;
                    }

                    needContinue = false;
                    if (LogEvent.QUERY_EVENT == event.getHeader().getType()) {
                        if (StringUtils.endsWithIgnoreCase(((QueryLogEvent) event).getQuery(), "BEGIN")) {
                            binlogFilename = lastXidLogFilename;
                            binlogFileOffset = lastXidLogFileOffset;
                        } else if (StringUtils.endsWithIgnoreCase(((QueryLogEvent) event).getQuery(), "COMMIT")) {
                            lastXidLogFilename = current.getName();
                            lastXidLogFileOffset = event.getLogPos();
                        }
                    } else if (LogEvent.XID_EVENT == event.getHeader().getType()) {
                        lastXidLogFilename = current.getName();
                        lastXidLogFileOffset = event.getLogPos();
                    } else if (LogEvent.FORMAT_DESCRIPTION_EVENT == event.getHeader().getType()) {
                        lastXidLogFilename = current.getName();
                        lastXidLogFileOffset = event.getLogPos();
                    }
                }
            }

            if (needContinue) {// 读取下一个
                fetcher.close(); // 关闭上一个文件

                File nextFile = binlogs.getBefore(current);
                if (nextFile == null) {
                    break;
                }

                current = nextFile;
                fetcher.open(current);
                context.setLogPosition(new LogPosition(current.getName()));
            } else {
                break;// 跳出
            }
        }
    } finally {
        if (fetcher != null) {
            fetcher.close();
        }
    }

    dump(binlogFilename, binlogFileOffset, coprocessor);
}
 
Example 19
public void dump(long timestampMills, SinkFunction func) throws IOException {
    List<File> currentBinlogs = binlogs.currentBinlogs();
    File current = currentBinlogs.get(currentBinlogs.size() - 1);
    long timestampSeconds = timestampMills / 1000;

    String binlogFilename = null;
    long binlogFileOffset = 0;

    FileLogFetcher fetcher = new FileLogFetcher(bufferSize);
    LogDecoder decoder = new LogDecoder();
    decoder.handle(LogEvent.FORMAT_DESCRIPTION_EVENT);
    decoder.handle(LogEvent.QUERY_EVENT);
    decoder.handle(LogEvent.XID_EVENT);
    LogContext context = new LogContext();
    try {
        fetcher.open(current);
        context.setLogPosition(new LogPosition(current.getName()));
        while (running) {
            boolean needContinue = true;
            String lastXidLogFilename = current.getName();
            long lastXidLogFileOffset = 0;

            binlogFilename = lastXidLogFilename;
            binlogFileOffset = lastXidLogFileOffset;
            while (fetcher.fetch()) {
                LogEvent event = decoder.decode(fetcher, context);
                if (event != null) {
                    if (serverId != 0 && event.getServerId() != serverId) {
                        throw new ServerIdNotMatchException("unexpected serverId " + serverId + " in binlog file !");
                    }

                    if (event.getWhen() > timestampSeconds) {
                        break;
                    }

                    needContinue = false;
                    if (LogEvent.QUERY_EVENT == event.getHeader().getType()) {
                        if (StringUtils.endsWithIgnoreCase(((QueryLogEvent) event).getQuery(), "BEGIN")) {
                            binlogFilename = lastXidLogFilename;
                            binlogFileOffset = lastXidLogFileOffset;
                        } else if (StringUtils.endsWithIgnoreCase(((QueryLogEvent) event).getQuery(), "COMMIT")) {
                            lastXidLogFilename = current.getName();
                            lastXidLogFileOffset = event.getLogPos();
                        }
                    } else if (LogEvent.XID_EVENT == event.getHeader().getType()) {
                        lastXidLogFilename = current.getName();
                        lastXidLogFileOffset = event.getLogPos();
                    } else if (LogEvent.FORMAT_DESCRIPTION_EVENT == event.getHeader().getType()) {
                        lastXidLogFilename = current.getName();
                        lastXidLogFileOffset = event.getLogPos();
                    }
                }
            }

            if (needContinue) {// 读取下一个
                fetcher.close(); // 关闭上一个文件

                File nextFile = binlogs.getBefore(current);
                if (nextFile == null) {
                    break;
                }

                current = nextFile;
                fetcher.open(current);
                context.setLogPosition(new LogPosition(current.getName()));
            } else {
                break;// 跳出
            }
        }
    } finally {
        if (fetcher != null) {
            fetcher.close();
        }
    }

    dump(binlogFilename, binlogFileOffset, func);
}
 
Example 20
Source Project: atlas   File: Services.java    License: Apache License 2.0 4 votes vote down vote up
private boolean isZipFileMigration() {
    return migrationEnabled && StringUtils.endsWithIgnoreCase(migrationDirName, FILE_EXTENSION_ZIP);
}