zipkin2.storage.cassandra.SelectTraceIdsFromServiceRemoteService Maven / Gradle / Ivy
/*
* Copyright The OpenZipkin Authors
* SPDX-License-Identifier: Apache-2.0
*/
package zipkin2.storage.cassandra;
import com.datastax.oss.driver.api.core.CqlSession;
import com.datastax.oss.driver.api.core.cql.AsyncResultSet;
import com.datastax.oss.driver.api.core.cql.PreparedStatement;
import com.google.auto.value.AutoValue;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.UUID;
import java.util.concurrent.CompletionStage;
import zipkin2.Call;
import zipkin2.storage.cassandra.CassandraSpanStore.TimestampRange;
import zipkin2.storage.cassandra.internal.call.AccumulateTraceIdTsUuid;
import zipkin2.storage.cassandra.internal.call.AggregateIntoMap;
import zipkin2.storage.cassandra.internal.call.ResultSetFutureCall;
import static zipkin2.storage.cassandra.Schema.TABLE_TRACE_BY_SERVICE_REMOTE_SERVICE;
final class SelectTraceIdsFromServiceRemoteService extends ResultSetFutureCall {
@AutoValue abstract static class Input {
abstract String service();
abstract String remote_service();
abstract int bucket();
abstract UUID start_ts();
abstract UUID end_ts();
abstract int limit_();
Input withService(String service) {
return new AutoValue_SelectTraceIdsFromServiceRemoteService_Input(
service,
remote_service(),
bucket(),
start_ts(),
end_ts(),
limit_());
}
}
static final class Factory {
final CqlSession session;
final PreparedStatement preparedStatement;
Factory(CqlSession session) {
this.session = session;
this.preparedStatement = session.prepare("SELECT trace_id,ts"
+ " FROM " + TABLE_TRACE_BY_SERVICE_REMOTE_SERVICE
+ " WHERE service=? AND remote_service=?"
+ " AND bucket=?"
+ " AND ts>=?"
+ " AND ts<=?"
+ " LIMIT ?");
}
Input newInput(
String serviceName,
String remoteServiceName,
int bucket,
TimestampRange timestampRange,
int limit) {
return new AutoValue_SelectTraceIdsFromServiceRemoteService_Input(
serviceName,
remoteServiceName,
bucket,
timestampRange.startUUID,
timestampRange.endUUID,
limit);
}
Call