com.aconex.scrutineer.elasticsearch.ElasticSearchSorter Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of scrutineer Show documentation
Show all versions of scrutineer Show documentation
Compares 2 streams of Ids and Versions to prove that a secondary source is
in sync with a primary source of truth. Designed to verify an elasticsearch
cluster contains correct information from a JDBC source.
package com.aconex.scrutineer.elasticsearch;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import org.slf4j.Logger;
import com.aconex.scrutineer.IdAndVersion;
import com.aconex.scrutineer.LogUtils;
import com.fasterxml.sort.Sorter;
import com.google.common.io.CountingInputStream;
public class ElasticSearchSorter {
private static final Logger LOG = LogUtils.loggerForThisClass();
private final Sorter sorter;
public ElasticSearchSorter(Sorter sorter) {
this.sorter = sorter;
}
public void sort(InputStream inputStream, OutputStream outputStream) {
long begin = System.currentTimeMillis();
CountingInputStream countingInputStream = new CountingInputStream(inputStream);
doSort(countingInputStream, outputStream);
LogUtils.infoTimeTaken(LOG, begin, countingInputStream.getCount(), "Sorted stream of %d bytes", countingInputStream.getCount());
}
private void doSort(InputStream inputStream, OutputStream outputStream ) {
try {
sorter.sort(inputStream,outputStream);
} catch (IOException e) {
throw new RuntimeException(e);
}
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy