congrats Icon
New! Announcing Tabnine Chat Beta
Learn More
Tabnine Logo
OutputStreamStreamOutput
Code IndexAdd Tabnine to your IDE (free)

How to use
OutputStreamStreamOutput
in
org.elasticsearch.common.io.stream

Best Java code snippets using org.elasticsearch.common.io.stream.OutputStreamStreamOutput (Showing top 19 results out of 315)

origin: org.elasticsearch/elasticsearch

  /**
   * Writes this header with the latest format into the file channel
   */
  void write(final FileChannel channel) throws IOException {
    // This output is intentionally not closed because closing it will close the FileChannel.
    @SuppressWarnings({"IOResourceOpenedButNotSafelyClosed", "resource"})
    final BufferedChecksumStreamOutput out = new BufferedChecksumStreamOutput(
      new OutputStreamStreamOutput(java.nio.channels.Channels.newOutputStream(channel)));
    CodecUtil.writeHeader(new OutputStreamDataOutput(out), TRANSLOG_CODEC, CURRENT_VERSION);
    // Write uuid
    final BytesRef uuid = new BytesRef(translogUUID);
    out.writeInt(uuid.length);
    out.writeBytes(uuid.bytes, uuid.offset, uuid.length);
    // Write primary term
    out.writeLong(primaryTerm);
    // Checksum header
    out.writeInt((int) out.getChecksum());
    out.flush();
    channel.force(true);
    assert channel.position() == headerSizeInBytes :
      "Header is not fully written; header size [" + headerSizeInBytes + "], channel position [" + channel.position() + "]";
  }
}
origin: org.elasticsearch/elasticsearch

  public void close() throws IOException {
    try {
      super.close();
    } finally {
      if (closed.compareAndSet(false, true)) {
        // important to release native memory
        deflater.end();
      }
    }
  }
};
origin: org.elasticsearch.plugin/percolator-client

static void createQueryBuilderField(Version indexVersion, BinaryFieldMapper qbField,
                  QueryBuilder queryBuilder, ParseContext context) throws IOException {
  if (indexVersion.onOrAfter(Version.V_6_0_0_beta2)) {
    try (ByteArrayOutputStream stream = new ByteArrayOutputStream()) {
      try (OutputStreamStreamOutput out  = new OutputStreamStreamOutput(stream)) {
        out.setVersion(indexVersion);
        out.writeNamedWriteable(queryBuilder);
        byte[] queryBuilderAsBytes = stream.toByteArray();
        qbField.parse(context.createExternalValueContext(queryBuilderAsBytes));
      }
    }
  } else {
    try (XContentBuilder builder = XContentFactory.contentBuilder(QUERY_BUILDER_CONTENT_TYPE)) {
      queryBuilder.toXContent(builder, new MapParams(Collections.emptyMap()));
      builder.flush();
      byte[] queryBuilderAsBytes = BytesReference.toBytes(BytesReference.bytes(builder));
      context.doc().add(new Field(qbField.name(), queryBuilderAsBytes, qbField.fieldType()));
    }
  }
}
origin: org.codelibs.elasticsearch.module/percolator

static void createQueryBuilderField(Version indexVersion, BinaryFieldMapper qbField,
                  QueryBuilder queryBuilder, ParseContext context) throws IOException {
  if (indexVersion.onOrAfter(Version.V_6_0_0_beta2)) {
    try (ByteArrayOutputStream stream = new ByteArrayOutputStream()) {
      try (OutputStreamStreamOutput out  = new OutputStreamStreamOutput(stream)) {
        out.setVersion(indexVersion);
        out.writeNamedWriteable(queryBuilder);
        byte[] queryBuilderAsBytes = stream.toByteArray();
        qbField.parse(context.createExternalValueContext(queryBuilderAsBytes));
      }
    }
  } else {
    try (XContentBuilder builder = XContentFactory.contentBuilder(QUERY_BUILDER_CONTENT_TYPE)) {
      queryBuilder.toXContent(builder, new MapParams(Collections.emptyMap()));
      builder.flush();
      byte[] queryBuilderAsBytes = BytesReference.toBytes(BytesReference.bytes(builder));
      context.doc().add(new Field(qbField.name(), queryBuilderAsBytes, qbField.fieldType()));
    }
  }
}
origin: org.elasticsearch/elasticsearch

/**
 * Writes the incompatible snapshot ids list to the `incompatible-snapshots` blob in the repository.
 *
 * Package private for testing.
 */
void writeIncompatibleSnapshots(RepositoryData repositoryData) throws IOException {
  assert isReadOnly() == false; // can not write to a read only repository
  final BytesReference bytes;
  try (BytesStreamOutput bStream = new BytesStreamOutput()) {
    try (StreamOutput stream = new OutputStreamStreamOutput(bStream)) {
      XContentBuilder builder = XContentFactory.contentBuilder(XContentType.JSON, stream);
      repositoryData.incompatibleSnapshotsToXContent(builder, ToXContent.EMPTY_PARAMS);
      builder.close();
    }
    bytes = bStream.bytes();
  }
  // write the incompatible snapshots blob
  writeAtomic(INCOMPATIBLE_SNAPSHOTS_BLOB, bytes, false);
}
origin: harbby/presto-connectors

  public void close() throws IOException {
    try {
      super.close();
    } finally {
      if (closed == false) {
        // important to release native memory
        deflater.end();
        closed = true;
      }
    }
  }
};
origin: org.elasticsearch/elasticsearch

