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

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

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

origin: org.elasticsearch/elasticsearch

               .flatMap(p -> p.getNamedWriteables().stream())
               .collect(Collectors.toList()));
NamedWriteableRegistry namedWriteableRegistry = new NamedWriteableRegistry(entries);
NamedXContentRegistry xContentRegistry = new NamedXContentRegistry(Stream.of(
    searchModule.getNamedXContents().stream(),
origin: org.elasticsearch/elasticsearch

  @Override
  public <C extends NamedWriteable> C readNamedWriteable(@SuppressWarnings("unused") Class<C> categoryClass,
                              @SuppressWarnings("unused") String name) throws IOException {
    Writeable.Reader<? extends C> reader = namedWriteableRegistry.getReader(categoryClass, name);
    C c = reader.read(this);
    if (c == null) {
      throw new IOException(
        "Writeable.Reader [" + reader + "] returned null which is not allowed and probably means it screwed up the stream.");
    }
    assert name.equals(c.getWriteableName()) : c + " claims to have a different name [" + c.getWriteableName()
      + "] than it was read from [" + name + "].";
    return c;
  }
}
origin: harbby/presto-connectors

public void registerTaskStatus(Task.Status prototype) {
  namedWriteableRegistry.registerPrototype(Task.Status.class, prototype);
}
origin: harbby/presto-connectors

  @Override
  <C> C readNamedWriteable(Class<C> categoryClass) throws IOException {
    String name = readString();
    NamedWriteable<? extends C> namedWriteable = namedWriteableRegistry.getPrototype(categoryClass, name);
    return namedWriteable.readFrom(this);
  }
}
origin: com.strapdata.elasticsearch.test/framework

/**
 * Get the {@link NamedWriteableRegistry} to use when de-serializing the object.
 * 
 * Override this method if you need to register {@link NamedWriteable}s for the test object to de-serialize.
 * 
 * By default this will return a {@link NamedWriteableRegistry} with no registered {@link NamedWriteable}s
 */
protected NamedWriteableRegistry getNamedWriteableRegistry() {
  return new NamedWriteableRegistry(Collections.emptyList());
}
origin: com.strapdata.elasticsearch.test/framework

@SuppressWarnings("unchecked")
private QB copyQuery(QB query) throws IOException {
  Reader<QB> reader = (Reader<QB>) serviceHolder.namedWriteableRegistry.getReader(QueryBuilder.class, query.getWriteableName());
  return copyWriteable(query, serviceHolder.namedWriteableRegistry, reader);
}
origin: com.strapdata.elasticsearch.test/framework

  /**
   * Get the {@link NamedWriteableRegistry} to use when de-serializing the object.
   *
   * Override this method if you need to register {@link NamedWriteable}s for the test object to de-serialize.
   *
   * By default this will return a {@link NamedWriteableRegistry} with no registered {@link NamedWriteable}s
   */
  protected NamedWriteableRegistry getNamedWriteableRegistry() {
    return new NamedWriteableRegistry(Collections.emptyList());
  }
}
origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.elasticsearch

  @Override
  public <C extends NamedWriteable> C readNamedWriteable(@SuppressWarnings("unused") Class<C> categoryClass,
                              @SuppressWarnings("unused") String name) throws IOException {
    Writeable.Reader<? extends C> reader = namedWriteableRegistry.getReader(categoryClass, name);
    C c = reader.read(this);
    if (c == null) {
      throw new IOException(
        "Writeable.Reader [" + reader + "] returned null which is not allowed and probably means it screwed up the stream.");
    }
    assert name.equals(c.getWriteableName()) : c + " claims to have a different name [" + c.getWriteableName()
      + "] than it was read from [" + name + "].";
    return c;
  }
}
origin: org.elasticsearch/elasticsearch

  ClusterModule.getNamedWriteables().stream())
  .flatMap(Function.identity()).collect(Collectors.toList());
