Merge branch '2.0.8-SNAPSHOT' into develop
This commit is contained in:
commit
cbc246f1c0
6 changed files with 51 additions and 24 deletions
2
pom.xml
2
pom.xml
|
@ -5,7 +5,7 @@
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<groupId>net.helenus</groupId>
|
<groupId>net.helenus</groupId>
|
||||||
<artifactId>helenus-core</artifactId>
|
<artifactId>helenus-core</artifactId>
|
||||||
<version>2.0.8-SNAPSHOT</version>
|
<version>2.0.9-SNAPSHOT</version>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
<name>helenus</name>
|
<name>helenus</name>
|
||||||
|
|
|
@ -21,8 +21,7 @@ import java.util.List;
|
||||||
import net.helenus.core.*;
|
import net.helenus.core.*;
|
||||||
|
|
||||||
public abstract class AbstractFilterStreamOperation<E, O extends AbstractFilterStreamOperation<E, O>>
|
public abstract class AbstractFilterStreamOperation<E, O extends AbstractFilterStreamOperation<E, O>>
|
||||||
extends
|
extends AbstractStreamOperation<E, O> {
|
||||||
AbstractStreamOperation<E, O> {
|
|
||||||
|
|
||||||
protected List<Filter<?>> filters = null;
|
protected List<Filter<?>> filters = null;
|
||||||
protected List<Filter<?>> ifFilters = null;
|
protected List<Filter<?>> ifFilters = null;
|
||||||
|
|
|
@ -30,8 +30,6 @@ import java.util.Optional;
|
||||||
public abstract class AbstractOptionalOperation<E, O extends AbstractOptionalOperation<E, O>>
|
public abstract class AbstractOptionalOperation<E, O extends AbstractOptionalOperation<E, O>>
|
||||||
extends AbstractStatementOperation<E, O> {
|
extends AbstractStatementOperation<E, O> {
|
||||||
|
|
||||||
Span span;
|
|
||||||
|
|
||||||
public AbstractOptionalOperation(AbstractSessionOperations sessionOperations) {
|
public AbstractOptionalOperation(AbstractSessionOperations sessionOperations) {
|
||||||
super(sessionOperations);
|
super(sessionOperations);
|
||||||
}
|
}
|
||||||
|
@ -53,17 +51,6 @@ public abstract class AbstractOptionalOperation<E, O extends AbstractOptionalOpe
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public AbstractOptionalOperation<E, O> withinSpan(Span span) {
|
|
||||||
if (span != null) {
|
|
||||||
Tracer tracer = this.sessionOps.getZipkinTracer();
|
|
||||||
if (tracer != null) {
|
|
||||||
this.span = span;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Optional<E> sync() {
|
public Optional<E> sync() {
|
||||||
Tracer tracer = this.sessionOps.getZipkinTracer();
|
Tracer tracer = this.sessionOps.getZipkinTracer();
|
||||||
final Span cassandraSpan = (tracer != null && span != null) ? tracer.newChild(span.context()) : null;
|
final Span cassandraSpan = (tracer != null && span != null) ? tracer.newChild(span.context()) : null;
|
||||||
|
@ -95,10 +82,11 @@ public abstract class AbstractOptionalOperation<E, O extends AbstractOptionalOpe
|
||||||
new Function<ResultSet, Optional<E>>() {
|
new Function<ResultSet, Optional<E>>() {
|
||||||
@Override
|
@Override
|
||||||
public Optional<E> apply(ResultSet resultSet) {
|
public Optional<E> apply(ResultSet resultSet) {
|
||||||
|
Optional<E> result = transform(resultSet);
|
||||||
if (cassandraSpan != null) {
|
if (cassandraSpan != null) {
|
||||||
cassandraSpan.finish();
|
cassandraSpan.finish();
|
||||||
}
|
}
|
||||||
return transform(resultSet);
|
return result;
|
||||||
}
|
}
|
||||||
}, sessionOps.getExecutor());
|
}, sessionOps.getExecutor());
|
||||||
|
|
||||||
|
|
|
@ -15,6 +15,8 @@
|
||||||
*/
|
*/
|
||||||
package net.helenus.core.operation;
|
package net.helenus.core.operation;
|
||||||
|
|
||||||
|
import brave.Span;
|
||||||
|
import brave.Tracer;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
@ -42,6 +44,7 @@ public abstract class AbstractStatementOperation<E, O extends AbstractStatementO
|
||||||
public abstract Statement buildStatement();
|
public abstract Statement buildStatement();
|
||||||
|
|
||||||
protected boolean showValues = true;
|
protected boolean showValues = true;
|
||||||
|
protected Span span;
|
||||||
private ConsistencyLevel consistencyLevel;
|
private ConsistencyLevel consistencyLevel;
|
||||||
private ConsistencyLevel serialConsistencyLevel;
|
private ConsistencyLevel serialConsistencyLevel;
|
||||||
private RetryPolicy retryPolicy;
|
private RetryPolicy retryPolicy;
|
||||||
|
@ -212,7 +215,18 @@ public abstract class AbstractStatementOperation<E, O extends AbstractStatementO
|
||||||
return statement;
|
return statement;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Statement statement() {
|
public O withinSpan(Span span) {
|
||||||
|
if (span != null) {
|
||||||
|
Tracer tracer = this.sessionOps.getZipkinTracer();
|
||||||
|
if (tracer != null) {
|
||||||
|
this.span = span;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return (O) this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Statement statement() {
|
||||||
return buildStatement();
|
return buildStatement();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -17,6 +17,8 @@ package net.helenus.core.operation;
|
||||||
|
|
||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
|
import brave.Span;
|
||||||
|
import brave.Tracer;
|
||||||
import com.datastax.driver.core.PreparedStatement;
|
import com.datastax.driver.core.PreparedStatement;
|
||||||
import com.datastax.driver.core.ResultSet;
|
import com.datastax.driver.core.ResultSet;
|
||||||
import com.datastax.driver.core.ResultSetFuture;
|
import com.datastax.driver.core.ResultSetFuture;
|
||||||
|
@ -50,19 +52,43 @@ public abstract class AbstractStreamOperation<E, O extends AbstractStreamOperati
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public Stream<E> sync() {
|
public Stream<E> sync() {
|
||||||
ResultSet resultSet = sessionOps.executeAsync(options(buildStatement()), showValues).getUninterruptibly();
|
Tracer tracer = this.sessionOps.getZipkinTracer();
|
||||||
return transform(resultSet);
|
final Span cassandraSpan = (tracer != null && span != null) ? tracer.newChild(span.context()) : null;
|
||||||
|
if (cassandraSpan != null) {
|
||||||
|
cassandraSpan.name("cassandra");
|
||||||
|
cassandraSpan.start();
|
||||||
|
}
|
||||||
|
|
||||||
|
ResultSet resultSet = sessionOps.executeAsync(options(buildStatement()), showValues).getUninterruptibly();
|
||||||
|
Stream<E> result = transform(resultSet);
|
||||||
|
|
||||||
|
if (cassandraSpan != null) {
|
||||||
|
cassandraSpan.finish();
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ListenableFuture<Stream<E>> async() {
|
public ListenableFuture<Stream<E>> async() {
|
||||||
|
Tracer tracer = this.sessionOps.getZipkinTracer();
|
||||||
|
final Span cassandraSpan = (tracer != null && span != null) ? tracer.newChild(span.context()) : null;
|
||||||
|
if (cassandraSpan != null) {
|
||||||
|
cassandraSpan.name("cassandra");
|
||||||
|
cassandraSpan.start();
|
||||||
|
}
|
||||||
|
|
||||||
ResultSetFuture resultSetFuture = sessionOps.executeAsync(options(buildStatement()), showValues);
|
ResultSetFuture resultSetFuture = sessionOps.executeAsync(options(buildStatement()), showValues);
|
||||||
ListenableFuture<Stream<E>> future = Futures.transform(resultSetFuture,
|
ListenableFuture<Stream<E>> future = Futures.transform(resultSetFuture,
|
||||||
new Function<ResultSet, Stream<E>>() {
|
new Function<ResultSet, Stream<E>>() {
|
||||||
@Override
|
@Override
|
||||||
public Stream<E> apply(ResultSet resultSet) {
|
public Stream<E> apply(ResultSet resultSet) {
|
||||||
return transform(resultSet);
|
Stream<E> result = transform(resultSet);
|
||||||
}
|
if (cassandraSpan != null) {
|
||||||
|
cassandraSpan.finish();
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
}, sessionOps.getExecutor());
|
}, sessionOps.getExecutor());
|
||||||
return future;
|
return future;
|
||||||
}
|
}
|
||||||
|
|
|
@ -166,7 +166,7 @@ public final class SelectOperation<E> extends AbstractFilterStreamOperation<E, S
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BuiltStatement buildStatement() {
|
public BuiltStatement buildStatement() {
|
||||||
|
|
||||||
HelenusEntity entity = null;
|
HelenusEntity entity = null;
|
||||||
|
|
Loading…
Reference in a new issue