final BytesReference snapshotsBytes;
try (BytesStreamOutput bStream = new BytesStreamOutput()) {
  try (StreamOutput stream = new OutputStreamStreamOutput(bStream)) {
    XContentBuilder builder = XContentFactory.contentBuilder(XContentType.JSON, stream);
    repositoryData.snapshotsToXContent(builder, ToXContent.EMPTY_PARAMS);
origin: com.strapdata.elasticsearch/elasticsearch

  public void close() throws IOException {
    try {
      super.close();
    } finally {
      if (closed.compareAndSet(false, true)) {
        // important to release native memory
        deflater.end();
      }
    }
  }
};
origin: apache/servicemix-bundles

  /**
   * Writes this header with the latest format into the file channel
   */
  void write(final FileChannel channel) throws IOException {
    // This output is intentionally not closed because closing it will close the FileChannel.
    @SuppressWarnings({"IOResourceOpenedButNotSafelyClosed", "resource"})
    final BufferedChecksumStreamOutput out = new BufferedChecksumStreamOutput(
      new OutputStreamStreamOutput(java.nio.channels.Channels.newOutputStream(channel)));
    CodecUtil.writeHeader(new OutputStreamDataOutput(out), TRANSLOG_CODEC, CURRENT_VERSION);
    // Write uuid
    final BytesRef uuid = new BytesRef(translogUUID);
    out.writeInt(uuid.length);
    out.writeBytes(uuid.bytes, uuid.offset, uuid.length);
    // Write primary term
    out.writeLong(primaryTerm);
    // Checksum header
    out.writeInt((int) out.getChecksum());
    out.flush();
    channel.force(true);
    assert channel.position() == headerSizeInBytes :
      "Header is not fully written; header size [" + headerSizeInBytes + "], channel position [" + channel.position() + "]";
  }
}
origin: apache/servicemix-bundles

  public void close() throws IOException {
    try {
      super.close();
    } finally {
      if (closed.compareAndSet(false, true)) {
        // important to release native memory
        deflater.end();
      }
    }
  }
};
origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.elasticsearch

  /**
   * Writes this header with the latest format into the file channel
   */
  void write(final FileChannel channel) throws IOException {
    // This output is intentionally not closed because closing it will close the FileChannel.
    @SuppressWarnings({"IOResourceOpenedButNotSafelyClosed", "resource"})
    final BufferedChecksumStreamOutput out = new BufferedChecksumStreamOutput(
      new OutputStreamStreamOutput(java.nio.channels.Channels.newOutputStream(channel)));
    CodecUtil.writeHeader(new OutputStreamDataOutput(out), TRANSLOG_CODEC, CURRENT_VERSION);
    // Write uuid
    final BytesRef uuid = new BytesRef(translogUUID);
    out.writeInt(uuid.length);
    out.writeBytes(uuid.bytes, uuid.offset, uuid.length);
    // Write primary term
    out.writeLong(primaryTerm);
    // Checksum header
    out.writeInt((int) out.getChecksum());
    out.flush();
    channel.force(true);
    assert channel.position() == headerSizeInBytes :
      "Header is not fully written; header size [" + headerSizeInBytes + "], channel position [" + channel.position() + "]";
  }
}
origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.elasticsearch

  public void close() throws IOException {
    try {
      super.close();
    } finally {
      if (closed.compareAndSet(false, true)) {
        // important to release native memory
        deflater.end();
      }
    }
  }
};
origin: apache/servicemix-bundles

/**
 * Writes the incompatible snapshot ids list to the `incompatible-snapshots` blob in the repository.
 *
 * Package private for testing.
 */
void writeIncompatibleSnapshots(RepositoryData repositoryData) throws IOException {
  assert isReadOnly() == false; // can not write to a read only repository
  final BytesReference bytes;
  try (BytesStreamOutput bStream = new BytesStreamOutput()) {
    try (StreamOutput stream = new OutputStreamStreamOutput(bStream)) {
      XContentBuilder builder = XContentFactory.contentBuilder(XContentType.JSON, stream);
      repositoryData.incompatibleSnapshotsToXContent(builder, ToXContent.EMPTY_PARAMS);
      builder.close();
    }
    bytes = bStream.bytes();
  }
  // write the incompatible snapshots blob
  writeAtomic(INCOMPATIBLE_SNAPSHOTS_BLOB, bytes, false);
}
origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.elasticsearch

/**
 * Writes the incompatible snapshot ids list to the `incompatible-snapshots` blob in the repository.
 *
 * Package private for testing.
 */