final NamedWriteableRegistry namedWriteableRegistry = new NamedWriteableRegistry(namedWriteables);
NamedXContentRegistry xContentRegistry = new NamedXContentRegistry(Stream.of(
  NetworkModule.getNamedXContents().stream(),
origin: com.strapdata.elasticsearch/elasticsearch

  @Override
  public <C extends NamedWriteable> C readNamedWriteable(@SuppressWarnings("unused") Class<C> categoryClass,
                              @SuppressWarnings("unused") String name) throws IOException {
    Writeable.Reader<? extends C> reader = namedWriteableRegistry.getReader(categoryClass, name);
    C c = reader.read(this);
    if (c == null) {
      throw new IOException(
        "Writeable.Reader [" + reader + "] returned null which is not allowed and probably means it screwed up the stream.");
    }
    assert name.equals(c.getWriteableName()) : c + " claims to have a different name [" + c.getWriteableName()
      + "] than it was read from [" + name + "].";
    return c;
  }
}
origin: com.strapdata.elasticsearch.test/framework

/**
 * The {@link NamedWriteableRegistry} to use for this test. Subclasses should override and use liberally.
 */
protected NamedWriteableRegistry writableRegistry() {
  return new NamedWriteableRegistry(ClusterModule.getNamedWriteables());
}
origin: apache/servicemix-bundles

  @Override
  public <C extends NamedWriteable> C readNamedWriteable(@SuppressWarnings("unused") Class<C> categoryClass,
                              @SuppressWarnings("unused") String name) throws IOException {
    Writeable.Reader<? extends C> reader = namedWriteableRegistry.getReader(categoryClass, name);
    C c = reader.read(this);
    if (c == null) {
      throw new IOException(
        "Writeable.Reader [" + reader + "] returned null which is not allowed and probably means it screwed up the stream.");
    }
    assert name.equals(c.getWriteableName()) : c + " claims to have a different name [" + c.getWriteableName()
      + "] than it was read from [" + name + "].";
    return c;
  }
}
origin: harbby/presto-connectors

static NamedWriteableRegistry getNamedWriteableRegistry()
{
  IndicesModule indicesModule = new IndicesModule(Collections.emptyList());
  SearchModule searchModule = new SearchModule(Settings.EMPTY, false, Collections.emptyList());
  List<NamedWriteableRegistry.Entry> entries = new ArrayList<>();
  entries.addAll(indicesModule.getNamedWriteables());
  entries.addAll(searchModule.getNamedWriteables());
  return new NamedWriteableRegistry(entries);
}
origin: com.strapdata.elasticsearch.test/framework

private AB copyAggregation(AB agg) throws IOException {
  try (BytesStreamOutput output = new BytesStreamOutput()) {
    agg.writeTo(output);
    try (StreamInput in = new NamedWriteableAwareStreamInput(output.bytes().streamInput(), namedWriteableRegistry)) {
      @SuppressWarnings("unchecked")
      AB secondAgg = (AB) namedWriteableRegistry.getReader(AggregationBuilder.class, agg.getWriteableName()).read(in);
      return secondAgg;
    }
  }
}
origin: harbby/presto-connectors

static NamedWriteableRegistry getNamedWriteableRegistry()
{
  IndicesModule indicesModule = new IndicesModule(Collections.emptyList());
  SearchModule searchModule = new SearchModule(Settings.EMPTY, false, Collections.emptyList());
  List<NamedWriteableRegistry.Entry> entries = new ArrayList<>();
  entries.addAll(indicesModule.getNamedWriteables());
  entries.addAll(searchModule.getNamedWriteables());
  return new NamedWriteableRegistry(entries);
}
origin: com.strapdata.elasticsearch.test/framework

public static MockTransportService createNewService(Settings settings, Version version, ThreadPool threadPool,
                          @Nullable ClusterSettings clusterSettings) {
  // some tests use MockTransportService to do network based testing. Yet, we run tests in multiple JVMs that means
  // concurrent tests could claim port that another JVM just released and if that test tries to simulate a disconnect it might
  // be smart enough to re-connect depending on what is tested. To reduce the risk, since this is very hard to debug we use
  // a different default port range per JVM unless the incoming settings override it
  int basePort = 10300 + (JVM_ORDINAL * 100); // use a non-default port otherwise some cluster in this JVM might reuse a port
  settings = Settings.builder().put(TcpTransport.PORT.getKey(), basePort + "-" + (basePort + 100)).put(settings).build();
  NamedWriteableRegistry namedWriteableRegistry = new NamedWriteableRegistry(ClusterModule.getNamedWriteables());
  final Transport transport = new MockTcpTransport(settings, threadPool, BigArrays.NON_RECYCLING_INSTANCE,
    new NoneCircuitBreakerService(), namedWriteableRegistry, new NetworkService(Collections.emptyList()), version);
  return createNewService(settings, transport, version, threadPool, clusterSettings, Collections.emptySet());
}
origin: com.strapdata.elasticsearch.test/framework

/**
 * Setup for the whole base test class.
 */
