diff options
Diffstat (limited to 'vespa-http-client/src/main/java/com/yahoo/vespa/http/client/core/api/MultiClusterSessionOutputStream.java')
-rw-r--r-- | vespa-http-client/src/main/java/com/yahoo/vespa/http/client/core/api/MultiClusterSessionOutputStream.java | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/vespa-http-client/src/main/java/com/yahoo/vespa/http/client/core/api/MultiClusterSessionOutputStream.java b/vespa-http-client/src/main/java/com/yahoo/vespa/http/client/core/api/MultiClusterSessionOutputStream.java new file mode 100644 index 00000000000..cfe63610f4b --- /dev/null +++ b/vespa-http-client/src/main/java/com/yahoo/vespa/http/client/core/api/MultiClusterSessionOutputStream.java @@ -0,0 +1,34 @@ +// Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +package com.yahoo.vespa.http.client.core.api; + +import com.yahoo.vespa.http.client.core.Document; +import com.yahoo.vespa.http.client.core.operationProcessor.OperationProcessor; + +import java.io.ByteArrayOutputStream; +import java.io.IOException; + +/** + * Class for wiring up the Session API. It is the return value of stream() in the Session API. + * @author dybdahl +*/ +class MultiClusterSessionOutputStream extends ByteArrayOutputStream { + private final CharSequence documentId; + private final OperationProcessor operationProcessor; + private final Object context; + + public MultiClusterSessionOutputStream( + CharSequence documentId, + OperationProcessor operationProcessor, + Object context) { + this.documentId = documentId; + this.context = context; + this.operationProcessor = operationProcessor; + } + + @Override + public void close() throws IOException { + Document document = new Document(documentId.toString(), toByteArray(), context); + operationProcessor.sendDocument(document); + super.close(); + } +} |