void writeIncompatibleSnapshots(RepositoryData repositoryData) throws IOException {
  assert isReadOnly() == false; // can not write to a read only repository
  final BytesReference bytes;
  try (BytesStreamOutput bStream = new BytesStreamOutput()) {
    try (StreamOutput stream = new OutputStreamStreamOutput(bStream)) {
      XContentBuilder builder = XContentFactory.contentBuilder(XContentType.JSON, stream);
      repositoryData.incompatibleSnapshotsToXContent(builder, ToXContent.EMPTY_PARAMS);
      builder.close();
    }
    bytes = bStream.bytes();
  }
  // write the incompatible snapshots blob
  writeAtomic(INCOMPATIBLE_SNAPSHOTS_BLOB, bytes, false);
}
origin: harbby/presto-connectors

/**
 * Writes snapshot index file
 * <p>
 * This file can be used by read-only repositories that are unable to list files in the repository
 *
 * @param snapshots list of snapshot ids
 * @throws IOException I/O errors
 */
protected void writeSnapshotList(List<SnapshotId> snapshots) throws IOException {
  final BytesReference bRef;
  try(BytesStreamOutput bStream = new BytesStreamOutput()) {
    try(StreamOutput stream = new OutputStreamStreamOutput(bStream)) {
      XContentBuilder builder = XContentFactory.contentBuilder(XContentType.JSON, stream);
      builder.startObject();
      builder.startArray("snapshots");
      for (SnapshotId snapshot : snapshots) {
        builder.value(snapshot.getSnapshot());
      }
      builder.endArray();
      builder.endObject();
      builder.close();
    }
    bRef = bStream.bytes();
  }
  if (snapshotsBlobContainer.blobExists(SNAPSHOTS_FILE)) {
    snapshotsBlobContainer.deleteBlob(SNAPSHOTS_FILE);
  }
  snapshotsBlobContainer.writeBlob(SNAPSHOTS_FILE, bRef);
}
origin: apache/servicemix-bundles

final BytesReference snapshotsBytes;
try (BytesStreamOutput bStream = new BytesStreamOutput()) {
  try (StreamOutput stream = new OutputStreamStreamOutput(bStream)) {
    XContentBuilder builder = XContentFactory.contentBuilder(XContentType.JSON, stream);
    repositoryData.snapshotsToXContent(builder, ToXContent.EMPTY_PARAMS);
origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.elasticsearch

final BytesReference snapshotsBytes;
try (BytesStreamOutput bStream = new BytesStreamOutput()) {
  try (StreamOutput stream = new OutputStreamStreamOutput(bStream)) {
    XContentBuilder builder = XContentFactory.contentBuilder(XContentType.JSON, stream);
    repositoryData.snapshotsToXContent(builder, ToXContent.EMPTY_PARAMS);
origin: com.strapdata.elasticsearch/elasticsearch

/**
 * Writes the incompatible snapshot ids list to the `incompatible-snapshots` blob in the repository.
 *
 * Package private for testing.
 */
void writeIncompatibleSnapshots(RepositoryData repositoryData) throws IOException {
  assert isReadOnly() == false; // can not write to a read only repository
  final BytesReference bytes;
  try (BytesStreamOutput bStream = new BytesStreamOutput()) {
    try (StreamOutput stream = new OutputStreamStreamOutput(bStream)) {
      XContentBuilder builder = XContentFactory.contentBuilder(XContentType.JSON, stream);
      repositoryData.incompatibleSnapshotsToXContent(builder, ToXContent.EMPTY_PARAMS);
      builder.close();
    }
    bytes = bStream.bytes();
  }
  if (snapshotsBlobContainer.blobExists(INCOMPATIBLE_SNAPSHOTS_BLOB)) {
    snapshotsBlobContainer.deleteBlob(INCOMPATIBLE_SNAPSHOTS_BLOB);
  }
  // write the incompatible snapshots blob
  writeAtomic(INCOMPATIBLE_SNAPSHOTS_BLOB, bytes);
}
origin: com.strapdata.elasticsearch/elasticsearch

final BytesReference snapshotsBytes;
try (BytesStreamOutput bStream = new BytesStreamOutput()) {
  try (StreamOutput stream = new OutputStreamStreamOutput(bStream)) {
    XContentBuilder builder = XContentFactory.contentBuilder(XContentType.JSON, stream);
    repositoryData.snapshotsToXContent(builder, ToXContent.EMPTY_PARAMS);
org.elasticsearch.common.io.streamOutputStreamStreamOutput

Most used methods

  • <init>
  • close
  • setVersion
  • writeNamedWriteable

Popular in Java

  • Making http requests using okhttp
  • notifyDataSetChanged (ArrayAdapter)
  • runOnUiThread (Activity)
  • addToBackStack (FragmentTransaction)
  • Rectangle (java.awt)
    A Rectangle specifies an area in a coordinate space that is enclosed by the Rectangle object's top-
  • FileReader (java.io)
    A specialized Reader that reads from a file in the file system. All read requests made by calling me
  • Connection (java.sql)
    A connection represents a link from a Java application to a database. All SQL statements and results
  • Semaphore (java.util.concurrent)
    A counting semaphore. Conceptually, a semaphore maintains a set of permits. Each #acquire blocks if
  • Cipher (javax.crypto)
    This class provides access to implementations of cryptographic ciphers for encryption and decryption
  • JTable (javax.swing)
  • Top Sublime Text plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now