use of org.elasticsearch.common.io.stream.StreamInput in project crate by crate.
the class ShardDeleteRequestTest method testStreaming.
@Test
public void testStreaming() throws Exception {
ShardId shardId = new ShardId("test", 1);
UUID jobId = UUID.randomUUID();
ShardDeleteRequest request = new ShardDeleteRequest(shardId, "42", jobId);
request.add(123, new ShardDeleteRequest.Item("99"));
request.add(5, new ShardDeleteRequest.Item("42"));
BytesStreamOutput out = new BytesStreamOutput();
request.writeTo(out);
StreamInput in = StreamInput.wrap(out.bytes());
ShardDeleteRequest request2 = new ShardDeleteRequest();
request2.readFrom(in);
assertThat(request, equalTo(request2));
}
use of org.elasticsearch.common.io.stream.StreamInput in project crate by crate.
the class ShardUpsertRequestTest method testStreaming.
@Test
public void testStreaming() throws Exception {
ShardId shardId = new ShardId("test", 1);
String[] assignmentColumns = new String[] { "id", "name" };
UUID jobId = UUID.randomUUID();
Reference[] missingAssignmentColumns = new Reference[] { ID_REF, NAME_REF };
ShardUpsertRequest request = new ShardUpsertRequest.Builder(false, false, assignmentColumns, missingAssignmentColumns, jobId, false).newRequest(shardId, "42");
request.validateConstraints(false);
request.add(123, new ShardUpsertRequest.Item("99", null, new Object[] { 99, new BytesRef("Marvin") }, null));
request.add(5, new ShardUpsertRequest.Item("42", new Symbol[] { Literal.of(42), Literal.of("Deep Thought") }, null, 2L));
BytesStreamOutput out = new BytesStreamOutput();
request.writeTo(out);
StreamInput in = StreamInput.wrap(out.bytes());
ShardUpsertRequest request2 = new ShardUpsertRequest();
request2.readFrom(in);
assertThat(request, equalTo(request2));
}
use of org.elasticsearch.common.io.stream.StreamInput in project crate by crate.
the class FailedShardsExceptionTest method testShardFailureReasonIsNull.
@Test
public void testShardFailureReasonIsNull() throws Exception {
FailedShardsException exception = new FailedShardsException(new ShardOperationFailedException[] { new ShardOperationFailedException() {
@Override
public String index() {
return null;
}
@Override
public int shardId() {
return 0;
}
@Override
public String reason() {
return null;
}
@Override
public RestStatus status() {
return null;
}
@Override
public void readFrom(StreamInput in) throws IOException {
}
@Override
public void writeTo(StreamOutput out) throws IOException {
}
@Override
public Throwable getCause() {
return null;
}
@Override
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
return null;
}
}, null });
assertThat(exception.getMessage(), is("query failed on shards 0 ( null )"));
}
use of org.elasticsearch.common.io.stream.StreamInput in project crate by crate.
the class NodeFetchRequestTest method testStreaming.
@Test
public void testStreaming() throws Exception {
IntObjectHashMap<IntContainer> toFetch = new IntObjectHashMap<>();
IntHashSet docIds = new IntHashSet(3);
toFetch.put(1, docIds);
NodeFetchRequest orig = new NodeFetchRequest(UUID.randomUUID(), 1, true, toFetch);
BytesStreamOutput out = new BytesStreamOutput();
orig.writeTo(out);
StreamInput in = StreamInput.wrap(out.bytes());
NodeFetchRequest streamed = new NodeFetchRequest();
streamed.readFrom(in);
assertThat(orig.jobId(), is(streamed.jobId()));
assertThat(orig.fetchPhaseId(), is(streamed.fetchPhaseId()));
assertThat(orig.isCloseContext(), is(streamed.isCloseContext()));
assertThat(orig.toFetch().toString(), is(streamed.toFetch().toString()));
}
use of org.elasticsearch.common.io.stream.StreamInput in project crate by crate.
the class ParameterSymbolTest method testSerialization.
@Test
public void testSerialization() throws Exception {
ParameterSymbol ps1 = new ParameterSymbol(2, DataTypes.INTEGER);
BytesStreamOutput out = new BytesStreamOutput();
ps1.writeTo(out);
StreamInput in = StreamInput.wrap(out.bytes());
ParameterSymbol ps2 = new ParameterSymbol(in);
assertThat(ps2.index(), is(ps1.index()));
assertThat(ps2.valueType(), is(ps1.valueType()));
}
Aggregations