@Override
public void setUp() throws Exception {
  super.setUp();
  Settings settings = Settings.builder()
    .put("node.name", AbstractQueryTestCase.class.toString())
    .put(Environment.PATH_HOME_SETTING.getKey(), createTempDir())
    .build();
  IndicesModule indicesModule = new IndicesModule(Collections.emptyList());
  PluginsService pluginsService = new PluginsService(settings, null, null, null, getPlugins());
  SearchModule searchModule = new SearchModule(settings, false, pluginsService.filterPlugins(SearchPlugin.class));
  List<NamedWriteableRegistry.Entry> entries = new ArrayList<>();
  entries.addAll(indicesModule.getNamedWriteables());
  entries.addAll(searchModule.getNamedWriteables());
  namedWriteableRegistry = new NamedWriteableRegistry(entries);
  xContentRegistry = new NamedXContentRegistry(searchModule.getNamedXContents());
  //create some random type with some default field, those types will stick around for all of the subclasses
  currentTypes = new String[randomIntBetween(0, 5)];
  for (int i = 0; i < currentTypes.length; i++) {
    String type = randomAlphaOfLengthBetween(1, 10);
    currentTypes[i] = type;
  }
}
origin: harbby/presto-connectors

final SearchRequest deserializedRequest = new SearchRequest();
StreamInput streamInput = new ByteBufferStreamInput(ByteBuffer.wrap(slice));
NamedWriteableRegistry namedWriteableRegistry = new NamedWriteableRegistry();
try (StreamInput in = new NamedWriteableAwareStreamInput(streamInput, namedWriteableRegistry)) {
  deserializedRequest.readFrom(in);
origin: com.strapdata.elasticsearch.test/framework

public void testHandshakeWithIncompatVersion() {
  assumeTrue("only tcp transport has a handshake method", serviceA.getOriginalTransport() instanceof TcpTransport);
  NamedWriteableRegistry namedWriteableRegistry = new NamedWriteableRegistry(Collections.emptyList());
  Version version = Version.fromString("2.0.0");
  try (MockTcpTransport transport = new MockTcpTransport(Settings.EMPTY, threadPool, BigArrays.NON_RECYCLING_INSTANCE,
    new NoneCircuitBreakerService(), namedWriteableRegistry, new NetworkService(Collections.emptyList()), version);
     MockTransportService service = MockTransportService.createNewService(Settings.EMPTY, transport, version, threadPool, null,
       Collections.emptySet())) {
    service.start();
    service.acceptIncomingRequests();
    DiscoveryNode node =
      new DiscoveryNode("TS_TPC", "TS_TPC", transport.boundAddress().publishAddress(), emptyMap(), emptySet(), version0);
    ConnectionProfile.Builder builder = new ConnectionProfile.Builder();
    builder.addConnections(1,
      TransportRequestOptions.Type.BULK,
      TransportRequestOptions.Type.PING,
      TransportRequestOptions.Type.RECOVERY,
      TransportRequestOptions.Type.REG,
      TransportRequestOptions.Type.STATE);
    expectThrows(ConnectTransportException.class, () -> serviceA.openConnection(node, builder.build()));
  }
}
origin: com.strapdata.elasticsearch.test/framework

public abstract class InternalAggregationTestCase<T extends InternalAggregation> extends AbstractWireSerializingTestCase<T> {
  public static final int DEFAULT_MAX_BUCKETS = 100000;
  private final NamedWriteableRegistry namedWriteableRegistry = new NamedWriteableRegistry(
      new SearchModule(Settings.EMPTY, false, emptyList()).getNamedWriteables());
org.elasticsearch.common.io.streamNamedWriteableRegistry

Javadoc

A registry for org.elasticsearch.common.io.stream.Writeable.Reader readers of NamedWriteable. The registration is keyed by the combination of the category class of NamedWriteable, and a name unique to that category.

Most used methods

  • <init>
    Constructs a new registry from the given entries.
  • getReader
    Returns a reader for a NamedWriteable object identified by the name provided as argument and its cat
  • getPrototype
    Returns a prototype of the NamedWriteable object identified by the name provided as argument and its
  • registerPrototype
    Registers a NamedWriteable prototype given its category

Popular in Java

  • Finding current android device location
  • setScale (BigDecimal)
  • getContentResolver (Context)
  • scheduleAtFixedRate (ScheduledExecutorService)
  • Rectangle (java.awt)
    A Rectangle specifies an area in a coordinate space that is enclosed by the Rectangle object's top-
  • File (java.io)
    An "abstract" representation of a file system entity identified by a pathname. The pathname may be a
  • FileInputStream (java.io)
    An input stream that reads bytes from a file. File file = ...finally if (in != null) in.clos
  • JarFile (java.util.jar)
    JarFile is used to read jar entries and their associated data from jar files.
  • XPath (javax.xml.xpath)
    XPath provides access to the XPath evaluation environment and expressions. Evaluation of XPath Expr
  • Project (org.apache.tools.ant)
    Central representation of an Ant project. This class defines an Ant project with all of its targets,
  • Github Copilot alternatives
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